@stacksjs/stx 0.2.771 → 0.2.775
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-shell.d.ts +10 -0
- package/dist/app-shell.js +3 -0
- package/dist/chunk-02mqhdjh.js +2 -0
- package/dist/chunk-0b5kxf5j.js +3 -0
- package/dist/chunk-0jvrzpfs.js +2 -0
- package/dist/chunk-11mygkp2.js +2 -0
- package/dist/chunk-1tvb2stj.js +2 -0
- package/dist/{chunk-krdc3c87.js → chunk-20afyff6.js} +3 -3
- package/dist/chunk-21kkn27r.js +2 -0
- package/dist/chunk-26bk0d1q.js +2 -0
- package/dist/{chunk-p1mbbdwj.js → chunk-27rzdq3n.js} +2 -2
- package/dist/{chunk-s369wfsp.js → chunk-286yy223.js} +6 -6
- package/dist/{chunk-xaqtk05e.js → chunk-2gqhfge6.js} +2 -2
- package/dist/chunk-2vnhyter.js +2 -0
- package/dist/{chunk-4833k99b.js → chunk-2yxva96k.js} +2 -2
- package/dist/chunk-3b2yc1p4.js +2 -0
- package/dist/{chunk-e6ynacgc.js → chunk-3vj887s9.js} +2 -2
- package/dist/{chunk-477gjb2b.js → chunk-416jy1m5.js} +2 -2
- package/dist/{chunk-c9ygnsx5.js → chunk-42d8076j.js} +68 -68
- package/dist/chunk-47qestfz.js +2 -0
- package/dist/chunk-4kx7pw6x.js +2 -0
- package/dist/{chunk-x148cxrj.js → chunk-4wc5pc19.js} +4 -4
- package/dist/{chunk-f7h5ty84.js → chunk-56j217w9.js} +2 -2
- package/dist/{chunk-3csfmhg0.js → chunk-5emrarpf.js} +2 -2
- package/dist/{chunk-erjp2w63.js → chunk-5mng4x26.js} +5 -5
- package/dist/{chunk-bwzjjxnj.js → chunk-605b93pe.js} +4 -4
- package/dist/chunk-6r5ynphk.js +2 -0
- package/dist/{chunk-pqyhxpa6.js → chunk-70x35hkm.js} +5 -5
- package/dist/chunk-713az4kg.js +2 -0
- package/dist/{chunk-bwv5j7z3.js → chunk-73197ak9.js} +6 -6
- package/dist/{chunk-6sa5adg6.js → chunk-7gdwvnwc.js} +2 -2
- package/dist/chunk-7gsp4wxj.js +2 -0
- package/dist/chunk-7mshja1h.js +177 -0
- package/dist/{chunk-g4k0svq6.js → chunk-7qk4exw1.js} +2 -2
- package/dist/{chunk-wmnzapn8.js → chunk-7sh9fa3q.js} +2 -2
- package/dist/{chunk-e6az23ep.js → chunk-7vpzzr5k.js} +59 -59
- package/dist/chunk-7y2h7nfd.js +2 -0
- package/dist/chunk-7y6ad89y.js +2 -0
- package/dist/{chunk-spr5bxm8.js → chunk-85tzv79s.js} +1 -1
- package/dist/chunk-8ds59ttd.js +2 -0
- package/dist/{chunk-m0deyakx.js → chunk-8ek9ayfk.js} +6 -6
- package/dist/{chunk-4qng287p.js → chunk-8nb8b0nf.js} +2 -2
- package/dist/chunk-8pyyqev1.js +2 -0
- package/dist/chunk-96zrm4x7.js +2 -0
- package/dist/{chunk-83fh7j8g.js → chunk-985afhhy.js} +2 -2
- package/dist/chunk-9896204h.js +2 -0
- package/dist/{chunk-2vbgm9t4.js → chunk-9ct3gbyv.js} +6 -6
- package/dist/{chunk-yzbdm457.js → chunk-9f6qx8b9.js} +2 -2
- package/dist/chunk-9qwkyt81.js +2 -0
- package/dist/{chunk-tahdfsp4.js → chunk-9tec9eap.js} +2 -2
- package/dist/{chunk-cn7d3389.js → chunk-9ydrcvjj.js} +30 -30
- package/dist/{chunk-vht2rhrj.js → chunk-ady8cnpb.js} +5 -5
- package/dist/chunk-aent8wje.js +2 -0
- package/dist/chunk-ajj56vrw.js +2 -0
- package/dist/{chunk-g9kgxx0t.js → chunk-apmn6hf2.js} +3 -3
- package/dist/chunk-b3b9tfpx.js +2 -0
- package/dist/chunk-ba0kefkt.js +2 -0
- package/dist/chunk-bc35m40d.js +2 -0
- package/dist/{chunk-efr9dgt6.js → chunk-bgc2fm73.js} +2 -2
- package/dist/{chunk-xw8ygkyb.js → chunk-bhbcm77r.js} +2 -2
- package/dist/{chunk-wabahwkj.js → chunk-bmfk3b29.js} +2 -2
- package/dist/{chunk-5s2dwh5z.js → chunk-bq9xf8nq.js} +16 -16
- package/dist/{chunk-hgm6f2t2.js → chunk-c0ejyxfj.js} +3 -3
- package/dist/chunk-c91y14ae.js +2 -0
- package/dist/{chunk-jasfbhp3.js → chunk-cb478dy9.js} +7 -7
- package/dist/{chunk-81x4xnv9.js → chunk-cf7rq74j.js} +9 -9
- package/dist/{chunk-dmj9gk6d.js → chunk-cfpw4c6b.js} +2 -2
- package/dist/chunk-cgamtmxv.js +2 -0
- package/dist/chunk-cpq9b0fx.js +2 -0
- package/dist/{chunk-m207mdpy.js → chunk-cz8mka1b.js} +2 -2
- package/dist/{chunk-rkz3k2td.js → chunk-d18xd9x5.js} +3 -3
- package/dist/{chunk-4q292036.js → chunk-dvarmxjq.js} +6 -6
- package/dist/chunk-dxp022r0.js +2 -0
- package/dist/{chunk-xr28hjkp.js → chunk-e1gxykm8.js} +7 -7
- package/dist/{chunk-7h0mjwkq.js → chunk-eapt899m.js} +5 -5
- package/dist/{chunk-qmwaqdc1.js → chunk-ee9f9ety.js} +17 -17
- package/dist/{chunk-qtja7fpr.js → chunk-et1vz3wd.js} +2 -2
- package/dist/{chunk-zs35vgyy.js → chunk-f5tg49tb.js} +4 -4
- package/dist/chunk-f9bj9nce.js +2 -0
- package/dist/{chunk-ssd9g1wz.js → chunk-fpn4dren.js} +1 -1
- package/dist/{chunk-2s0157xg.js → chunk-fppa729v.js} +3 -3
- package/dist/chunk-fprb7vaf.js +2 -0
- package/dist/{chunk-nk4jhdnk.js → chunk-fxwkw93g.js} +3 -3
- package/dist/{chunk-g53y0v3f.js → chunk-g31ca0ax.js} +10 -10
- package/dist/chunk-g9xeydd7.js +2 -0
- package/dist/chunk-ga3y58h7.js +2 -0
- package/dist/chunk-gbgbhpms.js +2 -0
- package/dist/{chunk-cn7zpm1x.js → chunk-gbx5vw81.js} +5 -5
- package/dist/{chunk-3jv81hw3.js → chunk-gybdzsj7.js} +3 -3
- package/dist/{chunk-w07n2ddj.js → chunk-he85ksa7.js} +2 -2
- package/dist/{chunk-yjdnfxm7.js → chunk-hrj5hg2n.js} +3 -3
- package/dist/{chunk-afxt272e.js → chunk-hvd3vdm9.js} +14 -14
- package/dist/chunk-j43asvw6.js +2 -0
- package/dist/chunk-jdj1358b.js +3 -0
- package/dist/{chunk-zkwtrmwg.js → chunk-jp0dachh.js} +2 -2
- package/dist/chunk-jy2xmwf4.js +2 -0
- package/dist/{chunk-z5vkzbct.js → chunk-k0aejzg9.js} +4 -4
- package/dist/{chunk-0wj31pqy.js → chunk-k3rcpnzm.js} +2 -2
- package/dist/{chunk-nnzmbfjq.js → chunk-k4bdf0dw.js} +3 -3
- package/dist/chunk-k5qgfjzg.js +2 -0
- package/dist/{chunk-6d1jmx97.js → chunk-k6exjw0z.js} +9 -9
- package/dist/chunk-k9dg3nyy.js +2 -0
- package/dist/{chunk-ddhazq2g.js → chunk-kf8hzvb7.js} +3 -3
- package/dist/{chunk-rc4zsymn.js → chunk-kr8qdg0r.js} +2 -2
- package/dist/chunk-ksq6q8n1.js +2 -0
- package/dist/{chunk-2bm97z09.js → chunk-m4mpyq3d.js} +3 -3
- package/dist/chunk-m90wyzhd.js +2 -0
- package/dist/chunk-mcevnfnx.js +2 -0
- package/dist/{chunk-am4wadh7.js → chunk-mv3yhspn.js} +2 -2
- package/dist/{chunk-2g7yg3na.js → chunk-n0czk1fr.js} +6 -6
- package/dist/chunk-n2wea4wt.js +2 -0
- package/dist/chunk-n5ejs365.js +2 -0
- package/dist/{chunk-v3kynq6v.js → chunk-na6yveav.js} +5 -5
- package/dist/chunk-ndjmt3vg.js +3 -0
- package/dist/chunk-nfkr531f.js +2 -0
- package/dist/chunk-nqases6m.js +3 -0
- package/dist/chunk-nx20kccb.js +2 -0
- package/dist/chunk-p43hw6ef.js +2 -0
- package/dist/chunk-q71qqjy7.js +2 -0
- package/dist/{chunk-6b32wt31.js → chunk-qby3e5nm.js} +30 -30
- package/dist/{chunk-ngzdcvry.js → chunk-qfcn4btf.js} +1 -1
- package/dist/chunk-qtcxy3y3.js +2 -0
- package/dist/chunk-r19swv5s.js +2 -0
- package/dist/{chunk-618d3ng3.js → chunk-r1jzbqr3.js} +6 -6
- package/dist/{chunk-55rg4qyr.js → chunk-r64derfx.js} +2 -2
- package/dist/{chunk-qk61pv1v.js → chunk-ra8f8sm2.js} +15 -10
- package/dist/chunk-s53psb1j.js +2 -0
- package/dist/{chunk-nbwmcm2p.js → chunk-s9vymzsb.js} +6 -6
- package/dist/chunk-scd1b28h.js +2 -0
- package/dist/chunk-srd9dakc.js +2 -0
- package/dist/{chunk-38c5cw2c.js → chunk-sxn4b24s.js} +1 -1
- package/dist/{chunk-ddjkt87h.js → chunk-sxwgq49z.js} +1 -1
- package/dist/chunk-t482tgm6.js +2 -0
- package/dist/{chunk-91q55gjp.js → chunk-td3qp5my.js} +3 -3
- package/dist/chunk-tsvnhc0c.js +4 -0
- package/dist/{chunk-qr5ddqbf.js → chunk-tyjzye2d.js} +2 -2
- package/dist/{chunk-nj2q40p8.js → chunk-vct6dec8.js} +2 -2
- package/dist/{chunk-4fkxm22d.js → chunk-w1mjt8jc.js} +2 -2
- package/dist/{chunk-1925kbjc.js → chunk-w9d18r1t.js} +1 -1
- package/dist/chunk-wcm7e1r3.js +2 -0
- package/dist/{chunk-5t33zwwg.js → chunk-wj78td69.js} +1 -1
- package/dist/chunk-wm8wz183.js +2 -0
- package/dist/{chunk-snbnhqn3.js → chunk-wsfk4y4m.js} +10 -10
- package/dist/chunk-x0e0pcn0.js +2 -0
- package/dist/chunk-x756yzrc.js +2 -0
- package/dist/{chunk-07thf07b.js → chunk-x8anspa5.js} +2 -2
- package/dist/{chunk-cak9fp9b.js → chunk-x8js27hd.js} +7 -7
- package/dist/chunk-xj6vm7v9.js +2 -0
- package/dist/chunk-xq2tfg4v.js +2 -0
- package/dist/{chunk-vke28xq8.js → chunk-y38swh5t.js} +2 -2
- package/dist/{chunk-pgkcbm6g.js → chunk-y5f04xtb.js} +2 -2
- package/dist/{chunk-z1br7qeb.js → chunk-yewd8836.js} +4 -4
- package/dist/chunk-yjeqae79.js +2 -0
- package/dist/chunk-yrdxvphr.js +2 -0
- package/dist/{chunk-x0qtgyqr.js → chunk-yzs2afn7.js} +9 -9
- package/dist/{chunk-nwhv1889.js → chunk-z2m9p8xe.js} +3 -3
- package/dist/chunk-zh8w0nb6.js +2 -0
- package/dist/chunk-zhm282df.js +2 -0
- package/dist/{chunk-79x0812m.js → chunk-zxfptbac.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/client/signals-dom-ready-runtime.js +6 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dev-server/serve-app.js +2 -2
- package/dist/native/bridge/protocol.d.ts +1 -1
- package/dist/native/compiler/headwind-to-style.d.ts +2 -10
- package/dist/native/compiler/headwind-to-style.js +31 -2
- package/dist/native/compiler/html-to-ir.js +14 -4
- package/dist/native/compiler/ir.d.ts +3 -0
- package/dist/native/event-names.js +14 -1
- package/dist/native/prop-names.js +8 -1
- package/dist/native/runtime/craft-bridge.js +7 -1
- package/dist/native/runtime/craft.d.ts +1 -1
- package/dist/native/runtime/native-host.d.ts +1 -0
- package/dist/native/runtime/native-host.js +8 -2
- package/dist/native/runtime/shared-screen.js +1 -0
- package/dist/native/testing.d.ts +1 -1
- package/dist/production-server.js +5 -5
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +10 -10
- package/package.json +5 -5
- package/dist/chunk-0qgdex7z.js +0 -2
- package/dist/chunk-1gpvkgb0.js +0 -2
- package/dist/chunk-1se5y83a.js +0 -2
- package/dist/chunk-1y4agex5.js +0 -2
- package/dist/chunk-2p301rsb.js +0 -2
- package/dist/chunk-2zg3jmy7.js +0 -2
- package/dist/chunk-33gccrx0.js +0 -2
- package/dist/chunk-3jkbs3fc.js +0 -2
- package/dist/chunk-3pxche1k.js +0 -2
- package/dist/chunk-3vankrf5.js +0 -2
- package/dist/chunk-4tvty67c.js +0 -2
- package/dist/chunk-4xdapekt.js +0 -2
- package/dist/chunk-4xzk9529.js +0 -3
- package/dist/chunk-53md2scd.js +0 -2
- package/dist/chunk-5c4g0v5g.js +0 -2
- package/dist/chunk-5g5v7yns.js +0 -2
- package/dist/chunk-6weh2dhz.js +0 -177
- package/dist/chunk-75st1ttq.js +0 -2
- package/dist/chunk-7k95121a.js +0 -2
- package/dist/chunk-7p4tvw5x.js +0 -2
- package/dist/chunk-825zg5ar.js +0 -2
- package/dist/chunk-83aq0n9s.js +0 -2
- package/dist/chunk-83c3vrbg.js +0 -3
- package/dist/chunk-9pgnhayn.js +0 -2
- package/dist/chunk-9vgkp3nj.js +0 -2
- package/dist/chunk-9za2wr5r.js +0 -2
- package/dist/chunk-ba43drcj.js +0 -2
- package/dist/chunk-bpbhjn4w.js +0 -2
- package/dist/chunk-cgv3r6q9.js +0 -2
- package/dist/chunk-cnt08b67.js +0 -2
- package/dist/chunk-e645nk33.js +0 -4
- package/dist/chunk-g3sgf16e.js +0 -2
- package/dist/chunk-g5ebz7hm.js +0 -2
- package/dist/chunk-g6m3q9n4.js +0 -2
- package/dist/chunk-h2ymq7fa.js +0 -2
- package/dist/chunk-hnen9b45.js +0 -2
- package/dist/chunk-hy91tn1w.js +0 -2
- package/dist/chunk-j46nvncc.js +0 -2
- package/dist/chunk-jjvrm2j8.js +0 -2
- package/dist/chunk-k4pwpr5q.js +0 -2
- package/dist/chunk-kh0szwf3.js +0 -2
- package/dist/chunk-kzx3t7q6.js +0 -2
- package/dist/chunk-mvfj17fr.js +0 -2
- package/dist/chunk-nmjgcw4g.js +0 -2
- package/dist/chunk-p454tj1h.js +0 -2
- package/dist/chunk-p7ksex4f.js +0 -2
- package/dist/chunk-q245q8z1.js +0 -2
- package/dist/chunk-q4m5p4wx.js +0 -2
- package/dist/chunk-q85s8ne0.js +0 -2
- package/dist/chunk-qy01jdzk.js +0 -2
- package/dist/chunk-rfp5f55f.js +0 -2
- package/dist/chunk-tk17tjzw.js +0 -2
- package/dist/chunk-tw2c09tw.js +0 -2
- package/dist/chunk-tynz075x.js +0 -2
- package/dist/chunk-v0tewfbx.js +0 -2
- package/dist/chunk-vdxjyrjf.js +0 -3
- package/dist/chunk-vk494kgn.js +0 -2
- package/dist/chunk-vyr8zzyr.js +0 -2
- package/dist/chunk-w1sjp421.js +0 -2
- package/dist/chunk-wq0wbvgd.js +0 -2
- package/dist/chunk-wr6b3a1w.js +0 -2
- package/dist/chunk-wwnqbv9j.js +0 -3
- package/dist/chunk-x3xtyr95.js +0 -2
- package/dist/chunk-xb16yy2x.js +0 -2
- package/dist/chunk-y7df8y9a.js +0 -2
- package/dist/chunk-ybd2tfqm.js +0 -2
- package/dist/chunk-yrh9yfnv.js +0 -2
- package/dist/chunk-ysm6gaq9.js +0 -2
- package/dist/chunk-z6xfmrtc.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{Q,ee,te,
|
|
2
|
+
import{Ke,re,Xa}from"./chunk-c0ejyxfj.js";import v from"fs";import g from"path";import V from"crypto";import{generatePlaceholder as T,processImage as L}from"ts-images";var Q=[320,640,768,1024,1280,1536,1920],ee=["webp","jpeg"],te=80,D=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],U={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},I=null,M=!1;async function d(){if(M)return I;M=!0;try{let t=await import("sharp");return I=t.default||t,I}catch{return null}}async function Nn(){return await d()!==null}async function me(){return!0}async function Te(t,e={}){let{widths:a=Q,formats:r=ee,quality:n=te,fit:c="cover",placeholder:i="none",outputDir:m=".stx/images",baseUrl:s="/images"}=e,h,l;if(typeof t==="string"){if(l=t,!await Bun.file(t).exists())throw new Xr(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((o)=>Buffer.from(o))}else l="buffer-input",h=t;let b=V.createHash("sha256").update(h).digest("hex").slice(0,12),j=await Kr(h),{width:u,height:x}=j,F=u/x;await v.promises.mkdir(m,{recursive:!0});let B=[],A=g.basename(l,g.extname(l)),f=a.filter((o)=>o<=u);if(!f.includes(u)&&u<=Math.max(...a))f.push(u);f.sort((o,p)=>o-p);for(let o of f){let p=Math.round(o/F);for(let w of r){let S=`${A}-${o}w-${b}.${w}`,P=g.join(m,S),q=`${s}/${S}`,E=await Hl(h,{width:o,height:p,format:w,quality:n,fit:c});await Bun.write(P,E),B.push({path:P,url:q,width:o,height:p,format:w,size:E.length})}}let y;if(i!=="none")y=await k(h,i);return{src:l,variants:B,placeholder:y,width:u,height:x,aspectRatio:F,hash:b}}async function Kr(t){let e=typeof t==="string"?Buffer.from(await Bun.file(t).arrayBuffer()):t,a=await d();if(a){let n=await a(e).metadata();return{width:n.width||0,height:n.height||0,format:n.format||"unknown",hasAlpha:n.hasAlpha}}return R(e)}function R(t){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let e=t.readUInt32BE(16),a=t.readUInt32BE(20);return{width:e,height:a,format:"png",hasAlpha:!0}}if(t[0]===255&&t[1]===216){let e=2;while(e<t.length){if(t[e]!==255)break;let a=t[e+1];if(a>=192&&a<=207&&a!==196&&a!==200&&a!==204){let n=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:n,format:"jpeg",hasAlpha:!1}}let r=t.readUInt16BE(e+2);e+=2+r}}if(t.toString("utf8",0,4)==="RIFF"&&t.toString("utf8",8,12)==="WEBP"){let e=t.toString("utf8",12,16);if(e==="VP8 "){let a=t.readUInt16LE(26)&16383,r=t.readUInt16LE(28)&16383;return{width:a,height:r,format:"webp",hasAlpha:!1}}if(e==="VP8L"){let a=t.readUInt32LE(21),r=(a&16383)+1,n=(a>>14&16383)+1;return{width:r,height:n,format:"webp",hasAlpha:!0}}}if(t.toString("utf8",0,3)==="GIF"){let e=t.readUInt16LE(6),a=t.readUInt16LE(8);return{width:e,height:a,format:"gif",hasAlpha:!0}}throw new Xr("Unable to parse image dimensions","PARSE_ERROR")}async function Hl(t,e){let a=await d();if(a){let r=a(t).resize(e.width,e.height,{fit:e.fit});switch(e.format){case"webp":r=r.webp({quality:e.quality});break;case"avif":r=r.avif({quality:e.quality});break;case"jpeg":r=r.jpeg({quality:e.quality});break;case"png":r=r.png({quality:e.quality});break}return r.toBuffer()}return await Xa("img",async(r)=>{let n=g.join(r,`out.${e.format}`);return await L({input:t,output:n,format:e.format,quality:e.quality,resize:{width:e.width,height:e.height,fit:e.fit}}),Buffer.from(await Bun.file(n).arrayBuffer())})}async function k(t,e){let a=await d();if(e==="blur"&&a){let m=(await a(t).resize(20).blur(10).toBuffer()).toString("base64"),s=await Kr(t);return`data:${U[s.format]||"image/jpeg"};base64,${m}`}if(e==="dominant-color"&&a){let{dominant:i}=await a(t).resize(1,1).toBuffer().then(async(m)=>{let s=await a(m).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${i.r}, ${i.g}, ${i.b})`}let r=await Kr(t),n=Ke("ph"),c=g.join(n,`in.${r.format==="unknown"?"bin":r.format}`);try{await Bun.write(c,t);let i=e==="blur"?"blur":e==="thumbhash"?"thumbhash":"dominant-color",s=await T(c,{strategy:i,width:i==="thumbhash"?void 0:32});if(e==="dominant-color"&&s.dominantColor)return s.dominantColor;if(s.dataURL)return s.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{re(n)}}function gt(t,e){return(e?t.filter((r)=>r.format===e):t).sort((r,n)=>r.width-n.width).map((r)=>`${r.url} ${r.width}w`).join(", ")}function Xt(t){if(!t||Object.keys(t).length===0)return"100vw";return Object.entries(t).sort((a,r)=>{let n=Number.parseInt(a[0].replace(/\D/g,""))||0;return(Number.parseInt(r[0].replace(/\D/g,""))||0)-n}).map(([a,r])=>`(max-width: ${a}) ${r}`).join(", ")+", 100vw"}function Dn(t){let e=t.filter((r)=>r.format==="jpeg");if(e.length===0)return t[Math.floor(t.length/2)];let a=e.sort((r,n)=>r.width-n.width);return a[Math.floor(a.length/2)]}function Mn(t){let e=new Map;for(let a of t){let r=e.get(a.format)||[];r.push(a),e.set(a.format,r)}return e}function Ln(t){let e=g.extname(t).toLowerCase();return D.includes(e)}function ne(t){return U[t]||"application/octet-stream"}function jn(t){return t.reduce((e,a)=>e+a.size,0)}function Bn(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;return`${(t/1048576).toFixed(2)} MB`}class Xr extends Error{code;constructor(t,e){super(t);this.name="ImageProcessingError",this.code=e}}
|
|
3
|
+
export{Q,ee,te,Nn,me,Te,Kr,Hl,gt,Xt,Dn,Mn,Ln,ne,jn,Bn,Xr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as
|
|
3
|
-
export{
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as im}from"ts-broadcasting";import{Broadcast as am,BroadcastServer as cm}from"ts-broadcasting";var e=null,u=[];function Zg(){return e}async function Qg(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function em(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function tm(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();Ll(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function Ll(n,t,r){if(!i())return;s.send(n,t,r)}function nm(n,t,r){if(!i())return;s.toUser(n,t,r)}function rm(n,t,r){if(!i())return;s.toUsers(n,t,r)}function sm(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function om(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{Zg,Qg,em,tm,Ll,nm,rm,sm,om,im,am,cm};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function
|
|
2
|
+
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function Ga(e){let t={pages:0,assets:0,bytesInlined:0},n=R.join(e,S),i=new Set;for(let s of k(e)){let r=y.readFileSync(s,"utf8"),{html:o,assets:g,bytesInlined:u}=I(r);if(o===r)continue;for(let c of g){if(i.has(c.filename))continue;i.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(R.join(n,c.filename),c.contents),t.assets++}y.writeFileSync(s,o),t.bytesInlined+=u,t.pages++}return t}import h from"fs";import T from"path";var L=1024,N=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,_=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function B(e){return Bun.hash(e).toString(16).slice(0,8)}function C(e){let t=[],n=(i)=>{for(let s of h.readdirSync(i,{withFileTypes:!0})){let r=T.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(h.existsSync(e))n(e);return t}function O(e,t){let n=e.match(new RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function H(e,t,n){if(n.length<L)return!1;if(/\b(?:src|href)\s*=/i.test(t))return!1;if(e.toLowerCase()==="script"){if(!_.has((O(t,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function D(e){let t=[];for(let n of e.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))t.push([n.index,n.index+n[0].length]);return t}function Ja(e){let t={pages:0,assets:0,bytesInlined:0},n=C(e);if(n.length<2)return t;let i=new Map,s=new Map;for(let a of n){let f=h.readFileSync(a,"utf8");i.set(a,f);let M=D(f);for(let d of f.matchAll(N)){let[x,p,l,m]=d;if(!H(p,l,m))continue;if(M.some(([j,A])=>d.index>=j&&d.index<A))continue;let w=`${p.toLowerCase()}\x00${m}`,b=s.get(w);if(b)b.push({file:a,whole:x,tag:p,attrs:l,body:m});else s.set(w,[{file:a,whole:x,tag:p,attrs:l,body:m}])}}let r=[...s.values()].filter((a)=>new Set(a.map((f)=>f.file)).size>1);if(r.length===0)return t;let o=T.join(e,S),g=new Map(i),u=new Map,c=[];for(let a of r){let{tag:f,body:M}=a[0],d=f.toLowerCase()==="script",x=`${d?"chunk":"style"}.${B(M)}.${d?"js":"css"}`;c.push({filename:x,contents:M,contentType:d?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${S}/${x}`;for(let l of a){let m=d?`<script${l.attrs} src="${p}"></script>`:`<link${l.attrs} rel="stylesheet" href="${p}">`,w=g.get(l.file),b=w.replace(l.whole,()=>m);if(b===w)continue;g.set(l.file,b),u.set(l.file,(u.get(l.file)??0)+l.body.length)}}h.mkdirSync(o,{recursive:!0});for(let a of c)h.writeFileSync(T.join(o,a.filename),a.contents),t.assets++;for(let[a,f]of g){if(f===i.get(a))continue;h.writeFileSync(a,f),t.pages++,t.bytesInlined+=u.get(a)??0}return t}import E from"fs";import v from"path";var K="layout-types.d.ts";function P(e){let t=[],n=(i,s)=>{let r;try{r=E.readdirSync(i,{withFileTypes:!0})}catch{return}for(let o of r){if(o.name.startsWith("."))continue;let g=v.join(i,o.name);if(o.isDirectory())n(g,s?`${s}/${o.name}`:o.name);else if(o.isFile()&&o.name.endsWith(".stx")&&o.name!=="_layout.stx"){let u=o.name.slice(0,-4);t.push(s?`${s}/${u}`:u)}}};return n(e,""),t.sort()}function W(e){let t=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(e.length===0)return t.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),t.join(`
|
|
3
3
|
`);return t.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...e.map((n)=>` '${n}': true`)," }","}","","export {}",""),t.join(`
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
4
|
+
`)}function Ya(e,t){if(!e)return[];let n=v.isAbsolute(e)?e:v.resolve(process.cwd(),e),i=P(n),s=W(i),r=v.join(t,K);try{if(E.existsSync(r)&&E.readFileSync(r,"utf8")===s)return i;E.mkdirSync(t,{recursive:!0}),E.writeFileSync(r,s)}catch{}return i}
|
|
5
|
+
export{Ga,Ja,Ya};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-9f6qx8b9.js";import"./chunk-2yxva96k.js";import{m}from"./chunk-7vpzzr5k.js";import"./chunk-bq9xf8nq.js";import"./chunk-27rzdq3n.js";import"./chunk-jp0dachh.js";import{Vt,eo,Ut,Hi,ct,Vi,to,Wt,Wi,qt}from"./chunk-7gdwvnwc.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Vi("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",pt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:pt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -487,7 +487,7 @@ else {
|
|
|
487
487
|
window.__stxShortcuts.init();
|
|
488
488
|
}
|
|
489
489
|
</script>
|
|
490
|
-
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var
|
|
490
|
+
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var Jt=new J;function G(){return`
|
|
491
491
|
<script>
|
|
492
492
|
window.__stxPerformance = {
|
|
493
493
|
metrics: new Map(),
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-zhm282df.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-zhm282df.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Wt(t);ut(t,r);let s=qt(t.config,r);dt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Wi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Wt(t);ut(t,u);let f=qt(t.config,u);if(dt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Vt();let e=await lt({mode:"dev"});if(!e.config.enabled){ct("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ut(e.storyFiles.length),eo(s.url),to()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await lt({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
|
|
1280
|
+
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":to();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{Hi("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Vt(),Ut(e.storyFiles.length),eo(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ht}from"./chunk-4wc5pc19.js";function Ys(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=Ht(e),i=`
|
|
3
3
|
<!-- stx PWA Meta Tags -->
|
|
4
4
|
<link rel="manifest" href="/manifest.json">
|
|
5
5
|
<meta name="theme-color" content="${a(r?.themeColor||"#000000")}">
|
|
@@ -43,12 +43,12 @@ if ('serviceWorker' in navigator) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
</script>
|
|
46
|
-
<!-- End stx PWA -->`,i}function
|
|
47
|
-
`+e.slice(o)}return e+
|
|
48
|
-
</head>`)}function
|
|
46
|
+
<!-- End stx PWA -->`,i}function Ai(e,n){let r=n.pwa;if(!r?.enabled||r.autoInject===!1)return e;if(e.includes("<!-- stx PWA Meta Tags -->"))return e;if(!e.includes("</head>")){let o=e.lastIndexOf("</body>");if(o!==-1){let i=Ys(n);return e.slice(0,o)+i+`
|
|
47
|
+
`+e.slice(o)}return e+Ys(n)}let t=Ys(n);return e.replace("</head>",`${t}
|
|
48
|
+
</head>`)}function wg(e){if(!e.pwa?.enabled)return"";return`<script>
|
|
49
49
|
if ('serviceWorker' in navigator) {
|
|
50
50
|
window.addEventListener('load', function() {
|
|
51
|
-
navigator.serviceWorker.register('/${
|
|
51
|
+
navigator.serviceWorker.register('/${Ht(e)}')
|
|
52
52
|
.then(function(registration) {
|
|
53
53
|
console.log('[PWA] Service Worker registered:', registration.scope);
|
|
54
54
|
})
|
|
@@ -57,5 +57,5 @@ if ('serviceWorker' in navigator) {
|
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
</script>`}function
|
|
61
|
-
export{
|
|
60
|
+
</script>`}function vg(){return'<link rel="manifest" href="/manifest.json">'}function xg(e){return`<meta name="theme-color" content="${a(e)}">`}function a(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
61
|
+
export{Ys,Ai,wg,vg,xg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function
|
|
2
|
+
function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function Hm(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(n.enterFrom),e.classList.add(n.enterActive),f(e),e.classList.remove(n.enterFrom),e.classList.add(n.enterTo),t.onEnter)await new Promise((a)=>{t.onEnter(e,a)});else await v(e,s);e.classList.remove(n.enterActive),e.classList.remove(n.enterTo),t.onAfterEnter?.(e)}async function Vm(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(n.leaveFrom),e.classList.add(n.leaveActive),f(e),e.classList.remove(n.leaveFrom),e.classList.add(n.leaveTo),t.onLeave)await new Promise((a)=>{t.onLeave(e,a)});else await v(e,s);e.classList.remove(n.leaveActive),e.classList.remove(n.leaveTo),t.onAfterLeave?.(e)}function Um(e,t={},o){let n=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(n,(s,a,i)=>{let r=p(a),l=r.name||"stx",c=r.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
|
|
3
3
|
<div
|
|
4
4
|
class="stx-transition-wrapper"
|
|
5
5
|
data-transition="${l}"
|
|
@@ -41,7 +41,7 @@ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:
|
|
|
41
41
|
});
|
|
42
42
|
})();
|
|
43
43
|
</script>
|
|
44
|
-
`})}function p(e){let t={},o=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,n;while((n=o.exec(e))!==null){let s=n[1],a=n[2]||n[3]||n[4]||n[5];switch(s){case"name":t.name=a;break;case"duration":t.duration=parseInt(a,10);break;case"mode":t.mode=a;break;case"easing":t.easing=a;break}}return t}function
|
|
44
|
+
`})}function p(e){let t={},o=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,n;while((n=o.exec(e))!==null){let s=n[1],a=n[2]||n[3]||n[4]||n[5];switch(s){case"name":t.name=a;break;case"duration":t.duration=parseInt(a,10);break;case"mode":t.mode=a;break;case"easing":t.easing=a;break}}return t}function Wm(){return`
|
|
45
45
|
/* STX Transition Presets */
|
|
46
46
|
|
|
47
47
|
/* Fade */
|
|
@@ -228,7 +228,7 @@ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:
|
|
|
228
228
|
opacity: 1;
|
|
229
229
|
max-height: 1000px;
|
|
230
230
|
}
|
|
231
|
-
`}function
|
|
231
|
+
`}function qm(){return`
|
|
232
232
|
// STX Transition Runtime
|
|
233
233
|
(function() {
|
|
234
234
|
if (typeof window === 'undefined') return;
|
|
@@ -317,5 +317,5 @@ else {
|
|
|
317
317
|
|
|
318
318
|
console.log('[stx] Transition runtime initialized');
|
|
319
319
|
})();
|
|
320
|
-
`}function
|
|
321
|
-
export{
|
|
320
|
+
`}function Km(e){let t=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return e.replace(t,(o,n,s,a)=>{let i=s||"300",r=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${n}" data-stx-transition-duration="${i}" data-stx-transition-condition="${a}" data-stx-transition-id="${r}"`})}
|
|
321
|
+
export{Hm,Vm,Um,Wm,qm,Km};
|