@stacksjs/stx 0.2.645 → 0.2.647
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/builtins/attrs.js +6 -6
- package/dist/builtins/escape.d.ts +0 -11
- package/dist/builtins/escape.js +2 -1
- package/dist/builtins/safe-image.js +1 -3
- package/dist/builtins/stx-image.js +1 -3
- package/dist/builtins/stx-link.d.ts +3 -0
- package/dist/builtins/stx-link.js +1 -3
- package/dist/{chunk-apeyn69a.js → chunk-04kg16qs.js} +4 -4
- package/dist/chunk-0jq3w712.js +65 -0
- package/dist/chunk-0ky1j84b.js +2 -0
- package/dist/chunk-0m08316b.js +2 -0
- package/dist/{chunk-c96f3eq5.js → chunk-0z5cc7qn.js} +8 -8
- package/dist/{chunk-hpggz2t4.js → chunk-120ze5ms.js} +3 -3
- package/dist/chunk-1c5p7ede.js +2 -0
- package/dist/chunk-1q6yvbdx.js +2 -0
- package/dist/chunk-1x4qn6fy.js +2 -0
- package/dist/chunk-20f1veqy.js +3 -0
- package/dist/chunk-2a4szpje.js +3 -0
- package/dist/chunk-2c3w367n.js +2 -0
- package/dist/chunk-2cxav9xe.js +2 -0
- package/dist/chunk-2f17h17f.js +2 -0
- package/dist/{chunk-ktvr45qg.js → chunk-2qbvsvwc.js} +2 -2
- package/dist/chunk-2v4s7xtx.js +2 -0
- package/dist/chunk-31714f76.js +2 -0
- package/dist/chunk-354jmw2k.js +3 -0
- package/dist/chunk-3e7haxwt.js +2 -0
- package/dist/{chunk-ph8dqgr5.js → chunk-3ghbxena.js} +14 -14
- package/dist/chunk-40y6mb8t.js +2 -0
- package/dist/chunk-42rghbqe.js +12 -0
- package/dist/chunk-4fz2eq7g.js +2 -0
- package/dist/{chunk-1t0m4pwg.js → chunk-4yf1w261.js} +2 -2
- package/dist/chunk-4yt8tg4j.js +2 -0
- package/dist/chunk-52gp2xxk.js +2 -0
- package/dist/chunk-55x799st.js +49 -0
- package/dist/chunk-5e20mvke.js +2 -0
- package/dist/chunk-5fzh8n52.js +2 -0
- package/dist/chunk-5gtpswnm.js +2 -0
- package/dist/{chunk-a0ygyftk.js → chunk-5t4qtxgr.js} +2 -2
- package/dist/chunk-5yg3tkth.js +2 -0
- package/dist/chunk-67kj14at.js +2 -0
- package/dist/{chunk-me1tdtzz.js → chunk-6ajahb2x.js} +3 -3
- package/dist/chunk-6vzktvyw.js +2 -0
- package/dist/chunk-70pmthc3.js +2 -0
- package/dist/chunk-74pej67a.js +18 -0
- package/dist/{chunk-r2seygb5.js → chunk-7rta163c.js} +2 -2
- package/dist/chunk-7s32fe6k.js +3 -0
- package/dist/chunk-84djpte6.js +3 -0
- package/dist/chunk-864qtx7y.js +2 -0
- package/dist/chunk-8ttg2d3m.js +2 -0
- package/dist/{chunk-9yk5rasj.js → chunk-9am6dsb1.js} +3 -3
- package/dist/{chunk-rmj0n3ss.js → chunk-9p6efb17.js} +1 -1
- package/dist/chunk-9qeg5trh.js +2 -0
- package/dist/chunk-9szxxgv5.js +2 -0
- package/dist/{chunk-bsts9pr5.js → chunk-9y2ncrnq.js} +2 -2
- package/dist/chunk-9z9jtwct.js +33 -0
- package/dist/{chunk-gvr10eqb.js → chunk-a3d0g4mr.js} +2 -2
- package/dist/{chunk-wpc04ygt.js → chunk-a8j91pqz.js} +11 -11
- package/dist/{chunk-mfd3fca7.js → chunk-aah6csjm.js} +11 -11
- package/dist/{chunk-dmg8dpah.js → chunk-ajv5xmjx.js} +169 -169
- package/dist/chunk-apgb7r22.js +2 -0
- package/dist/{chunk-v1mvbf82.js → chunk-aprhqxky.js} +5 -5
- package/dist/{chunk-kfq594fh.js → chunk-ar22s1e1.js} +2 -2
- package/dist/chunk-asqnaddf.js +3 -0
- package/dist/chunk-aze7k3a5.js +2 -0
- package/dist/chunk-b07djygp.js +18 -0
- package/dist/chunk-b0vhe6d4.js +4 -0
- package/dist/chunk-b4fd2dtk.js +2 -0
- package/dist/chunk-bk96wjaz.js +61 -0
- package/dist/chunk-c7fs96n6.js +4 -0
- package/dist/chunk-c9k40352.js +2 -0
- package/dist/{chunk-ahyq08mp.js → chunk-ce6zddpf.js} +3 -3
- package/dist/{chunk-392pj66x.js → chunk-cj2xj1v6.js} +29 -29
- package/dist/chunk-cs0dd5w8.js +2 -0
- package/dist/chunk-cwd65649.js +2 -0
- package/dist/{chunk-w9zxb26s.js → chunk-da7x7y7j.js} +1 -1
- package/dist/{chunk-9wbtj6tj.js → chunk-dgb4z4kw.js} +2 -2
- package/dist/chunk-dpjnjs09.js +888 -0
- package/dist/chunk-e7sg0fa0.js +2 -0
- package/dist/chunk-edz1h5f9.js +2 -0
- package/dist/chunk-egg54kd0.js +12 -0
- package/dist/chunk-ek2adv0n.js +2 -0
- package/dist/chunk-emaexvgz.js +2 -0
- package/dist/{chunk-pp6ycfay.js → chunk-ewcrsyr7.js} +2 -2
- package/dist/chunk-fcn71bq1.js +2 -0
- package/dist/{chunk-38ngmh6h.js → chunk-fg3jw17w.js} +48 -48
- package/dist/chunk-fygp3cs9.js +2 -0
- package/dist/chunk-g2jmwh7p.js +2 -0
- package/dist/chunk-g8r0km7g.js +106 -0
- package/dist/{chunk-kchphxkm.js → chunk-gc9ftf7r.js} +3 -3
- package/dist/chunk-ggwm8w5m.js +2 -0
- package/dist/chunk-h5zr710w.js +2 -0
- package/dist/chunk-hgy4c6mm.js +11 -0
- package/dist/chunk-hvtzw1jh.js +2 -0
- package/dist/{chunk-4n24jbfs.js → chunk-hvzzhkhr.js} +2 -2
- package/dist/chunk-j0v970k3.js +2 -0
- package/dist/chunk-jk41jwsc.js +2 -0
- package/dist/{chunk-6mnwvn9v.js → chunk-jkvr7e91.js} +2 -2
- package/dist/{chunk-3ns5k9nf.js → chunk-jsb4pvj1.js} +2 -2
- package/dist/{chunk-pf5s5gjp.js → chunk-jx3wpgv0.js} +2 -2
- package/dist/{chunk-2zcbx82x.js → chunk-jxda11cg.js} +2 -2
- package/dist/chunk-jyth1zjy.js +127 -0
- package/dist/chunk-k2pa44rf.js +2 -0
- package/dist/{chunk-kad2cp0z.js → chunk-k79x96ra.js} +37 -37
- package/dist/{chunk-75c46b62.js → chunk-kgfgb971.js} +4 -4
- package/dist/chunk-ma7d95f0.js +31 -0
- package/dist/chunk-mmm6mm16.js +3 -0
- package/dist/{chunk-r7haw6r7.js → chunk-mmwedr93.js} +5 -5
- package/dist/{chunk-dyg6sadv.js → chunk-mrrrngzd.js} +1 -1
- package/dist/{chunk-kvn23sz5.js → chunk-msr25dhc.js} +4 -4
- package/dist/chunk-myq3hrww.js +6 -0
- package/dist/{chunk-fk1rs7jb.js → chunk-n38yb274.js} +6 -6
- package/dist/chunk-n4cvg2sw.js +2 -0
- package/dist/chunk-nph4d1ff.js +42 -0
- package/dist/{chunk-7jgtphhg.js → chunk-nrvwejdw.js} +5 -5
- package/dist/{chunk-3cqxtkqv.js → chunk-p08x0z86.js} +7 -7
- package/dist/chunk-p22w6mwr.js +2 -0
- package/dist/{chunk-fb17t651.js → chunk-pdc9s7bg.js} +2 -2
- package/dist/chunk-pfk9ffbz.js +3 -0
- package/dist/{chunk-pvfx0dgz.js → chunk-prf164ct.js} +2 -2
- package/dist/chunk-pw9bhdaz.js +4 -0
- package/dist/chunk-qn63btbf.js +2 -0
- package/dist/{chunk-2bsrmqr8.js → chunk-qv6axke4.js} +2 -2
- package/dist/{chunk-n54c06wt.js → chunk-r3e6x87d.js} +3 -3
- package/dist/chunk-rb5xdcen.js +25 -0
- package/dist/{chunk-zm4s3n4p.js → chunk-rcadtv3x.js} +1 -1
- package/dist/{chunk-vbqts5sf.js → chunk-rjh2jwxx.js} +9 -9
- package/dist/chunk-rwrbdpdk.js +2 -0
- package/dist/chunk-sf0wsq74.js +2 -0
- package/dist/chunk-shkysa02.js +20 -0
- package/dist/chunk-shpc1ttk.js +2 -0
- package/dist/{chunk-22hdbqad.js → chunk-t2pzy3x1.js} +3 -3
- package/dist/chunk-t6yjxhn8.js +2 -0
- package/dist/chunk-tkkvvt26.js +2 -0
- package/dist/{chunk-g06qzkmp.js → chunk-tre98h62.js} +2 -2
- package/dist/chunk-vac56rgd.js +12 -0
- package/dist/chunk-vdxjy7j2.js +4 -0
- package/dist/{chunk-qa625vwc.js → chunk-vgt9f7ac.js} +4 -4
- package/dist/{chunk-xbdbn3bf.js → chunk-vmwdt8fr.js} +5 -5
- package/dist/chunk-vn3yx05b.js +2 -0
- package/dist/{chunk-fqg0espy.js → chunk-vqc4h16r.js} +2 -2
- package/dist/chunk-w1v1d7rq.js +406 -0
- package/dist/chunk-w2q32x72.js +2 -0
- package/dist/chunk-weqc0ssb.js +2 -0
- package/dist/{chunk-0zr1zxar.js → chunk-wpmrz872.js} +2 -2
- package/dist/chunk-wq712sw1.js +2 -0
- package/dist/chunk-wzgn9fv7.js +20 -0
- package/dist/{chunk-g2mcw1r4.js → chunk-x8k64g1e.js} +2 -2
- package/dist/chunk-xaa36b0x.js +3 -0
- package/dist/chunk-xnjf1zbn.js +21 -0
- package/dist/chunk-xyjn0rvj.js +3 -0
- package/dist/chunk-y3vget29.js +2 -0
- package/dist/chunk-y9x4pyp2.js +2 -0
- package/dist/chunk-yfrvbnc6.js +1312 -0
- package/dist/{chunk-febtq3xj.js → chunk-ym41ybz2.js} +6 -6
- package/dist/chunk-z8p6tk5z.js +2 -0
- package/dist/{chunk-4g8zase6.js → chunk-zevx9866.js} +2 -2
- package/dist/chunk-zhf01af3.js +3 -0
- package/dist/{chunk-jtvcxbwd.js → chunk-zqtbtqbq.js} +2 -2
- package/dist/chunk-ztbzktzg.js +2 -0
- package/dist/cli.js +62 -62
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.d.ts +6 -21
- package/dist/expressions.js +12 -41
- package/dist/forms-validation.d.ts +0 -16
- package/dist/forms-validation.js +4 -2
- package/dist/forms.js +8 -6
- package/dist/i18n.js +6 -4
- package/dist/interpolation-context.js +69 -28
- package/dist/loops.js +70 -90
- package/dist/mustache-span.d.ts +21 -0
- package/dist/mustache-span.js +35 -0
- package/dist/process.js +4 -3
- package/dist/pwa.js +3 -3
- package/dist/server-bindings.js +12 -6
- package/dist/ssg.js +28 -28
- package/dist/utils.js +1 -2
- package/package.json +5 -5
- package/dist/chunk-1jgsst0v.js +0 -2
- package/dist/chunk-1vrqmdfe.js +0 -2
- package/dist/chunk-1vx1ha9v.js +0 -2
- package/dist/chunk-1y9jphbg.js +0 -2
- package/dist/chunk-22kgdhxy.js +0 -2
- package/dist/chunk-2etamr31.js +0 -4
- package/dist/chunk-2s49ggrz.js +0 -12
- package/dist/chunk-2zbnc6jq.js +0 -2
- package/dist/chunk-39beqd1g.js +0 -2
- package/dist/chunk-3q5yn5r0.js +0 -6
- package/dist/chunk-3tcy2hdt.js +0 -2
- package/dist/chunk-3ycbhpa2.js +0 -2
- package/dist/chunk-3yqs2ekt.js +0 -2
- package/dist/chunk-4mm9ttc7.js +0 -2
- package/dist/chunk-4q4vy4g6.js +0 -2
- package/dist/chunk-4zapx8zt.js +0 -20
- package/dist/chunk-5zkwems4.js +0 -2
- package/dist/chunk-6e4es31t.js +0 -3
- package/dist/chunk-6hmbzqt8.js +0 -2
- package/dist/chunk-7a3kffqy.js +0 -2
- package/dist/chunk-7mkw98cr.js +0 -3
- package/dist/chunk-7xks65hg.js +0 -3
- package/dist/chunk-8k38mddf.js +0 -2
- package/dist/chunk-8q05cxzd.js +0 -2
- package/dist/chunk-a7y0fk20.js +0 -12
- package/dist/chunk-abwxa3tj.js +0 -2
- package/dist/chunk-ayjje1hk.js +0 -2
- package/dist/chunk-c93291jk.js +0 -2
- package/dist/chunk-cf6d5kgb.js +0 -65
- package/dist/chunk-crahn5xa.js +0 -4
- package/dist/chunk-d1jyxxcm.js +0 -3
- package/dist/chunk-d365tseq.js +0 -20
- package/dist/chunk-d67qvrzc.js +0 -24
- package/dist/chunk-dwnvqy3f.js +0 -4
- package/dist/chunk-dxb7jw7g.js +0 -2
- package/dist/chunk-e8483tnk.js +0 -2
- package/dist/chunk-eaphbqqx.js +0 -2
- package/dist/chunk-em0chjea.js +0 -18
- package/dist/chunk-ercd4pqc.js +0 -2
- package/dist/chunk-ewj4gqwe.js +0 -31
- package/dist/chunk-f7bgg2e4.js +0 -2
- package/dist/chunk-g6s0xdgb.js +0 -4
- package/dist/chunk-jxsgky4v.js +0 -2
- package/dist/chunk-k90yzxwp.js +0 -2
- package/dist/chunk-kfx4cte8.js +0 -127
- package/dist/chunk-kxbw0e2f.js +0 -3
- package/dist/chunk-ky043mkv.js +0 -2
- package/dist/chunk-mbqqc20a.js +0 -2
- package/dist/chunk-mq2kpg6w.js +0 -2
- package/dist/chunk-n58ky78d.js +0 -2
- package/dist/chunk-n80wh9b5.js +0 -2
- package/dist/chunk-p7sfjgtm.js +0 -2
- package/dist/chunk-ps9htxmp.js +0 -2
- package/dist/chunk-qhaw7f32.js +0 -2
- package/dist/chunk-rh33ra9e.js +0 -2
- package/dist/chunk-rzs2hpqa.js +0 -2
- package/dist/chunk-s3sckkvv.js +0 -2
- package/dist/chunk-s89pq4v1.js +0 -2
- package/dist/chunk-sdqgmcbk.js +0 -2
- package/dist/chunk-srmm69d4.js +0 -2852
- package/dist/chunk-t00y30w3.js +0 -2
- package/dist/chunk-t1a39rpd.js +0 -2
- package/dist/chunk-tj4rzy69.js +0 -2
- package/dist/chunk-tme51pg1.js +0 -2
- package/dist/chunk-tv1qtqab.js +0 -3
- package/dist/chunk-twh5ck5w.js +0 -2
- package/dist/chunk-v4tt3t1y.js +0 -2
- package/dist/chunk-v5ekdsw0.js +0 -2
- package/dist/chunk-vdsrae92.js +0 -2
- package/dist/chunk-w88mpbxk.js +0 -11
- package/dist/chunk-wg6n7txf.js +0 -2
- package/dist/chunk-wj4rf7sb.js +0 -2
- package/dist/chunk-wrd5me1w.js +0 -33
- package/dist/chunk-xbevgwks.js +0 -2
- package/dist/chunk-y2k3ynr2.js +0 -2
- package/dist/chunk-y51ndrdb.js +0 -2
- package/dist/chunk-y9wqzvxt.js +0 -2
- package/dist/chunk-yn2d8x8m.js +0 -3
- package/dist/chunk-ysmt4jpn.js +0 -2
- package/dist/chunk-zmccfvbf.js +0 -2
- package/dist/chunk-ztpqxs72.js +0 -2
- package/dist/chunk-ztwnn466.js +0 -2
- package/dist/chunk-zx7v6a4g.js +0 -40
- package/dist/chunk-zx94g4pg.js +0 -2
- package/dist/chunk-zze1ez1c.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{M,I,vr,wr,xr}from"./chunk-hvzzhkhr.js";import{resolve as z,basename as j,extname as T,join as q}from"path";import{mkdir as k}from"fs/promises";var S={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class Yo{config;constructor(e={}){this.config={...S,...e}}async get(e,s){return vr(e,s,"image",this.config)}async set(e,s,r){return wr(e,s,r,"image",this.config)}async clear(){return xr("image",this.config)}updateConfig(e){this.config={...this.config,...e}}}var w=null;function x(e){if(!w)w=new Yo(e);else if(e)w.updateConfig(e);return w}async function Zo(e,s,r){let t=r?{directory:`${r.outputDir}/../.cache`}:{};return x(t).get(e,s)}async function Qo(e,s,r,t){let a=t?{directory:`${t.outputDir}/../.cache`}:{};return x(a).set(e,s,r)}async function vu(){return x().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function F(e){switch(e){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function E(e,s){let r=s?F(s):F("web"),t=e.formatQuality||{};return{jpeg:{...r.jpeg,...t.jpeg},png:{...r.png,...t.png},webp:{...r.webp,...t.webp},avif:{...r.avif,...t.avif}}}async function wu(e,s,r){let t=await R();if(!t)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:e,processed:!1};let a=await Zo(e,s,r);if(a)return a;try{let c=z(e);if(!await I(c))return{src:e,processed:!1,errors:[`Source file not found: ${e}`]};let n=E(r,s.preset),p=r.outputDir||"dist/images",P=r.baseUrl||"/images";await k(p,{recursive:!0});let d=await M(c),b=j(e,T(e)),C=s.outputFormat?[s.outputFormat]:r.defaultFormats||["avif","webp","jpeg"],o={src:e,processed:!0,variants:[],hash:d},u=null;if(s.transformations&&s.transformations.length>0)u=await vc(c,s.transformations,t);for(let i of C){let l=n[i]||{},g=`${b}-${d}.${i}`,h=q(p,g);try{let m=await t.optimizeImage({input:u||c,output:h,format:i,quality:l.quality,progressive:l.progressive});if(m){if(o.variants.push({path:h,url:`${P}/${g}`,width:m.width||0,height:m.height||0,format:i,size:m.outputSize||0}),!o.originalWidth&&m.width)o.originalWidth=m.width,o.originalHeight=m.height}}catch(m){o.errors=o.errors||[],o.errors.push(`Failed to optimize ${i}: ${m}`)}}if(s.embedThumbhash||s.placeholder==="thumbhash")try{let i=await t.generateThumbHash(c);o.placeholder=i.dataUrl}catch(i){o.errors=o.errors||[],o.errors.push(`Failed to generate thumbhash: ${i}`)}if(s.useDominantColor)try{let i=await t.generatePlaceholder(c,{strategy:"dominant-color"});o.dominantColor=i.dominantColor}catch(i){o.errors=o.errors||[],o.errors.push(`Failed to extract dominant color: ${i}`)}return await Qo(e,s,o,r),o}catch(c){return{src:e,processed:!1,errors:[`Processing failed: ${c}`]}}}async function xu(e,s,r,t){let a=await R();if(!a)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await a.optimizeImage({input:e,output:t,format:s,quality:r}))?.outputSize}}catch(c){return{success:!1,error:String(c)}}}async function vc(e,s,r){let t=r||await R();if(!t)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let a=await t.decode(e);for(let c of s){let n=c.options||{};switch(c.type){case"resize":if(n.width||n.height)a=await t.resize(a,{width:n.width,height:n.height,fit:n.fit});break;case"blur":if(n.sigma!==void 0)a=await t.blur(a,n.sigma);break;case"sharpen":if(n.amount!==void 0)a=await t.sharpen(a,n.amount);break;case"grayscale":a=await t.grayscale(a);break;case"rotate":if(n.angle!==void 0)a=await t.rotate(a,n.angle);break;case"flip":a=await t.flip(a);break;case"flop":a=await t.flop(a);break;case"brightness":if(n.value!==void 0)a=await t.brightness(a,n.value);break;case"contrast":if(n.value!==void 0)a=await t.contrast(a,n.value);break;case"saturation":if(n.value!==void 0)a=await t.saturation(a,n.value);break}}return await t.encode(a,"png")}catch(a){return console.error(`[stx-media] Transformation failed: ${a}`),null}}import{resolve as D,basename as Q,extname as U,join as V}from"path";import{mkdir as L}from"fs/promises";async function H(){try{return await import("ts-images")}catch{return null}}var O=[320,480,640,768,1024,1280,1536,1920];async function Su(e,s,r){let t=await H();if(!t)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let a=D(e);if(!await I(a))return console.warn(`[stx-media] Source file not found: ${e}`),null;try{let c=s.responsiveWidths||r.breakpoints||O,n=s.formats||r.defaultFormats||["avif","webp","jpeg"],p=r.outputDir||"dist/images",P=r.baseUrl||"/images";await L(p,{recursive:!0});let d=await M(a),b=Q(e,U(e)),C=r.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},o={src:e,byFormat:{},srcsets:{}};for(let i of n){o.byFormat[i]=[];let l=[];for(let g of c){let h=`${b}-${g}w-${d}.${i}`,m=V(p,h),y=`${P}/${h}`;try{let v=C[i]?.quality||80;if(await I(m)){o.byFormat[i].push({path:m,url:y,width:g,height:0,format:i,size:0}),l.push(`${y} ${g}w`);continue}let f=await t.processImage({input:a,output:m,format:i,quality:v,resize:{width:g}});if(f)o.byFormat[i].push({path:m,url:y,width:g,height:f.height||Math.round(g*(f.height||1)/(f.width||1)),format:i,size:f.outputSize||0}),l.push(`${y} ${g}w`)}catch(v){console.warn(`[stx-media] Failed to generate ${i} at ${g}w: ${v}`)}}o.srcsets[i]=l.join(", ")}let u=s.placeholder||r.placeholderStrategy||"thumbhash";if(u!=="none")try{if(u==="thumbhash"){let i=await t.generateThumbHash(a);o.placeholder={dataURL:i.dataUrl,width:i.width||32,height:i.height||32,strategy:"thumbhash"}}else{let i=await t.generatePlaceholder(a,{strategy:u,width:20});o.placeholder={dataURL:i.dataURL,width:i.width,height:i.height,strategy:u}}}catch(i){console.warn(`[stx-media] Failed to generate placeholder: ${i}`)}return o.sizes=s.sizes||A(c),o}catch(c){return console.error(`[stx-media] Responsive generation failed: ${c}`),null}}function A(e){let s=[...e].sort((t,a)=>t-a),r=[];for(let t=0;t<s.length-1;t++){let a=s[t];r.push(`(max-width: ${a}px) ${a}px`)}return r.push(`${s[s.length-1]}px`),r.join(", ")}function ku(e,s="width"){if(!e||e.length===0)return"";if(s==="dpr")return e.filter((r)=>r.dpr).map((r)=>`${r.url} ${r.dpr}x`).join(", ");return e.map((r)=>`${r.url} ${r.width}w`).join(", ")}export{Yo,Zo,Qo,vu,wu,xu,vc,Su,ku};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{kl,Br}from"./chunk-nph4d1ff.js";import"./chunk-asqnaddf.js";import"./chunk-3e7haxwt.js";import{ar}from"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import{et}from"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{et as freeIdentifiers,Br as processComponents,kl as processESImports,ar as rendersAsElement};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Wc,qc,Gc,Kc,Xc,Jc,Yc,Zc,Qc,el,ed}from"./chunk-n38yb274.js";export{Wc as createIslandRegistry,ed as default,el as generateIslandManifest,Gc as generatePartialHydrationCSS,Jc as hydrateAll,Xc as hydrateByStrategy,Kc as hydrateIsland,Yc as isHydrated,Zc as onHydrated,qc as processPartialHydrationDirectives,Qc as processStaticDirectives};
|
|
@@ -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 zn(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 _e(n,i){return zn(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{zn,_e};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{x}from"./chunk-7rta163c.js";import{T,vn}from"./chunk-ce6zddpf.js";import{rn,y,b,S,G}from"./chunk-w1v1d7rq.js";import{i}from"./chunk-yfrvbnc6.js";import{ke,Xt,Jt,Yt}from"./chunk-wzgn9fv7.js";import{mt}from"./chunk-xnjf1zbn.js";import{dt,In,Wt,re}from"./chunk-vdxjy7j2.js";import{E,yr}from"./chunk-354jmw2k.js";import w from"path";var C=new Map,D=new Map,k=y(64),A=new Map,Z=["composables","functions"];function z(t){let n=w.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function q(t){if(t)return w.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await Q();if(e!==null)A.set(n,e);return e}async function Q(){let t=await i(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return w.resolve(n,a);for(let e of Z){let s=w.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function J(t){let n=Array.isArray(t)?t:t?[w.resolve(t)]:(await i())._layerComposableDirs??[await q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=w.relative(e,d);if(!z(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function zs(t){let{files:n}=await J(t),a=G({loader:"ts",target:"browser",define:S()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function V(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):V(t,s))e.add(s);return e}var U=y(64);function Y(t,n){let a=b(t,n.size),e=U.get(a);if(e)return e;let s;try{s=rn(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(a,s),s}function ee(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of Y(u,d))l.push(e.get(f));return l},m=new Set,p=a.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function zd(t,n,a){let{key:e,files:s}=await J(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((o)=>ke(o))])],c=dt(d());if(s.length===0)return re(C,e,c,""),null;s.sort();let m=G({loader:"ts",target:"browser",define:S()}),p=Wt(D,e,c);if(!p){let o=new Map,r=[];for(let g of s)try{let h=await Bun.file(g).text();o.set(g,h);let _=m.scan(h).exports.filter((X)=>X!=="default");if(_.length>0)r.push({file:g,names:_})}catch{o.set(g,"")}p=re(D,e,c,{codeByFile:o,modules:r})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let o=a?[n,...a]:[n],r=b(o.join("\x00"),e,o.length,c),g=k.get(r);if(f=g??ee(l,u,o),!g)k.set(r,f)}if(f.size===0)return null;let I=s.filter((o)=>f.has(o)),B=`${e}\x00${I.join("\x00")}\x00${Jt()}`,F=Wt(C,B,c);if(F!==void 0)return F||null;let M=[],v=new Set,R=new Set;for(let o of I)try{let r=u.get(o)??await Bun.file(o).text(),g=w.basename(o,".ts");for(let _ of r.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let h=[];try{for(let _ of m.scan(r).exports)if(_!=="default")v.add(_),h.push(_)}catch{}if(r=T(r),Xt(r))r=await Yt(r,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:h}),r=mt(r);r=vn(r),r=r.replace(/^export\s+(default\s+)?/gm,""),r=m.transformSync(r),M.push(`// Composable: ${g}
|
|
3
|
+
${r.trim()}`)}catch(r){console.warn(`[stx] Failed to load composable ${o}:`,r)}if(M.length===0||v.size===0)return re(C,B,c,""),null;let H=[...v].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
|
+
`),j=JSON.stringify([...v]),N=M.join(`
|
|
5
|
+
|
|
6
|
+
`),W=x.filter((o)=>!R.has(o)&&new RegExp(`\\b${o}\\b`).test(N)).map((o)=>`var ${o} = __stx[${JSON.stringify(o)}];`).join(`
|
|
7
|
+
`),P=JSON.stringify(new Bun.CryptoHasher("md5").update(`${j}\x00${N}`).digest("hex").slice(0,12)),K=`;(function(){
|
|
8
|
+
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
|
+
if (__bundles[${P}]) return;
|
|
10
|
+
__bundles[${P}] = true;
|
|
11
|
+
var __published = window.__stxComposableGlobals || (window.__stxComposableGlobals = {});
|
|
12
|
+
window.__composables = window.__composables || {};
|
|
13
|
+
var __c = window.__composables;
|
|
14
|
+
var __stx = window.stx || {};
|
|
15
|
+
${W}
|
|
16
|
+
${N}
|
|
17
|
+
${H}
|
|
18
|
+
var __names = ${j};
|
|
19
|
+
for (var __i = 0; __i < __names.length; __i++) {
|
|
20
|
+
var __n = __names[__i];
|
|
21
|
+
if (!(__n in __c) || __published[__n]) continue;
|
|
22
|
+
var __takenByBuiltin = !!(window.stx && __n in window.stx);
|
|
23
|
+
if (__takenByBuiltin || __n in window) {
|
|
24
|
+
console.warn('[stx] composable "' + __n + '" is not available as a bare identifier: '
|
|
25
|
+
+ (__takenByBuiltin ? 'a built-in of that name already exists' : 'window already defines that property')
|
|
26
|
+
+ '. Rename it, or use: import { ' + __n + ' } from "@composables"');
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
window[__n] = __c[__n];
|
|
30
|
+
__published[__n] = true;
|
|
31
|
+
}
|
|
32
|
+
})();`,O=E()?yr(K):K;return c=dt(d()),re(C,B,c,O),O}function Hd(){C.clear(),In(),D.clear(),k.clear(),A.clear()}
|
|
33
|
+
export{zs,zd,Hd};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{existsSync as g,statSync as p}from"fs";import e from"path";var w=/[*?[\]{}]/;function
|
|
3
|
-
export{
|
|
2
|
+
import{existsSync as g,statSync as p}from"fs";import e from"path";var w=/[*?[\]{}]/;function Al(o){return w.test(o)}async function fo(o,n={}){let i=n.cwd??process.cwd(),u=n.recursive!==!1,l=n.ignorePaths??[],c=globalThis.Bun.Glob,a=new Set,r=(t)=>{if(t.includes(`${e.sep}node_modules${e.sep}`)||t.includes(`${e.sep}dist${e.sep}`))return;if(l.some((s)=>s&&t.includes(e.normalize(s))))return;a.add(t)},d=async(t)=>{try{for await(let s of new c(t).scan({cwd:i,absolute:!0}))r(s)}catch{}};for(let t of o){if(!t)continue;if(Al(t)){await d(t);continue}let s=e.resolve(i,t);if(!g(s))continue;if(p(s).isDirectory()){for await(let f of new c(u?"**/*.stx":"*.stx").scan({cwd:s,absolute:!0}))r(f);continue}r(s)}return[...a].sort()}
|
|
3
|
+
export{Al,fo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{X,J,Y,Cn,pe,Se,ut,Ut,En,Tn,$n,Z,Rn,An}from"./chunk-x8k64g1e.js";import{yt}from"./chunk-ewcrsyr7.js";function kc(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=Y,placeholder:l="none",formats:f=J,widths:y=X,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 G(s,I,w);if(A||!b)return ee(s);return te(s)}function G(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=Tn(r),v=En(r),w=typeof m==="object"?Ut(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}"`:"",F=u?"":` loading="${o}"`,R=` decoding="${l}"`,C=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",E=["avif","webp","jpeg","png"],M=[];for(let k of E){let z=p.get(k);if(z&&z.length>0){let O=ut(z),K=Z(k);M.push(` <source type="${K}" srcset="${O}" sizes="${w}" />`)}}let U="",L="",T;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(U=`<div class="stx-image-wrapper" id="${k}">`,L="</div>",h==="blur")T=`
|
|
3
3
|
#${k} {
|
|
4
4
|
position: relative;
|
|
5
5
|
background-image: url('${e.placeholder}');
|
|
@@ -12,25 +12,25 @@ import{F,z,H,Zt,te,ue,Ve,Ct,Qt,en,tn,V,nn,rn}from"./chunk-g2mcw1r4.js";import{it
|
|
|
12
12
|
#${k}.loaded img {
|
|
13
13
|
opacity: 1;
|
|
14
14
|
}
|
|
15
|
-
`.trim();else if(h==="color")
|
|
15
|
+
`.trim();else if(h==="color")T=`
|
|
16
16
|
#${k} {
|
|
17
17
|
background-color: ${e.placeholder};
|
|
18
18
|
}
|
|
19
|
-
`.trim()}let
|
|
20
|
-
${
|
|
19
|
+
`.trim()}let _=a?` width="${a}"`:e?` width="${e.width}"`:"",H=i?` height="${i}"`:e?` height="${e.height}"`:"",Q=`${U}<picture>
|
|
20
|
+
${M.join(`
|
|
21
21
|
`)}
|
|
22
22
|
<img
|
|
23
23
|
src="${v?.url||t}"
|
|
24
|
-
alt="${
|
|
24
|
+
alt="${B(n)}"${_}${H}${S}${A}${F}${R}${C}
|
|
25
25
|
/>
|
|
26
|
-
</picture>${
|
|
26
|
+
</picture>${L}`,V;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,O=Z(z.format);V=`<link rel="preload" as="image" href="${z.url}" type="${O}" />`}return{html:Q,preloadLink:V,placeholderCss:T}}function ee(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="${B(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function te(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=Y,formats:u=J,widths:l=X,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}"`,F=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",R=typeof a==="object"?Ut(a):a,C=`
|
|
27
27
|
data-stx-image
|
|
28
28
|
data-src="${r}"
|
|
29
|
-
data-sizes="${
|
|
29
|
+
data-sizes="${R}"
|
|
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="${
|
|
33
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${B(e)}"${I}${b}${w}${v}${A}${S}${F} ${C} />`}}function wi(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 _c(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=wi(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 B(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var D=new Map;function Cc(){D.clear()}async function se(s,r){let e=`${s}:${JSON.stringify(r)}`;if(D.has(e))return D.get(e);try{let t=await Se(s,r);return D.set(e,t),t}catch{return null}}function xi(){return yt({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=re(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]:X),formats:a.formats||J,quality:a.quality||Y,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await pe())return q(t,n||"",a);let o=await se(t,i);if(!o)return q(t,n||"",a);return ie(o,n||"",a)}})}function re(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=ae(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 ae(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 q(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 ie(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=ut(p),w=Z(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(" ")} />
|
|
@@ -38,6 +38,6 @@ ${L.join(`
|
|
|
38
38
|
${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
|
-
</div>`}}if(e.priority&&y){let g=
|
|
42
|
-
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var
|
|
43
|
-
export{
|
|
41
|
+
</div>`}}if(e.priority&&y){let g=Z(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 Ec=xi();import P from"fs";import j from"path";function Tc(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=J,widths:a=X,quality:i=Y,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 pe()){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 Cn();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=ne(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ce(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await pe())return;await P.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!P.existsSync(w))continue;let I=await N(w);g.push(...I)}let p=f?g.filter((w)=>oe(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=W(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await Se(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=Rn(b.variants);if(c.stats.savedBytes+=Math.max(0,A-S/b.variants.length),y)console.log(` \u2713 ${j.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: ~${An(c.stats.savedBytes)}`)}}}function ne(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 oe(s,r){let e=j.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ce(s,r){return s}async function N(s){let r=[];async function e(t){let n=await P.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=j.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&$n(i))r.push(i)}}return await e(s),r}function W(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function $c(s,r,e={}){if(!await pe())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return Se(s,{...e,outputDir:r})}async function Rc(s,r,e={}){let{formats:t=J,widths:n=X,quality:a=Y,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await pe())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 N(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=W(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await Se(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${j.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 Si(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function Ac(s,r){let e=Si(s);await Bun.write(r,JSON.stringify(e,null,2))}var Pu={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{kc,wi,_c,Cc,xi,Ec,Tc,$c,Rc,Si,Ac,Pu};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{f,g,m}from"./chunk-w1v1d7rq.js";import{N}from"./chunk-yfrvbnc6.js";import{s}from"./chunk-dpjnjs09.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=n[1],i=n[2];t.push({type:"suspense",name:r,content:i}),o=n.index+n[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function rd(e,t={},o={}){let n={...N,...o,streaming:{...q,...o.streaming}},r=n.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await f(p,h,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await s(c,h,e,n,l);for(let b=0;b<u.length;b+=r)i.enqueue(u.slice(b,b+r)),await new Promise((y)=>setTimeout(y,0))}else{let u=[],b=new RegExp(T.source,"g"),y;while((y=b.exec(c))!==null)u.push({name:y[1],content:y[2],start:y.index,end:y.index+y[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await s(I,h,e,n,l);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await s(_.content,h,e,n,l);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await s(_,h,e,n,l);i.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await s(d.content,h,e,n,l);i.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;i.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
|
-
</div>`),
|
|
4
|
+
</div>`),w.set(d.name,s(d.content,h,e,n,l))}i.enqueue(`
|
|
5
5
|
<script>
|
|
6
6
|
(function() {
|
|
7
7
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -17,13 +17,13 @@ import{b,u,n,g,A}from"./chunk-srmm69d4.js";import k from"path";var q={enabled:!0
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
})();
|
|
20
|
-
</script>`);let
|
|
20
|
+
</script>`);let x=Array.from(w.entries()).map(async([d,u])=>{i.enqueue(await Li(d,u))});await Promise.all(x)}i.close()}catch(a){i.error(a)}}})}async function Li(e,t){try{let n=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
|
|
21
21
|
<script>
|
|
22
|
-
window.__stxSuspense.resolve('${e}', \`${
|
|
23
|
-
</script>`}catch(o){let
|
|
22
|
+
window.__stxSuspense.resolve('${e}', \`${n}\`);
|
|
23
|
+
</script>`}catch(o){let n=o instanceof Error?o.message:String(o);return`
|
|
24
24
|
<script>
|
|
25
|
-
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${
|
|
26
|
-
</script>`}}var
|
|
25
|
+
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${m(n)}</div>');
|
|
26
|
+
</script>`}}var il=`
|
|
27
27
|
<script>
|
|
28
28
|
(function(){
|
|
29
29
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -43,12 +43,12 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
|
-
</script>`;function z(e,t,o){if(!t||t<=0)return e;let
|
|
46
|
+
</script>`;function z(e,t,o){if(!t||t<=0)return e;let n,r=new Promise((i,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,r]).finally(()=>clearTimeout(n))}function sd(e,t=[],o={}){let n=o.timeoutMs??0;return new ReadableStream({async start(r){try{if(r.enqueue(e),t.length>0)r.enqueue(il),await Promise.all(t.map(async(i)=>{let a=z(i.render(),n,i.id);r.enqueue(await Li(i.id,a))}));r.close()}catch(i){r.error(i)}}})}var A=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function od(e,t){return e.replace(A,(o,n,r)=>{let i=n.trim(),a=r.split(/@fallback/i),S=a[0].trim(),p=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[i]=S,`<div data-suspense="${i}">${p}</div>`})}function id(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,n])=>typeof n==="function");return o.length>0?o.map(([n,r])=>({id:n,render:r})):void 0}async function ad(e,t={},o={}){let n={...N,...o,streaming:{...q,...o.streaming}},r=n.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await f(p,h,e);let E=new Set,l=n.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(l!=="manual"&&R.test(c))){let x=await s(c,h,e,n,E);for(let d=0;d<x.length;d+=r)i.enqueue(x.slice(d,d+r))}else{let x=[],d=new RegExp(T.source,"g"),u;while((u=d.exec(c))!==null)x.push({name:u[1],content:u[2],start:u.index,end:u.index+u[0].length});let b=0;for(let y of x){if(y.start>b){let _=c.slice(b,y.start);if(_.trim()){let C=await s(_,h,e,n,E);i.enqueue(C)}}let v=await s(y.content,h,e,n,E);i.enqueue(v),b=y.end}if(b<c.length){let y=c.slice(b);if(y.trim()){let v=await s(y,h,e,n,E);i.enqueue(v)}}}i.close()}catch(a){i.error(a)}}})}async function cd(e,t={}){let o={...N,...t,streaming:{...q,...t.streaming}},n=await Bun.file(e).text(),r=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),i=r?r[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,p={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let l=c[1],R=c[2];p[l]=R}let h=a.replace(T,"");return{renderShell:async(l={})=>{let R={...l,__filename:e,__dirname:k.dirname(e)};return await f(i,R,e),s(h,R,e,o,new Set)},renderSection:async(l,R={})=>{try{if(!p[l])return`<div class="error-message">Section "${m(l)}" not found in template "${m(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await f(i,w,e);let x=new Set;return await s(p[l],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return g("Expression",x,e,p[l]||"",0,p[l]||"")}},getSections:()=>Object.keys(p),getTemplate:()=>S}}var al={name:"suspense",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let r=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${r} -->${e}<!-- @endsuspense:${r} -->`}},cl={name:"island",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let r=t[0].replace(/['"`]/g,""),i=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${r}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),p=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${r}" data-island-id="${a}" data-priority="${i}">
|
|
47
47
|
${c}
|
|
48
48
|
<script type="application/json" data-island-props="${a}">
|
|
49
|
-
${
|
|
49
|
+
${p?`{${p}}`:"{}"}
|
|
50
50
|
</script>
|
|
51
|
-
</div>`}};function
|
|
51
|
+
</div>`}};function ld(e={}){let t=[];if(e.streaming?.enabled)t.push(al);if(e.hydration?.enabled)t.push(cl);return t}async function ud(e,t,o,n={}){return e}function dd(e,t={}){let o=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(i,a){a.enqueue(o.encode(i))}})),r=new Headers(t.headers);if(!r.has("Content-Type"))r.set("Content-Type","text/html; charset=utf-8");if(!r.has("Transfer-Encoding"))r.set("Transfer-Encoding","chunked");if(!r.has("X-Content-Type-Options"))r.set("X-Content-Type-Options","nosniff");if(!r.has("X-Accel-Buffering"))r.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:r})}function pd(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:n=!0}=e,r=Object.entries(o).map(([i,a])=>`'${i}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
|
|
52
52
|
`);if(t==="loader")return`
|
|
53
53
|
(function() {
|
|
54
54
|
window.__stx = window.__stx || {};
|
|
@@ -191,4 +191,4 @@ else {
|
|
|
191
191
|
stx.hydrate();
|
|
192
192
|
}
|
|
193
193
|
})();`}
|
|
194
|
-
export{
|
|
194
|
+
export{rd,Li,il,sd,od,id,ad,cd,al,cl,ld,ud,dd,pd};
|