@stacksjs/stx 0.2.826 → 0.2.827
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-02zvytqx.js +2 -0
- package/dist/{chunk-bt0amey5.js → chunk-04z1xyrb.js} +2 -2
- package/dist/chunk-0jhq2kza.js +2 -0
- package/dist/{chunk-f0txsdpa.js → chunk-0rvntfhj.js} +3 -3
- package/dist/chunk-12m1qwzd.js +2 -0
- package/dist/chunk-17zrprh0.js +2 -0
- package/dist/chunk-1bpx9b0m.js +2 -0
- package/dist/{chunk-wy0gghvh.js → chunk-1vzncfka.js} +2 -2
- package/dist/chunk-2b1w7py1.js +2 -0
- package/dist/chunk-2mrdtxfy.js +2 -0
- package/dist/{chunk-2vqpz4qv.js → chunk-2qngyyaz.js} +2 -2
- package/dist/{chunk-7yb82rm6.js → chunk-2x9zhezb.js} +2 -2
- package/dist/{chunk-cmf6ar8v.js → chunk-3esj6tb8.js} +5 -5
- package/dist/{chunk-mfy2ayv0.js → chunk-3g7bjpj6.js} +3 -3
- package/dist/{chunk-981z8va1.js → chunk-3p7r3ajd.js} +2 -2
- package/dist/chunk-3qx7whh5.js +2 -0
- package/dist/chunk-3vsz0vrk.js +2 -0
- package/dist/{chunk-cgtpbr01.js → chunk-3x3zcfxp.js} +48 -48
- package/dist/chunk-3zfras5s.js +2 -0
- package/dist/chunk-42c92rp3.js +2 -0
- package/dist/{chunk-8ycrmsba.js → chunk-48z7tg83.js} +3 -3
- package/dist/chunk-4a3r1kh1.js +43 -0
- package/dist/{chunk-vwtejkb5.js → chunk-4d8ep00w.js} +50 -50
- package/dist/chunk-4z0jpzdq.js +3 -0
- package/dist/{chunk-6qvn1h09.js → chunk-5201w0f1.js} +3 -3
- package/dist/{chunk-bq7cfqk3.js → chunk-543yvntm.js} +2 -2
- package/dist/{chunk-d9yjpdyn.js → chunk-5phdmpa7.js} +6 -6
- package/dist/{chunk-q45xwvf6.js → chunk-5r63bv4g.js} +3 -3
- package/dist/chunk-67nq6csk.js +2 -0
- package/dist/chunk-6aak0b7c.js +2 -0
- package/dist/{chunk-7sh9fa3q.js → chunk-6k26n0sj.js} +2 -2
- package/dist/chunk-6r4teng3.js +2 -0
- package/dist/{chunk-d6d2s7n6.js → chunk-6tjm38e4.js} +2 -2
- package/dist/{chunk-06hc6rs6.js → chunk-716jrdcg.js} +1 -1
- package/dist/{chunk-y2bf32vg.js → chunk-717qsbap.js} +10 -10
- package/dist/chunk-72n804gy.js +2 -0
- package/dist/chunk-7amk61bt.js +2 -0
- package/dist/{chunk-3yh6y00f.js → chunk-7k9yahng.js} +6 -6
- package/dist/{chunk-wf0n9gpj.js → chunk-7p8m82pj.js} +4 -4
- package/dist/{chunk-h864en4b.js → chunk-7z2ygy9p.js} +7 -7
- package/dist/chunk-8n8vj099.js +2 -0
- package/dist/chunk-8ta7f5en.js +2 -0
- package/dist/{chunk-r9e0r6jx.js → chunk-8y8kgw9s.js} +3 -3
- package/dist/{chunk-b64y3yh0.js → chunk-8yy8qrcv.js} +10 -10
- package/dist/chunk-a7ewznxk.js +2 -0
- package/dist/{chunk-gjf8cjdt.js → chunk-ac9ncbfw.js} +3 -3
- package/dist/chunk-ahd8jdzx.js +2 -0
- package/dist/chunk-ay7ggc4k.js +2 -0
- package/dist/chunk-ayk94a19.js +2 -0
- package/dist/{chunk-mv3yhspn.js → chunk-b1q40vq4.js} +2 -2
- package/dist/{chunk-w45njn1r.js → chunk-b3nv89wq.js} +2 -2
- package/dist/{chunk-3axb6t08.js → chunk-b7tb00nz.js} +2 -2
- package/dist/chunk-b92vzax2.js +2 -0
- package/dist/{chunk-he5njpsd.js → chunk-bh35v908.js} +1 -1
- package/dist/chunk-bh7v78je.js +2 -0
- package/dist/{chunk-tgk2hcxv.js → chunk-bjvmmsvp.js} +6 -6
- package/dist/{chunk-8qy616yt.js → chunk-bwnwv91e.js} +8 -8
- package/dist/chunk-c7ybxv8x.js +2 -0
- package/dist/{chunk-4qhz8q0d.js → chunk-c8vza3p0.js} +22 -22
- package/dist/{chunk-8ttmzcxb.js → chunk-c9mdvpf5.js} +29 -29
- package/dist/{chunk-5emrarpf.js → chunk-car6nhfe.js} +2 -2
- package/dist/{chunk-e4jwhmpb.js → chunk-cca18z35.js} +31 -31
- package/dist/chunk-cfrgrnej.js +2 -0
- package/dist/{chunk-vzbyn4nh.js → chunk-ckg6q98b.js} +5 -5
- package/dist/{chunk-k81trehg.js → chunk-cv1zc9dg.js} +2 -2
- package/dist/chunk-cw8vpk41.js +2 -0
- package/dist/chunk-d2n2zrdg.js +2 -0
- package/dist/{chunk-0scyzg9r.js → chunk-d9s37xm5.js} +19 -19
- package/dist/chunk-db1c0c3c.js +2 -0
- package/dist/{chunk-cxz4cdcn.js → chunk-e75dntfb.js} +2 -2
- package/dist/chunk-e8a6s6xs.js +25 -0
- package/dist/{chunk-wceg59n0.js → chunk-ekh3mxyp.js} +2 -2
- package/dist/{chunk-4mj9dem1.js → chunk-em8tv6nz.js} +2 -2
- package/dist/{chunk-7qk4exw1.js → chunk-ema1c29k.js} +2 -2
- package/dist/{chunk-z23arg8m.js → chunk-f49x34sr.js} +2 -2
- package/dist/{chunk-8w9spdbn.js → chunk-f6b7av6b.js} +9 -9
- package/dist/{chunk-9gmceny5.js → chunk-f7jgda7x.js} +5 -5
- package/dist/chunk-fb90n0by.js +2 -0
- package/dist/chunk-fevyb337.js +3 -0
- package/dist/chunk-fqq5qzm0.js +2 -0
- package/dist/chunk-fr9e8kb9.js +2 -0
- package/dist/{chunk-g25rz48g.js → chunk-ftw0a5dm.js} +6 -6
- package/dist/{chunk-b4x5ndt9.js → chunk-fwktw49p.js} +4 -4
- package/dist/chunk-g4qzy5hv.js +2 -0
- package/dist/{chunk-tksjakyv.js → chunk-gcf97wgx.js} +1 -1
- package/dist/chunk-gg48cgx3.js +2 -0
- package/dist/{chunk-076fj387.js → chunk-hd378dgy.js} +1 -1
- package/dist/chunk-j9aftb7p.js +2 -0
- package/dist/chunk-jp6sbk05.js +2 -0
- package/dist/chunk-k6ye0159.js +3 -0
- package/dist/{chunk-eycaj8mk.js → chunk-kfkbqwyf.js} +2 -2
- package/dist/{chunk-p1sfwzmb.js → chunk-kh2n3zqa.js} +1 -1
- package/dist/{chunk-x6863pzd.js → chunk-kmqcvpz2.js} +5 -5
- package/dist/chunk-kshem79d.js +2 -0
- package/dist/chunk-kve27dy3.js +2 -0
- package/dist/chunk-m3tnxk01.js +2 -0
- package/dist/chunk-m716f2ga.js +2 -0
- package/dist/{chunk-sk0tmtd3.js → chunk-m973xh3a.js} +13 -13
- package/dist/chunk-m9bbhg46.js +3 -0
- package/dist/chunk-m9dj8pgb.js +2 -0
- package/dist/{chunk-8p86mpfv.js → chunk-mfebs2s2.js} +2 -2
- package/dist/{chunk-qj4r08jb.js → chunk-mxvevxb8.js} +4 -4
- package/dist/{chunk-btxnrqxf.js → chunk-myje6fhm.js} +5 -5
- package/dist/{chunk-1f7d1c0y.js → chunk-mypygxdm.js} +2 -2
- package/dist/{chunk-76eh43e9.js → chunk-nfpsaaqm.js} +2 -2
- package/dist/{chunk-rptnx3s6.js → chunk-ng5revck.js} +29 -29
- package/dist/chunk-nxnkd48v.js +2 -0
- package/dist/chunk-pe5qqem0.js +2 -0
- package/dist/chunk-pg146fc5.js +2 -0
- package/dist/{chunk-67kbsav0.js → chunk-q5pwvr98.js} +1 -1
- package/dist/{chunk-2nj9aewf.js → chunk-qadce16v.js} +1 -1
- package/dist/chunk-qg2tpvdw.js +2 -0
- package/dist/chunk-qm6epp9h.js +2 -0
- package/dist/{chunk-bwsz6sv4.js → chunk-qn06sy9j.js} +5 -5
- package/dist/{chunk-q7zwv88b.js → chunk-qnrgfm9v.js} +2 -2
- package/dist/{chunk-f05tmz4z.js → chunk-qz82cpyv.js} +9 -9
- package/dist/chunk-rbq4dn2a.js +2 -0
- package/dist/{chunk-t9vwggkw.js → chunk-ret52ds0.js} +6 -6
- package/dist/{chunk-xpy9yjyx.js → chunk-rkdsgfhd.js} +13 -13
- package/dist/{chunk-bfbh0hfn.js → chunk-rmygv0n0.js} +6 -6
- package/dist/{chunk-n7arptzc.js → chunk-s53wjw7y.js} +3 -3
- package/dist/{chunk-p1fpferp.js → chunk-s5dhvnnd.js} +6 -6
- package/dist/chunk-s5ejh2yx.js +2 -0
- package/dist/chunk-s6399qe7.js +2 -0
- package/dist/chunk-se3fqsxk.js +2 -0
- package/dist/chunk-t59bc7na.js +3 -0
- package/dist/{chunk-21syn2j5.js → chunk-t96229jm.js} +2 -2
- package/dist/{chunk-9kj5p5jq.js → chunk-tngj0fp6.js} +8 -8
- package/dist/chunk-txzap6yn.js +2 -0
- package/dist/{chunk-tjhcrj3z.js → chunk-tzhs7drk.js} +11 -11
- package/dist/chunk-v1mwhvf8.js +2 -0
- package/dist/chunk-vb4xzz5c.js +2 -0
- package/dist/{chunk-me6kgvsm.js → chunk-vpnyqf0h.js} +1 -1
- package/dist/chunk-vxhq8n8y.js +2 -0
- package/dist/{chunk-mwxbdpb1.js → chunk-vyv76w55.js} +2 -2
- package/dist/chunk-w39cfxa6.js +2 -0
- package/dist/chunk-w9gpscjf.js +2 -0
- package/dist/chunk-wb6w807m.js +2 -0
- package/dist/chunk-wpyhavjy.js +2 -0
- package/dist/{chunk-j3st59hv.js → chunk-wr7bmkne.js} +2 -2
- package/dist/chunk-wt7qhv5b.js +2 -0
- package/dist/{chunk-y8p85kcj.js → chunk-wvds0s9m.js} +2 -2
- package/dist/chunk-x742wppj.js +2 -0
- package/dist/chunk-xdwnbr9b.js +4 -0
- package/dist/{chunk-928y0wer.js → chunk-xj3my6b9.js} +105 -105
- package/dist/{chunk-qz3fdmrc.js → chunk-xn9jg1q5.js} +3 -3
- package/dist/chunk-xrspzeqx.js +2 -0
- package/dist/{chunk-x5vxkypk.js → chunk-xtn0hnmz.js} +6 -6
- package/dist/{chunk-1d67wtj4.js → chunk-y6nz6bk2.js} +3 -3
- package/dist/{chunk-cmnze7at.js → chunk-ybq56wam.js} +2 -2
- package/dist/{chunk-y9bj3566.js → chunk-yrw5ensv.js} +3 -3
- package/dist/{chunk-e648sx8w.js → chunk-yv1vw0kx.js} +2 -2
- package/dist/{chunk-pvj0bpqg.js → chunk-z25w7kmr.js} +4 -4
- package/dist/chunk-zty254tw.js +2 -0
- package/dist/{chunk-j737tnvt.js → chunk-zvvv6x8c.js} +4 -4
- package/dist/cli.js +23 -23
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/loops.d.ts +2 -0
- package/dist/loops.js +22 -3
- package/dist/performance-utils.d.ts +2 -0
- package/dist/performance-utils.js +7 -0
- package/dist/process.js +16 -10
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +11 -11
- package/package.json +5 -5
- package/dist/chunk-09285y4b.js +0 -2
- package/dist/chunk-0jvrzpfs.js +0 -2
- package/dist/chunk-19gk9k01.js +0 -2
- package/dist/chunk-2c5bwrnh.js +0 -2
- package/dist/chunk-2fwssv2z.js +0 -2
- package/dist/chunk-2v3r330m.js +0 -3
- package/dist/chunk-2vk7dtvs.js +0 -2
- package/dist/chunk-30rpspzt.js +0 -43
- package/dist/chunk-3bf48zrh.js +0 -2
- package/dist/chunk-4amybnpc.js +0 -2
- package/dist/chunk-4zjxj8ex.js +0 -2
- package/dist/chunk-58e92xts.js +0 -2
- package/dist/chunk-6h1qa3hw.js +0 -2
- package/dist/chunk-7pz76f28.js +0 -2
- package/dist/chunk-82v1egn6.js +0 -2
- package/dist/chunk-897gqcby.js +0 -2
- package/dist/chunk-9z9c025j.js +0 -2
- package/dist/chunk-a8fy7jv8.js +0 -2
- package/dist/chunk-akj26p4b.js +0 -3
- package/dist/chunk-b22yj5j5.js +0 -2
- package/dist/chunk-brhas9mp.js +0 -3
- package/dist/chunk-c1e45rtv.js +0 -2
- package/dist/chunk-cgamtmxv.js +0 -2
- package/dist/chunk-d0jcw9h6.js +0 -2
- package/dist/chunk-erf2g5b2.js +0 -2
- package/dist/chunk-exke928x.js +0 -2
- package/dist/chunk-fwk0gjbq.js +0 -2
- package/dist/chunk-g4sdthck.js +0 -2
- package/dist/chunk-g8nqmnb7.js +0 -2
- package/dist/chunk-gnt36wgk.js +0 -25
- package/dist/chunk-h67pm636.js +0 -2
- package/dist/chunk-hb8jxg45.js +0 -2
- package/dist/chunk-hfgzqapw.js +0 -2
- package/dist/chunk-hhats9b3.js +0 -2
- package/dist/chunk-htdbm0sd.js +0 -2
- package/dist/chunk-j0hrk24j.js +0 -2
- package/dist/chunk-jjbdtj4w.js +0 -2
- package/dist/chunk-jzc3rw49.js +0 -2
- package/dist/chunk-jzgyrxye.js +0 -2
- package/dist/chunk-k0xdvegc.js +0 -2
- package/dist/chunk-kep17bvj.js +0 -2
- package/dist/chunk-kfn7g24h.js +0 -2
- package/dist/chunk-kq5k2qbz.js +0 -2
- package/dist/chunk-ksxtrmy2.js +0 -2
- package/dist/chunk-m934bzg2.js +0 -2
- package/dist/chunk-mfc5d181.js +0 -2
- package/dist/chunk-mmeck545.js +0 -2
- package/dist/chunk-mz6qjee1.js +0 -2
- package/dist/chunk-ndjmt3vg.js +0 -3
- package/dist/chunk-p9dma8k0.js +0 -2
- package/dist/chunk-pby6dxnc.js +0 -2
- package/dist/chunk-prt4ntb0.js +0 -2
- package/dist/chunk-q2ynwst2.js +0 -2
- package/dist/chunk-q5bct2ks.js +0 -2
- package/dist/chunk-qp7dajd2.js +0 -2
- package/dist/chunk-r2hjn9ds.js +0 -2
- package/dist/chunk-s2zsa16d.js +0 -2
- package/dist/chunk-s8b6re34.js +0 -2
- package/dist/chunk-sddp2398.js +0 -2
- package/dist/chunk-sv4emtcj.js +0 -2
- package/dist/chunk-tcyvwy8p.js +0 -2
- package/dist/chunk-tg18j1yf.js +0 -2
- package/dist/chunk-tj7dh2dz.js +0 -2
- package/dist/chunk-tsvnhc0c.js +0 -4
- package/dist/chunk-v2ps4gnx.js +0 -2
- package/dist/chunk-vafxrky2.js +0 -2
- package/dist/chunk-wpendr22.js +0 -3
- package/dist/chunk-x30gh7vt.js +0 -2
- package/dist/chunk-x5r1cty7.js +0 -2
- package/dist/chunk-zd3dsp6p.js +0 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Se,It,ui,Ls,Oc,Nc,Mc,Dc,js,pi,Lc,jc,fi,yn}from"./chunk-xj3my6b9.js";import{k}from"./chunk-04z1xyrb.js";import{a}from"./chunk-ng5revck.js";import{wo}from"./chunk-7z2ygy9p.js";import{c}from"./chunk-k6ye0159.js";import{existsSync as B,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=yn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),he=[...new Set([...ee,...te])].sort(),be=new Set(ee),xe=new Set(te),ye=new Set(he),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function ke(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let f of t){if(f.offset===void 0)continue;let i=f.kind==="server"?be:xe;Y.lastIndex=0;for(let p of f.code.matchAll(Y)){let g=p.index+p[0].indexOf("{")+1;for(let d of p[1].matchAll(/[^,]+/g)){let y=d[0];if(/^\s*type\s/.test(y))continue;let b=/^\s*([A-Za-z_$][\w$]*)/.exec(y);if(!b)continue;let r=b[1];if(!ye.has(r)||i.has(r))continue;let o=f.offset+g+d.index+b[0].length-r.length,u=e.slice(0,o),S=u.split(`
|
|
3
3
|
`).length;s.push({line:S,column:o-(u.lastIndexOf(`
|
|
4
|
-
`)+1)+1,offset:o,length:r.length,name:r,kind:f.kind,message:ke(r,f.kind)})}}}return s}import E from"path";var we="@stacksjs/stx-typescript-plugin";function $e(e,t){let s=E.resolve(e);for(;;){let f=E.join(s,"tsconfig.json");if(t(f))return f;let i=E.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let f=$e(e,s);if(!f)return;let i=new Set,p=(g)=>{if(i.has(g))return;i.add(g);let d=t(g);if(!d)return;let y=d.compilerOptions?.plugins;if(Array.isArray(y)){let r=y.find((u)=>u?.name===we),o=Array.isArray(r?.libs)?r.libs.filter((u)=>typeof u==="string"):[];return r?{configPath:g,libs:o.map((u)=>E.resolve(E.dirname(g),u))}:null}let b=typeof d.extends==="string"?[d.extends]:Array.isArray(d.extends)?d.extends:[];for(let r of[...b].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let o=E.resolve(E.dirname(g),r.endsWith(".json")?r:`${r}.json`),u=p(o);if(u!==void 0)return u}return};return p(f)??void 0}function
|
|
5
|
-
`.repeat(e.startLine-1):"",i=
|
|
4
|
+
`)+1)+1,offset:o,length:r.length,name:r,kind:f.kind,message:ke(r,f.kind)})}}}return s}import E from"path";var we="@stacksjs/stx-typescript-plugin";function $e(e,t){let s=E.resolve(e);for(;;){let f=E.join(s,"tsconfig.json");if(t(f))return f;let i=E.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let f=$e(e,s);if(!f)return;let i=new Set,p=(g)=>{if(i.has(g))return;i.add(g);let d=t(g);if(!d)return;let y=d.compilerOptions?.plugins;if(Array.isArray(y)){let r=y.find((u)=>u?.name===we),o=Array.isArray(r?.libs)?r.libs.filter((u)=>typeof u==="string"):[];return r?{configPath:g,libs:o.map((u)=>E.resolve(E.dirname(g),u))}:null}let b=typeof d.extends==="string"?[d.extends]:Array.isArray(d.extends)?d.extends:[];for(let r of[...b].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let o=E.resolve(E.dirname(g),r.endsWith(".json")?r:`${r}.json`),u=p(o);if(u!==void 0)return u}return};return p(f)??void 0}function aa(e,t="",s=""){let f=e.startLine>1?`
|
|
5
|
+
`.repeat(e.startLine-1):"",i=ui(pi(e)+e.code,t),p=Ls(i.code),g=e.kind==="client"||e.kind==="plain"?Mc(t,e.code):"",d=(f+p).split(`
|
|
6
6
|
`),y=d.length,b=new Map;for(let o of i.declarations)for(let[u,S]of o.text.split(`
|
|
7
7
|
`).entries())if(d.push(S),o.origin)b.set(d.length,{...o.origin,line:e.startLine+o.origin.line-1+u,column:u===0?o.origin.column:1});d.push(g,"export {}","");let r=js(d.join(`
|
|
8
|
-
`),s);return{text:r.code,sourceLineCount:y,lineMap:b,scriptColumns:new Map([...i.columns].map(([o,u])=>[o+e.startLine-1,u])),importColumns:r.columns}}function
|
|
9
|
-
`)}function
|
|
8
|
+
`),s);return{text:r.code,sourceLineCount:y,lineMap:b,scriptColumns:new Map([...i.columns].map(([o,u])=>[o+e.startLine-1,u])),importColumns:r.columns}}function tm(e,t="",s=""){return aa(e,t,s).text}var ve=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function Te(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(k),f=[];for(let{file:i,names:p}of e){let g=JSON.stringify(i.replace(/\\/g,"/").replace(/\.ts$/,""));f.push(` export * from ${g}`);for(let d of p){if(s.has(d)||ve.has(d))continue;s.add(d),t.push(`declare const ${d}: typeof import(${g})[${JSON.stringify(d)}]`)}}return t.push("declare module '@composables' {",...f,"}"),t.join(`
|
|
9
|
+
`)}function ca(e,t,s){return`${e}.__stx_${t}${s}.ts`}function nm(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Bl(){return se("stx.d.ts")}function Fl(){return se("stx-module.d.ts")}function se(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(B(t))return t;return null}var De=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function re(e){return e>=1000&&e<2000}function oe(e){let t="",s=!1,f=!1;for(let i=0;i<e.length;i++){let p=e[i];if(s){if(t+=p,f)f=!1;else if(p==="\\")f=!0;else if(p==='"')s=!1;continue}if(p==='"'){s=!0,t+=p;continue}if(p==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
|
|
10
10
|
`)i++;t+=`
|
|
11
|
-
`;continue}if(p==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=p}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Ne(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(B(r)){s=r;break}let o=h.dirname(t);if(o===t)break;t=o}if(!s)return{};let f=new Set,i=s,p,g,d=s;while(i&&!f.has(i)){f.add(i);let r;try{r=JSON.parse(oe(K(i,"utf8")))}catch{break}let o=r?.compilerOptions??{};if(!p&&o.paths&&typeof o.paths==="object")p=o.paths,d=i;if(!g&&typeof o.baseUrl==="string")g=h.resolve(h.dirname(i),o.baseUrl);if(p&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!p)return{};let y=g??h.dirname(d),b={};for(let[r,o]of Object.entries(p)){if(!Array.isArray(o))continue;b[r]=o.map((u)=>typeof u==="string"&&!h.isAbsolute(u)?h.resolve(y,u):u)}return{paths:b}}async function
|
|
12
|
-
`);for(let m of ne(l,x))y.push({file:n,line:m.line,column:m.column,code:0,message:m.message,category:"error",blockKind:m.kind});if(s&&w){let m=x.filter((v)=>v.kind!=="server"),O=[...new Set(m.flatMap((v)=>
|
|
11
|
+
`;continue}if(p==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=p}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(oe(K(e,"utf8")))}catch{return}}function Ne(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(B(r)){s=r;break}let o=h.dirname(t);if(o===t)break;t=o}if(!s)return{};let f=new Set,i=s,p,g,d=s;while(i&&!f.has(i)){f.add(i);let r;try{r=JSON.parse(oe(K(i,"utf8")))}catch{break}let o=r?.compilerOptions??{};if(!p&&o.paths&&typeof o.paths==="object")p=o.paths,d=i;if(!g&&typeof o.baseUrl==="string")g=h.resolve(h.dirname(i),o.baseUrl);if(p&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!p)return{};let y=g??h.dirname(d),b={};for(let[r,o]of Object.entries(p)){if(!Array.isArray(o))continue;b[r]=o.map((u)=>typeof u==="string"&&!h.isAbsolute(u)?h.resolve(y,u):u)}return{paths:b}}async function rm(e,t={}){let s=t.client!==!1,f=t.server!==!1,i=t.templates!==!1,p=t.componentsDir??(i?(await a()).componentsDir:void 0),g=new Map,d=new Map,y=[],b=[],r=0,o=0,u=Bl();for(let n of e){let l=await Bun.file(n).text(),x=It(l).filter((m)=>{if(m.kind==="server")return f;return s}),w=It(l).filter((m)=>m.kind==="server").map((m)=>m.code).join(`
|
|
12
|
+
`);for(let m of ne(l,x))y.push({file:n,line:m.line,column:m.column,code:0,message:m.message,category:"error",blockKind:m.kind});if(s&&w){let m=x.filter((v)=>v.kind!=="server"),O=[...new Set(m.flatMap((v)=>Dc(w,v.code)))];if(O.length>0)d.set(n,{names:O,line:m[0].startLine,kind:m[0].kind})}let N=h.dirname(h.resolve(n)),D=i?Lc(l,{runtimeGlobals:!u,originDir:N,filePath:h.resolve(n),componentsDir:p}):null,R=D?[...D.lineMap.values()].filter((m)=>m.expression).length:0;if(x.length===0&&R===0)continue;if(b.push(n),r+=x.length,o+=R,x.forEach((m,O)=>{let v=aa(m,w,N);g.set(ca(n,m.kind,O),{virtual:v,source:v.text,origin:n,kind:m.kind})}),D&&R>0)g.set(ca(n,"template",0),{source:D.text,origin:n,kind:"template",virtual:D})}if(g.size===0)return{diagnostics:y,checkedFiles:b,blockCount:0,expressionCount:0};let S=(t.extraLibs??[]).map((n)=>h.resolve(n)),ce=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,B);for(let n of ce?.libs??[])if(!S.includes(n)&&B(n))S.push(n);if(u)S.push(u);let F=u?Fl():null;if(F)S.push(F);let G=`${c()}/typecheck/__stx_globals.d.ts`,ae=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Oc(u?Nc(K(u,"utf8")):void 0),...u?[]:["declare const window: any",...k.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...Se.map((n)=>`declare const ${n}: any`)].join(`
|
|
13
13
|
`),Te(await wo())].filter(Boolean).join(`
|
|
14
14
|
`),C=`${c()}/typecheck`;await Bun.$`rm -rf ${C}`.quiet().nothrow(),await Bun.$`mkdir -p ${C}`.quiet().nothrow(),await Bun.write(G,ae);let M=new Map,le=0;for(let[n,l]of g){let x=`${le++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${C}/${x}`,l.source),M.set(x,l)}let ue={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Ne(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},V=async(n,l)=>{let x=`${C}/tsconfig${l===1?"":`.${l}`}.json`;await Bun.write(x,JSON.stringify({compilerOptions:ue,files:n.map((N)=>`${C}/${N}`).concat(G,...S)},null,2));let w=Bun.spawnSync(["bun","x","tsc","-p",x,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(w.stdout)+new TextDecoder().decode(w.stderr),exitCode:w.exitCode??0}},X=await V([...M.keys()],1),J=X.output,P=[],U=X.exitCode,W=0,pe=new Set(S.map((n)=>n.split("/").pop())),z=0,j=new Set,q=(n)=>{for(let l of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
|
|
15
|
-
`)){let x=l.match(De);if(!x)continue;if(W++,pe.has(x[1].split("/").pop()))z++;let[,w,N,D,R,m,O]=x,v=w.split("/").pop(),T=M.get(v);if(!T)continue;if(re(Number(m)))j.add(v);let L=Number(N),A=Number(D),Q;if(T.virtual){let _=
|
|
15
|
+
`)){let x=l.match(De);if(!x)continue;if(W++,pe.has(x[1].split("/").pop()))z++;let[,w,N,D,R,m,O]=x,v=w.split("/").pop(),T=M.get(v);if(!T)continue;if(re(Number(m)))j.add(v);let L=Number(N),A=Number(D),Q;if(T.virtual){let _=fi(T.virtual,L,A)??(T.kind!=="template"&&re(Number(m))?fi(T.virtual,T.virtual.sourceLineCount,1):null);if(!_||T.kind==="template"&&!_.expression)continue;if(jc(_,Number(m)))continue;L=_.line,A=_.column,Q=_.expression?.code.trim()}P.push({file:T.origin,line:L,column:A,code:Number(m),message:O,category:R==="error"?"error":"warning",blockKind:T.kind,expression:Q})}};q(J);let de=W,fe=z;if(j.size>0&&j.size<M.size){let n=[...M.keys()].filter((l)=>!j.has(l));q((await V(n,2)).output)}if(s)for(let[n,l]of d){if(l.names.length===0)continue;P.push({file:n,line:l.line,column:1,code:0,message:`${l.names.length===1?"1 value reaches":`${l.names.length} values reach`} this block on the implicit bridge and ${l.names.length===1?"is":"are"} untyped: ${l.names.join(", ")}. Declare them with defineClientPayload({ ${l.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:l.kind})}P.push(...y);let H=new Set,I=P.filter((n)=>{let l=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(l))return!1;return H.add(l),!0});I.sort((n,l)=>n.file.localeCompare(l.file)||n.line-l.line||n.column-l.column);let Z=fe>0&&I.length===0,me=Z||U!==0&&de===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
16
16
|
${J.trim().split(`
|
|
17
17
|
`).slice(0,12).join(`
|
|
18
|
-
`)||"(no output)"}`:void 0;return{diagnostics:I,checkedFiles:b,blockCount:r,expressionCount:o,failure:me}}function
|
|
18
|
+
`)||"(no output)"}`:void 0;return{diagnostics:I,checkedFiles:b,blockCount:r,expressionCount:o,failure:me}}function sm(e){return e.map((t)=>{let s=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${s}`}).join(`
|
|
19
19
|
`)}
|
|
20
|
-
export{
|
|
20
|
+
export{aa,tm,ca,nm,Bl,Fl,rm,sm};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Sf,kf,ye,_f,nc,tn,nn,Eh,rc,rn,er,Cf,Ef,Tf,ss,sn,$f,on,sc,Th}from"./chunk-tngj0fp6.js";import"./chunk-qn06sy9j.js";import"./chunk-6k26n0sj.js";import"./chunk-ng5revck.js";import"./chunk-y6nz6bk2.js";import"./chunk-cv1zc9dg.js";import"./chunk-7p8m82pj.js";import"./chunk-rkdsgfhd.js";import"./chunk-mxvevxb8.js";import"./chunk-xj3my6b9.js";import"./chunk-yv1vw0kx.js";import"./chunk-2qngyyaz.js";import"./chunk-c9mdvpf5.js";import"./chunk-8y8kgw9s.js";import"./chunk-04z1xyrb.js";export{er as MODULE_SPECIFIER_PREFIX,Sf as bundleCacheDir,kf as bundleCacheEntryLimit,Th as bundleClientEntriesSplit,on as bundleClientScript,nn as clearBundleFailures,ye as clientBundleDependencies,tn as getBundleFailures,rn as hasUserImports,sn as moduleSubstitutionKey,Ef as normalizeRegistrySpecifiers,$f as queueClientBundleBuild,nc as recordBundleFailure,Cf as registryIdForPath,rc as resolveBundlerFallback,Tf as rewriteRegistryImports,Eh as setBundlerFallbackMode,_f as shouldLogBundlerDiagnostics,sc as tempBuildName,ss as withModuleSubstitutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function
|
|
2
|
+
import y from"fs";import R from"path";var S="_stx";function F(e){return Bun.hash(e).toString(16).slice(0,8)}function k(e){let t=[],n=(i)=>{for(let s of y.readdirSync(i,{withFileTypes:!0})){let r=R.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(y.existsSync(e))n(e);return t}var z=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-runtime src="${e}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(e)=>`<script data-stx-router src="${e}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(e)=>`<link data-css="generated" rel="stylesheet" href="${e}">`}];function I(e,t=`/${S}`){let n=[],i=new Set,s=0,r=e;for(let o of z)r=r.replace(o.pattern,(g,u,c)=>{if(/\b(?:src|href)\s*=/.test(u)||!c.trim())return g;let a=`${o.prefix}.${F(c)}.${o.extension}`;if(!i.has(a))i.add(a),n.push({filename:a,contents:c,contentType:o.contentType});return s+=c.length,o.replace(`${t}/${a}`)});return{html:r,assets:n,bytesInlined:s}}function Qa(e){let t={pages:0,assets:0,bytesInlined:0},n=R.join(e,S),i=new Set;for(let s of k(e)){let r=y.readFileSync(s,"utf8"),{html:o,assets:g,bytesInlined:u}=I(r);if(o===r)continue;for(let c of g){if(i.has(c.filename))continue;i.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(R.join(n,c.filename),c.contents),t.assets++}y.writeFileSync(s,o),t.bytesInlined+=u,t.pages++}return t}import h from"fs";import T from"path";var L=1024,N=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,_=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function B(e){return Bun.hash(e).toString(16).slice(0,8)}function C(e){let t=[],n=(i)=>{for(let s of h.readdirSync(i,{withFileTypes:!0})){let r=T.join(i,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))t.push(r)}};if(h.existsSync(e))n(e);return t}function O(e,t){let n=e.match(new RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function H(e,t,n){if(n.length<L)return!1;if(/\b(?:src|href)\s*=/i.test(t))return!1;if(e.toLowerCase()==="script"){if(!_.has((O(t,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function D(e){let t=[];for(let n of e.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))t.push([n.index,n.index+n[0].length]);return t}function ec(e){let t={pages:0,assets:0,bytesInlined:0},n=C(e);if(n.length<2)return t;let i=new Map,s=new Map;for(let a of n){let f=h.readFileSync(a,"utf8");i.set(a,f);let M=D(f);for(let d of f.matchAll(N)){let[x,p,l,m]=d;if(!H(p,l,m))continue;if(M.some(([j,A])=>d.index>=j&&d.index<A))continue;let w=`${p.toLowerCase()}\x00${m}`,b=s.get(w);if(b)b.push({file:a,whole:x,tag:p,attrs:l,body:m});else s.set(w,[{file:a,whole:x,tag:p,attrs:l,body:m}])}}let r=[...s.values()].filter((a)=>new Set(a.map((f)=>f.file)).size>1);if(r.length===0)return t;let o=T.join(e,S),g=new Map(i),u=new Map,c=[];for(let a of r){let{tag:f,body:M}=a[0],d=f.toLowerCase()==="script",x=`${d?"chunk":"style"}.${B(M)}.${d?"js":"css"}`;c.push({filename:x,contents:M,contentType:d?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${S}/${x}`;for(let l of a){let m=d?`<script${l.attrs} src="${p}"></script>`:`<link${l.attrs} rel="stylesheet" href="${p}">`,w=g.get(l.file),b=w.replace(l.whole,()=>m);if(b===w)continue;g.set(l.file,b),u.set(l.file,(u.get(l.file)??0)+l.body.length)}}h.mkdirSync(o,{recursive:!0});for(let a of c)h.writeFileSync(T.join(o,a.filename),a.contents),t.assets++;for(let[a,f]of g){if(f===i.get(a))continue;h.writeFileSync(a,f),t.pages++,t.bytesInlined+=u.get(a)??0}return t}import E from"fs";import v from"path";var K="layout-types.d.ts";function P(e){let t=[],n=(i,s)=>{let r;try{r=E.readdirSync(i,{withFileTypes:!0})}catch{return}for(let o of r){if(o.name.startsWith("."))continue;let g=v.join(i,o.name);if(o.isDirectory())n(g,s?`${s}/${o.name}`:o.name);else if(o.isFile()&&o.name.endsWith(".stx")&&o.name!=="_layout.stx"){let u=o.name.slice(0,-4);t.push(s?`${s}/${u}`:u)}}};return n(e,""),t.sort()}function W(e){let t=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(e.length===0)return t.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),t.join(`
|
|
3
3
|
`);return t.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...e.map((n)=>` '${n}': true`)," }","}","","export {}",""),t.join(`
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
4
|
+
`)}function tc(e,t){if(!e)return[];let n=v.isAbsolute(e)?e:v.resolve(process.cwd(),e),i=P(n),s=W(i),r=v.join(t,K);try{if(E.existsSync(r)&&E.readFileSync(r,"utf8")===s)return i;E.mkdirSync(t,{recursive:!0}),E.writeFileSync(r,s)}catch{}return i}
|
|
5
|
+
export{Qa,ec,tc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{an,Ao,Po,Io,$h,Oo}from"./chunk-qn06sy9j.js";import"./chunk-7p8m82pj.js";import"./chunk-mxvevxb8.js";import"./chunk-2qngyyaz.js";export{Po as buildServerApi,$h as createServerApi,an as discoverServerApi,Ao as generateApiTypes,Oo as isServerApiSource,Io as productionApiDispatcher};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var l=new Map,u=new Map;function m(t){if(l.set(t.name,t),t.client)u.set(t.name,t.client)}function
|
|
3
|
-
export{
|
|
2
|
+
var l=new Map,u=new Map;function m(t){if(l.set(t.name,t),t.client)u.set(t.name,t.client)}function St(t){return m(t),{name:t.name,hasEndTag:t.hasEndTag??!0,description:t.description,handler:async(r,o,a,s)=>{let n=f(o,t.defaults);if(t.validate){let e=t.validate(n);if(e!==!0){let d=typeof e==="string"?e:`Invalid parameters for @${t.name}`;throw Error(d)}}let i=r;if(t.transform)i=await t.transform(r,n,a,s);if(t.clientScript){let e=t.clientScript(n);i+=`<script>${e}</script>`}if(t.css){let e=t.css(n);i+=`<style>${e}</style>`}return i}}}function f(t,c){let r={...c};for(let o of t){let a=o.indexOf(":"),s=o.indexOf("="),n=a>=0&&(s<0||a<s)?a:s;if(n>=0){let i=o.slice(0,n).trim(),e=o.slice(n+1).trim();if(e==="true")e=!0;else if(e==="false")e=!1;else if(e==="null")e=null;else if(!Number.isNaN(Number(e)))e=Number(e);else if(typeof e==="string"&&e.startsWith("{"))try{e=JSON.parse(e)}catch{}r[i]=e}else{let i=Object.keys(r).filter((e)=>!c||!(e in c)).length;r[i===0?"value":`arg${i}`]=o}}return r}
|
|
3
|
+
export{St};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ze,N,Dt}from"./chunk-2vqpz4qv.js";import{T}from"./chunk-8ttmzcxb.js";import{ft,Ce,L,qe,Ee,pa,ho,fa,In}from"./chunk-t9vwggkw.js";import{St,ue,et}from"./chunk-qj4r08jb.js";import{Io}from"./chunk-bwsz6sv4.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-d9yjpdyn.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",L(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ce(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,k=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",L(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=k().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Gg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=pa(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,v=new Map,k=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Dt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=ue(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=pe[R]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ce(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=St(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return fa(B,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-9z9c025j.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",L(w.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let S=et(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",be(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
-
export{
|
|
2
|
+
import{He,M,Lt}from"./chunk-2qngyyaz.js";import{T}from"./chunk-c9mdvpf5.js";import{gt,Ee,j,Ke,Te,fa,ho,ga,On}from"./chunk-ret52ds0.js";import{kt,de,tt}from"./chunk-mxvevxb8.js";import{Io}from"./chunk-qn06sy9j.js";import{Nn}from"./chunk-wr7bmkne.js";import{we}from"./chunk-5phdmpa7.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function Rn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",j(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ee(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,k=async()=>{let s=await a();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",j(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return i();x=k().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let E=await x;return E?l(E):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Yg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=fa(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=Nn(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?M(l):void 0,v=new Map,k=new Map,x=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Lt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,tt(c.html)),E.set(n.pattern,we(c.html));let _=P.join(e,n.fragmentPath);if(Ke(c.html,r.routerContainer||"main")&&await Bun.file(_).exists()){let A=await Bun.file(_).text();k.set(n.pattern,m?Lt(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:c}=de(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let B=ce({port:a,async fetch(n){return Rn(n,await He(m??M(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=pe[R]||"application/octet-stream",N=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ee(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,L)=>{q[R]=o[L+1]});break}}if(!C){let p=kt(c)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(C.pattern)?{"X-STX-Runtime":E.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...j(),...O.cache?{}:{"Cache-Control":gt}}})}}let d=ho(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...j(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await On(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return ga(L,N,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-3zfras5s.js"),X=new Headers({...j(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(A&&!d&&Ke(o,r.routerContainer||"main")){let V=tt(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",we(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&Ke(o,r.routerContainer||"main")?Te(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let w=new Headers({"Content-Type":"text/html",...j(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of N??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",j(w.get("Vary")).Vary),A&&!d&&Ke(o,r.routerContainer||"main")){let S=tt(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",we(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Te(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
+
export{Rn,Yg};
|
|
@@ -72,7 +72,7 @@ else {
|
|
|
72
72
|
${t}
|
|
73
73
|
})();
|
|
74
74
|
</script>
|
|
75
|
-
`}function
|
|
75
|
+
`}function Km(i,n,o){f=0;let l=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return i.replace(l,(t,e,s)=>{let a=v(),r=p(t,e,s),d=r.placeholder?`<div data-defer-placeholder>${r.placeholder}</div>`:"",c=r.loading?`<div data-defer-loading style="display: none;">${r.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',g=r.error?`<div data-defer-error style="display: none;">${r.error}</div>`:"",u=`<div data-defer-content style="display: none;">${r.content}</div>`,h=E(a,r);return`
|
|
76
76
|
<div id="${a}" class="stx-defer" data-defer-trigger="${r.trigger}">
|
|
77
77
|
${d}
|
|
78
78
|
${c}
|
|
@@ -81,4 +81,4 @@ else {
|
|
|
81
81
|
</div>
|
|
82
82
|
${h}
|
|
83
83
|
`})}
|
|
84
|
-
export{
|
|
84
|
+
export{Km};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Jg}from"./chunk-kfkbqwyf.js";import"./chunk-ng5revck.js";import"./chunk-y6nz6bk2.js";import"./chunk-cv1zc9dg.js";import"./chunk-7p8m82pj.js";import"./chunk-rkdsgfhd.js";import"./chunk-mxvevxb8.js";import"./chunk-xj3my6b9.js";import"./chunk-yv1vw0kx.js";import"./chunk-2qngyyaz.js";import"./chunk-c9mdvpf5.js";import"./chunk-8y8kgw9s.js";import"./chunk-04z1xyrb.js";export{Jg as buildApp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-c9mdvpf5.js";import"./chunk-04z1xyrb.js";import"./chunk-8y8kgw9s.js";import"./chunk-xj3my6b9.js";import"./chunk-2qngyyaz.js";import"./chunk-yv1vw0kx.js";import"./chunk-cv1zc9dg.js";import"./chunk-y6nz6bk2.js";import{c}from"./chunk-k6ye0159.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{yn,tg,ng,rg,sg,og,m,ig,hi,ag,Kc,Xc}from"./chunk-xj3my6b9.js";import"./chunk-yv1vw0kx.js";import"./chunk-2qngyyaz.js";import"./chunk-c9mdvpf5.js";import"./chunk-8y8kgw9s.js";import"./chunk-04z1xyrb.js";export{yn as STX_ENGINE_BINDING_NAMES,hi as convertToCommonJS,Kc as extractScriptFromTemplate,m as extractVariables,Xc as hasVariables,ig as isCompleteImport,og as isMissingBindingFailure,rg as isModuleResolutionFailure,sg as isSyntaxFailure,ag as splitDeclaration,tg as stripTypeScript,ng as withoutStxReferrer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ut,dt,pt}from"./chunk-ema1c29k.js";import"./chunk-04z1xyrb.js";import"./chunk-8y8kgw9s.js";import"./chunk-c9mdvpf5.js";import{m}from"./chunk-xj3my6b9.js";import"./chunk-2qngyyaz.js";import"./chunk-yv1vw0kx.js";import{Ut,no,Wt,Wi,lt,qi,ro,qt,Xi,Kt}from"./chunk-qnrgfm9v.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{qi("Config file changed, restarting...");try{await e.onChange()}catch(p){lt(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",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}');
|
|
@@ -487,7 +487,7 @@ else {
|
|
|
487
487
|
window.__stxShortcuts.init();
|
|
488
488
|
}
|
|
489
489
|
</script>
|
|
490
|
-
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var
|
|
490
|
+
`}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var Dt=new J;function G(){return`
|
|
491
491
|
<script>
|
|
492
492
|
window.__stxPerformance = {
|
|
493
493
|
metrics: new Map(),
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-3vsz0vrk.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-3vsz0vrk.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await qt(t);dt(t,r);let s=Kt(t.config,r);pt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Xi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await qt(t);dt(t,u);let f=Kt(t.config,u);if(pt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":ro();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Ut();let e=await ut({mode:"dev"});if(!e.config.enabled){lt("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}),Wt(e.storyFiles.length),no(s.url),ro()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await ut({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":ro();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{Wi("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Ut(),Wt(e.storyFiles.length),no(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
|