@stacksjs/stx 0.2.577 → 0.2.580
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-0047meje.js +2 -0
- package/dist/chunk-00p22wzr.js +3 -0
- package/dist/{chunk-z33z3rr4.js → chunk-0k5faspy.js} +6 -6
- package/dist/{chunk-wwhxgvr8.js → chunk-0vnngvy1.js} +4 -4
- package/dist/{chunk-7a0ewpz0.js → chunk-101ekf6y.js} +2 -2
- package/dist/{chunk-t79xnvzr.js → chunk-117xss52.js} +2 -2
- package/dist/chunk-1cat8kdj.js +2 -0
- package/dist/chunk-1dwnp35v.js +2 -0
- package/dist/{chunk-5vw8493b.js → chunk-1r1maqep.js} +3 -3
- package/dist/{chunk-zak5xare.js → chunk-1v1mew46.js} +1 -1
- package/dist/chunk-2dnr5qfk.js +2 -0
- package/dist/{chunk-1swmxkdt.js → chunk-2rx9d75e.js} +2 -2
- package/dist/chunk-2v73cjbc.js +2 -0
- package/dist/chunk-30rf7k4n.js +122 -0
- package/dist/chunk-3akgppsy.js +2 -0
- package/dist/{chunk-8efe5vpm.js → chunk-3e3dpp7w.js} +3 -3
- package/dist/{chunk-vnsby98n.js → chunk-3qrrv6af.js} +1 -1
- package/dist/{chunk-fkbthywg.js → chunk-3wy8q3aq.js} +5 -5
- package/dist/chunk-3x6p9me0.js +2 -0
- package/dist/{chunk-tybk9hw9.js → chunk-43h8q2cm.js} +9 -9
- package/dist/{chunk-pqkb1m5x.js → chunk-4rkvwm6v.js} +5 -5
- package/dist/{chunk-bks1fe5e.js → chunk-4srg0qbv.js} +1 -1
- package/dist/chunk-4t67wmcg.js +2 -0
- package/dist/chunk-51zn42jy.js +2 -0
- package/dist/chunk-5702x95v.js +2 -0
- package/dist/{chunk-4z21afpp.js → chunk-5db5sxy3.js} +2 -2
- package/dist/{chunk-r4w1cye7.js → chunk-5kh5ehfh.js} +2 -2
- package/dist/chunk-5pgbsc3a.js +2 -0
- package/dist/chunk-60c2bsh9.js +2 -0
- package/dist/{chunk-vw1rmevt.js → chunk-620szfcp.js} +3 -3
- package/dist/{chunk-6rfm6b1c.js → chunk-6w2yqtrd.js} +2 -2
- package/dist/{chunk-37d52q0d.js → chunk-6z3e1tyz.js} +1 -1
- package/dist/{chunk-nskvepjv.js → chunk-71sdgv7e.js} +5 -5
- package/dist/chunk-79v4d9qh.js +2 -0
- package/dist/{chunk-qfb34r6k.js → chunk-7hkc96de.js} +6 -6
- package/dist/chunk-7pp2vx1g.js +2 -0
- package/dist/chunk-84f9dnq5.js +2 -0
- package/dist/chunk-8tq5x4z8.js +2 -0
- package/dist/{chunk-gjp2jxrp.js → chunk-8v19753h.js} +1 -1
- package/dist/chunk-8zm6tkqb.js +2 -0
- package/dist/{chunk-1dg5qxg9.js → chunk-9jh2ake5.js} +5 -5
- package/dist/chunk-a1z36dt5.js +2 -0
- package/dist/{chunk-7hr63cp5.js → chunk-ah9xyss2.js} +2 -2
- package/dist/chunk-atsf1fe0.js +2 -0
- package/dist/{chunk-x5xwe5nr.js → chunk-ayy9mmrw.js} +7 -7
- package/dist/chunk-b8qd6h1q.js +2 -0
- package/dist/{chunk-vde4mtfr.js → chunk-be2ba3hj.js} +2 -2
- package/dist/{chunk-pxk0tpw2.js → chunk-bj29pwm0.js} +3 -3
- package/dist/{chunk-gpb22a8n.js → chunk-c0h2eqe0.js} +2 -2
- package/dist/{chunk-agk478t4.js → chunk-c0s3k64c.js} +2 -2
- package/dist/{chunk-bctjmaxg.js → chunk-c1r7zq0q.js} +41 -41
- package/dist/{chunk-32gycb72.js → chunk-cb2pyg5t.js} +2 -2
- package/dist/chunk-ccxs40xy.js +2 -0
- package/dist/{chunk-7j9m4d7x.js → chunk-cdgwkzms.js} +3 -3
- package/dist/{chunk-6c2y9h5h.js → chunk-cnknvvwm.js} +1 -1
- package/dist/chunk-cp442y7a.js +2 -0
- package/dist/chunk-d4en5d3s.js +2 -0
- package/dist/chunk-dh80d57p.js +2 -0
- package/dist/{chunk-je0cttam.js → chunk-djft0m5h.js} +2 -2
- package/dist/chunk-dpn1pmxj.js +2 -0
- package/dist/chunk-dtcc09x1.js +2 -0
- package/dist/{chunk-sf7z2ar9.js → chunk-dvgvvy5b.js} +3 -3
- package/dist/chunk-dyqte1xq.js +2 -0
- package/dist/chunk-e4n4v022.js +2 -0
- package/dist/chunk-efgk2xv1.js +2 -0
- package/dist/{chunk-h1n43e5n.js → chunk-ev5f79mg.js} +5 -5
- package/dist/{chunk-1wkpxa58.js → chunk-eww6sdzz.js} +2 -2
- package/dist/{chunk-34fajf1n.js → chunk-faghmmrs.js} +139 -139
- package/dist/chunk-fj70wq7k.js +2 -0
- package/dist/chunk-g2fw68zm.js +2 -0
- package/dist/{chunk-szfkkbve.js → chunk-g4crr86j.js} +3 -3
- package/dist/{chunk-xh0808cd.js → chunk-h0a2s340.js} +2 -2
- package/dist/chunk-hcgm37dy.js +2 -0
- package/dist/chunk-hd2bn5q7.js +2 -0
- package/dist/{chunk-5dm4k229.js → chunk-hzfhn2vr.js} +2 -2
- package/dist/{chunk-6wz6f8d5.js → chunk-j1nqnmcd.js} +4 -4
- package/dist/{chunk-1c8sdf9a.js → chunk-jpqkm8tm.js} +2 -2
- package/dist/{chunk-550q827h.js → chunk-jtbzmbzz.js} +4 -4
- package/dist/chunk-k7jqkt93.js +2 -0
- package/dist/{chunk-wvk932dp.js → chunk-k9th7hc4.js} +4 -4
- package/dist/chunk-kp0hg06s.js +15 -0
- package/dist/{chunk-kskyfss0.js → chunk-ktyctev3.js} +2 -2
- package/dist/{chunk-xk2v20xe.js → chunk-m8tm44rq.js} +2 -2
- package/dist/chunk-mhjwtkx9.js +2 -0
- package/dist/chunk-mqy7g74k.js +2 -0
- package/dist/chunk-mxe21m6q.js +2 -0
- package/dist/chunk-ne03tfje.js +2 -0
- package/dist/{chunk-3gqrv02t.js → chunk-nrfh7gaa.js} +3 -3
- package/dist/chunk-p2sns0bn.js +2 -0
- package/dist/{chunk-jgrtvs81.js → chunk-pmpb34md.js} +5 -5
- package/dist/chunk-q2a58n2a.js +2 -0
- package/dist/{chunk-5xwmkxkk.js → chunk-qazn64pm.js} +1 -1
- package/dist/{chunk-7bwkeake.js → chunk-qccgncp2.js} +6 -6
- package/dist/{chunk-1edvsndv.js → chunk-qdyp2zqf.js} +2 -2
- package/dist/chunk-rr8a7d4q.js +11 -0
- package/dist/{chunk-mr9c2ej6.js → chunk-s12bnv32.js} +2 -2
- package/dist/chunk-s1sycp43.js +2 -0
- package/dist/chunk-s932zfjz.js +2 -0
- package/dist/chunk-sp46w7z9.js +2 -0
- package/dist/{chunk-tasjpnbf.js → chunk-sv5nvfmb.js} +2 -2
- package/dist/chunk-sy1bk1ry.js +2 -0
- package/dist/chunk-t48ws5j0.js +2 -0
- package/dist/{chunk-sn3htx1z.js → chunk-t4g2fptt.js} +6 -6
- package/dist/{chunk-d8ek63nc.js → chunk-t8wpzqs4.js} +1 -1
- package/dist/{chunk-bpdsdbvg.js → chunk-ta3wn842.js} +2 -2
- package/dist/chunk-thbc9gtj.js +2 -0
- package/dist/chunk-tn9v10q2.js +2 -0
- package/dist/chunk-tpd5nwa3.js +2 -0
- package/dist/chunk-tpt4bgs5.js +2 -0
- package/dist/{chunk-n829xbbq.js → chunk-tszkg6sj.js} +2 -2
- package/dist/chunk-v8p5p2kp.js +2 -0
- package/dist/chunk-v9jd283e.js +2 -0
- package/dist/{chunk-4xvbc0mb.js → chunk-vpdx7qr3.js} +2 -2
- package/dist/chunk-vq0cb1m9.js +2 -0
- package/dist/chunk-vx75fb0d.js +33 -0
- package/dist/{chunk-pveafhzg.js → chunk-w3rmepwy.js} +2 -2
- package/dist/{chunk-xsxh7h8z.js → chunk-wg2w7zmt.js} +2 -2
- package/dist/chunk-wgkxgsqx.js +2 -0
- package/dist/{chunk-707n4pbz.js → chunk-wwj8zbzc.js} +5 -5
- package/dist/{chunk-p3xkj7pm.js → chunk-xpnpg967.js} +2 -2
- package/dist/chunk-y1bppxgw.js +2 -0
- package/dist/{chunk-1w9ngqpv.js → chunk-y8q1n7hx.js} +10 -10
- package/dist/{chunk-vmetcczm.js → chunk-yfq2v7x5.js} +6 -6
- package/dist/{chunk-h72befy4.js → chunk-yhpyqsbr.js} +4 -4
- package/dist/{chunk-n0kw3q6p.js → chunk-yk3fbzx5.js} +4 -4
- package/dist/chunk-yv5rwthv.js +2 -0
- package/dist/{chunk-mp99h8wh.js → chunk-yy3ser06.js} +5 -5
- package/dist/chunk-yygze2s0.js +2 -0
- package/dist/chunk-z1r4tdqy.js +2 -0
- package/dist/chunk-z732tf98.js +2 -0
- package/dist/{chunk-haeb904b.js → chunk-zk2xk0wd.js} +2 -2
- package/dist/chunk-zv288w4e.js +2 -0
- package/dist/{chunk-j4zyq2ap.js → chunk-zz02hwec.js} +11 -11
- package/dist/cli.js +19 -19
- package/dist/client-script-bundler.d.ts +12 -0
- package/dist/client-script-bundler.js +19 -5
- package/dist/composable-loader.js +2 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/bridge/protocol.d.ts +2 -0
- package/dist/native/compiler/bundle.d.ts +22 -0
- package/dist/native/compiler/bundle.js +164 -20
- package/dist/native/runtime/craft-bridge.js +16 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +3 -3
- package/dist/store-loader.js +7 -7
- package/package.json +5 -5
- package/dist/chunk-08a98yqt.js +0 -2
- package/dist/chunk-0q5s55km.js +0 -2
- package/dist/chunk-181m21rg.js +0 -2
- package/dist/chunk-194qgkc9.js +0 -2
- package/dist/chunk-1nbn56jw.js +0 -2
- package/dist/chunk-2ry2pfpe.js +0 -2
- package/dist/chunk-3bj1w990.js +0 -2
- package/dist/chunk-4a12azrb.js +0 -2
- package/dist/chunk-6aq3sm83.js +0 -2
- package/dist/chunk-6fpynp8q.js +0 -2
- package/dist/chunk-6q3yszw9.js +0 -74
- package/dist/chunk-6ryab0yy.js +0 -2
- package/dist/chunk-6sasxbv9.js +0 -2
- package/dist/chunk-6w9km7qb.js +0 -2
- package/dist/chunk-7kh4p06d.js +0 -2
- package/dist/chunk-7xrrzqh7.js +0 -2
- package/dist/chunk-7y73q42g.js +0 -11
- package/dist/chunk-8jaw6exk.js +0 -2
- package/dist/chunk-98r9jk2b.js +0 -2
- package/dist/chunk-9dgygz8d.js +0 -2
- package/dist/chunk-a51f04an.js +0 -2
- package/dist/chunk-aa52jhak.js +0 -2
- package/dist/chunk-ambynnzb.js +0 -2
- package/dist/chunk-ampr3fpv.js +0 -2
- package/dist/chunk-asbq9cgs.js +0 -2
- package/dist/chunk-bbdg3sqq.js +0 -33
- package/dist/chunk-bmtsb5mr.js +0 -2
- package/dist/chunk-c8rd3573.js +0 -2
- package/dist/chunk-d4b8cgvt.js +0 -2
- package/dist/chunk-d7skqhrc.js +0 -2
- package/dist/chunk-ensp20xk.js +0 -2
- package/dist/chunk-f1zyc84x.js +0 -2
- package/dist/chunk-f2y8bwdd.js +0 -2
- package/dist/chunk-g9vtny6q.js +0 -2
- package/dist/chunk-hcsrj8z6.js +0 -3
- package/dist/chunk-hj1bntaa.js +0 -2
- package/dist/chunk-hwy3aw5v.js +0 -2
- package/dist/chunk-hyafyqy6.js +0 -2
- package/dist/chunk-j75hqvgt.js +0 -2
- package/dist/chunk-j83ax407.js +0 -2
- package/dist/chunk-k3hfwve1.js +0 -2
- package/dist/chunk-ktc1ecsm.js +0 -2
- package/dist/chunk-mbmbaj0m.js +0 -2
- package/dist/chunk-nd3qttxh.js +0 -2
- package/dist/chunk-ndc1bmj7.js +0 -2
- package/dist/chunk-nn462qm9.js +0 -2
- package/dist/chunk-nr07vxm2.js +0 -2
- package/dist/chunk-q7a5pwaz.js +0 -2
- package/dist/chunk-qx6tr8mr.js +0 -2
- package/dist/chunk-r51vyhms.js +0 -2
- package/dist/chunk-s68bqf62.js +0 -2
- package/dist/chunk-s6sf70ty.js +0 -2
- package/dist/chunk-svavrmxb.js +0 -2
- package/dist/chunk-sw7mvg9p.js +0 -2
- package/dist/chunk-tz40t18m.js +0 -2
- package/dist/chunk-v1k0bdsg.js +0 -2
- package/dist/chunk-vd10tty0.js +0 -2
- package/dist/chunk-vqkzhd19.js +0 -2
- package/dist/chunk-w1yft5gg.js +0 -2
- package/dist/chunk-w6sa921x.js +0 -2
- package/dist/chunk-y120qq1a.js +0 -15
- package/dist/chunk-zcw74jmk.js +0 -2
- package/dist/chunk-zxvndwaz.js +0 -2
- package/dist/chunk-zzr0p4bb.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{K,ss,os,lc,_t,Zo,is,Qo,Fd,be,ln,we}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import{Ai,s}from"./chunk-3e3dpp7w.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{K as BROWSER_CORE_IMPORTS,lc as STX_AUTO_IMPORTS,ss as extractAndStripCssImports,be as extractBridgeData,Ai as findInterpolationEnd,Qo as generateAutoImportDestructuring,Fd as generateBrowserAutoImportDestructuring,ln as generateServerDataBridge,_t as injectBrowserCoreAutoImports,we as processClientScript,is as referencesName,os as renderVendorStyleTags,s as stripCommentsAndLiterals,Zo as transformAutoImports};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R,k,
|
|
3
|
-
`)}async function
|
|
2
|
+
import{R,k,Gt,Kt,Xt}from"./chunk-m8tm44rq.js";import{resolve as Q,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class jr{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return Gt(t,e,"video",this.config)}async set(t,e,a){return Kt(t,e,a,"video",this.config)}async clear(){return Xt("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var v=null;function B(t){if(!v)v=new jr(t);else if(t)v.updateConfig(t);return v}async function Br(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return B(c).get(t,e)}async function Fr(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return B(r).set(t,e,a)}async function Ea(){return B().clear()}import{resolve as _,basename as D,extname as A,join as H}from"path";import{mkdir as M}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function zr(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=H(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function Hr(t,e,a,c){let r=await L();if(!r)return[];try{let n=_(t);if(!await k(n))return[];await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||H(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function Ta(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await R(n),s=D(t,A(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=H(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:H(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as E,basename as F,extname as W,join as V}from"path";import{mkdir as T,writeFile as q}from"fs/promises";async function z(){try{return await import("ts-videos")}catch{return null}}var j=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function Ur(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await R(i),o=F(t,W(t)),h=V(a,`${o}-${s}-hls`);await T(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=V(h,w.label);await T(C,{recursive:!0});let p=`${w.label}.m3u8`,P=V(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=V(h,"master.m3u8"),S=X(l,c,o,s);return await q(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
|
|
3
|
+
`)}async function Vr(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await R(i),o=F(t,W(t)),h=V(a,`${o}-${s}-dash`);await T(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||4,m=r?.minBufferTime||2,l=(await new n.Input(i).getInfo()).duration||0,f=[],b=[];for(let p of y){let P=V(h,p.label);await T(P,{recursive:!0});try{if(await n.generateDASH(i,{outputDir:P,segmentDuration:u,width:p.width,height:p.height,videoBitrate:p.bitrate,audioBitrate:p.audioBitrate})){if(f.push({bandwidth:p.bitrate,width:p.width,height:p.height||Math.round(p.width*9/16),url:`${c}/${o}-${s}-dash/${p.label}/video`}),p.audioBitrate)b.push({bandwidth:p.audioBitrate,url:`${c}/${o}-${s}-dash/${p.label}/audio`})}}catch(x){console.warn(`[stx-media] Failed to generate DASH for ${p.label}: ${x}`)}}if(f.length===0)return null;let S=V(h,"manifest.mpd"),w=G(f,b,l,u,m);await q(S,w);let C=[{type:"video",representations:f}];if(b.length>0)C.push({type:"audio",representations:b});return{manifestUrl:`${c}/${o}-${s}-dash/manifest.mpd`,manifestPath:S,adaptationSets:C,duration:l}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function G(t,e,a,c,r){let n=I(a),i=I(r),s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
4
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
5
5
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
6
6
|
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
|
|
@@ -26,4 +26,4 @@ import{R,k,qt,Gt,Kt}from"./chunk-xk2v20xe.js";import{resolve as Q,basename as J,
|
|
|
26
26
|
</Representation>
|
|
27
27
|
`}s+=` </AdaptationSet>
|
|
28
28
|
`}return s+=` </Period>
|
|
29
|
-
</MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function
|
|
29
|
+
</MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function To(t){let e=await O();if(!e)return null;try{let a=Q(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function $a(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await Br(t,e,a);if(n)return n;try{let i=Q(t);if(!await k(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await R(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await To(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await zr(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await Hr(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await Ur(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await Vr(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await Fr(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{jr,Br,Fr,Ea,zr,Hr,Ta,Ur,Vr,To,$a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{H}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{H}from"./chunk-sv5nvfmb.js";import R from"fs";import g from"path";import C from"crypto";var S=new Set(["webp","avif","jpeg","png"]),T=new Set(["cover","contain","fill","inside","outside"]),q=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"]),k=4096,D=80,U="cover";async function Co(e,t){let r=t.routePath??"/_stx/img",h=new URL(e.url);if(h.pathname!==r)return null;let a=A(h,t);if(!a.ok)return new Response(a.error,{status:a.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:n,srcUrl:d,width:l,height:i,format:s,quality:u,fit:c}=a,m;try{m=R.statSync(n)}catch{return new Response(`Source image not found: ${d}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!m.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let w=t.cacheDir??".stx/cache/img";await R.promises.mkdir(w,{recursive:!0});let b=`${n}:${m.mtimeMs}:${m.size}`,I=`${l}x${i}:${s}:${u}:${c}`,f=C.createHash("sha256").update(`${b}|${I}`).digest("hex").slice(0,16),o=g.join(w,`${f}.${s}`),p={"Content-Type":H(s),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${f}"`,"X-Stx-Image-Cache":"HIT"};if(e.headers.get("if-none-match")===`"${f}"`)return new Response(null,{status:304,headers:p});let v=Bun.file(o);if(await v.exists())return new Response(v,{headers:p});try{let x=Buffer.from(await Bun.file(n).arrayBuffer()),{resizeAndConvert:P}=await L(),F=await P(x,{width:l,height:i,format:s,quality:u,fit:c});return await Bun.write(o,F),p["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(F),{headers:p})}catch(x){let P=x.message;return new Response(`Image processing failed: ${P}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function ha(e){return async(t)=>await Co(t,e)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}function A(e,t){let r=e.searchParams.get("src");if(!r)return{ok:!1,error:"Missing required param: src",status:400};if(!r.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(r.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let h=g.extname(r).toLowerCase();if(!q.has(h))return{ok:!1,error:`Unsupported source extension: ${h}`,status:400};let a=g.resolve(t.publicDir),n=g.resolve(a,r.slice(1));if(!n.startsWith(`${a}${g.sep}`)&&n!==a)return{ok:!1,error:"src is outside publicDir",status:400};let d=t.maxWidth??k,l=t.maxHeight??k,i=e.searchParams.get("w"),s=e.searchParams.get("h"),u=i?Number.parseInt(i,10):0,c=s?Number.parseInt(s,10):0;if(i&&(!Number.isFinite(u)||u<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(s&&(!Number.isFinite(c)||c<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!i&&!s)return{ok:!1,error:"At least one of w or h is required",status:400};let m=Math.min(u||d,d),w=Math.min(c||l,l),b=e.searchParams.get("f")||"webp";if(!S.has(b))return{ok:!1,error:`Invalid f (must be one of: ${[...S].join(", ")})`,status:400};let I=b,f=e.searchParams.get("q"),o=f?Number.parseInt(f,10):t.defaultQuality??D;if(!Number.isFinite(o)||o<1||o>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let y=e.searchParams.get("fit")||t.defaultFit||U;if(!T.has(y))return{ok:!1,error:`Invalid fit (must be one of: ${[...T].join(", ")})`,status:400};return{ok:!0,srcFsPath:n,srcUrl:r,width:m,height:w,format:I,quality:o,fit:y}}async function L(){return await import("./chunk-z732tf98.js")}
|
|
3
|
+
export{Co,ha};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{bl,wl,vl,xl,ma,Sl,kl,Cl,_l,El,Tl,$l}from"./chunk-ta3wn842.js";export{Tl as Broadcast,$l as BroadcastServer,ma as broadcast,_l as broadcastPresence,Cl as broadcastPrivate,El as channel,bl as getBroadcastServer,xl as loadChannels,wl as startBroadcasting,vl as stopBroadcasting,Sl as toUser,kl as toUsers};
|
|
@@ -298,5 +298,5 @@ catch (error) {
|
|
|
298
298
|
init();
|
|
299
299
|
}
|
|
300
300
|
})();
|
|
301
|
-
</script>`}var
|
|
302
|
-
export{
|
|
301
|
+
</script>`}var sl={name:"pwa.installButton",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return r(t,n)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},ol={name:"pwa.updatePrompt",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return p(t,n)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},il={name:"pwa.offlineIndicator",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return d(t,n)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},al={name:"pwa.pushSubscribe",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return l(t,n)},hasEndTag:!0,description:"Renders a push notification subscription button"},xr=[sl,ol,il,al];function Tu(t){return[...t,...xr]}
|
|
302
|
+
export{sl,ol,il,al,xr,Tu};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Wn,Be,be,we,ii,Jn,te,J,gn,d,n,A}from"./chunk-faghmmrs.js";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:m}=Wn(o),c=await(e.renderer??((s)=>Be(s)))(m);return{html:_(c),frontmatter:r??{}}}import{dirname as C,resolve as R}from"path";function k(o){let e=o,r=te(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function v(o,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -9,10 +9,10 @@ import{Vn,Be,be,we,si,Xn,te,J,fn,d,n,A}from"./chunk-34fajf1n.js";function h(o){r
|
|
|
9
9
|
<body>
|
|
10
10
|
${o}
|
|
11
11
|
</body>
|
|
12
|
-
</html>`}async function
|
|
12
|
+
</html>`}async function zo(o,e={}){let r=R(o),m=Bun.file(r);if(!await m.exists())throw Error(`Template file not found: ${r}`);let a=await m.text(),c=null;if(h(r)){let s=await b(a,{renderer:e.markdownRenderer});a=s.html,c=s.frontmatter}if(c)e={...e,context:{...c,...e.context||{}}};if(e.layout){let s=R(e.layout),p=Bun.file(s);if(!await p.exists())throw Error(`Layout template not found: ${s}`);let{layout:u,injectCSS:t,...i}=e,l={...e.context||{}};gn(l);let f=await S(a,r,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),g=await p.text(),x={...l,content:f},w={...i,context:x,injectCSS:t};return S(g,s,w)}return S(a,r,e)}async function S(o,e,r={}){let{templateContent:m,serverScripts:a,clientScripts:c}=k(o),s={...A,...r.options},p={__filename:e,__dirname:C(e),__stx:{},__stx_options:s,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...Jn(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let i of a)await d(i,p,e);let u=new Set,t=m;if(t=await n(t,p,e,s,u),ii(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),c.length>0)t+=`
|
|
13
13
|
${c.join(`
|
|
14
14
|
`)}`}else{if(r.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=be(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await we(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${g}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${g}`}t=await J(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
18
|
-
export{
|
|
17
|
+
${g}`}t=await J(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-dyqte1xq.js");t=await i(t)}catch{}return t}
|
|
18
|
+
export{zo};
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function ae(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function yt(e){if(e.entries.length===0)return"[]";return`[
|
|
3
3
|
${e.entries.map((t)=>` { url: '${t.url}', revision: '${t.revision}' }`).join(`,
|
|
4
4
|
`)}
|
|
5
|
-
]`}function
|
|
6
|
-
export{ae,yt,
|
|
5
|
+
]`}function Zr(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(2)} MB`}
|
|
6
|
+
export{ae,yt,Zr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function
|
|
3
|
-
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
2
|
+
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function Pi(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
|
|
3
|
+
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function Ii(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await Is(m,e),{config:f,graph:m}}async function Is(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function sr(e){return O(A(e))}function or(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
|
|
4
|
+
`)}function Oi(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
|
|
5
|
+
export{Pi,Ii,Is,sr,or,Oi};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{At,$c,Rc,Ac,Pc,Ic,d,Oc,xs,Dc,bi,wi}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{At as STX_ENGINE_BINDING_NAMES,xs as convertToCommonJS,bi as extractScriptFromTemplate,d as extractVariables,wi as hasVariables,Oc as isCompleteImport,Ic as isMissingBindingFailure,Ac as isModuleResolutionFailure,Pc as isSyntaxFailure,Dc as splitDeclaration,$c as stripTypeScript,Rc as withoutStxReferrer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B,F,z,
|
|
2
|
+
import{B,F,z,zt,Q,ie,De,gt,Ht,Ut,Vt,H,Wt,qt}from"./chunk-sv5nvfmb.js";import{Je}from"./chunk-r47cs92n.js";function ra(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=z,placeholder:l="none",formats:f=F,widths:y=B,decoding:c="async",fetchpriority:h,objectFit:d,objectPosition:g}=s,{class:p,style:v}=s,{processedImage:w,variants:I,optimize:b=!0,isDev:A=!1}=r;if(I&&I.length>0)return ee(s,I,w);if(A||!b)return te(s);return se(s)}function ee(s,r,e){let{src:t,alt:n,width:a,height:i,sizes:m="100vw",loading:o="lazy",priority:u=!1,decoding:l="async",fetchpriority:f,objectFit:y,objectPosition:c,placeholder:h="none"}=s,{class:d,style:g}=s,p=Ut(r),v=Ht(r),w=typeof m==="object"?gt(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("; ")}"`:"",D=d?` class="${d}"`:"",C=u?"":` loading="${o}"`,T=` decoding="${l}"`,O=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",L=["avif","webp","jpeg","png"],V=[];for(let k of L){let P=p.get(k);if(P&&P.length>0){let M=De(P),X=H(k);V.push(` <source type="${X}" srcset="${M}" sizes="${w}" />`)}}let q="",N="",E;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(q=`<div class="stx-image-wrapper" id="${k}">`,N="</div>",h==="blur")E=`
|
|
3
3
|
#${k} {
|
|
4
4
|
position: relative;
|
|
5
5
|
background-image: url('${e.placeholder}');
|
|
@@ -30,7 +30,7 @@ ${V.join(`
|
|
|
30
30
|
data-quality="${o}"
|
|
31
31
|
data-formats="${u.join(",")}"
|
|
32
32
|
data-widths="${l.join(",")}"
|
|
33
|
-
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${U(e)}"${I}${b}${w}${v}${A}${D}${C} ${O} />`}}function
|
|
33
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${U(e)}"${I}${b}${w}${v}${A}${D}${C} ${O} />`}}function po(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 sa(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=po(u);if(l){let f=await r(l);if(a=a.replace(u,f.html),f.preloadLink)t.push(f.preloadLink);if(f.placeholderCss)n.push(f.placeholderCss)}}return{html:a,preloadLinks:t,styles:n}}function U(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var j=new Map;function oa(){j.clear()}async function re(s,r){let e=`${s}:${JSON.stringify(r)}`;if(j.has(e))return j.get(e);try{let t=await ie(s,r);return j.set(e,t),t}catch{return null}}function fo(){return Je({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=ae(s,r,e);if(!t)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let i={widths:a.widths||(a.width?[a.width]:B),formats:a.formats||F,quality:a.quality||z,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await Q())return _(t,n||"",a);let o=await re(t,i);if(!o)return _(t,n||"",a);return oe(o,n||"",a)}})}function ae(s,r,e){if(r.src)return{src:String(r.src),alt:String(r.alt||""),options:r.options||{}};let n=s.trim();if(n.startsWith("@image(")||n.startsWith("("))n=n.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let a=ne(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 ne(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 _(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 oe(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=De(p),w=H(g),I=e.sizes||"100vw";l.push(` <source type="${w}" srcset="${x(v)}" sizes="${x(I)}" />`)}}let f=o.get("jpeg")||[],y=f.length>0?f[Math.floor(f.length/2)]:t[Math.floor(t.length/2)],c=[`src="${y?.url||s.src}"`,`alt="${x(r)}"`];if(e.width||a)c.push(`width="${e.width||a}"`);if(e.height||i)c.push(`height="${e.height||i}"`);if(e.class)c.push(`class="${x(e.class)}"`);let h=[];if(m)h.push(`aspect-ratio: ${m.toFixed(4)}`);if(e.style)h.push(e.style);if(h.length>0)c.push(`style="${h.join("; ")}"`);if(e.lazy!==!1&&!e.priority)c.push('loading="lazy"');if(c.push('decoding="async"'),e.priority)c.push('fetchpriority="high"');let d=`<picture>
|
|
34
34
|
`;if(d+=l.join(`
|
|
35
35
|
`)+`
|
|
36
36
|
`,d+=` <img ${c.join(" ")} />
|
|
@@ -39,5 +39,5 @@ ${d}
|
|
|
39
39
|
</div>`}else if(e.placeholder==="color"){let p=n.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");d=`<div id="${g}" class="stx-image-placeholder" style="background-color: ${p};">
|
|
40
40
|
${d}
|
|
41
41
|
</div>`}}if(e.priority&&y){let g=H(y.format);d=`<link rel="preload" as="image" href="${x(y.url)}" type="${g}" />
|
|
42
|
-
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var
|
|
43
|
-
export{
|
|
42
|
+
`+d}return d}function x(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var ia=fo();import S from"fs";import R from"path";function aa(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=F,widths:a=B,quality:i=z,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 Q()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(u)await S.promises.mkdir(l,{recursive:!0});if(y){let g=await zt();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${g?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${r.join(", ")}`),console.log(` Output dir: ${e}`),console.log(` Formats: ${n.join(", ")}`),console.log(` Widths: ${a.join(", ")}`)}},async buildStart(){c.imageReferences.clear(),c.processedImages.clear(),c.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(h,d){if(d.endsWith(".html")||d.endsWith(".stx")){let g=ce(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ge(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await Q())return;await S.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!S.existsSync(w))continue;let I=await Y(w);g.push(...I)}let p=f?g.filter((w)=>le(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=J(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await ie(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=S.statSync(I).size,D=Wt(b.variants);if(c.stats.savedBytes+=Math.max(0,A-D/b.variants.length),y)console.log(` \u2713 ${R.basename(I)} \u2192 ${b.variants.length} variants`)}catch(b){console.error(`[stx-images] Error processing ${I}:`,b)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${c.stats.optimizedImages}/${c.stats.totalImages}`),console.log(` Variants: ${c.stats.variants}`),c.stats.savedBytes>0)console.log(` Saved: ~${qt(c.stats.savedBytes)}`)}}}function ce(s){let r=[],e=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,t;while((t=e.exec(s))!==null)r.push(t[1]);let n=/<Image[^>]+src=["']([^"']+)["']/gi;while((t=n.exec(s))!==null)r.push(t[1]);let a=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((t=a.exec(s))!==null)r.push(t[1]);let i=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((t=i.exec(s))!==null)r.push(t[1]);return r}function le(s,r){let e=R.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ge(s,r){return s}async function Y(s){let r=[];async function e(t){let n=await S.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=R.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&Vt(i))r.push(i)}}return await e(s),r}function J(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function ca(s,r,e={}){if(!await Q())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return ie(s,{...e,outputDir:r})}async function la(s,r,e={}){let{formats:t=F,widths:n=B,quality:a=z,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await Q())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await S.promises.mkdir(r,{recursive:!0});let l=await Y(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=J(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await ie(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${R.basename(g)}`);return p}catch(p){return console.error(`Error processing ${g}:`,p),null}}));f.push(...d.filter((g)=>g!==null))}return{processed:f,stats:y}}function go(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function da(s,r){let e=go(s);await Bun.write(r,JSON.stringify(e,null,2))}var pl={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{ra,po,sa,oa,fo,ia,aa,ca,la,go,da,pl};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{an,le}from"./chunk-ktyctev3.js";import{m,cn,w,Fe,o,P}from"./chunk-faghmmrs.js";import{rs}from"./chunk-yy3ser06.js";import{s,Se}from"./chunk-3e3dpp7w.js";import{a}from"./chunk-00p22wzr.js";import h from"path";import v from"fs";import{AsyncLocalStorage as fe}from"async_hooks";var me=10;function J(e,n,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(h.basename(e))||rs(e,n,r)}var re=1,se=new Map,V=600,ge=100,W=new Map;async function he(e){let n=W.get(e)??0;if(n>0&&n<ge){W.set(e,n+1);return}W.set(e,1);try{let r=(await v.promises.readdir(e)).filter((c)=>c.endsWith(".js"));if(r.length<=V)return;let p=(await Promise.all(r.map(async(c)=>{try{return{name:c,at:(await v.promises.stat(h.join(e,c))).mtimeMs}}catch{return null}}))).filter((c)=>c!==null);p.sort((c,l)=>l.at-c.at);for(let c of p.slice(V)){let l=c.name.slice(0,-3);await v.promises.rm(h.join(e,`${l}.js`),{force:!0}),await v.promises.rm(h.join(e,`${l}.deps.json`),{force:!0})}D("pruned bundle cache to",V,"entries")}catch{}}function ce(e){return se.get(e)??[]}function X(e,n){if(e)se.set(e,n)}function rc(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function D(...e){if(rc())console.log("[stx:bundler]",...e)}var Z=[];function Jo(e,n,r){Z.push({filePath:e||"<inline>",message:n,details:r})}function bt(){return Z.slice()}function wt(){Z.length=0}var H;function jd(e){H=e}function Yo(){if(H)return H;try{let e=P.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function vt(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=n.exec(e))!==null){let p=r[1];if(!q.some((l)=>l.test(p)))return D("detected user import:",p),!0}let u=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((r=u.exec(e))!==null){let p=r[1];if(/\.css(?:\?.*)?$/.test(p))continue;if(!q.some((l)=>l.test(p)))return D("detected side-effect import:",p),!0}return!1}var on="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function sc(e,n){return h.relative(e,n).split(h.sep).join("/")}function oc(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(r,u,p,c)=>{let l=n.get(c);return l&&!c.startsWith(on)?`${u}${p}${l}${p}`:r})}function ic(e,n){let r=0,u=(c)=>{let l=`__stxMod${r++}`,E=JSON.stringify(c);return n.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${E}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(E)} + " is not registered on this page (#1957)");`),l},p=(c,l)=>{for(let E of c.split(",")){let _=E.trim();if(!_)continue;let j=_.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let d=j[1].startsWith('"')?JSON.parse(j[1]):j[1],t=j[2]??d;n.push(`var ${t} = ${l}[${JSON.stringify(d)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(c,l,E)=>{let _=E.slice(on.length),j=u(_),d=l.trim(),t=d.match(/^([\w$]+)\s*(?:,\s*|$)/);if(t&&!d.startsWith("{")&&!d.startsWith("*"))n.push(`var ${t[1]} = ${j}.default;`),d=d.slice(t[0].length).trim();let i=d.match(/^\*\s*as\s+([\w$]+)$/);if(i)n.push(`var ${i[1]} = ${j};`);else if(d.startsWith("{"))p(d.replace(/^\{|\}$/g,""),j);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(c,l)=>(u(l.slice(on.length)),"")),e}function te(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,h.join(e,"index.ts"),h.join(e,"index.tsx"),h.join(e,"index.js"),h.join(e,"index.mjs")];for(let r of n)try{if(v.existsSync(r)&&v.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}var Y=new fe;function Qr(e,n){let r=new Bun.CryptoHasher("md5");for(let[u,p]of[...e].sort(([c],[l])=>c<l?-1:c>l?1:0))r.update(`${u}\x00${p}\x00`);return Y.run({modules:e,key:r.digest("hex").slice(0,12)},n)}function xt(){return Y.getStore()?.key??""}function $e(e,n,r,u,p,c=new Map,l,E){let _=(d,t,i)=>{if(J(t,e,l))return null;if(!p||d!==r||!xe.test(t))return null;try{if(!v.statSync(t,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(t);let x=`${on}${sc(process.cwd(),t)}`;return c.set(i,x),{path:x,external:!0}},j=(d,t)=>{let i=d===r?n:h.dirname(d),x=h.resolve(i,t);return te(x)??x};return{name:"stx-client-bundle",setup(d){if(d.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(t)=>({path:t.path,external:!0})),d.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(t)=>({path:t.path,external:!0})),d.onResolve({filter:/^\//},(t)=>{let i=te(t.path);if(i){let x=_(t.importer,i,t.path);if(x)return x;if(i!==r)u.add(i);return{path:i}}return{path:t.path,external:!0}}),d.onResolve({filter:/^\.\.?\//},(t)=>{let i=j(t.importer,t.path),x=_(t.importer,i,t.path);if(x)return x;return u.add(i),{path:i}}),d.onResolve({filter:/^[@~]\//},(t)=>{let i=h.resolve(e,t.path.slice(2)),x=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,h.join(i,"index.ts"),h.join(i,"index.tsx"),h.join(i,"index.js"),h.join(i,"index.mjs")];for(let F of x)if(v.existsSync(F)&&v.statSync(F,{throwIfNoEntry:!1})?.isFile()){let B=_(t.importer,F,t.path);if(B)return B;return D(`resolved ${t.path[0]}/ import:`,t.path,"\u2192",F),u.add(F),{path:F}}return console.warn(`[stx:bundler] could not resolve ${t.path[0]}/ import:`,t.path),{path:i}}),p)d.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(t)=>{if(t.importer!==r)return;let i=`${on}npm:${t.path}`;return c.set(t.path,i),{path:i,external:!0}});d.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(t)=>{if(J(t.path,e,l))throw Error(`Server-only API source cannot be imported by a client script: ${t.path}`);let i=h.extname(t.path).toLowerCase(),x=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(t.path!==r)u.add(t.path);let F=E?.get(t.path);if(F!==void 0)return{contents:F,loader:"js"};return{contents:v.readFileSync(t.path,"utf8"),loader:x}})}}}var G=new Map,k=m(64),ne=Symbol.for("stx.client-bundle-build-queue");function ac(e){let n=globalThis,u=(n[ne]??Promise.resolve()).then(e,e);return n[ne]=u.then(()=>{return},()=>{return}),u}async function St(e,n,r={}){let u=r.projectRoot||process.cwd(),p=(await o(u)).serverApi,c=r.minify??!1,l=r.externalizeUserModules??!0,E=r.expose?.length?[...new Set(r.expose)].sort():void 0,_=r.cacheDir||a(u,"bundle-cache"),j=Y.getStore(),d=new Bun.CryptoHasher("md5");d.update(`${me}\x00${Fe()}\x00${JSON.stringify(p??!1)}\x00${l?"registry":"inline"}\x00${E?E.join(","):"*"}\x00${c?"minified":"readable"}\x00${j?.key??""}\x00${e}\x00${n}`);let t=d.digest("hex").slice(0,12),i=h.join(_,`${t}.js`),x=k.get(i);if(x){if(cn(x.files)&&x.files.every((M)=>!J(M.path,u,p))){D("memo hit:",t);let M=x.files.map((A)=>A.path);return X(n,M),r.collectInputs?.push(...M),x.code}k.delete(i),D("memo invalidated by dep change:",t)}let F=h.join(_,`${t}.deps.json`),B=Bun.file(i);if(await B.exists()){let M=Bun.file(F),A=!1,N=null;if(await M.exists())try{let I=JSON.parse(await M.text());if(I.metadataVersion!==re||!Array.isArray(I.files))A=!1;else N=I.files,A=!0;if(N&&(!cn(N)||N.some((g)=>J(g.path,u,p))))A=!1}catch{A=!1}if(A){if(D("cache hit:",t),N)X(n,N.map((g)=>g.path)),r.collectInputs?.push(...N.map((g)=>g.path));let I=await B.text();if(N)k.set(i,{code:I,files:N});return I}D("cache invalidated by dep change:",t)}let U=G.get(t);if(U){let M=await U;if(r.collectInputs)r.collectInputs.push(...(k.get(i)?.files??[]).map((A)=>A.path));return M}let L=ac(()=>be(e,n,{projectRoot:u,minify:c,cacheDir:_,hash:t,cachePath:i,depsPath:F,collectInputs:r.collectInputs,externalizeUserModules:l,serverApi:p,expose:E,throwOnFailure:r.throwOnFailure,substitutes:j?.modules}));G.set(t,L);try{return await L}finally{G.delete(t)}}var ye=0;function cc(e){return`${e}-${process.pid}-${++ye}`}async function be(e,n,r){let{projectRoot:u,minify:p,cacheDir:c,hash:l,cachePath:E,depsPath:_,externalizeUserModules:j}=r,d=a(u,"bundle-tmp"),t=cc(l),i=h.join(d,`${t}.ts`),x=h.join(d,"out",t);v.mkdirSync(d,{recursive:!0}),v.mkdirSync(x,{recursive:!0});let F=h.dirname(n),B=new Set,U=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(e),{depths:A,balanced:N}=Se(M),I=(S)=>!N||A[S]===0,g;while((g=U.exec(M))!==null){if(g[1])continue;if(!I(g.index))continue;if(g[2])g[2].split(",").forEach((S)=>{let f=we(S);if(f)B.add(f)});else if(g[3])B.add(g[3])}while((g=L.exec(M))!==null){if(g[1])continue;if(!I(g.index))continue;B.add(g[2])}let ie=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=ie.exec(M))!==null){if(!I(g.index))continue;let S=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(S&&q.some((f)=>f.test(S)))continue;if(g[1])B.add(g[1]);if(g[2])B.add(g[2]);for(let f of(g[3]??"").split(",")){let b=f.trim();if(!b||/^type\s/.test(b))continue;let T=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(T)B.add(T)}}for(let S of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of S[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(b)B.delete(b)}let oe=B.size>0?`
|
|
3
|
+
export { ${[...B].join(", ")} }`:"";await Bun.write(i,e+oe),D("bundling:",l,"from:",h.basename(n));let Q=new Set,K=new Map;try{let S=await Bun.build({entrypoints:[i],outdir:x,target:"browser",format:"esm",minify:p?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[$e(u,F,i,Q,j,K,r.serverApi,r.substitutes)],define:{"process.env.NODE_ENV":p?'"production"':'"development"',...w()},root:u});if(!S.success){let R=S.logs.filter((O)=>O.level==="error").map((O)=>O.message).join(", ")||`Unable to bundle ${h.basename(n)}`,C=an(S.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",R),Jo(n||"",R,C),r.throwOnFailure||Yo()==="error")throw Error(R);return e}let f="";for(let y of S.outputs){f=await y.text();break}let b=[];for(let y of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let R of y[1].split(",")){let C=R.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(C){b.push([C[2],C[1]]);continue}let O=R.trim();if(/^[A-Za-z_$][\w$]*$/.test(O))b.push([O,O])}if(r.expose){let y=new Set(r.expose);for(let R=b.length-1;R>=0;R--)if(!y.has(b[R][0]))b.splice(R,1)}let T=[];f=ic(oc(f,K),T);let ae=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),p&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let ee=`__stxBundle_${l}`,ue=b.map(([y,R])=>`${JSON.stringify(y)}: ${R}`).join(", "),de=b.map(([y])=>`var ${y} = undefined;`).join(`
|
|
4
|
+
`),pe=b.map(([y])=>`${y} = ${ee}[${JSON.stringify(y)}];`).join(`
|
|
5
|
+
`);if(f=`${ae.join(`
|
|
6
|
+
`)}
|
|
7
|
+
${de}
|
|
8
|
+
var ${ee} = (function() {
|
|
9
|
+
${T.join(`
|
|
10
|
+
`)}
|
|
11
|
+
${f}
|
|
12
|
+
return { ${ue} };
|
|
13
|
+
})();
|
|
14
|
+
${pe}`.trim(),D("bundled:",l,"output:",f.length,"bytes"),B.size>0&&b.length===0)return console.warn(`[stx:bundler] dropped every binding for ${h.basename(n)} (${l}); serving the unbundled source and not caching this result`),e;v.mkdirSync(c,{recursive:!0}),await Bun.write(E,f);let z=Array.from(Q).map((y)=>{try{return{path:y,mtimeMs:v.statSync(y).mtimeMs}}catch{return null}}).filter((y)=>y!==null);return await Bun.write(_,JSON.stringify({metadataVersion:re,files:z})),X(n,z.map((y)=>y.path)),r.collectInputs?.push(...z.map((y)=>y.path)),k.set(E,{code:f,files:z}),await he(c),f}catch(S){let f=an(S,n||void 0),b=le(S,n||void 0);if(console.warn(`[stx:bundler] error: ${b}`),Jo(n||"",b,f),r.throwOnFailure||Yo()==="error")throw S;return e}finally{try{v.rmSync(i,{force:!0}),v.rmSync(x,{recursive:!0,force:!0})}catch{}}}function we(e){let n=e.trim();if(!n)return null;let r=n.indexOf("=");if(r!==-1)n=n.slice(0,r).trim();let u=n.indexOf(":");if(u!==-1)n=n.slice(u+1).trim();if(n.startsWith("..."))n=n.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:null}
|
|
15
|
+
export{ce,rc,Jo,bt,wt,jd,Yo,vt,on,sc,oc,ic,Qr,xt,ac,St,cc};
|
|
@@ -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 an(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 le(n,i){return an(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{an,le};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{createHash as g}from"crypto";import{readFile as b,stat as y}from"fs/promises";async function R(e){try{let t=await b(e);return g("sha256").update(t).digest("hex").slice(0,16)}catch{return""}}function l(e){return g("sha256").update(e).digest("hex").slice(0,16)}function m(e,t){let r=JSON.stringify(t,Object.keys(t).sort());return`${l(e)}-${l(r)}`}async function h(e){try{return(await y(e)).mtimeMs}catch{return 0}}async function k(e){try{return await y(e),!0}catch{return!1}}import{mkdir as v,readFile as A,writeFile as P,readdir as B,rm as D,stat as H}from"fs/promises";import{join as w,dirname as E}from"path";var c=new Map,d={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500};async function S(e){try{await v(e,{recursive:!0})}catch{}}function p(e,t,r){return w(e,r,`${t}.json`)}async function C(e,t,r){if((Date.now()-e.createdAt)/86400000>r)return!1;if(await h(t)!==e.srcMtime)return!1;return!0}async function
|
|
3
|
-
export{R,k,
|
|
2
|
+
import{createHash as g}from"crypto";import{readFile as b,stat as y}from"fs/promises";async function R(e){try{let t=await b(e);return g("sha256").update(t).digest("hex").slice(0,16)}catch{return""}}function l(e){return g("sha256").update(e).digest("hex").slice(0,16)}function m(e,t){let r=JSON.stringify(t,Object.keys(t).sort());return`${l(e)}-${l(r)}`}async function h(e){try{return(await y(e)).mtimeMs}catch{return 0}}async function k(e){try{return await y(e),!0}catch{return!1}}import{mkdir as v,readFile as A,writeFile as P,readdir as B,rm as D,stat as H}from"fs/promises";import{join as w,dirname as E}from"path";var c=new Map,d={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500};async function S(e){try{await v(e,{recursive:!0})}catch{}}function p(e,t,r){return w(e,r,`${t}.json`)}async function C(e,t,r){if((Date.now()-e.createdAt)/86400000>r)return!1;if(await h(t)!==e.srcMtime)return!1;return!0}async function Gt(e,t,r,a=d){if(!a.enabled)return null;let n=m(e,t),i=c.get(n);if(i){if(await C(i,e,a.maxAge))return i.lastAccessedAt=Date.now(),i.data;c.delete(n)}let o=p(a.directory,n,r);if(await k(o))try{let u=await A(o,"utf-8"),s=JSON.parse(u);if(await C(s,e,a.maxAge))return s.lastAccessedAt=Date.now(),c.set(n,s),s.data}catch{}return null}async function Kt(e,t,r,a,n=d){if(!n.enabled)return;let i=m(e,t),o=await R(e),u=await h(e),s={key:i,src:e,srcHash:o,srcMtime:u,optionsHash:m("",t),data:r,createdAt:Date.now(),lastAccessedAt:Date.now()};c.set(i,s);let f=p(n.directory,i,a);try{await S(E(f)),await P(f,JSON.stringify(s,null,2))}catch(x){console.warn(`[stx-media] Failed to write cache: ${x}`)}}async function Xt(e,t=d){if(e==="all")c.clear();else c.clear();let r=e==="all"?["image","video"]:[e];for(let a of r){let n=w(t.directory,a);try{await D(n,{recursive:!0,force:!0})}catch{}}}
|
|
3
|
+
export{R,k,Gt,Kt,Xt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{qn,dc,zd,uc,Hd,pc,Gn,b,Tt,ve,fc,cs,gc,Ud,X,mc,Vd,x,Wd}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{mc as applyFilters,Hd as clearCustomFilters,fc as clientLoopScopes,qn as defaultFilters,b as escapeHtml,Tt as escapeHtmlValue,x as evaluateExpression,pc as findMustacheEnd,uc as getAllFilters,gc as interpolateScriptAttributes,cs as interpolateScriptExpressions,Ud as interpolateScriptsInTemplate,X as processExpressions,dc as registerFilter,zd as registerFilters,Gn as replaceInterpolations,Vd as resetRejectedExpressionWarnings,Wd as unescapeHtml,ve as usesSignalsInScript};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ou,_c,ys,bs,gi,mi,ws,vs,Qn,Ec,hi,yi,Tc,qe}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{ou as clearScriptScanCache,ws as convertServerLoopAttributesToDirectives,gi as convertSignalDirectivesToAttributes,vs as convertSignalLoopsToAttributes,Ec as extractExports,yi as findMarkupIndexOutsideScripts,bs as hasSignalsSyntax,ys as parseLoopExpression,mi as preEvalLiteralReactiveIfs,Qn as processScriptSetup,hi as processSignals,Tc as rewriteStxImportSpecifiers,_c as scanScriptTags,qe as stripStxRuntimeImports};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W}from"./chunk-
|
|
3
|
-
`)}catch{return""}})}function
|
|
4
|
-
`)}catch{return""}})}function
|
|
2
|
+
import{W}from"./chunk-c0s3k64c.js";function g(e,t){let r={};for(let n of e)r[n]=W(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=W(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Ao(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=W(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var Ua=Ao;class Jt{rules=[];defaultValue="";addRule(e){let t=new Jt;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Jt;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Jt;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Ul=new Jt;function Va(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
3
|
+
`)}catch{return""}})}function Wa(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
4
|
+
`)}catch{return""}})}function qa(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function Vl(e,t,r){let n=e;return n=Va(n,t,r),n=Wa(n,t,r),n=qa(n,t,r),n}export{Ao,Ua,Jt,Ul,Va,Wa,qa,Vl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{yl}from"./chunk-6w2yqtrd.js";import"./chunk-4rkvwm6v.js";import"./chunk-71sdgv7e.js";import"./chunk-yy3ser06.js";import"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{yl as buildForProduction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-
|
|
2
|
+
import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import{d}from"./chunk-faghmmrs.js";import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-jtbzmbzz.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import{lt,Sr,dt,Zs,$e,Qs,kr,ut,to,pt}from"./chunk-101ekf6y.js";import"./chunk-cdgwkzms.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,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Qs("Config file changed, restarting...");try{await e.onChange()}catch(l){$e(`Failed to restart: ${l}`)}},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 p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.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",ct=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:ct,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}');
|
|
@@ -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:p}=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:p}=await import("./chunk-sy1bk1ry.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,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 d(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-sy1bk1ry.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,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 ut(t);Ae(t,r);let s=pt(t.config,r);Pe(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),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.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){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=
|
|
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 ut(t);Ae(t,r);let s=pt(t.config,r);Pe(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),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.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){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=to(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await ut(t);Ae(t,u);let f=pt(t.config,u);if(Pe(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.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),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}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),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,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(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}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),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}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(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}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),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}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),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}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 he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("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}),dt(e.storyFiles.length),
|
|
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 he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("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}),dt(e.storyFiles.length),Sr(s.url),kr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Re({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":kr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{Zs("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),lt(),dt(e.storyFiles.length),Sr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
|