@stacksjs/stx 0.2.887 → 0.2.889
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-c0g30cjs.js → chunk-05x1rd86.js} +2 -2
- package/dist/chunk-0g9cceht.js +2 -0
- package/dist/chunk-0k437z3q.js +2 -0
- package/dist/{chunk-69ezjc8k.js → chunk-0ncafcs2.js} +4 -4
- package/dist/chunk-0rpj5t80.js +2 -0
- package/dist/{chunk-sc1gmts0.js → chunk-1gyxxfdf.js} +2 -2
- package/dist/{chunk-aaea157p.js → chunk-1knk403z.js} +2 -2
- package/dist/{chunk-q74affc4.js → chunk-1n33yrar.js} +2 -2
- package/dist/chunk-1p4q6t48.js +2 -0
- package/dist/chunk-1z6pqvmf.js +2 -0
- package/dist/{chunk-s29hp1qw.js → chunk-2a5g80mq.js} +3 -3
- package/dist/chunk-2ba4zfa0.js +2 -0
- package/dist/chunk-2gn2nc2j.js +2 -0
- package/dist/chunk-2nqmw4dv.js +2 -0
- package/dist/chunk-2wkpksg1.js +2 -0
- package/dist/chunk-3dqfjpz4.js +68 -0
- package/dist/{chunk-zpj6ggee.js → chunk-3hsv6ejp.js} +4 -4
- package/dist/{chunk-8e1cv1hh.js → chunk-3qk8vf9m.js} +3 -3
- package/dist/chunk-3yjyjq0m.js +2 -0
- package/dist/chunk-444haxxa.js +2 -0
- package/dist/{chunk-azf6tdq6.js → chunk-446tb2th.js} +28 -28
- package/dist/{chunk-4251fy7d.js → chunk-48rwqchc.js} +11 -11
- package/dist/chunk-4akw3bym.js +2 -0
- package/dist/{chunk-twmkz0xs.js → chunk-4kmg6g5n.js} +9 -9
- package/dist/chunk-4rvfeee5.js +2 -0
- package/dist/{chunk-4n45qa0b.js → chunk-51720m79.js} +5 -5
- package/dist/chunk-53kcqdjj.js +2 -0
- package/dist/{chunk-02qmvcmv.js → chunk-55tc5w32.js} +3 -3
- package/dist/{chunk-0mx7rg07.js → chunk-58qzyyyv.js} +3 -3
- package/dist/chunk-5aa83bpm.js +2 -0
- package/dist/{chunk-d2pexm3z.js → chunk-5kqezrjt.js} +2 -2
- package/dist/chunk-5ssv10ep.js +2 -0
- package/dist/chunk-67rppc5v.js +2 -0
- package/dist/{chunk-care745q.js → chunk-6gtecbe7.js} +2 -2
- package/dist/{chunk-km14pdrt.js → chunk-6kyqejnq.js} +22 -22
- package/dist/{chunk-32twt3wx.js → chunk-6pdy7ajr.js} +3 -3
- package/dist/{chunk-fg67643b.js → chunk-6pz5gq6v.js} +9 -9
- package/dist/{chunk-rsxxajv6.js → chunk-700m927w.js} +2 -2
- package/dist/{chunk-gvd8nb8z.js → chunk-7212fwzz.js} +2 -2
- package/dist/chunk-732gb689.js +2 -0
- package/dist/chunk-77c89d23.js +2 -0
- package/dist/chunk-79vbkez0.js +2 -0
- package/dist/{chunk-88tshy2f.js → chunk-7hpca9c7.js} +6 -6
- package/dist/chunk-80xzjxah.js +2 -0
- package/dist/chunk-8354mzpd.js +2 -0
- package/dist/{chunk-2v7v6jcs.js → chunk-87g5xmmr.js} +12 -12
- package/dist/{chunk-sv7fdqmc.js → chunk-8hwfdwgn.js} +6 -6
- package/dist/chunk-8ygf6jnt.js +2 -0
- package/dist/{chunk-0rdh8bw3.js → chunk-95sd8h5g.js} +7 -7
- package/dist/{chunk-50cnypys.js → chunk-967ydrq4.js} +6 -6
- package/dist/chunk-9afkttvz.js +2 -0
- package/dist/{chunk-7wqz32ay.js → chunk-9d91h636.js} +2 -2
- package/dist/{chunk-kwf3kfr0.js → chunk-9n5h4sqc.js} +2 -2
- package/dist/chunk-9ztn7w4y.js +2 -0
- package/dist/chunk-ah8az9vv.js +2 -0
- package/dist/chunk-ankap9pc.js +2 -0
- package/dist/chunk-asnd03sr.js +2 -0
- package/dist/chunk-b0b5yr97.js +2 -0
- package/dist/chunk-b0e7dgv8.js +3 -0
- package/dist/{chunk-zj5eq4b6.js → chunk-b15c4g3e.js} +5 -5
- package/dist/{chunk-czcx3nbx.js → chunk-b6bf0t02.js} +6 -6
- package/dist/chunk-b7jj45bz.js +2 -0
- package/dist/{chunk-ybjgnnyf.js → chunk-bgfs3mbg.js} +5 -5
- package/dist/{chunk-f2twg7ze.js → chunk-bqtj62ys.js} +8 -8
- package/dist/{chunk-a0q0kb0s.js → chunk-bw2m1e7g.js} +5 -5
- package/dist/chunk-bwx6w87c.js +2 -0
- package/dist/{chunk-ef9m5fjb.js → chunk-cgfjrgfw.js} +14 -14
- package/dist/{chunk-463weehv.js → chunk-ch9028z3.js} +1 -1
- package/dist/{chunk-57q4nvs9.js → chunk-cmg9x1ka.js} +3 -3
- package/dist/{chunk-9f31gs4m.js → chunk-cz1sdes5.js} +2 -2
- package/dist/{chunk-satrf398.js → chunk-dvjv4c3a.js} +1 -1
- package/dist/{chunk-dz7amds0.js → chunk-dymck524.js} +5 -5
- package/dist/chunk-dzqfv801.js +3 -0
- package/dist/{chunk-agd2b928.js → chunk-eceeqy74.js} +4 -4
- package/dist/{chunk-c47stwqj.js → chunk-eqffvse2.js} +1 -1
- package/dist/chunk-ery4tty7.js +20 -0
- package/dist/chunk-evwrxsxd.js +3 -0
- package/dist/{chunk-6t04tqvh.js → chunk-eyx92t9n.js} +2 -2
- package/dist/{chunk-6mfpns00.js → chunk-f3cyghnb.js} +5 -5
- package/dist/chunk-f60k8j9m.js +2 -0
- package/dist/chunk-fdqdz018.js +2 -0
- package/dist/chunk-g6ap4085.js +2 -0
- package/dist/chunk-gz9pknbw.js +1204 -0
- package/dist/{chunk-pgrm1vet.js → chunk-hgf7bc50.js} +7 -7
- package/dist/chunk-hjb4c8g2.js +2 -0
- package/dist/chunk-hk241gt2.js +2 -0
- package/dist/{chunk-yasdj4ve.js → chunk-hm9d40yf.js} +2 -2
- package/dist/{chunk-6df3j3qq.js → chunk-hpzje67q.js} +2 -2
- package/dist/{chunk-qt39mb2a.js → chunk-htx5yezj.js} +2 -2
- package/dist/{chunk-xpbakn6t.js → chunk-hxws025y.js} +3 -3
- package/dist/chunk-jhbj9ja2.js +2 -0
- package/dist/chunk-k4x680e3.js +2 -0
- package/dist/chunk-k9abxnpa.js +2 -0
- package/dist/{chunk-c73c0wf9.js → chunk-kbbbpae2.js} +2 -2
- package/dist/chunk-kfdmm240.js +2 -0
- package/dist/{chunk-xcsgpf83.js → chunk-kj43fbzm.js} +1 -1
- package/dist/{chunk-59er0fc7.js → chunk-kk2p2tgv.js} +3 -3
- package/dist/{chunk-dwyhpbpx.js → chunk-ksmn19qw.js} +2 -2
- package/dist/{chunk-16aqrwmk.js → chunk-kx09v9ya.js} +7 -7
- package/dist/{chunk-3bfheqe3.js → chunk-m95sygv4.js} +3 -3
- package/dist/{chunk-nzpzyz22.js → chunk-mctzpw0w.js} +1 -1
- package/dist/{chunk-y6eaqs8v.js → chunk-me4yq8c2.js} +3 -3
- package/dist/{chunk-n22xtagg.js → chunk-mgh5rst1.js} +2 -2
- package/dist/{chunk-zch65qrd.js → chunk-mhxg6j6s.js} +1 -1
- package/dist/{chunk-pc8dt8xs.js → chunk-mjp1z9kz.js} +1 -1
- package/dist/{chunk-gtv9jd68.js → chunk-mt8edb75.js} +49 -49
- package/dist/chunk-mvavjydq.js +2 -0
- package/dist/{chunk-e362e615.js → chunk-mw7hacm3.js} +30 -30
- package/dist/{chunk-cv4bfhn1.js → chunk-nbdscgvj.js} +6 -6
- package/dist/{chunk-qx1nbryq.js → chunk-njpva3zq.js} +2 -2
- package/dist/{chunk-6qpe4f8e.js → chunk-nkyff7v6.js} +11 -11
- package/dist/{chunk-mxvgft6p.js → chunk-p8shtje2.js} +32 -32
- package/dist/{chunk-cb0c6959.js → chunk-pctf14yw.js} +1 -1
- package/dist/{chunk-3cq4a4x7.js → chunk-pjj54ddk.js} +3 -3
- package/dist/{chunk-pdprhg5k.js → chunk-pnmafbv5.js} +1 -1
- package/dist/{chunk-kee5a3ce.js → chunk-pz554g43.js} +3 -3
- package/dist/{chunk-h63ma36g.js → chunk-q0y8gv18.js} +2 -2
- package/dist/{chunk-ws2h92mm.js → chunk-q9tc9rdv.js} +2 -2
- package/dist/chunk-qqng9545.js +2 -0
- package/dist/{chunk-8va3fs07.js → chunk-r5ecgcx2.js} +5 -5
- package/dist/{chunk-q1mb0fbt.js → chunk-ranjkpc8.js} +2 -2
- package/dist/{chunk-ssg6ne5b.js → chunk-rb2zbdqd.js} +4 -4
- package/dist/{chunk-e41pgmgk.js → chunk-rf0smj4c.js} +2 -2
- package/dist/chunk-rjm515e2.js +2 -0
- package/dist/chunk-rye4b2x3.js +2 -0
- package/dist/chunk-ryj8139z.js +2 -0
- package/dist/{chunk-q3epnfp4.js → chunk-s0mf56y1.js} +5 -5
- package/dist/{chunk-kaem8q20.js → chunk-s93yh7ed.js} +2 -2
- package/dist/chunk-s9b809n2.js +2 -0
- package/dist/chunk-sb67wg5x.js +2 -0
- package/dist/{chunk-rv0a3stz.js → chunk-sjjw6y49.js} +6 -6
- package/dist/chunk-snkbn5y8.js +2 -0
- package/dist/{chunk-7mcs59pr.js → chunk-snv80b1b.js} +2 -2
- package/dist/chunk-sqwx2g02.js +2 -0
- package/dist/{chunk-2r0nrvqe.js → chunk-t0ttxayz.js} +2 -2
- package/dist/chunk-tbh7r1wh.js +2 -0
- package/dist/chunk-tpyekw0q.js +2 -0
- package/dist/chunk-v2627s75.js +2 -0
- package/dist/chunk-v3jyb8k6.js +2 -0
- package/dist/chunk-v98n53nk.js +2 -0
- package/dist/{chunk-sfyyn0mg.js → chunk-vc432a0w.js} +9 -9
- package/dist/{chunk-a7ryj8z8.js → chunk-vf4ejngv.js} +6 -6
- package/dist/{chunk-hxhmhw23.js → chunk-vk2jy6mn.js} +3 -3
- package/dist/chunk-w34vvhm7.js +2 -0
- package/dist/chunk-w82nk19t.js +2 -0
- package/dist/{chunk-ezna4dhj.js → chunk-x5bn2svk.js} +2 -2
- package/dist/chunk-x6565mhk.js +2 -0
- package/dist/{chunk-gbncp2gp.js → chunk-xvncq3m5.js} +2 -2
- package/dist/chunk-xwgdcc7w.js +2 -0
- package/dist/{chunk-ram5944w.js → chunk-xy8smv5e.js} +2 -2
- package/dist/{chunk-yp4tn4zn.js → chunk-y1d3j2j7.js} +4 -4
- package/dist/chunk-yjwa7ktk.js +2 -0
- package/dist/{chunk-94ctmp0j.js → chunk-ytjn0gq2.js} +2 -2
- package/dist/chunk-z47p2gx8.js +2 -0
- package/dist/chunk-z4tdnfxd.js +2 -0
- package/dist/chunk-z6kw6sct.js +4 -0
- package/dist/{chunk-shcnt6aa.js → chunk-zf68afyh.js} +3 -3
- package/dist/chunk-zhywjwdr.js +2 -0
- package/dist/{chunk-g2xy0z0e.js → chunk-zwwhpxp7.js} +2 -2
- package/dist/cli.js +21 -21
- package/dist/component-library.d.ts +2 -1
- package/dist/component-library.js +126 -308
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/directive-arguments.js +39 -6
- package/dist/parser/tokenizer.d.ts +2 -1
- package/dist/parser/tokenizer.js +7 -5
- package/dist/props-declaration.d.ts +64 -0
- package/dist/props-declaration.js +354 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +7 -7
- package/dist/utils.js +20 -109
- package/package.json +5 -5
- package/dist/chunk-08cb7cyw.js +0 -2
- package/dist/chunk-0gkxqcpj.js +0 -2
- package/dist/chunk-0h1dyd38.js +0 -2
- package/dist/chunk-0sew66hf.js +0 -2
- package/dist/chunk-13dgqekj.js +0 -2
- package/dist/chunk-15n20xwe.js +0 -2
- package/dist/chunk-1ta1pj1t.js +0 -2
- package/dist/chunk-1z3r2jjp.js +0 -2
- package/dist/chunk-1z6rrqvm.js +0 -2
- package/dist/chunk-295bykzd.js +0 -61
- package/dist/chunk-41353gyc.js +0 -2
- package/dist/chunk-4j50hrgq.js +0 -20
- package/dist/chunk-4pjqj54a.js +0 -2
- package/dist/chunk-53cc06w7.js +0 -2
- package/dist/chunk-5m02cbxg.js +0 -2
- package/dist/chunk-5rd0an89.js +0 -2
- package/dist/chunk-5s0w910j.js +0 -2
- package/dist/chunk-6fy11vfb.js +0 -2
- package/dist/chunk-6mjk28s3.js +0 -2
- package/dist/chunk-8h5nje66.js +0 -2
- package/dist/chunk-97kgrevs.js +0 -4
- package/dist/chunk-9h3qq2d2.js +0 -2
- package/dist/chunk-9kza7gxd.js +0 -2
- package/dist/chunk-a02gt4tz.js +0 -1199
- package/dist/chunk-a30zpnqp.js +0 -2
- package/dist/chunk-aq0fz4mr.js +0 -2
- package/dist/chunk-aqxh80vh.js +0 -2
- package/dist/chunk-axra1yas.js +0 -2
- package/dist/chunk-b2vhsyf9.js +0 -2
- package/dist/chunk-c42b1y7z.js +0 -2
- package/dist/chunk-c89wryyz.js +0 -2
- package/dist/chunk-cev5z6gj.js +0 -2
- package/dist/chunk-ch57kgb6.js +0 -2
- package/dist/chunk-cv1vm1w0.js +0 -2
- package/dist/chunk-d7b30bg6.js +0 -2
- package/dist/chunk-f3j1h3ch.js +0 -2
- package/dist/chunk-fz4c5e9m.js +0 -2
- package/dist/chunk-gd04nvj3.js +0 -2
- package/dist/chunk-gmp10259.js +0 -2
- package/dist/chunk-gr956aar.js +0 -2
- package/dist/chunk-h3fv0q25.js +0 -2
- package/dist/chunk-jghpzx5m.js +0 -2
- package/dist/chunk-kcqfrw10.js +0 -2
- package/dist/chunk-kfzvtzsz.js +0 -2
- package/dist/chunk-kqgspa3s.js +0 -2
- package/dist/chunk-mast9wb2.js +0 -2
- package/dist/chunk-mqy1wz09.js +0 -3
- package/dist/chunk-mv21mc9p.js +0 -2
- package/dist/chunk-n9bw9bsn.js +0 -2
- package/dist/chunk-ngzyzcrp.js +0 -2
- package/dist/chunk-nnqyn7db.js +0 -2
- package/dist/chunk-p5qac909.js +0 -2
- package/dist/chunk-p6hcrg3r.js +0 -3
- package/dist/chunk-pa2vt2ej.js +0 -2
- package/dist/chunk-pa6kgbmw.js +0 -2
- package/dist/chunk-pd089tq0.js +0 -2
- package/dist/chunk-pjjrx9pk.js +0 -2
- package/dist/chunk-pt3rp3zg.js +0 -2
- package/dist/chunk-qg1kw5yf.js +0 -2
- package/dist/chunk-s7xywsqd.js +0 -3
- package/dist/chunk-t8r40wgf.js +0 -2
- package/dist/chunk-w5zzwe2f.js +0 -2
- package/dist/chunk-wjafpvjv.js +0 -2
- package/dist/chunk-x44f0eq1.js +0 -2
- package/dist/chunk-xhr35ctb.js +0 -2
- package/dist/chunk-xk15vzb6.js +0 -2
- package/dist/chunk-xmmr0916.js +0 -2
- package/dist/chunk-ywnqjqns.js +0 -2
- package/dist/chunk-z7k1xn6k.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h,y,g}from"./chunk-
|
|
2
|
+
import{h,y,g}from"./chunk-gz9pknbw.js";import{q}from"./chunk-p8shtje2.js";import{i}from"./chunk-mt8edb75.js";import k from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,n;O.lastIndex=0;while((n=O.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function dh(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await h(p,f,e);let E=z(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,f,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],b=new RegExp(T.source,"g"),m;while((m=b.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let D=await i(I,f,e,n,l);r.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,i(d.content,f,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -17,13 +17,13 @@ import{h,y,g}from"./chunk-a02gt4tz.js";import{W}from"./chunk-mxvgft6p.js";import
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
})();
|
|
20
|
-
</script>`);let x=Array.from(w.entries()).map(async([d,u])=>{r.enqueue(await
|
|
20
|
+
</script>`);let x=Array.from(w.entries()).map(async([d,u])=>{r.enqueue(await Va(d,u))});await Promise.all(x)}r.close()}catch(a){r.error(a)}}})}async function Va(e,t){try{let n=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
|
|
21
21
|
<script>
|
|
22
22
|
window.__stxSuspense.resolve('${e}', \`${n}\`);
|
|
23
23
|
</script>`}catch(o){let n=o instanceof Error?o.message:String(o);return`
|
|
24
24
|
<script>
|
|
25
25
|
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${g(n)}</div>');
|
|
26
|
-
</script>`}}var
|
|
26
|
+
</script>`}}var Bu=`
|
|
27
27
|
<script>
|
|
28
28
|
(function(){
|
|
29
29
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -43,12 +43,12 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
|
-
</script>`;function
|
|
46
|
+
</script>`;function A(e,t,o){if(!t||t<=0)return e;let n,s=new Promise((r,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}function ph(e,t=[],o={}){let n=o.timeoutMs??0;return new ReadableStream({async start(s){try{if(s.enqueue(e),t.length>0)s.enqueue(Bu),await Promise.all(t.map(async(r)=>{let a=A(r.render(),n,r.id);s.enqueue(await Va(r.id,a))}));s.close()}catch(r){s.error(r)}}})}var B=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function fh(e,t){return e.replace(B,(o,n,s)=>{let r=n.trim(),a=s.split(/@fallback/i),S=a[0].trim(),p=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[r]=S,`<div data-suspense="${r}">${p}</div>`})}function gh(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,n])=>typeof n==="function");return o.length>0?o.map(([n,s])=>({id:n,render:s})):void 0}async function mh(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await h(p,f,e);let E=new Set,l=n.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(l!=="manual"&&R.test(c))){let x=await i(c,f,e,n,E);for(let d=0;d<x.length;d+=s)r.enqueue(x.slice(d,d+s))}else{let x=[],d=new RegExp(T.source,"g"),u;while((u=d.exec(c))!==null)x.push({name:u[1],content:u[2],start:u.index,end:u.index+u[0].length});let b=0;for(let m of x){if(m.start>b){let _=c.slice(b,m.start);if(_.trim()){let C=await i(_,f,e,n,E);r.enqueue(C)}}let v=await i(m.content,f,e,n,E);r.enqueue(v),b=m.end}if(b<c.length){let m=c.slice(b);if(m.trim()){let v=await i(m,f,e,n,E);r.enqueue(v)}}}r.close()}catch(a){r.error(a)}}})}async function hh(e,t={}){let o={...q,...t,streaming:{...M,...t.streaming}},n=await Bun.file(e).text(),s=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),r=s?s[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,p={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let l=c[1],R=c[2];p[l]=R}let f=a.replace(T,"");return{renderShell:async(l={})=>{let R={...l,__filename:e,__dirname:k.dirname(e)};return await h(r,R,e),i(f,R,e,o,new Set)},renderSection:async(l,R={})=>{try{if(!p[l])return`<div class="error-message">Section "${g(l)}" not found in template "${g(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await h(r,w,e);let x=new Set;return await i(p[l],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return y("Expression",x,e,p[l]||"",0,p[l]||"")}},getSections:()=>Object.keys(p),getTemplate:()=>S}}var Fu={name:"suspense",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let s=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${s} -->${e}<!-- @endsuspense:${s} -->`}},zu={name:"island",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let s=t[0].replace(/['"`]/g,""),r=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${s}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),p=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${s}" data-island-id="${a}" data-priority="${r}">
|
|
47
47
|
${c}
|
|
48
48
|
<script type="application/json" data-island-props="${a}">
|
|
49
49
|
${p?`{${p}}`:"{}"}
|
|
50
50
|
</script>
|
|
51
|
-
</div>`}};function
|
|
51
|
+
</div>`}};function yh(e={}){let t=[];if(e.streaming?.enabled)t.push(Fu);if(e.hydration?.enabled)t.push(zu);return t}async function bh(e,t,o,n={}){return e}function wh(e,t={}){let o=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(r,a){a.enqueue(o.encode(r))}})),s=new Headers(t.headers);if(!s.has("Content-Type"))s.set("Content-Type","text/html; charset=utf-8");if(!s.has("Transfer-Encoding"))s.set("Transfer-Encoding","chunked");if(!s.has("X-Content-Type-Options"))s.set("X-Content-Type-Options","nosniff");if(!s.has("X-Accel-Buffering"))s.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:s})}function vh(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:n=!0}=e,s=Object.entries(o).map(([r,a])=>`'${r}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
|
|
52
52
|
`);if(t==="loader")return`
|
|
53
53
|
(function() {
|
|
54
54
|
window.__stx = window.__stx || {};
|
|
@@ -191,4 +191,4 @@ else {
|
|
|
191
191
|
stx.hydrate();
|
|
192
192
|
}
|
|
193
193
|
})();`}
|
|
194
|
-
export{
|
|
194
|
+
export{dh,Va,Bu,ph,fh,gh,mh,hh,Fu,zu,yh,bh,wh,vh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{mr,i}from"./chunk-mt8edb75.js";import"./chunk-vc432a0w.js";import"./chunk-48rwqchc.js";import"./chunk-05x1rd86.js";import"./chunk-hgf7bc50.js";import"./chunk-b0e7dgv8.js";import"./chunk-dymck524.js";import"./chunk-5kqezrjt.js";import"./chunk-4kmg6g5n.js";import{Re}from"./chunk-bqtj62ys.js";import"./chunk-pctf14yw.js";import"./chunk-9d91h636.js";import"./chunk-eqffvse2.js";import"./chunk-p8shtje2.js";import"./chunk-58qzyyyv.js";import"./chunk-q0y8gv18.js";import"./chunk-rb2zbdqd.js";import"./chunk-95sd8h5g.js";import"./chunk-eceeqy74.js";import{Ue,io,ao}from"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{mr as buildModulesTag,Re as injectRouterScript,i as processDirectives,io as processJsonDirective,ao as processOnceDirective,Ue as validateClientScript};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S,C,A,
|
|
3
|
-
${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(F.length===0||
|
|
4
|
-
`),
|
|
2
|
+
import{S,C,A,se,O,no,ie}from"./chunk-gz9pknbw.js";import{De}from"./chunk-9n5h4sqc.js";import{_}from"./chunk-mgh5rst1.js";import{D,Bn}from"./chunk-vk2jy6mn.js";import{a}from"./chunk-p8shtje2.js";import{Ee,mn,hn,yn}from"./chunk-ery4tty7.js";import{Pt}from"./chunk-4kmg6g5n.js";import{Tt,tr,cn,we}from"./chunk-z6kw6sct.js";import{Z}from"./chunk-eqffvse2.js";import{I,et}from"./chunk-q9tc9rdv.js";import y from"path";var B=new Map,P=new Map,R=S(64),T=new Map,te=["composables","functions"];function W(e){let s=y.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ne(e){if(e)return y.resolve(e);let s=`<default>:${process.cwd()}`,i=T.get(s);if(i!==void 0)return i;let t=await oe();if(t!==null)T.set(s,t);return t}async function oe(){let e=await a(),s=e.root||process.cwd(),i=e.composablesDir;if(i)return y.resolve(s,i);for(let t of te){let n=y.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let r of c.scan({cwd:n,absolute:!0}))if(!W(r))return n}catch{}}return null}async function X(e){let s=Array.isArray(e)?e:e?[y.resolve(e)]:(await a())._layerComposableDirs??[await ne()].filter((t)=>!!t),i=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let r=y.relative(t,c);if(!W(c)&&!i.has(r))i.set(r,c)}}catch{}}return{key:s.join("\x00"),files:[...i.values()].sort()}}async function Fo(e){let{files:s}=await X(e),i=ie({loader:"ts",target:"browser",define:A()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),r=i.scan(c).exports.filter((d)=>d!=="default");if(r.length>0)t.push({file:n,names:r})}catch{}return t}function re(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function Q(e,s){let i=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?i.has(n):re(e,n))t.add(n);return t}var H=S(64);function U(e,s){let i=C(e,s.size),t=H.get(i);if(t)return t;let n;try{n=De(e,s)}catch{n=Q(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let r of c)for(let d of r[1].split(",")){let f=d.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return H.set(i,n),n}function ae(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var q=S(256);function ce(e,s){let i=new Set(s),t="",n=0,c=new Set;for(let r of se(e)){t+=e.slice(n,r.start),n=r.end;let d=O(r.attrs),f=e.slice(r.bodyStart,r.bodyEnd),u=d.get("type"),m=typeof u==="string"?u.trim():void 0;if(!ae(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let x=Q(f,i);if(x.size===0)continue;let b=C(f,[...x].sort().join(",")),w=q.get(b);if(!w)w=U(f,x),q.set(b,w);for(let M of w)c.add(M)}t+=e.slice(n);for(let r of no(t))for(let d of U(r.code,i))c.add(d);return c}function le(e,s,i){let t=new Map;for(let{file:f,names:u}of e)for(let m of u)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let u=[];for(let m of U(f,n))u.push(t.get(m));return u},r=new Set,d=i.flatMap((f,u)=>u===0?[...ce(f,t.keys())].map((m)=>t.get(m)):c(f));while(d.length>0){let f=[];for(let u of d){if(r.has(u))continue;r.add(u);for(let m of c(s.get(u)??""))if(!r.has(m))f.push(m)}d=f}return r}async function Fh(e,s,i,t){let{key:n,files:c}=await X(e);if(!n)return null;let r=()=>[...new Set([...c,...c.flatMap((o)=>Ee(o))])],d=Tt(r());if(c.length===0)return we(B,n,d,""),null;c.sort();let f=ie({loader:"ts",target:"browser",define:A()}),u=cn(P,n,d);if(!u){let o=new Map,l=[];for(let p of c)try{let v=await Bun.file(p).text();o.set(p,v);let g=f.scan(v).exports.filter((ee)=>ee!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}u=we(P,n,d,{codeByFile:o,modules:l})}let{codeByFile:m,modules:x}=u,b;if(s===void 0)b=new Set(c);else{let o=i?[s,...i]:[s],l=C(o.join("\x00"),n,o.length,d),p=R.get(l);if(b=p??le(x,m,o),!p)R.set(l,b)}if(b.size===0)return null;let w=c.filter((o)=>b.has(o)),M=()=>{if(!t)return;for(let o of w)t.push(o,...Ee(o))},E=`${n}\x00${w.join("\x00")}\x00${hn()}`,z=cn(B,E,d);if(z!==void 0)return M(),z||null;let F=[],j=new Set,K=new Set;for(let o of w)try{let l=m.get(o)??await Bun.file(o).text(),p=y.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])K.add(g[1]);let v=[];try{for(let g of f.scan(l).exports)if(g!=="default")j.add(g),v.push(g)}catch{}if(l=D(l),mn(l))l=await yn(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:v}),l=Pt(l);l=Bn(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),F.push(`// Composable: ${p}
|
|
3
|
+
${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(F.length===0||j.size===0)return we(B,E,d,""),null;let V=[...j].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
|
+
`),G=JSON.stringify([...j]),N=F.join(`
|
|
5
5
|
|
|
6
|
-
`),Y=_.filter((o)=>!K.has(o)&&new RegExp(`\\b${o}\\b`).test(
|
|
7
|
-
`),h=JSON.stringify(new Bun.CryptoHasher("md5").update(`${
|
|
6
|
+
`),Y=_.filter((o)=>!K.has(o)&&new RegExp(`\\b${o}\\b`).test(N)).map((o)=>`var ${o} = __stx[${JSON.stringify(o)}];`).join(`
|
|
7
|
+
`),h=JSON.stringify(new Bun.CryptoHasher("md5").update(`${G}\x00${N}`).digest("hex").slice(0,12)),k=Z(N),J=`;${k?"await (async function":"(function"}(){
|
|
8
8
|
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
|
-
if (__bundles[${h}]) { ${
|
|
10
|
-
${
|
|
9
|
+
if (__bundles[${h}]) { ${k?"await __bundles["+h+"];":""} return; }
|
|
10
|
+
${k?`var __resolveBundle, __rejectBundle;
|
|
11
11
|
__bundles[${h}]=new Promise(function(resolve,reject){__resolveBundle=resolve;__rejectBundle=reject;});
|
|
12
12
|
__bundles[${h}].catch(function(){});
|
|
13
13
|
try {`:`__bundles[${h}] = true;`}
|
|
@@ -16,9 +16,9 @@ window.__composables = window.__composables || {};
|
|
|
16
16
|
var __c = window.__composables;
|
|
17
17
|
var __stx = window.stx || {};
|
|
18
18
|
${Y}
|
|
19
|
-
${
|
|
19
|
+
${N}
|
|
20
20
|
${V}
|
|
21
|
-
var __names = ${
|
|
21
|
+
var __names = ${G};
|
|
22
22
|
for (var __i = 0; __i < __names.length; __i++) {
|
|
23
23
|
var __n = __names[__i];
|
|
24
24
|
if (!(__n in __c) || __published[__n]) continue;
|
|
@@ -32,7 +32,7 @@ ${V}
|
|
|
32
32
|
window[__n] = __c[__n];
|
|
33
33
|
__published[__n] = true;
|
|
34
34
|
}
|
|
35
|
-
${
|
|
35
|
+
${k?`__resolveBundle();
|
|
36
36
|
} catch(error) { delete __bundles[${h}]; __rejectBundle(error); throw error; }`:""}
|
|
37
|
-
})();`,L=I()?et(
|
|
38
|
-
export{
|
|
37
|
+
})();`,L=I()?et(J):J;return d=Tt(r()),we(B,E,d,L),M(),L}function zh(){B.clear(),tr(),P.clear(),R.clear(),T.clear()}
|
|
38
|
+
export{Fo,Fh,zh};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function Fa(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function za(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
|
|
3
3
|
<div class="virtual-item ${t.itemClass||""}"
|
|
4
4
|
style="position: absolute; top: ${a*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
|
|
5
5
|
data-index="${a}">
|
|
@@ -76,7 +76,7 @@ function ja(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
76
76
|
};
|
|
77
77
|
})();
|
|
78
78
|
</script>
|
|
79
|
-
`})}function
|
|
79
|
+
`})}function xu(){return`
|
|
80
80
|
.virtual-list-container {
|
|
81
81
|
position: relative;
|
|
82
82
|
overflow-y: auto;
|
|
@@ -124,7 +124,7 @@ function ja(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
124
124
|
0% { background-position: 200% 0; }
|
|
125
125
|
100% { background-position: -200% 0; }
|
|
126
126
|
}
|
|
127
|
-
`}function
|
|
127
|
+
`}function Su(v,c){let l=null,u=()=>{if(!l)l=Fa(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function ku(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=za(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
|
|
128
128
|
// Infinite scroll detection
|
|
129
129
|
container.addEventListener('scroll', function() {
|
|
130
130
|
const scrollBottom = container.scrollTop + container.clientHeight;
|
|
@@ -142,7 +142,7 @@ function ja(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
142
142
|
${x}
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
|
-
`})}function
|
|
145
|
+
`})}function _u(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
|
|
146
146
|
<div class="virtual-grid-item"
|
|
147
147
|
style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
|
|
148
148
|
data-index="${I}">
|
|
@@ -212,5 +212,5 @@ function ja(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
212
212
|
});
|
|
213
213
|
})();
|
|
214
214
|
</script>
|
|
215
|
-
`})}var
|
|
216
|
-
export{
|
|
215
|
+
`})}var ah={createVirtualList:Fa,processVirtualListDirectives:za,processInfiniteListDirectives:ku,processVirtualGridDirectives:_u,generateVirtualListCSS:xu,useVirtualList:Su};
|
|
216
|
+
export{Fa,za,xu,Su,ku,_u,ah};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pa,Rm,Mo,Am,pu,fu,Pm,Im}from"./chunk-cgfjrgfw.js";import"./chunk-87g5xmmr.js";import"./chunk-ery4tty7.js";import"./chunk-s0mf56y1.js";import"./chunk-cz1sdes5.js";import"./chunk-4kmg6g5n.js";import"./chunk-bqtj62ys.js";import"./chunk-pctf14yw.js";import"./chunk-eqffvse2.js";import"./chunk-p8shtje2.js";import"./chunk-58qzyyyv.js";import"./chunk-q0y8gv18.js";import"./chunk-rb2zbdqd.js";import"./chunk-95sd8h5g.js";import"./chunk-eceeqy74.js";import{ke,no}from"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{Pa as buildScriptVirtualFile,Rm as buildVirtualSource,ke as extractScriptBlocks,no as extractTemplateExpressions,pu as findRuntimeTypeDeclarations,fu as findStxModuleDeclarations,Im as formatTypecheckDiagnostics,Am as sourcePathFor,Pm as typecheckStxFiles,Mo as virtualPathFor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{n,u,Jt,Yt,
|
|
2
|
+
import{n,u,Xt,Jt,Yt,Ze,yt,H,mo,qr,Qe}from"./chunk-3dqfjpz4.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,t){return(r)=>H(e,r,"the call has no closing parenthesis",t,n.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${c(e.property)}" content="${c(e.content)}">`:`<meta name="${c(e.name)}" content="${c(e.content)}">`}function vi(e,t,r,g){if(!e.includes("@meta"))return e;let i=Xt(e,O,(a,o)=>{let s=qr(Jt(a),t);if(s.kind==="tag")return N(s.tag);if(s.kind==="empty")return"";return H("Meta",o,s.message,r,s.code)},_("Meta",r));return i=Xt(i,I,(a,o)=>{let s=Yt(a,t);if(!s.ok)return H("MetaTag",o,s.message,r,s.code);if(s.value===void 0||s.value===null)return"";if(!yt(s.value))return H("MetaTag",o,`expected an object such as { name, content }, got ${Ze(s.value)}`,r,n.TYPE_ERROR);let l=s.value;if(!l.name&&!l.property&&!l.httpEquiv)return H("MetaTag",o,"the tag needs a name, property or httpEquiv",r,n.INVALID_DIRECTIVE_SYNTAX);if(l.content===void 0||l.content===null||l.content===""||l.content===!1)return"";let p="<meta";if(l.name)p+=` name="${c(l.name)}"`;if(l.property)p+=` property="${c(l.property)}"`;if(l.httpEquiv)p+=` http-equiv="${c(l.httpEquiv)}"`;return p+=` content="${c(l.content)}">`,p},_("MetaTag",r)),i}function b(e){let t=(r)=>r["@context"]?{...r}:{...r,"@context":"https://schema.org"};if(yt(e))return t(e);if(Array.isArray(e)&&e.length>0&&e.every(yt))return e.map(t);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function xi(e,t,r){if(!e.includes("@structuredData"))return e;return Xt(e,C,(g,i)=>{let a=Yt(g,t);if(!a.ok)return H("StructuredData",i,a.message,r,a.code);if(a.value===void 0||a.value===null)return"";let o=b(a.value);if(!o)return H("StructuredData",i,`expected an object or an array of objects, got ${Ze(a.value)}`,r,n.TYPE_ERROR);try{return E(o)}catch(s){let l=s instanceof Error?s.message:String(s);return H("StructuredData",i,`the data cannot be written as JSON: ${l}`,r,n.EVALUATION_ERROR)}},_("StructuredData",r))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function Si(e,t,r,g){if(!e.includes("@seo"))return e;return Xt(e,k,(i,a)=>{if(!i.trim())return H("SEO",a,"expected an object: @seo({ title, description }) or @seo(seoVariable)",r,n.INVALID_DIRECTIVE_SYNTAX);let o=Yt(i,t);if(!o.ok)return H("SEO",a,o.message,r,o.code);if(o.value===void 0||o.value===null)return"";if(!yt(o.value))return H("SEO",a,`expected an object such as { title, description }, got ${Ze(o.value)}`,r,n.TYPE_ERROR);try{return L(o.value,a,r)}catch(s){let l=s instanceof Error?s.message:String(s);return H("SEO",a,`Error processing @seo directive: ${l}`,r,n.EVALUATION_ERROR)}},_("SEO",r))}function R(e,t,r,g){let i=e[t];if(i===void 0||i===null||i===!1)return;if(yt(i))return i;mo(r,`${t} must be an object, got ${Ze(i)}; its tags were left out`,g);return}function L(e,t,r){let g=Object.keys(e).filter((s)=>!j.has(s));if(g.length>0){let s=g.map((l)=>A[l]?`${l} (use ${A[l]})`:l).join(", ");mo(t,`@seo does not read ${s}; ${g.length===1?"it was":"they were"} ignored`,r)}let i="";if(e.title)i+=`<title>${c(e.title)}</title>
|
|
3
3
|
`,i+=`<meta name="title" content="${c(e.title)}">
|
|
4
4
|
`;if(e.description)i+=`<meta name="description" content="${c(e.description)}">
|
|
5
5
|
`;if(e.keywords){let s=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${c(s)}">
|
|
@@ -25,7 +25,7 @@ import{n,u,Jt,Yt,Zt,Ze,yt,z,po,Ur,Qe}from"./chunk-295bykzd.js";var O=/(?<![\w$@]
|
|
|
25
25
|
`}if(o.site)i+=`<meta name="twitter:site" content="${c(o.site)}">
|
|
26
26
|
`;if(o.creator)i+=`<meta name="twitter:creator" content="${c(o.creator)}">
|
|
27
27
|
`}if(e.structuredData!==void 0&&e.structuredData!==null){let s=b(e.structuredData);if(s)i+=`${E(s)}
|
|
28
|
-
`;else
|
|
28
|
+
`;else mo(t,`structuredData must be an object or an array of objects, got ${Ze(e.structuredData)}; it was left out`,r)}return i.trim()}function ki(e,t,r){if(r.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||t.__stx_seo_staged===!0||r.skipDefaultSeoTags===!0)return e;let g=t.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let a=e.includes("<title>")||e.includes("</title>"),o=q(e),s=M(o),l=G(o),p="";if(t.title)p=t.title;else if(t.meta&&t.meta.title)p=t.meta.title;else if(s)p=s;else if(r.seo?.defaultConfig?.title)p=r.seo.defaultConfig.title;else p=r.defaultTitle||"stx Project";let m="";if(t.description)m=t.description;else if(t.meta&&t.meta.description)m=t.meta.description;else if(l)m=l;else if(r.seo?.defaultConfig?.description)m=r.seo.defaultConfig.description;else m=r.defaultDescription||"A website built with stx templating engine";let d="";if(t.image)d=t.image;else if(t.meta&&t.meta.image)d=t.meta.image;else if(t.openGraph&&t.openGraph.image)d=t.openGraph.image;else if(r.seo?.defaultImage)d=r.seo.defaultImage;else if(r.defaultImage)d=r.defaultImage;let f=a?"":`
|
|
29
29
|
<meta name="title" content="${c(p)}">`,D=V(o)?"":`
|
|
30
30
|
<meta name="description" content="${c(m)}">`,y=`
|
|
31
31
|
<!-- stx SEO Tags -->${f}${D}
|
|
@@ -43,7 +43,7 @@ import{n,u,Jt,Yt,Zt,Ze,yt,z,po,Ur,Qe}from"./chunk-295bykzd.js";var O=/(?<![\w$@]
|
|
|
43
43
|
${y}
|
|
44
44
|
`),h;return h.replace(/<head[^>]*>/,`$&
|
|
45
45
|
${y}
|
|
46
|
-
`)}function q(e){let t=e.search(/<\/head\s*>/i);return t===-1?e:e.slice(0,t)}function v(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�*39;|'/g,"'").replace(/&/g,"&")}function M(e){let t=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return t?v(t[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((t)=>/\sname\s*=\s*["']description["']/i.test(t))}function V(e){return x(e).length>0}function G(e){for(let t of x(e)){let r=t.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(r?.[1]??r?.[2]??"").trim();if(g)return v(g)}return""}function c(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var
|
|
46
|
+
`)}function q(e){let t=e.search(/<\/head\s*>/i);return t===-1?e:e.slice(0,t)}function v(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�*39;|'/g,"'").replace(/&/g,"&")}function M(e){let t=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return t?v(t[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((t)=>/\sname\s*=\s*["']description["']/i.test(t))}function V(e){return x(e).length>0}function G(e){for(let t of x(e)){let r=t.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(r?.[1]??r?.[2]??"").trim();if(g)return v(g)}return""}function c(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var zs={name:"meta",rawParams:!0,handler:(e,t,r,g)=>{let i=qr(t,r??{});if(i.kind==="error")return H("Meta",`@meta(${t.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(r)r.__stx_runtime_head=Qe(r.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Hs={name:"structuredData",handler:(e,t,r,g)=>{if(e.trim()==="")return u("StructuredData","structuredData directive requires JSON-LD content",n.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return u("StructuredData","structuredData requires @type property",n.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let a=i instanceof Error?i.message:String(i);return u("StructuredData",a,n.EVALUATION_ERROR)}},hasEndTag:!0};function Sy(){return[zs,Hs]}function ky(e,t){let{baseUrl:r,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:a=!0}=t,o=r.replace(/\/$/,""),s=(m)=>m.startsWith("http")?m:`${o}${m.startsWith("/")?"":"/"}${m}`,l=e.map((m)=>{let d=s(m.loc),f=m.lastmod||(a?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
|
|
47
47
|
<loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
|
|
48
48
|
<xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(s(w.href))}"/>`;if(f)h+=`
|
|
49
49
|
<lastmod>${f}</lastmod>`;return h+=`
|
|
@@ -53,13 +53,13 @@ ${y}
|
|
|
53
53
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.some((m)=>m.alternates?.length)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>
|
|
54
54
|
${l.join(`
|
|
55
55
|
`)}
|
|
56
|
-
</urlset>`}function
|
|
56
|
+
</urlset>`}function _y(e,t){let r=t.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
57
57
|
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
58
58
|
${e.map((a)=>{let o=a.startsWith("http")?a:`${r}${a.startsWith("/")?"":"/"}${a}`;return` <sitemap>
|
|
59
59
|
<loc>${T(o)}</loc>
|
|
60
60
|
<lastmod>${g}</lastmod>
|
|
61
61
|
</sitemap>`}).join(`
|
|
62
62
|
`)}
|
|
63
|
-
</sitemapindex>`}async function
|
|
64
|
-
`).trim()}function
|
|
65
|
-
export{
|
|
63
|
+
</sitemapindex>`}async function Cy(e,t){let{extensions:r=[".stx",".html",".htm"],ignore:g=["_*",".*","node_modules","components","partials","layouts"]}=t,i=[],a=r.length===1?`*${r[0]}`:`*{${r.join(",")}}`,o=new Bun.Glob(`**/${a}`);for await(let s of o.scan(e)){if(g.some((f)=>{if(f.startsWith("*"))return s.includes(f.slice(1));return s.startsWith(f)||s.includes(`/${f}`)}))continue;let p=s.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!p.startsWith("/"))p=`/${p}`;if(p!=="/"&&p.endsWith("/"))p=p.slice(0,-1);let m=`${e}/${s}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}i.push({loc:p||"/",lastmod:d,priority:p==="/"?1:0.5})}return i.sort((s,l)=>s.loc.localeCompare(l.loc)),i}function Vs(e){let t=[];for(let r of e.rules){if(t.push(`User-agent: ${r.userAgent}`),r.allow)for(let g of r.allow)t.push(`Allow: ${g}`);if(r.disallow)for(let g of r.disallow)t.push(`Disallow: ${g}`);if(r.crawlDelay!==void 0)t.push(`Crawl-delay: ${r.crawlDelay}`);t.push("")}if(e.sitemap){let r=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let g of r)t.push(`Sitemap: ${g}`)}if(e.host)t.push(`Host: ${e.host}`);return t.join(`
|
|
64
|
+
`).trim()}function Ey(e){return Vs({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
65
|
+
export{vi,xi,Si,ki,zs,Hs,Sy,ky,_y,Cy,Vs,Ey};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Qt}from"./chunk-0ncafcs2.js";import{c,f}from"./chunk-hxws025y.js";function vo(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=Qt(e),i=`
|
|
3
3
|
<!-- stx PWA Meta Tags -->
|
|
4
4
|
<link rel="manifest" href="/manifest.json">
|
|
5
5
|
<meta name="theme-color" content="${a(r?.themeColor||"#000000")}">
|
|
@@ -43,11 +43,11 @@ if ('serviceWorker' in navigator) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
</script>
|
|
46
|
-
<!-- End stx PWA -->`,i}function
|
|
47
|
-
`+e.slice(o)}return e+
|
|
46
|
+
<!-- End stx PWA -->`,i}function ra(e,n){let r=n.pwa;if(!r?.enabled||r.autoInject===!1)return e;if(e.includes("<!-- stx PWA Meta Tags -->"))return e;if(!e.includes("</head>")){let o=c(e);if(o!==-1){let i=vo(n);return e.slice(0,o)+i+`
|
|
47
|
+
`+e.slice(o)}return e+vo(n)}let t=vo(n);return f(e,t)}function em(e){if(!e.pwa?.enabled)return"";return`<script>
|
|
48
48
|
if ('serviceWorker' in navigator) {
|
|
49
49
|
window.addEventListener('load', function() {
|
|
50
|
-
navigator.serviceWorker.register('/${
|
|
50
|
+
navigator.serviceWorker.register('/${Qt(e)}')
|
|
51
51
|
.then(function(registration) {
|
|
52
52
|
console.log('[PWA] Service Worker registered:', registration.scope);
|
|
53
53
|
})
|
|
@@ -56,5 +56,5 @@ if ('serviceWorker' in navigator) {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
</script>`}function
|
|
60
|
-
export{
|
|
59
|
+
</script>`}function tm(){return'<link rel="manifest" href="/manifest.json">'}function nm(e){return`<meta name="theme-color" content="${a(e)}">`}function a(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
60
|
+
export{vo,ra,em,tm,nm};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{nl,s,_e}from"./chunk-gz9pknbw.js";import{ft}from"./chunk-6c1vm6bs.js";import{l}from"./chunk-dzqfv801.js";import o from"fs";import u from"path";var mg=new Map,m=new Map;async function fy(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function gy(e){m.delete(e)}function my(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function hy(e){x=e}async function hg(e=!1){let t=x??await import("./chunk-v98n53nk.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function yg(){if(S===null){let{getRouterScript:e}=await import("./chunk-3yjyjq0m.js");S=e()}return S}var y={};async function yy(e,t=!1){let n=e==="runtime"?await hg(t):await yg(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function by(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let r=c.keys().next().value;p-=c.get(r).length*2,c.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(u.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function hi(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function wy(){m.clear(),_e(),nl(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function kr(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${Ds(e)}.html`),r=u.join(n,`${Ds(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==ft())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function _r(e,t,n,i){try{if(!i.cachePath)return;let r=u.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=u.join(r,`${Ds(e)}.html`),a=u.join(r,`${Ds(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:ft(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),mg.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function Ds(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
|
+
export{mg,fy,gy,my,hy,hg,yg,yy,by,hi,wy,kr,_r,Ds};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{T}from"./chunk-2a5g80mq.js";import{t,Fn,E}from"./chunk-3hsv6ejp.js";var M=new T(32,{maxBytes:2097152,sizeOf:(x)=>x.code.length*4}),N=/^[A-Za-z_$][\w$]*$/,O=new Set(["if","for","while","switch","with"]),_=["(","[","{"],D=[")","]","}"],Z=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function C(x){let u=t(x),m=[];for(let e of u.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let r=e.index??0;m.push({text:e[0],start:r,end:r+e[0].length})}return{code:u,tokens:m}}function z(x){let u=M.get(x);if(u)return u;let{code:m,tokens:e}=C(x),r=new Map,f=[];for(let o=0;o<e.length;o++){let n=e[o].text;if(["(","[","{"].includes(n))f.push(o);else if([")","]","}"].includes(n)){let i=f.at(-1);if(i!==void 0&&["()","[]","{}"].includes(e[i].text+n))f.pop(),r.set(i,o),r.set(o,i)}}function S(o,n){let i=[],s=o;for(let c=o;c<n;c++){if(["(","[","{"].includes(e[c].text)&&(r.get(c)??n)<n){c=r.get(c);continue}if(e[c].text===",")i.push([s,c]),s=c+1}return i.push([s,n]),i}let y=[];function k(o,n,i,s=!1,c){if(e[o]?.text==="...")o++;if(o>=n)return;let d=e[o].text;if(N.test(d)){if(i.add(d),i===I)y.push({name:d,token:o,functionScoped:s,declarationToken:c});return}if(d!=="{"&&d!=="[")return;let A=r.get(o);if(A===void 0||A>=n)return;for(let[w,h]of S(o+1,A)){let g=w;if(d==="{")for(let v=w;v<h;v++){if(e[v].text===":"){g=v+1;break}if(e[v].text==="=")break;if(["(","[","{"].includes(e[v].text)&&r.has(v))v=r.get(v)}k(g,h,i,s,c)}}function p(o,n){let i=new Set;for(let[s,c]of S(o,n))k(s,c,i);return i}function L(o){let n=o;for(;n<e.length;n++){let i=e[n].text;if(["(","[","{"].includes(i)&&r.has(n)){n=r.get(n);continue}if([",",";",")","]","}"].includes(i))break}return e[Math.max(o,n-1)]?.end??m.length}let I=new Set,B=[];for(let o=0;o<e.length;o++)if(e[o].text==="=>"){let n=o-1,i=n,s;if(e[n]?.text===")"&&r.has(n))i=r.get(n),s=p(i+1,n);else if(e[n]&&N.test(e[n].text))s=new Set([e[n].text]);else continue;let c=o+1,d=e[c]?.text==="{"&&r.has(c)?e[r.get(c)].end:L(c);B.push({start:e[i].start,end:d,bodyStart:e[c]?.start??d,functionBody:!0,names:s})}else if(e[o].text==="("&&r.has(o)){let n=e[o-1]?.text;if(!n||O.has(n)||!N.test(n)&&n!=="*"&&n!=="]")continue;let i=r.get(o),s=i+1;if(e[s]?.text===":"){s++;while(s<e.length&&!["{","=>",";","="].includes(e[s].text))s++}if(e[s]?.text!=="{"||!r.has(s))continue;B.push({start:e[o].start,end:e[r.get(s)].end,bodyStart:e[s].start,functionBody:n!=="catch",names:p(o+1,i)})}function a(o){let n=o;for(;n<e.length;n++){let i=e[n].text;if(_.includes(i)&&r.has(n)){n=r.get(n);continue}if(i===";"||D.includes(i))break;let s=e[n-1];if(n>o&&Z.has(i)&&s.text!==".")break;if(n>o&&/[\n\r]/.test(m.slice(s.end,e[n].start))&&(/^[\w$]+$/.test(s.text)||D.includes(s.text)||['"',"'","`"].includes(s.text))&&N.test(i)&&!["in","of","instanceof"].includes(i))break}return n}let l=[];for(let o=0;o<e.length;o++){if(e[o].text!=="for")continue;let n=e[o+1]?.text==="await"?o+2:o+1;if(e[n]?.text!=="("||!r.has(n))continue;let i=r.get(n),s=i+1,c=e[s]?.text==="{"&&r.has(s)?r.get(s):a(s),d=e[c]?.text===";"||e[c]?.text==="}"?e[c].end:e[Math.max(s,c-1)]?.end??m.length;l.push({headStart:n,headEnd:i,start:e[n].start,end:d})}for(let o=0;o<e.length;o++){let n=e[o].text,i=e[o-1]?.text;if(i==="."||e[o+1]?.text===":")continue;if(i==="as"||i==="<")continue;if(n==="const"||n==="let"||n==="var"){let s=a(o+1),c=o+1,d=!1,A=!1,w=0;for(let h=o+1;h<=s;h++){let g=e[h]?.text;if(h<s&&_.includes(g)&&r.has(h)&&r.get(h)<s){h=r.get(h);continue}if(h<s&&g===":"&&!A)d=!0;else if(h<s&&g==="="&&w===0)d=!1,A=!0;else if(h<s&&d&&g==="<")w++;else if(h<s&&d&&g===">"&&w>0)w--;else if(h===s||g===","&&w===0)k(c,h,I,n==="var",o),c=h+1,d=!1,A=!1}}else if(n==="function"||n==="class"){let s=o+1;if(e[s]?.text==="*")s++;if(e[s]&&N.test(e[s].text)&&e[s].text!=="extends")I.add(e[s].text),y.push({name:e[s].text,token:s,declarationToken:o})}else if(n==="import"){let s=o+1;if(e[s]?.text==="*"&&e[s+1]?.text==="as")s+=2;let c=e[s]?.text;if(c&&N.test(c)&&c!=="type"&&e[s+1]?.text!=="("&&e[s+1]?.text!==".")I.add(c),y.push({name:c,token:s,file:!0});let d=e[s]?.text==="{"?s:e[s+1]?.text===","&&e[s+2]?.text==="{"?s+2:-1;if(d!==-1&&r.has(d)){let A=r.get(d);for(let[w,h]of S(d+1,A)){let g=h-1;while(g>=w&&!N.test(e[g].text))g--;if(g>=w&&e[g].text!=="type")y.push({name:e[g].text,token:g,file:!0})}}}}let b={code:m,scopes:B,loops:l,declarations:I,sites:y,tokens:e,pairs:r};return M.set(x,b),b}function Gr(x){let u=z(x);return{code:u.code,shadows:(m,e)=>u.scopes.some((r)=>e>=r.start&&e<r.end&&r.names.has(m))}}function bo(x){return new Set(z(x).declarations)}function Xr(x){let u=z(x),m=Fn(x),{depths:e}=E(m),r=[];for(let f of u.sites){if(f.file||f.declarationToken===void 0)continue;let S=u.tokens[f.declarationToken];if(e[S.start]!==0)continue;let y=m.slice(0,S.start),k=[...y.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],p=k.pop();if(p?.[0]==="declare")continue;if(S.text==="function"||S.text==="class"){while(p&&["async","export","default","abstract"].includes(p[0]))p=k.pop();if(p&&![";","}"].includes(p[0])){let L=y.slice(p.index+p[0].length);if(!/[\r\n]/.test(L)||!/^(?:[\w$]+|[)\]])$/.test(p[0])||["return","throw","yield","await","new"].includes(p[0]))continue}}r.push({name:f.name,start:S.start})}return r}function Dl(x){return[...new Set(Xr(x).map((u)=>u.name))].sort()}function De(x,u){let{scopes:m,loops:e,sites:r,tokens:f,pairs:S}=z(x),y=Array.from({length:f.length},()=>-1),k=[];for(let a=0;a<f.length;a++){y[a]=k.length?k[k.length-1]:-1;let l=f[a].text;if(l==="{"&&S.has(a))k.push(a);else if(l==="}"&&k.length&&S.get(a)===k[k.length-1])k.pop()}let p=new Set,L=new Map;for(let a of r){if(!u.has(a.name))continue;p.add(a.token);let l=a.file?-1:y[a.token],b=l===-1?[0,Number.POSITIVE_INFINITY]:[f[l].start,f[S.get(l)].end];if(a.functionScoped){let n=f[a.token].start,i=m.filter((s)=>s.functionBody&&n>=s.bodyStart&&n<s.end).sort((s,c)=>s.end-s.bodyStart-(c.end-c.bodyStart))[0];b=i?[i.bodyStart,i.end]:[0,Number.POSITIVE_INFINITY]}else if(!a.file){let n=e.filter((i)=>a.token>i.headStart&&a.token<i.headEnd).sort((i,s)=>i.headEnd-i.headStart-(s.headEnd-s.headStart))[0];if(n)b=[n.start,n.end]}let o=L.get(a.name);if(o)o.push(b);else L.set(a.name,[b])}let I=new Set;for(let a=0;a<f.length;a++){if(f[a].text!=="import"||f[a-1]?.text===".")continue;let l=a+1;if(f[l]?.text==="type")l++;if(f[l]&&N.test(f[l].text)&&f[l+1]?.text===",")l+=2;if(f[l]?.text==="{"&&S.has(l))for(let b=l+1;b<S.get(l);b++)I.add(b)}let B=new Set;for(let a=0;a<f.length;a++){let l=f[a].text;if(!u.has(l)||B.has(l)||p.has(a)||I.has(a))continue;let b=f[a-1]?.text;if(b==="#"||b==="."&&f[a-2]?.text!=="..")continue;if(f[a+1]?.text===":"&&(b==="{"||b===","))continue;let o=f[a].start;if(L.get(l)?.some(([n,i])=>o>=n&&o<i))continue;if(m.some((n)=>o>=n.start&&o<n.end&&n.names.has(l)))continue;B.add(l)}return B}function Ll(x){let u=z(Fn(x));return u.tokens.some((m,e)=>{if(m.text!=="await")return!1;if(u.tokens[e-1]?.text==="."||u.tokens[e+1]?.text===":")return!1;let r=e+1;if(u.tokens[r]?.text==="("&&u.tokens[(u.pairs.get(r)??-2)+1]?.text==="{")return!1;return!u.scopes.some((f)=>f.functionBody&&f.start<=m.start&&m.start<f.end)})}
|
|
3
|
+
export{Gr,bo,Xr,Dl,De,Ll};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Om}from"./chunk-m95sygv4.js";import"./chunk-kx09v9ya.js";import"./chunk-6pz5gq6v.js";import"./chunk-7212fwzz.js";import"./chunk-s0mf56y1.js";import"./chunk-mt8edb75.js";import"./chunk-vc432a0w.js";import"./chunk-48rwqchc.js";import"./chunk-05x1rd86.js";import"./chunk-hgf7bc50.js";import"./chunk-b0e7dgv8.js";import"./chunk-dymck524.js";import"./chunk-5kqezrjt.js";import"./chunk-4kmg6g5n.js";import"./chunk-bqtj62ys.js";import"./chunk-pctf14yw.js";import"./chunk-9d91h636.js";import"./chunk-eqffvse2.js";import"./chunk-p8shtje2.js";import"./chunk-58qzyyyv.js";import"./chunk-q0y8gv18.js";import"./chunk-rb2zbdqd.js";import"./chunk-95sd8h5g.js";import"./chunk-eceeqy74.js";import"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{Om as buildForProduction};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ao,Ea,is,Po,Io,Vn,sn,Ta,as,cs,Oo,No,Em,Tm,_t}from"./chunk-51720m79.js";export{_t as DeployError,Ea as calculateSha1,is as collectDeployFiles,cs as createDefaultNetlifyConfig,Po as createFileManifest,Ao as createNetlifyClient,Em as deploy,as as detectProjectConfig,Io as filterRequiredFiles,Vn as formatSize,Ta as generateNetlifyToml,sn as getTotalSize,No as hasNetlifyConfig,Tm as initNetlify,Oo as writeNetlifyConfig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{sg,Ac,ry,Pc,og,ig,vn,br,sy,ag,cg,oy,x}from"./chunk-vc432a0w.js";import"./chunk-9d91h636.js";import"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{vn as buildCss,ag as extractClassNames,ig as fingerprintConfig,cg as generateCss,sy as getCachedCSS,sg as getCssServeAsset,x as injectCss,Ac as loadCssEngine,Pc as loadCssEngineConfig,br as rebuildCss,ry as resetCssCache,og as resolveUserCssConfig,oy as withLinkedModuleBundles};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Rs,dg,ai,pg}from"./chunk-dymck524.js";import"./chunk-5kqezrjt.js";import"./chunk-4kmg6g5n.js";import"./chunk-bqtj62ys.js";import"./chunk-pctf14yw.js";import"./chunk-p8shtje2.js";import"./chunk-58qzyyyv.js";import"./chunk-q0y8gv18.js";import"./chunk-rb2zbdqd.js";import"./chunk-95sd8h5g.js";import"./chunk-eceeqy74.js";import{Vt}from"./chunk-gz9pknbw.js";import"./chunk-s93yh7ed.js";import"./chunk-eyx92t9n.js";import"./chunk-3dqfjpz4.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-2a5g80mq.js";import"./chunk-mgh5rst1.js";export{pg as declareBareLoopHead,Vt as parseLoopBinding,dg as processLoops,ai as processLoopsAsync,Rs as reportDeferredLoopWarnings};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xt,St,kt}from"./chunk-zek9t5za.js";import"./chunk-
|
|
2
|
+
import{xt,St,kt}from"./chunk-zek9t5za.js";import"./chunk-mgh5rst1.js";import"./chunk-vk2jy6mn.js";import"./chunk-2a5g80mq.js";import"./chunk-9n5h4sqc.js";import{h}from"./chunk-gz9pknbw.js";import"./chunk-3dqfjpz4.js";import"./chunk-eyx92t9n.js";import"./chunk-s93yh7ed.js";import{en,ko,tn,ha,vt,ya,_o,nn,wa,rn}from"./chunk-zwwhpxp7.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()=>{ya("Config file changed, restarting...");try{await e.onChange()}catch(p){vt(`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),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,f=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:f,variantViews:n,avgTimeSpent:u}}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:dt(),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 dt(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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-8354mzpd.js"),p={},u=y(n);if(u)try{await h(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=y(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,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 gt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=y(e);if(!r)return null;let s={};if(await h(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 gt(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 ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-8354mzpd.js"),c={...r},n=y(e);if(n)try{await h(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:y(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 y(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 nn(t);St(t,r);let s=rn(t.config,r);kt(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 g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return yt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return ht(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,f=wa(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await nn(t);St(t,m);let g=rn(t.config,m);if(kt(t,g),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=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{f(),p.stop()}}}async function yt(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],u=d[1]||"default",f,i=n.searchParams.get("props");if(i)try{f=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,f);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],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((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function ht(t,e,r){let s=bt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function bt(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 wt 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 wt.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={}){
|
|
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 wt 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 wt.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={}){en();let e=await xt({mode:"dev"});if(!e.config.enabled){vt("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}),tn(e.storyFiles.length),ko(s.url),_o()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await xt({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":_o();break;case"o":try{let{exec:p}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${u} ${s.url}`)}catch{ha("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),en(),tn(e.storyFiles.length),ko(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
|