@stacksjs/stx 0.2.898 → 0.2.899
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-qe0t0m38.js → chunk-0b57fgpn.js} +4 -4
- package/dist/chunk-0f2d61b3.js +2 -0
- package/dist/{chunk-pjj54ddk.js → chunk-0gc1hez6.js} +3 -3
- package/dist/chunk-0ht6exrv.js +2 -0
- package/dist/{chunk-t3zmfh8w.js → chunk-150cz8qq.js} +7 -7
- package/dist/chunk-1pbghytr.js +2 -0
- package/dist/chunk-1tb18a92.js +2 -0
- package/dist/{chunk-dvjv4c3a.js → chunk-2sz1kh9m.js} +1 -1
- package/dist/chunk-2vqamyay.js +2 -0
- package/dist/chunk-36mz0nwv.js +2 -0
- package/dist/{chunk-q4dcchrt.js → chunk-3k4rteax.js} +13 -13
- package/dist/chunk-3m37fzvh.js +2 -0
- package/dist/chunk-3my2eef2.js +2 -0
- package/dist/{chunk-qcbj1m21.js → chunk-40fpt0r6.js} +10 -10
- package/dist/{chunk-khm56bfm.js → chunk-46khhke2.js} +1 -1
- package/dist/{chunk-4wh71ddp.js → chunk-472w7t7p.js} +2 -2
- package/dist/{chunk-bjmkyead.js → chunk-4e28p8vf.js} +6 -6
- package/dist/{chunk-bgfs3mbg.js → chunk-4hk1mjtv.js} +5 -5
- package/dist/chunk-4jtewn1v.js +2 -0
- package/dist/chunk-4s6w89m2.js +2 -0
- package/dist/{chunk-dd074gp5.js → chunk-4wd5sn16.js} +7 -7
- package/dist/{chunk-1bft48gk.js → chunk-50wjk5ap.js} +2 -2
- package/dist/{chunk-ch9028z3.js → chunk-54x7h3sb.js} +1 -1
- package/dist/chunk-5astk182.js +2 -0
- package/dist/{chunk-3b3mkgpj.js → chunk-5g5khx0m.js} +2 -2
- package/dist/{chunk-zf68afyh.js → chunk-5gnt3qtn.js} +3 -3
- package/dist/{chunk-80ky40mm.js → chunk-5jrpzepc.js} +2 -2
- package/dist/{chunk-q0y8gv18.js → chunk-5mrt1enm.js} +2 -2
- package/dist/{chunk-wg6fmren.js → chunk-5tm1pvt3.js} +2 -2
- package/dist/chunk-5tvse0vw.js +2 -0
- package/dist/{chunk-ytjn0gq2.js → chunk-5yvgzh6n.js} +2 -2
- package/dist/{chunk-n6q1d66k.js → chunk-65g78sge.js} +1 -1
- package/dist/chunk-65rx54n6.js +2 -0
- package/dist/{chunk-x5bn2svk.js → chunk-67pq803s.js} +2 -2
- package/dist/{chunk-neg6ckjg.js → chunk-68r2zs20.js} +4 -4
- package/dist/{chunk-2s0q8mjx.js → chunk-6hjcqaqr.js} +2 -2
- package/dist/chunk-70ez3njv.js +2 -0
- package/dist/chunk-726w7fm2.js +2 -0
- package/dist/{chunk-xy8smv5e.js → chunk-73ebyhqq.js} +2 -2
- package/dist/chunk-73nazfe5.js +2 -0
- package/dist/{chunk-vk2jy6mn.js → chunk-7b3dqeyr.js} +2 -2
- package/dist/{chunk-whcrca58.js → chunk-7nn5s0c3.js} +30 -30
- package/dist/{chunk-062qfv99.js → chunk-7pfhr4nk.js} +2 -2
- package/dist/chunk-7r294vc9.js +2 -0
- package/dist/chunk-7rn7w53f.js +2 -0
- package/dist/{chunk-5v4e2a02.js → chunk-7z1hqp86.js} +4 -4
- package/dist/chunk-81qvg3yd.js +2 -0
- package/dist/{chunk-e16ef18k.js → chunk-83hs9905.js} +2 -2
- package/dist/chunk-8a9gmbxa.js +2 -0
- package/dist/chunk-8jvwapq3.js +2 -0
- package/dist/{chunk-g8p4sjy4.js → chunk-8rgy17fj.js} +8 -8
- package/dist/{chunk-ns2d6pb9.js → chunk-8v2hsn4d.js} +3 -3
- package/dist/{chunk-y1d3j2j7.js → chunk-8xb09hnn.js} +4 -4
- package/dist/{chunk-xmg6bmh6.js → chunk-945zygwa.js} +13 -13
- package/dist/{chunk-pvm48tse.js → chunk-9ejk9mwk.js} +2 -2
- package/dist/{chunk-bw2m1e7g.js → chunk-9hwg13ec.js} +5 -5
- package/dist/{chunk-ezpk14gs.js → chunk-9jpsxqaf.js} +1 -1
- package/dist/{chunk-0vrt55pp.js → chunk-9m45t60c.js} +80 -80
- package/dist/{chunk-jm9rbxj4.js → chunk-9n5san33.js} +14 -14
- package/dist/chunk-9vafweyd.js +3 -0
- package/dist/{chunk-zwqkbk2m.js → chunk-9w7whtbx.js} +2 -2
- package/dist/{chunk-1ph2yhfn.js → chunk-arfpzf17.js} +2 -2
- package/dist/chunk-avqxkbrd.js +2 -0
- package/dist/{chunk-htx5yezj.js → chunk-ayady5ws.js} +2 -2
- package/dist/{chunk-051r7ebx.js → chunk-b6ctdvdf.js} +6 -6
- package/dist/{chunk-taeqm3nc.js → chunk-becs8132.js} +5 -5
- package/dist/chunk-bmwcgmev.js +2 -0
- package/dist/{chunk-67j2m620.js → chunk-bzd387yx.js} +4 -4
- package/dist/{chunk-mhrnjaka.js → chunk-c0x9wyj7.js} +4 -4
- package/dist/chunk-cgqpn3e2.js +2 -0
- package/dist/chunk-cp82351f.js +2 -0
- package/dist/chunk-cvxg2rc1.js +2 -0
- package/dist/{chunk-v8ewgs1y.js → chunk-d1bwb2kz.js} +3 -3
- package/dist/{chunk-05x1rd86.js → chunk-de61k0ab.js} +2 -2
- package/dist/chunk-dj8fyaea.js +2 -0
- package/dist/chunk-dmc91qke.js +2 -0
- package/dist/{chunk-mr34w48c.js → chunk-e0bwzxfd.js} +6 -6
- package/dist/{chunk-w2qct5kq.js → chunk-e4xd1ca7.js} +1 -1
- package/dist/{chunk-3jxmnnef.js → chunk-e5q1ammf.js} +3 -3
- package/dist/{chunk-xvncq3m5.js → chunk-eb5cma4b.js} +2 -2
- package/dist/{chunk-3bsz7zj3.js → chunk-eb5v9npc.js} +2 -2
- package/dist/{chunk-aj5tsksz.js → chunk-edpsk4bg.js} +5 -5
- package/dist/{chunk-6kn2vwtn.js → chunk-eka2e4cm.js} +4 -4
- package/dist/{chunk-pnmafbv5.js → chunk-ern5hyvr.js} +1 -1
- package/dist/{chunk-41z7f41b.js → chunk-esm0pnpz.js} +2 -2
- package/dist/chunk-fe1wmmr5.js +2 -0
- package/dist/{chunk-r5ecgcx2.js → chunk-ffytbb4x.js} +5 -5
- package/dist/{chunk-vf4ejngv.js → chunk-fksmr50h.js} +6 -6
- package/dist/{chunk-nw2zjwcg.js → chunk-fsxk5fsh.js} +8 -8
- package/dist/{chunk-htvft92j.js → chunk-ft9h5qbs.js} +4 -4
- package/dist/chunk-fznzn35q.js +2 -0
- package/dist/{chunk-s94gqce0.js → chunk-g065d7p7.js} +2 -2
- package/dist/{chunk-rf0smj4c.js → chunk-g32hc78c.js} +2 -2
- package/dist/{chunk-nq60tjkz.js → chunk-gnf1e5q7.js} +2 -2
- package/dist/{chunk-bj8pv8m9.js → chunk-gq3gttt5.js} +21 -21
- package/dist/chunk-h2gnz7ja.js +2 -0
- package/dist/chunk-hc8ks7y3.js +2 -0
- package/dist/{chunk-cphc60zw.js → chunk-hdfhaddy.js} +2 -2
- package/dist/{chunk-t0ttxayz.js → chunk-hnjeqxqy.js} +2 -2
- package/dist/chunk-hpqvq1r9.js +2 -0
- package/dist/chunk-hs2a040z.js +2 -0
- package/dist/{chunk-xdrp6d7e.js → chunk-javb4e3b.js} +5 -5
- package/dist/chunk-jq49238b.js +2 -0
- package/dist/chunk-jr3fmkq7.js +2 -0
- package/dist/chunk-k2fw6paw.js +2 -0
- package/dist/chunk-k352spys.js +2 -0
- package/dist/{chunk-1knk403z.js → chunk-k3566kgd.js} +2 -2
- package/dist/{chunk-cmg9x1ka.js → chunk-k3ytyhkr.js} +3 -3
- package/dist/chunk-k79dvx67.js +2 -0
- package/dist/chunk-km1k3c4e.js +2 -0
- package/dist/chunk-kvjbpbmw.js +2 -0
- package/dist/chunk-mhv84p0x.js +2 -0
- package/dist/{chunk-ykax1thr.js → chunk-mjqsz20a.js} +2 -2
- package/dist/chunk-mmtyp5z4.js +2 -0
- package/dist/{chunk-8hwfdwgn.js → chunk-mry67rsk.js} +6 -6
- package/dist/{chunk-ksmn19qw.js → chunk-n3fgrsva.js} +2 -2
- package/dist/{chunk-jnwj14eq.js → chunk-n8xjqsze.js} +3 -3
- package/dist/{chunk-p3hbsrk9.js → chunk-nc5d3a5r.js} +5 -5
- package/dist/chunk-p4hm5srd.js +2 -0
- package/dist/{chunk-0jkj8thz.js → chunk-p89rpak1.js} +1 -1
- package/dist/{chunk-hxws025y.js → chunk-p92272k0.js} +2 -2
- package/dist/{chunk-bh2j50cy.js → chunk-pd31ge72.js} +6 -6
- package/dist/chunk-pjpy86c3.js +3 -0
- package/dist/chunk-psyqrxg0.js +2 -0
- package/dist/chunk-q4yq72wh.js +2 -0
- package/dist/{chunk-5xq6eky7.js → chunk-q6p96qq7.js} +7 -7
- package/dist/{chunk-115bb91s.js → chunk-qs0zk04y.js} +2 -2
- package/dist/{chunk-ta07gj66.js → chunk-qt2mr3f0.js} +31 -16
- package/dist/{chunk-a0aqs5a8.js → chunk-qykbjg3z.js} +2 -2
- package/dist/chunk-qzx6h6af.js +2 -0
- package/dist/{chunk-g5nfqzfh.js → chunk-r0az4z6d.js} +2 -2
- package/dist/{chunk-b9npgke0.js → chunk-r9n86na1.js} +39 -39
- package/dist/{chunk-zy97etqx.js → chunk-rapr0m13.js} +3 -3
- package/dist/{chunk-j1cgj6z2.js → chunk-rrpfn9rr.js} +1 -1
- package/dist/chunk-ryp47rwp.js +2 -0
- package/dist/{chunk-3qk8vf9m.js → chunk-t14bn66j.js} +3 -3
- package/dist/chunk-t9j000tb.js +2 -0
- package/dist/{chunk-7h52e87j.js → chunk-tga3nrn6.js} +5 -5
- package/dist/chunk-tgwwa872.js +2 -0
- package/dist/chunk-v0r6zb87.js +2 -0
- package/dist/{chunk-n0jfwsz1.js → chunk-v5v6w6rn.js} +2 -2
- package/dist/{chunk-9rjgq8k4.js → chunk-vbmvft7g.js} +1 -1
- package/dist/{chunk-kk2p2tgv.js → chunk-vfctk20v.js} +3 -3
- package/dist/{chunk-66qfr6b0.js → chunk-vgvxs1ag.js} +2 -2
- package/dist/{chunk-rb2zbdqd.js → chunk-vw7crz0z.js} +4 -4
- package/dist/chunk-vxtna1b1.js +2 -0
- package/dist/chunk-x43x2c6v.js +2 -0
- package/dist/chunk-xqx8t9w5.js +2 -0
- package/dist/{chunk-sh7a0g09.js → chunk-xr1s56k5.js} +3 -3
- package/dist/chunk-y10eaxgc.js +2 -0
- package/dist/chunk-ytk4f2j9.js +2 -0
- package/dist/chunk-z33r3pzy.js +2 -0
- package/dist/chunk-zcys6b06.js +2 -0
- package/dist/chunk-zkr42285.js +2 -0
- package/dist/chunk-zpwh9bpc.js +2 -0
- package/dist/chunk-zrs22j09.js +2 -0
- package/dist/chunk-zw6tgr0s.js +2 -0
- package/dist/cli.js +19 -19
- package/dist/client/signals-scope-disposal-runtime.js +18 -3
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dynamic-components.js +47 -25
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +4 -4
- package/package.json +5 -5
- package/dist/chunk-0hgetg3j.js +0 -2
- package/dist/chunk-0k437z3q.js +0 -2
- package/dist/chunk-0yh33smh.js +0 -2
- package/dist/chunk-0yycygry.js +0 -2
- package/dist/chunk-1a7a8cjs.js +0 -2
- package/dist/chunk-1p4q6t48.js +0 -2
- package/dist/chunk-1z6pqvmf.js +0 -2
- package/dist/chunk-2nqmw4dv.js +0 -2
- package/dist/chunk-2shw0j2q.js +0 -2
- package/dist/chunk-35j7gaj5.js +0 -2
- package/dist/chunk-3hd73qqj.js +0 -2
- package/dist/chunk-4akw3bym.js +0 -2
- package/dist/chunk-4d85str1.js +0 -2
- package/dist/chunk-53kcqdjj.js +0 -2
- package/dist/chunk-5eq2e6p3.js +0 -2
- package/dist/chunk-690518hw.js +0 -2
- package/dist/chunk-732gb689.js +0 -2
- package/dist/chunk-80xzjxah.js +0 -2
- package/dist/chunk-8cs8jckk.js +0 -2
- package/dist/chunk-9afkttvz.js +0 -2
- package/dist/chunk-a0jhmkpd.js +0 -2
- package/dist/chunk-a1s0tfcd.js +0 -3
- package/dist/chunk-a2bstyq1.js +0 -2
- package/dist/chunk-ah8az9vv.js +0 -2
- package/dist/chunk-arr79m90.js +0 -2
- package/dist/chunk-cgxmgjk4.js +0 -2
- package/dist/chunk-cp5x6kx1.js +0 -2
- package/dist/chunk-e28czxw3.js +0 -2
- package/dist/chunk-e8szp5wa.js +0 -2
- package/dist/chunk-essd43ad.js +0 -2
- package/dist/chunk-f60k8j9m.js +0 -2
- package/dist/chunk-fsehzmg8.js +0 -2
- package/dist/chunk-fsk3rk2x.js +0 -2
- package/dist/chunk-g0p2n9tm.js +0 -2
- package/dist/chunk-g5axctr0.js +0 -2
- package/dist/chunk-ggnhr4r3.js +0 -2
- package/dist/chunk-hk241gt2.js +0 -2
- package/dist/chunk-hmpmvf5c.js +0 -2
- package/dist/chunk-j1ncsbk2.js +0 -2
- package/dist/chunk-j9kejcrx.js +0 -2
- package/dist/chunk-jhbz5w30.js +0 -2
- package/dist/chunk-jvc2qb1n.js +0 -2
- package/dist/chunk-jytqf6p6.js +0 -2
- package/dist/chunk-k4x680e3.js +0 -2
- package/dist/chunk-kfdmm240.js +0 -2
- package/dist/chunk-mx5twaps.js +0 -2
- package/dist/chunk-nd2bhjdw.js +0 -2
- package/dist/chunk-qfxy34d4.js +0 -2
- package/dist/chunk-qwt94yh2.js +0 -2
- package/dist/chunk-rarsjcs4.js +0 -2
- package/dist/chunk-rryzw9x7.js +0 -2
- package/dist/chunk-ryj1srqn.js +0 -2
- package/dist/chunk-s5j4fpdr.js +0 -2
- package/dist/chunk-snkbn5y8.js +0 -2
- package/dist/chunk-tbh7r1wh.js +0 -2
- package/dist/chunk-tsz03zc9.js +0 -2
- package/dist/chunk-v3jyb8k6.js +0 -2
- package/dist/chunk-wbp6jgcr.js +0 -2
- package/dist/chunk-x6565mhk.js +0 -2
- package/dist/chunk-x8yne6s5.js +0 -2
- package/dist/chunk-xwgdcc7w.js +0 -2
- package/dist/chunk-z4tdnfxd.js +0 -2
- package/dist/chunk-zrbyvyn2.js +0 -2
- package/dist/chunk-zxjdfgdx.js +0 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B
|
|
2
|
+
import{B,Rn,Kt,Gt,y,s,Ce,g}from"./chunk-9m45t60c.js";import{Pt,He,Ac,_s,ni,ri,i}from"./chunk-r9n86na1.js";import{we}from"./chunk-0jdz31q1.js";import{ce,Vr,Me,K,Ln}from"./chunk-945zygwa.js";import{Dt,$r,Ws,qs,Ks,Lt,jt,Bt,Ft,zt,Ht,pt}from"./chunk-0b57fgpn.js";import{Bs,a,j}from"./chunk-40fpt0r6.js";import{Tt,cn,je,U,Oa,Lo,us,rt,Na,st,Be}from"./chunk-4wd5sn16.js";import{Cr,Er}from"./chunk-g065d7p7.js";import{e,Sn,vr,S}from"./chunk-fsxk5fsh.js";import{ct}from"./chunk-q6p96qq7.js";import{ze}from"./chunk-qs0zk04y.js";import{Un}from"./chunk-6hjcqaqr.js";import{re,Re,Ae}from"./chunk-e0bwzxfd.js";import{l}from"./chunk-pjpy86c3.js";import{ne}from"./chunk-qykbjg3z.js";import{c,f}from"./chunk-p92272k0.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=An(t,o),p=Dn(t,o);return{file:n,metrics:o,issues:d,suggestions:r,performance:p}}catch(t){throw Error(`Failed to analyze template ${n}: ${t instanceof Error?t.message:String(t)}`)}}function En(n){let t=n.split(`
|
|
3
3
|
`),o=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=(o?o[1]:"").split(`
|
|
4
4
|
`).length,p={conditionals:(n.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(n.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(n.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};p.total=p.conditionals+p.loops+p.includes+p.custom;let u=(n.match(/\{\{[\s\S]*?\}\}/g)||[]).length,m=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length,x=(n.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+m+x,b=(n.match(/<[A-Z][^>]*>/g)||[]).length,C=(n.match(/@(?:layout|extends)\(/g)||[]).length,R=0,O=0;for(let A of t)if(/@(?:if|unless|foreach|for|while|section)\b/.test(A)&&!/@end/.test(A)&&!/@else/.test(A))O++,R=Math.max(R,O);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(A))O--;let v=R>=4?3:0,w=Math.min(10,Math.ceil(p.total*0.5+h*0.1+b*0.3+(r>10?r*0.05:0)+v));return{lines:t.length,characters:n.length,directives:p,expressions:h,components:b,layouts:C,scriptLines:r,complexity:w}}function On(n,t){let o=[],d=Ut(n,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let r=Ut(n,"foreach","endforeach");if(r>0)o.push({type:"error",category:"syntax",message:`Found ${r} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let p=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=n.match(/<img[^>]*>/g);if(m){let b=m.filter((C)=>!C.includes("alt="));if(b.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${b.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let x=n.split(`
|
|
5
|
-
`).filter((b)=>b.length>120);if(x.length>0)o.push({type:"info",category:"maintainability",message:`Found ${x.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(n.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)o.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function An(n,t){let o=[];if(t.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(t.complexity>5&&t.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(t.lines>100&&t.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(t.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(t.directives.total===0&&t.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(t.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function
|
|
5
|
+
`).filter((b)=>b.length>120);if(x.length>0)o.push({type:"info",category:"maintainability",message:`Found ${x.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(n.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)o.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function An(n,t){let o=[];if(t.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(t.complexity>5&&t.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(t.lines>100&&t.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(t.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(t.directives.total===0&&t.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(t.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Dn(n,t){let o=1;if(o+=t.directives.conditionals*0.1,o+=t.directives.loops*0.5,o+=t.directives.includes*2,o+=t.expressions*0.05,o+=t.components*1,t.scriptLines>10)o+=t.scriptLines*0.1;let d;if(t.expressions===0&&t.directives.total===0)d="high";else if(t.expressions<5&&t.directives.total<3)d="medium";else d="low";let r=[];if(o>10)r.push("Consider optimizing template complexity");if(d==="low"&&t.directives.total>5)r.push("Reduce dynamic content for better caching");if(t.components===0&&t.lines>40)r.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:t.complexity,cacheability:d,recommendations:r}}function Ut(n,t,o){let d=n.replace(/<!--[\s\S]*?-->/g,""),r=(d.match(new RegExp(`@${t}\\b`,"g"))||[]).length,p=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(r-p)}async function Sa(n=["**/*.stx"],t){let o=[],d=[];for(let p of n){let u=await Array.fromAsync(new Bun.Glob(p).scan({cwd:t||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((m)=>m.endsWith(".stx")))}for(let p of d)try{let u=await Pn(p);o.push(u)}catch(u){console.warn(`Failed to analyze ${p}:`,u)}let r=Mn(o);return{results:o,summary:r}}function Mn(n){let t=n.length,o=n.reduce((h,b)=>h+b.metrics.lines,0),d=t>0?n.reduce((h,b)=>h+b.metrics.complexity,0)/t:0,r=n.reduce((h,b)=>h+b.issues.length,0),p={};n.forEach((h)=>{h.issues.forEach((b)=>{p[b.category]=(p[b.category]||0)+1})});let u=t>0?n.reduce((h,b)=>h+b.performance.estimatedRenderTime,0)/t:0,m=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),x=[];if(d>6)x.push("Project has high average complexity. Consider refactoring complex templates.");if(r>t*2)x.push("High number of issues detected. Run detailed analysis on individual files.");if(p.security>0)x.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:t,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:r,issuesByCategory:p,performanceScore:m,recommendations:x}}var{serve:Wn}=globalThis.Bun;import Rt from"fs";import Qe from"path";function dt(){return`
|
|
6
6
|
/* Theme selector for code blocks */
|
|
7
7
|
.theme-selector {
|
|
8
8
|
margin: 1rem 0;
|
|
@@ -82,7 +82,7 @@ else {
|
|
|
82
82
|
<span class="frontmatter-label">${t}:</span>
|
|
83
83
|
<span>${Array.isArray(o)?o.join(", "):String(o)}</span>
|
|
84
84
|
</div>`).join("")}
|
|
85
|
-
</div>`}async function
|
|
85
|
+
</div>`}async function _n(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"0.0.0.0")})}async function In(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"::")})}async function jn(n){if(!await _n(n))return!1;return await In(n)}async function Ve(n,t=20){n=Number(n);for(let o=0;o<t;o++){let d=n+o;if(await jn(d))return d}throw Error(`Could not find an available port between ${n} and ${n+t-1}`)}var Hn={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Bn(){try{let n=await import("./chunk-dmc91qke.js");if(typeof n.openDevWindow!=="function")return null;return n}catch{return null}}async function Ye(n,t={}){let o={...Hn,...t},d=await Bn();if(!d)return console.log(`${e.yellow}\u26A0${e.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let r=await d.openDevWindow(n,{title:o.title,width:o.width,height:o.height,darkMode:o.darkMode,hotReload:o.hotReload,titlebarHidden:o.titlebarHidden,nativeSidebar:o.nativeSidebar,sidebarWidth:o.sidebarWidth,sidebarConfig:o.sidebarConfig});if(r&&o.nativeSidebar)console.log(`${e.green}\u2713${e.reset} Native sidebar enabled (macOS Tahoe style)`);return r}catch(r){return console.log(`${e.red}\u2717${e.reset} Could not open native window:`,r),!1}}function gt(n){if(n.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let r=n.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(r){let p=r[1];try{let u=`
|
|
86
86
|
${p}
|
|
87
87
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
88
88
|
`,x=Function(u)();if(x)return x}catch(u){console.warn("Invalid sidebarConfig:",u)}}return{sections:[]}}let o=n.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(o)try{return JSON.parse(o[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let d=n.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(d)try{let r=d[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(r)return Function(`return ${r[1]}`)()}catch(r){console.warn("Invalid native-sidebar script configuration:",r)}return}function $t(){console.log(`
|
|
@@ -94,7 +94,7 @@ Keyboard shortcuts:`),console.log(` ${e.cyan}o${e.reset} + Enter - Open in brow
|
|
|
94
94
|
<head>
|
|
95
95
|
<meta charset="UTF-8">
|
|
96
96
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
97
|
-
<title>${
|
|
97
|
+
<title>${Vn(R.title||Qe.basename(r))}</title>
|
|
98
98
|
<!-- Syntax highlighting styles -->
|
|
99
99
|
<style id="syntax-theme">
|
|
100
100
|
:root {
|
|
@@ -250,12 +250,12 @@ Keyboard shortcuts:`),console.log(` ${e.cyan}o${e.reset} + Enter - Open in brow
|
|
|
250
250
|
</script>
|
|
251
251
|
</body>
|
|
252
252
|
</html>
|
|
253
|
-
`,!0}catch(C){return console.error(`${e.red}Error processing Markdown file:${e.reset}`,C),!1}};if(!await u())return!1;let x=o;try{if(x=await Ve(o),x!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${x} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${x}/${e.reset}...`);let h=
|
|
253
|
+
`,!0}catch(C){return console.error(`${e.red}Error processing Markdown file:${e.reset}`,C),!1}};if(!await u())return!1;let x=o;try{if(x=await Ve(o),x!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${x} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${x}/${e.reset}...`);let h=Wn({port:x,fetch(C){if(new URL(C.url).pathname==="/")return new Response(p,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}});return new Response("Not Found",{status:404})},error(C){return new Response(`<pre>${C}
|
|
254
254
|
${C.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
255
255
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
256
256
|
${e.bright}\u2192 ${e.cyan}http://localhost:${x}/${e.reset}`),console.log(`
|
|
257
257
|
${e.yellow}Routes:${e.reset}`);let b=Qe.relative(process.cwd(),r);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${b}${e.reset}`),console.log(`
|
|
258
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(h.url.toString(),()=>{if(d)Rt.watch(Qe.dirname(r),{recursive:!0}).close();h.stop()}),t.native)await Ye(x,{title:Qe.basename(r,".md")});if(d){let C=Qe.dirname(r);console.log(`${e.blue}Watching ${e.bright}${C}${e.reset} for changes...`);let R=Rt.watch(C,{recursive:!0},async(O,v)=>{if(v&&v.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${v}${e.yellow} changed, reprocessing...${e.reset}`),await u()});process.on("SIGINT",()=>{R.close(),h.stop(),process.exit(0)})}return!0}function
|
|
258
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(h.url.toString(),()=>{if(d)Rt.watch(Qe.dirname(r),{recursive:!0}).close();h.stop()}),t.native)await Ye(x,{title:Qe.basename(r,".md")});if(d){let C=Qe.dirname(r);console.log(`${e.blue}Watching ${e.bright}${C}${e.reset} for changes...`);let R=Rt.watch(C,{recursive:!0},async(O,v)=>{if(v&&v.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${v}${e.yellow} changed, reprocessing...${e.reset}`),await u()});process.on("SIGINT",()=>{R.close(),h.stop(),process.exit(0)})}return!0}function Vn(n){return String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Kn}=globalThis.Bun;import Ie from"fs";import ge from"path";class Wt{clients=new Set;server=null;options;constructor(n={}){this.options={wsPort:n.wsPort??3001,showOverlay:n.showOverlay??!0,reconnectInterval:n.reconnectInterval??1000,maxReconnectAttempts:n.maxReconnectAttempts??10,verbose:n.verbose??!1}}start(n){let t=n??this.options.wsPort,o=20;for(let d=0;d<o;d++)try{if(this.server=Bun.serve({port:t,fetch(r,p){if(p.upgrade(r,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(r)=>{if(this.clients.add(r),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);r.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(r)=>{if(this.clients.delete(r),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(r,p)=>{let u=typeof p==="string"?p:p.toString();if(u==="ping")return;try{let m=JSON.parse(u);if(m.type==="console"&&Array.isArray(m.args)){let x=m.args.join(" "),b={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[m.level]??"\x1B[36m";console.log(`${b}[browser]${m.level!=="log"?` ${m.level}`:""}\x1B[0m ${x}`)}}catch{}}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${t}`);return t}catch(r){if(r?.code==="EADDRINUSE"){t++;continue}throw r}throw Error(`Could not find an available port after ${o} attempts starting from ${n??this.options.wsPort}`)}stop(){for(let n of this.clients)try{n.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast(n){let t=JSON.stringify(n),o=0;for(let d of this.clients)try{if(d.readyState===1)d.send(t),o++}catch{this.clients.delete(d)}if(this.options.verbose&&o>0)console.log(`[HMR] Broadcast ${n.type} to ${o} client(s)`)}reload(n){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${n||"all"}`);this.broadcast({type:"reload",path:n,timestamp:Date.now()})}updateCss(n,t){this.broadcast({type:"css-update",path:n,content:t,timestamp:Date.now()})}error(n){this.broadcast({type:"error",content:n,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function qn(n,t={}){let{showOverlay:o=!0,reconnectInterval:d=1000,maxReconnectAttempts:r=10}=t;return`
|
|
259
259
|
<script>
|
|
260
260
|
(function() {
|
|
261
261
|
// stx Hot Reload Client
|
|
@@ -454,10 +454,10 @@ else {
|
|
|
454
454
|
};
|
|
455
455
|
})();
|
|
456
456
|
</script>
|
|
457
|
-
`}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Wt(n);return Ze}function ot(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await
|
|
457
|
+
`}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Wt(n);return Ze}function ot(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await Bs(o,d);if(p.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}n.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(o.cache&&o.cachePath){let w=await Cr(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let x=await Me(()=>Bun.file(u).text(),"",(w)=>{throw new Vr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${w.message}`)});if(!x)throw new Vr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:b,allScripts:C}=we.time("script-extraction",()=>{let w=x,A=B(x);if(A)w=A.content.trim();let W=x.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],oe="",I=[];for(let k of W){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),q=D?D[1]:"";if(/\bserver\b/i.test(q))oe=P;else I.push(k)}let L=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:oe,templateContent:L,allScripts:I}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Me(()=>y(h,R,u),void 0,(w)=>{let A=new ce(`Script execution failed in ${u}: ${w.message}`,u,void 0,void 0,h.substring(0,100));if(K.log(A,{filePath:u,scriptContent:h}),o.debug)throw A});let v=await we.timeAsync("directive-processing",async()=>await i(b,R,u,o,m));if(C.length>0){let{interpolateScriptsInTemplate:w}=await import("./chunk-k352spys.js"),A=w(C.join(`
|
|
458
458
|
`),R),W=v.search(/<\/body>/i);if(W!==-1)v=v.slice(0,W)+A+`
|
|
459
459
|
`+v.slice(W);else v+=`
|
|
460
|
-
${A}`}if(v=await Ae(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await
|
|
460
|
+
${A}`}if(v=await Ae(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await Er(u,v,m,o),o.debug)console.log(`Cached template ${u} with ${m.size} dependencies`)}return{contents:v,loader:"html"}}catch(m){let x=m instanceof Error?m:new ce(`Plugin processing failed: ${String(m)}`,u);if(K.log(x,{filePath:u,buildConfig:n.config}),Ln.logDetailedError(x,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",x);let h=x,b=h.line||null,C=h.context||null;return{contents:o.debug||ne()?`<!DOCTYPE html>
|
|
461
461
|
<html lang="en">
|
|
462
462
|
<head>
|
|
463
463
|
<meta charset="UTF-8">
|
|
@@ -517,12 +517,12 @@ ${A}`}if(v=await Ae(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await C
|
|
|
517
517
|
<h1>Something went wrong</h1>
|
|
518
518
|
<p>An internal error occurred. Please try again later.</p>
|
|
519
519
|
</body>
|
|
520
|
-
</html>`,loader:"html"}}})}};async function
|
|
520
|
+
</html>`,loader:"html"}}})}};async function ss(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=ge.resolve(n);if(!Ie.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Et(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let x=l(process.cwd(),"output");Ie.mkdirSync(x,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${n}${e.reset}...`);let h=null,b=async()=>{try{let P={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:x,plugins:[P,et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!D.success)return console.error(`${e.red}Build failed:${e.reset}`,D.logs),!1;let q=D.outputs.find((xe)=>xe.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(q.path).text(),!0}catch(P){return console.error(`${e.red}Error building stx file:${e.reset}`,P),!1}};if(!await b())return!1;let R=ge.dirname(m);await Sn(R);let O=o;try{if(O=await Ve(o),O!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${O} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let P=t.hmrPort||O+1;p=bt({wsPort:P,verbose:!1}),u=p.start(P)}let v={},w=null,A;try{let{loadStxConfig:P}=await import("./chunk-zpwh9bpc.js"),D=await P();if(A=t.stxOptions?.serverApi??D.serverApi,D?.apiRouter)w=D?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(D?.apiRoutes){v=D.apiRoutes;let q=Object.keys(v).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:Y}=await import("./chunk-cvxg2rc1.js"),xe=D.broadcasting;await q(xe);let pe=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let ke=ge.join(process.cwd(),"channels.ts");if(Ie.existsSync(ke))try{let se=await Y(ke);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:W,isServerApiSource:oe}=await import("./chunk-h2gnz7ja.js"),I=await W(process.cwd(),A);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${O}/${e.reset}...`),r)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let L=Kn({port:O,async fetch(P){return Un(P,await(async()=>{let D=new URL(P.url);if([x,ge.dirname(m),ge.join(process.cwd(),"public")].some((se)=>oe(ge.join(se,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(w)try{let se=await w.handleRequest(P);if(se.status!==404)return se}catch{}if(v[D.pathname])try{return await v[D.pathname](P)}catch(se){return new Response(JSON.stringify({error:se.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await I(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ue(F,u);if(t.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(t.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(x,D.pathname);if(Ie.existsSync(Y)&&Ie.statSync(Y).isFile()){let se=Bun.file(Y),F=ge.extname(Y).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await se.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}let xe=ge.dirname(m),pe=ge.join(xe,D.pathname);if(Ie.existsSync(pe)&&Ie.statSync(pe).isFile()){let se=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await se.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}let ke=ge.join(process.cwd(),"public",D.pathname);if(Ie.existsSync(ke)&&Ie.statSync(ke).isFile()){let se=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await se.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(P){return new Response(`<pre>${P}
|
|
521
521
|
${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
522
522
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
523
523
|
${e.bright}\u2192 ${e.cyan}http://localhost:${O}/${e.reset}`),console.log(`
|
|
524
524
|
${e.yellow}Routes:${e.reset}`);let k=ge.relative(process.cwd(),m);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${k}${e.reset}`),console.log(`
|
|
525
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(L.url.toString(),()=>{if(d)Ie.watch(ge.dirname(m),{recursive:!0}).close();L.stop()}),t.native){let P=await Bun.file(m).text(),D=gt(P);await Ye(O,{title:ge.basename(m,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=ge.dirname(m);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=Ie.watch(P,{recursive:!0},async(q,Y)=>{if(!Y||xt(Y))return;if(yt(Y)){console.log(`${e.yellow}File ${e.bright}${Y}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce();let xe=await b();if(await
|
|
525
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(L.url.toString(),()=>{if(d)Ie.watch(ge.dirname(m),{recursive:!0}).close();L.stop()}),t.native){let P=await Bun.file(m).text(),D=gt(P);await Ye(O,{title:ge.basename(m,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=ge.dirname(m);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=Ie.watch(P,{recursive:!0},async(q,Y)=>{if(!Y||xt(Y))return;if(yt(Y)){console.log(`${e.yellow}File ${e.bright}${Y}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce();let xe=await b();if(await vr(R),r&&p)if(xe)p.reload(Y);else p.error("Build failed - check console for details")}else if(ht(Y)){if(console.log(`${e.cyan}CSS ${e.bright}${Y}${e.cyan} changed${e.reset}`),r&&p)p.updateCss(Y)}});process.on("SIGINT",()=>{if(D.close(),p)ot();L.stop(),process.exit(0)})}return!0}var{serve:Xn}=globalThis.Bun;import Ke from"fs";import Se from"path";var Vt=`
|
|
526
526
|
<script data-stx-helpers>
|
|
527
527
|
(function() {
|
|
528
528
|
'use strict'
|
|
@@ -833,7 +833,7 @@ else {
|
|
|
833
833
|
|
|
834
834
|
})()
|
|
835
835
|
</script>
|
|
836
|
-
`;function Xt(n){if(n.length===0)return"";if(n.length===1)return n[0];let t=n.map((d)=>d.split(Se.sep)),o=[];for(let d=0;d<t[0].length;d++){let r=t[0][d];if(t.every((p)=>p[d]===r))o.push(r);else break}return o.join(Se.sep)}async function
|
|
836
|
+
`;function Xt(n){if(n.length===0)return"";if(n.length===1)return n[0];let t=n.map((d)=>d.split(Se.sep)),o=[];for(let d=0;d<t[0].length;d++){let r=t[0][d];if(t.every((p)=>p[d]===r))o.push(r);else break}return o.join(Se.sep)}async function os(n,t={}){let o=t.port||3000,d=t.watch!==!1;for(let v of n){let w=Se.resolve(v);if(!Ke.existsSync(w))return console.error(`${e.red}Error: File not found: ${e.bright}${w}${e.reset}`),!1;if(!w.endsWith(".stx")&&!w.endsWith(".md"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${w}${e.reset}. Only .stx and .md files are supported.`),!1}let r=l(process.cwd(),"output");Ke.mkdirSync(r,{recursive:!0});let p=Xt(n.map((v)=>Se.dirname(Se.resolve(v))));console.log(`${e.blue}Processing ${e.bright}${n.length}${e.reset} files...`);let u={},m=[],x=async()=>{try{for(let v of n){let w=Se.resolve(v);if(w.endsWith(".md"))try{let{content:W,data:oe}=await He(w,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:j.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),I=t.markdown?.syntaxHighlighting||j.markdown?.syntaxHighlighting,L=I?.defaultTheme||"github-dark",k=["github-dark"],P=I?.additionalThemes||[],q=[...new Set([...k,...P])].map((ke)=>`<option value="${ke}"${ke===L?" selected":""}>${ke}</option>`).join(`
|
|
837
837
|
`),Y=`
|
|
838
838
|
<!DOCTYPE html>
|
|
839
839
|
<html lang="en">
|
|
@@ -997,17 +997,17 @@ else {
|
|
|
997
997
|
</body>
|
|
998
998
|
</html>
|
|
999
999
|
`,pe=`/${Se.relative(p,w).replace(/\.md$/,"")}`;if(pe.endsWith("/index"))pe=pe.slice(0,-6)||"/";u[pe||"/"]={filePath:w,content:Y,fileType:"md"}}catch(W){console.error(`${e.red}Error processing Markdown file ${e.bright}${v}${e.reset}:`,W);continue}else{let W={name:"public-assets",setup(k){k.onResolve({filter:/^\/(images|fonts|assets|public)\//},(P)=>({path:P.path,external:!0}))}},oe;try{let k=await Bun.build({entrypoints:[w],outdir:r,plugins:[W,et],define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!k.success){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:`,ze(k.logs,w));continue}let P=k.outputs.find((D)=>D.path.endsWith(".html"));if(!P){console.error(`${e.red}No HTML output found for ${e.bright}${v}${e.reset}`);continue}oe=await Bun.file(P.path).text()}catch(k){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:
|
|
1000
|
-
${ze(k,w)}`);continue}let L=`/${Se.relative(p,w).replace(/\.stx$/,"")}`;if(L.endsWith("/index"))L=L.slice(0,-6)||"/";if(L.includes("[")){let{regex:k,params:P}=
|
|
1000
|
+
${ze(k,w)}`);continue}let L=`/${Se.relative(p,w).replace(/\.stx$/,"")}`;if(L.endsWith("/index"))L=L.slice(0,-6)||"/";if(L.includes("[")){let{regex:k,params:P}=Ws(L,{page:!0});m.push({pattern:k,paramNames:P,filePath:w,routeTemplate:L,fileType:"stx"}),u[L]={filePath:w,content:oe,fileType:"stx"}}else u[L||"/"]={filePath:w,content:oe,fileType:"stx"}}}if(Object.keys(u).length===0)return console.error(`${e.red}No files were successfully processed${e.reset}`),!1;return!0}catch(v){return console.error(`${e.red}Error processing files:${e.reset}`,ze(v)),!1}};if(!await x())return!1;let b=o;try{if(b=await Ve(o),b!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${b} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${b}/${e.reset}...`);let C=Xn({port:b,async fetch(v){let w=new URL(v.url),A=Se.join(process.cwd(),"public",w.pathname);if(Ke.existsSync(A)&&Ke.statSync(A).isFile()){let I=Bun.file(A),L=Se.extname(A).toLowerCase(),k="application/octet-stream";if(L===".ts"||L===".tsx"){let P=new Bun.Transpiler({loader:L===".tsx"?"tsx":"ts"}),D=await I.text(),q=P.transformSync(D);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(L){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":k}})}let W=u[w.pathname];if(!W&&!w.pathname.endsWith("/"))W=u[`${w.pathname}/`];if(!W)for(let I of m){let L=w.pathname.match(I.pattern);if(L){let k=u[I.routeTemplate];if(k){let P={};for(let Y=0;Y<I.paramNames.length;Y++)P[I.paramNames[Y]]=decodeURIComponent(L[Y+1]);let D=k.content,q=`<script>window.__routeParams = ${JSON.stringify(P)};</script>`;if(D.includes("</head>"))D=f(D,q);else D=q+D;W={...k,content:D}}break}}if(W)return S(W.content).then((I)=>{if(I.includes("</head>"))I=f(I,Vt);return new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let oe=Se.join(r,w.pathname);if(Ke.existsSync(oe)&&Ke.statSync(oe).isFile()){let I=Bun.file(oe),L=Se.extname(oe).toLowerCase(),k="text/plain";if(L===".ts"||L===".tsx"){let P=new Bun.Transpiler({loader:L===".tsx"?"tsx":"ts"}),D=await I.text(),q=P.transformSync(D);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(L){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":k}})}if(w.pathname!=="/"&&u["/"]){let I=je(v);return S(u["/"].content).then((L)=>{if(I){let k=L.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(k){let P=L.match(/<title[^>]*>([\s\S]*?)<\/title>/i),D=P?P[1]:"",q=`<!DOCTYPE html><html><head><title>${qt(D)}</title></head><body><main>${k[1]}</main></body></html>`;return new Response(q,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...U(),"Cache-Control":Tt,Pragma:"no-cache",Expires:"0"}})}}return new Response(L,{headers:{"Content-Type":"text/html",...U(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(v){return new Response(`<pre>${v}
|
|
1001
1001
|
${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1002
1002
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1003
1003
|
${e.bright}\u2192 ${e.cyan}http://localhost:${b}/${e.reset}`),console.log(`
|
|
1004
1004
|
${e.yellow}Routes:${e.reset}`);let R=new Set(m.map((v)=>v.routeTemplate)),O=Object.entries(u).filter(([v])=>!R.has(v)).sort(([v],[w])=>v.localeCompare(w)).map(([v,w])=>({route:v==="/"?"/":v,filePath:Se.relative(process.cwd(),w.filePath),fileType:w.fileType}));for(let v of m){let w=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");O.push({route:w,filePath:Se.relative(process.cwd(),v.filePath),fileType:"stx"})}if(O.sort((v,w)=>v.route.localeCompare(w.route)),O.forEach((v,w)=>{let W=w===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",oe=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${W}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${oe}`)}),console.log(`
|
|
1005
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(p,{recursive:!0},async(w,A)=>{if(!A)return;if(A.endsWith(".stx")||A.endsWith(".js")||A.endsWith(".ts")||A.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${A}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce(),await x()});process.on("SIGINT",()=>{v.close(),C.stop(),process.exit(0)})}return!0}function qt(n){return String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Gn}=globalThis.Bun;import me from"fs";import te from"path";async function Jt(n){try{return $n(await Bun.file(n).text())}catch{return}}function Ot(n){let t=Bun.file(n),o=te.extname(n).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},p=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(t,{headers:{"Content-Type":d[o]||"application/octet-stream",...p}})}async function os(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=te.resolve(n),{loadStxConfig:x}=await import("./chunk-tsz03zc9.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-3hd73qqj.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await b(m,R),v=h.root&&h.root!=="."?te.join(m,h.root):m,w=t.pagesDir||h.pagesDir||"pages",A=te.join(v,w);if(!me.existsSync(A)&&!h._layerPageDirs?.some((T)=>me.existsSync(T)))return console.error(`${e.red}Error: No '${w}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${A}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${w}/index.stx for the homepage.${e.reset}`),!1;let W=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(W.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${W.length}${e.blue} routes${e.reset}`);let oe=h?._pluginPageDirs||[],I=[];for(let{dir:T,prefix:M}of oe)if(me.existsSync(T)){let z=re(te.dirname(T),{pagesDir:te.basename(T)});for(let Q of z){let X=M==="/"?Q.pattern:`${M}${Q.pattern==="/"?"":Q.pattern}`;I.push({route:{...Q,pattern:X},prefix:M})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${M}${e.reset}`)}let L=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Ia(m,t.stxOptions?.shell),P){if(k=await Do(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(m,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Lt(),await Bt(m);let D=jt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let q={},Y=null;try{let{loadStxConfig:T}=await import("./chunk-tsz03zc9.js"),M=await T(m);if(M?.apiRouter)Y=M?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(M?.apiRoutes){q=M.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-0k437z3q.js"),X=M.broadcasting;await z(X);let Te=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let be=te.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Q(be);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let xe=l(m,"output");me.mkdirSync(xe,{recursive:!0});let pe=new Map,ke=new Set,se=async(T)=>{let M=Ws(A,T);if(!M)return null;try{let z=await Bun.build({entrypoints:[M],outdir:xe,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,E=async(T,M)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-tsz03zc9.js"),{checkCache:N,cacheTemplate:J,readFileCached:V,templateCache:ue}=await import("./chunk-8cs8jckk.js"),G=await Te(m),We=(le)=>{if(!le)return le;if(te.isAbsolute(le))return le;return te.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=We(de.partialsDir),de.componentsDir=We(de.componentsDir),de.layoutsDir=We(de.layoutsDir),de.storesDir=We(de.storesDir||"stores"),de.cachePath=We(de.cachePath)??l(m,"cache");let _=!M&&!t.profile,ie=de.cache!==!1;if(ie&&_){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Le=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Le=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Le=!1;break}}if(Le){let ve=le.output;if(k)ve=rt(ve,{preserveHead:!0});let nt=F.get(T.filePath);return{route:T,content:ve,status:nt?.status??await Jt(T.filePath),headers:nt?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let _e=De;if(k)_e=rt(_e,{preserveHead:!0});let Le=F.get(T.filePath);return{route:T,content:_e,status:Le?.status??await Jt(T.filePath),headers:Le?.headers}}}let Z=ie?await V(T.filePath):await Bun.file(T.filePath).text(),ae=$n(Z),{classifyAllScripts:fe}=await import("./chunk-tsz03zc9.js"),H=fe(Z),Oe=H.server.map((le)=>le.content),Pe=Z;for(let le of H.server)Pe=Pe.replace(le.fullTag,"");let ee={__filename:T.filePath,__dirname:te.dirname(T.filePath),__stx_options:de,params:M??{},__stx_runtime_head:{}};for(let le of Oe)try{await Q(le,ee,T.filePath)}catch(De){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,De?.message||De)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Pe,ee,T.filePath,de,$e);let De=performance.now()-le,_e=te.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Pe,ee,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-fsehzmg8.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,_e,Le)=>{if(!/function\s+__stx_setup_/.test(Le))return De;return`<script${_e}>${le(Le,ee)}</script>`})}if(k)he=rt(he,{preserveHead:!0});if(ie&&_)await J(T.filePath,he,$e,de);let{extractStreamBoundaries:lt}=await import("./chunk-rarsjcs4.js"),Je=lt(ee),tt=ee.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=ee.streamBoundaries||{},De={...de,autoShell:!1},_e=Object.keys(tt).map((ve)=>({id:ve,render:async()=>{let nt=typeof le[ve]==="function"?await le[ve]():void 0;return z(tt[ve],{...ee,$boundary:nt},T.filePath,De,new Set)}})),Le=new Set(_e.map((ve)=>ve.id));Je=[...(Je||[]).filter((ve)=>!Le.has(ve.id)),..._e]}if(Je&&Je.length>0)ke.add(T.pattern);else Je=void 0;let _t=Kt(ee),It=Gt(ee);if(_)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},Fe=8,Ne=async()=>{let T=new Set(pe.keys()),M=new Set(L.keys());pe.clear(),L.clear();let z=t.prebuild===!1?W.filter((X)=>T.has(X.pattern)):W,Q=t.prebuild===!1?I.filter(({route:X})=>M.has(X.pattern)):I;for(let X=0;X<z.length;X+=Fe){let Te=z.slice(X,X+Fe),be=await Promise.all(Te.map((N)=>E(N)));for(let N of be)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=Fe){let Te=Q.slice(X,X+Fe),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)L.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?W.length+I.length>0:await Ne()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,M)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(M).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Q,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let M=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(M.pathname===ti&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(T.method==="HEAD"?null:ni(z,ks()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",X=te.join(m,Q,M.pathname),Te=te.join(m,M.pathname),be=te.join(xe,M.pathname);if([X,Te,be].some((_)=>C(_,m,R)))return new Response("Not Found",{status:404});let[N,J,V]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(be).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(J?.isFile()&&!C(Te,m,R))return Ot(Te);if(V?.isFile()&&!C(be,m,R))return Ot(be);if(M.pathname.startsWith("/_stx/component/")){let _=decodeURIComponent(M.pathname.slice(16));if(_)try{let ie=`<${_} />`,Z={...buildConfig,autoShell:!1},ae=await processDirectives(ie,{},te.join(m,"components",`${_}.stx`),Z,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(M.pathname==="/_stx/img"){let{handleImageRequest:_}=await import("./chunk-1a7a8cjs.js"),ie=await _(T,{publicDir:te.join(m,Q),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Y)try{let _=await Y.handleRequest(T);if(_.status!==404)return _}catch{}if(q[M.pathname])try{return await q[M.pathname](T)}catch(_){return new Response(JSON.stringify({error:_.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=Tr(M.pathname,W);if(G){let _=pe.get(G.route.pattern),ie=ke.has(G.route.pattern);if(!_||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let Z=await E(G.route,G.params);if(Z){if(_=Z,!G.route.isDynamic&&!ie)pe.set(G.route.pattern,Z)}}if(_){let Z=_.status??200,ae=_.headers??{},fe=(G.route.filePath?Pt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await se(404);if(Pe){let ee=Pe;if(ee=await S(ee,m),r)ee=Ue(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=Ft(M.pathname,G.params,fe,M.search),Pe=zt(Oe,null,T,{isServer:!0}),ee=await Ht(fe.middleware,Pe);if(ee.redirect){let $e=ee.redirect.path,he=ee.redirect.options.redirectCode||302,lt=new Headers(ee.responseHeaders);return lt.set("Location",$e),new Response(null,{status:he,headers:lt})}if(ee.abort){let{statusCode:$e,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${$e}</title></head><body><h1>Error ${$e}</h1><p>${he}</p></body></html>`,{status:$e,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;_.content=f(_.content,$e,"")}}let H=_.content;if(k&&Oa(T)&&st(H,h?.router?.container||"main")){let Oe=pt(H),Pe=Re(H),ee=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=ee?cn(ee[1].trim()):"";if(Object.keys(G.params).length>0)H=St(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Be(H,he,!0),new Response(H,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Pe?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Rc]:ks(),...U(),"Cache-Control":Tt}})}if(k)H=ls(k,H);if(Object.keys(G.params).length>0)H=St(H,G.params);if(H=await S(H,m),r)H=Ue(H,u);if(t.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;if(t.titlebarHidden)if(H.includes("<head>"))H=H.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else H=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${H}`;if(_.boundaries&&_.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Pe}=await import("./chunk-rarsjcs4.js");return Pe(Oe(H,_.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:Z,headers:{"Content-Type":"text/html",...U(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(I.length>0){let _=I.map((Z)=>Z.route),ie=Tr(M.pathname,_);if(ie){let Z=L.get(ie.route.pattern);if(!Z||ie.route.isDynamic){let ae=await E(ie.route,ie.params);if(ae){if(Z=ae,!ie.route.isDynamic)L.set(ie.route.pattern,ae)}}if(Z){let ae=Z.content;if(k)ae=ls(k,ae);if(Object.keys(ie.params).length>0)ae=St(ae,ie.params);if(ae=await S(ae,m),r)ae=Ue(ae,u);return new Response(ae,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of oe)if(Z!=="/"&&M.pathname.startsWith(Z)){let ae=L.get(Z)||L.get(Z+"/");if(!ae){let fe=I.find(({route:H})=>H.pattern===Z||H.pattern===`${Z}/`);if(fe){let H=await E(fe.route);if(H)ae=H,L.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=ls(k,fe);if(fe=await S(fe,m),r)fe=Ue(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Dt(M.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let _=We.content;if(_=await S(_,m),r)_=Ue(_,u);if(t.native)if(_.includes("<head>"))_=_.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else _="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+_;return new Response(_,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await se(404);if(de){let _=de;if(_=await S(_,m),r)_=Ue(_,u);return new Response(_,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let M=await se(500);if(M)return new Response(M,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
|
|
1005
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(p,{recursive:!0},async(w,A)=>{if(!A)return;if(A.endsWith(".stx")||A.endsWith(".js")||A.endsWith(".ts")||A.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${A}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce(),await x()});process.on("SIGINT",()=>{v.close(),C.stop(),process.exit(0)})}return!0}function qt(n){return String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Gn}=globalThis.Bun;import me from"fs";import te from"path";async function Jt(n){try{return Rn(await Bun.file(n).text())}catch{return}}function Ot(n){let t=Bun.file(n),o=te.extname(n).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},p=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(t,{headers:{"Content-Type":d[o]||"application/octet-stream",...p}})}async function is(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=te.resolve(n),{loadStxConfig:x}=await import("./chunk-zpwh9bpc.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-h2gnz7ja.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await b(m,R),v=h.root&&h.root!=="."?te.join(m,h.root):m,w=t.pagesDir||h.pagesDir||"pages",A=te.join(v,w);if(!me.existsSync(A)&&!h._layerPageDirs?.some((T)=>me.existsSync(T)))return console.error(`${e.red}Error: No '${w}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${A}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${w}/index.stx for the homepage.${e.reset}`),!1;let W=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(W.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${W.length}${e.blue} routes${e.reset}`);let oe=h?._pluginPageDirs||[],I=[];for(let{dir:T,prefix:M}of oe)if(me.existsSync(T)){let z=re(te.dirname(T),{pagesDir:te.basename(T)});for(let Q of z){let X=M==="/"?Q.pattern:`${M}${Q.pattern==="/"?"":Q.pattern}`;I.push({route:{...Q,pattern:X},prefix:M})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${M}${e.reset}`)}let L=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Oa(m,t.stxOptions?.shell),P){if(k=await Lo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(m,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Lt(),await Bt(m);let D=jt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let q={},Y=null;try{let{loadStxConfig:T}=await import("./chunk-zpwh9bpc.js"),M=await T(m);if(M?.apiRouter)Y=M?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(M?.apiRoutes){q=M.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-cvxg2rc1.js"),X=M.broadcasting;await z(X);let Te=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let be=te.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Q(be);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let xe=l(m,"output");me.mkdirSync(xe,{recursive:!0});let pe=new Map,ke=new Set,se=async(T)=>{let M=qs(A,T);if(!M)return null;try{let z=await Bun.build({entrypoints:[M],outdir:xe,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,E=async(T,M)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-zpwh9bpc.js"),{checkCache:N,cacheTemplate:J,readFileCached:V,templateCache:ue}=await import("./chunk-0f2d61b3.js"),G=await Te(m),We=(le)=>{if(!le)return le;if(te.isAbsolute(le))return le;return te.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=We(de.partialsDir),de.componentsDir=We(de.componentsDir),de.layoutsDir=We(de.layoutsDir),de.storesDir=We(de.storesDir||"stores"),de.cachePath=We(de.cachePath)??l(m,"cache");let _=!M&&!t.profile,ie=de.cache!==!1;if(ie&&_){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Le=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Le=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Le=!1;break}}if(Le){let ve=le.output;if(k)ve=rt(ve,{preserveHead:!0});let nt=F.get(T.filePath);return{route:T,content:ve,status:nt?.status??await Jt(T.filePath),headers:nt?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let _e=De;if(k)_e=rt(_e,{preserveHead:!0});let Le=F.get(T.filePath);return{route:T,content:_e,status:Le?.status??await Jt(T.filePath),headers:Le?.headers}}}let Z=ie?await V(T.filePath):await Bun.file(T.filePath).text(),ae=Rn(Z),{classifyAllScripts:fe}=await import("./chunk-zpwh9bpc.js"),H=fe(Z),Oe=H.server.map((le)=>le.content),Pe=Z;for(let le of H.server)Pe=Pe.replace(le.fullTag,"");let ee={__filename:T.filePath,__dirname:te.dirname(T.filePath),__stx_options:de,params:M??{},__stx_runtime_head:{}};for(let le of Oe)try{await Q(le,ee,T.filePath)}catch(De){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,De?.message||De)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Pe,ee,T.filePath,de,$e);let De=performance.now()-le,_e=te.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Pe,ee,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-k352spys.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,_e,Le)=>{if(!/function\s+__stx_setup_/.test(Le))return De;return`<script${_e}>${le(Le,ee)}</script>`})}if(k)he=rt(he,{preserveHead:!0});if(ie&&_)await J(T.filePath,he,$e,de);let{extractStreamBoundaries:lt}=await import("./chunk-y10eaxgc.js"),Je=lt(ee),tt=ee.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=ee.streamBoundaries||{},De={...de,autoShell:!1},_e=Object.keys(tt).map((ve)=>({id:ve,render:async()=>{let nt=typeof le[ve]==="function"?await le[ve]():void 0;return z(tt[ve],{...ee,$boundary:nt},T.filePath,De,new Set)}})),Le=new Set(_e.map((ve)=>ve.id));Je=[...(Je||[]).filter((ve)=>!Le.has(ve.id)),..._e]}if(Je&&Je.length>0)ke.add(T.pattern);else Je=void 0;let _t=Kt(ee),It=Gt(ee);if(_)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},Fe=8,Ne=async()=>{let T=new Set(pe.keys()),M=new Set(L.keys());pe.clear(),L.clear();let z=t.prebuild===!1?W.filter((X)=>T.has(X.pattern)):W,Q=t.prebuild===!1?I.filter(({route:X})=>M.has(X.pattern)):I;for(let X=0;X<z.length;X+=Fe){let Te=z.slice(X,X+Fe),be=await Promise.all(Te.map((N)=>E(N)));for(let N of be)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=Fe){let Te=Q.slice(X,X+Fe),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)L.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?W.length+I.length>0:await Ne()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,M)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(M).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Q,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let M=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(M.pathname===ni&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(T.method==="HEAD"?null:ri(z,_s()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",X=te.join(m,Q,M.pathname),Te=te.join(m,M.pathname),be=te.join(xe,M.pathname);if([X,Te,be].some((_)=>C(_,m,R)))return new Response("Not Found",{status:404});let[N,J,V]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(be).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(J?.isFile()&&!C(Te,m,R))return Ot(Te);if(V?.isFile()&&!C(be,m,R))return Ot(be);if(M.pathname.startsWith("/_stx/component/")){let _=decodeURIComponent(M.pathname.slice(16));if(_)try{let ie=`<${_} />`,Z={...buildConfig,autoShell:!1},ae=await processDirectives(ie,{},te.join(m,"components",`${_}.stx`),Z,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(M.pathname==="/_stx/img"){let{handleImageRequest:_}=await import("./chunk-8jvwapq3.js"),ie=await _(T,{publicDir:te.join(m,Q),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Y)try{let _=await Y.handleRequest(T);if(_.status!==404)return _}catch{}if(q[M.pathname])try{return await q[M.pathname](T)}catch(_){return new Response(JSON.stringify({error:_.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=$r(M.pathname,W);if(G){let _=pe.get(G.route.pattern),ie=ke.has(G.route.pattern);if(!_||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let Z=await E(G.route,G.params);if(Z){if(_=Z,!G.route.isDynamic&&!ie)pe.set(G.route.pattern,Z)}}if(_){let Z=_.status??200,ae=_.headers??{},fe=(G.route.filePath?Pt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await se(404);if(Pe){let ee=Pe;if(ee=await S(ee,m),r)ee=Ue(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=Ft(M.pathname,G.params,fe,M.search),Pe=zt(Oe,null,T,{isServer:!0}),ee=await Ht(fe.middleware,Pe);if(ee.redirect){let $e=ee.redirect.path,he=ee.redirect.options.redirectCode||302,lt=new Headers(ee.responseHeaders);return lt.set("Location",$e),new Response(null,{status:he,headers:lt})}if(ee.abort){let{statusCode:$e,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${$e}</title></head><body><h1>Error ${$e}</h1><p>${he}</p></body></html>`,{status:$e,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;_.content=f(_.content,$e,"")}}let H=_.content;if(k&&Na(T)&&st(H,h?.router?.container||"main")){let Oe=pt(H),Pe=Re(H),ee=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=ee?cn(ee[1].trim()):"";if(Object.keys(G.params).length>0)H=St(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Be(H,he,!0),new Response(H,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Pe?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Ac]:_s(),...U(),"Cache-Control":Tt}})}if(k)H=us(k,H);if(Object.keys(G.params).length>0)H=St(H,G.params);if(H=await S(H,m),r)H=Ue(H,u);if(t.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;if(t.titlebarHidden)if(H.includes("<head>"))H=H.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else H=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${H}`;if(_.boundaries&&_.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Pe}=await import("./chunk-y10eaxgc.js");return Pe(Oe(H,_.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:Z,headers:{"Content-Type":"text/html",...U(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(I.length>0){let _=I.map((Z)=>Z.route),ie=$r(M.pathname,_);if(ie){let Z=L.get(ie.route.pattern);if(!Z||ie.route.isDynamic){let ae=await E(ie.route,ie.params);if(ae){if(Z=ae,!ie.route.isDynamic)L.set(ie.route.pattern,ae)}}if(Z){let ae=Z.content;if(k)ae=us(k,ae);if(Object.keys(ie.params).length>0)ae=St(ae,ie.params);if(ae=await S(ae,m),r)ae=Ue(ae,u);return new Response(ae,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of oe)if(Z!=="/"&&M.pathname.startsWith(Z)){let ae=L.get(Z)||L.get(Z+"/");if(!ae){let fe=I.find(({route:H})=>H.pattern===Z||H.pattern===`${Z}/`);if(fe){let H=await E(fe.route);if(H)ae=H,L.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=us(k,fe);if(fe=await S(fe,m),r)fe=Ue(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Dt(M.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let _=We.content;if(_=await S(_,m),r)_=Ue(_,u);if(t.native)if(_.includes("<head>"))_=_.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else _="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+_;return new Response(_,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await se(404);if(de){let _=de;if(_=await S(_,m),r)_=Ue(_,u);return new Response(_,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let M=await se(500);if(M)return new Response(M,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
|
|
1006
1006
|
${T.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1007
1007
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1008
1008
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Xe}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1009
|
-
${e.yellow}Routes:${e.reset}`);let Ct=[...
|
|
1010
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)ot();kt.stop()}),t.native){let T,M=te.join(A,"index.stx");if(me.existsSync(M)){let Q=await Bun.file(M).text();T=gt(Q)}let z=h?.app?.window??{};await Ye(Xe,{title:h?.app?.head?.title||te.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),M=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([m,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let V of Object.values(J.resources)){if(!me.existsSync(V))continue;let ue=me.realpathSync(V);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${te.sep}`)))N.add(ue)}for(let[J,V]of z)if(!N.has(J))V.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(V,ue)=>{Te(J,V,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,J,V)=>(X=X.catch(()=>{}).then(()=>be(N,J,V)),X),be=async(N,J,V)=>{if(!V||xt(V))return;if(yt(V)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),W.splice(0,W.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Q()}if(T(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),r&&p)p.reload(V)}else if(M(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-
|
|
1009
|
+
${e.yellow}Routes:${e.reset}`);let Ct=[...Ks(W,m)];for(let{route:T}of I)Ct.push(`${T.pattern}`);if(Ct.forEach((T,M)=>{let Q=M===Ct.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${T}`)}),console.log(`
|
|
1010
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)ot();kt.stop()}),t.native){let T,M=te.join(A,"index.stx");if(me.existsSync(M)){let Q=await Bun.file(M).text();T=gt(Q)}let z=h?.app?.window??{};await Ye(Xe,{title:h?.app?.head?.title||te.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),M=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([m,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let V of Object.values(J.resources)){if(!me.existsSync(V))continue;let ue=me.realpathSync(V);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${te.sep}`)))N.add(ue)}for(let[J,V]of z)if(!N.has(J))V.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(V,ue)=>{Te(J,V,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,J,V)=>(X=X.catch(()=>{}).then(()=>be(N,J,V)),X),be=async(N,J,V)=>{if(!V||xt(V))return;if(yt(V)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),W.splice(0,W.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Q()}if(T(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),r&&p)p.reload(V)}else if(M(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-0f2d61b3.js");ue(te.resolve(N,V)),G.delete(te.resolve(N,V))}catch{}if(P&&V){if(te.resolve(N,V)===P||te.basename(P)===V){let G=await Lo(P,t.stxOptions||{});if(G)k=G}}if(await Ne(),await vr(m),r&&p)p.reload(V)}else{console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-0f2d61b3.js");ue(te.resolve(N,V)),G.delete(te.resolve(N,V))}catch{}if(await Ne(),r&&p)p.reload(V)}}else if(ht(V)){if(console.log(`${e.cyan}CSS ${V} changed${e.reset}`),r&&p)p.updateCss(V)}};Q(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)ot();kt.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Jn(n){try{let o=(await Bun.file(n).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],r=[],p=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=p.exec(d))!==null){let m=u[1],x=u[2]||u[3]||u[4];if(!x)continue;let h={name:x},b=m.match(/@type\s+\{([^}]+)\}/i);if(b)h.type=b[1].trim();if(m.match(/@required/i))h.required=!0;let R=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(R)h.default=R[1].trim();let O=m.split(`
|
|
1011
1011
|
`).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);h.description=O.join(" ").trim(),r.push(h)}if(r.length===0){let m=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(m){let h=m[1].split(",").map((b)=>b.trim()).filter(Boolean);for(let b of h){let[C]=b.split(":").map((R)=>R.trim());if(C)r.push({name:C})}}}return r}catch(t){return console.error(`Error extracting props from ${n}:`,t),[]}}async function Yn(n){try{let t=await Bun.file(n).text(),o=t.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||t.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
|
|
1012
1012
|
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Qn(n,t=!1,o){let d=it.basename(n,".stx"),r=await Jn(n),p=await Yn(n),u="";if(t&&o)u=`<${o}></${o}>`;else{let m=r.map((x)=>{if(x.type==="boolean")return`:${x.name}="true"`;return`${x.name}="value"`}).join(`
|
|
1013
1013
|
`);u=`<${d}
|
|
@@ -1146,15 +1146,15 @@ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.
|
|
|
1146
1146
|
<td>@${p.name}</td>
|
|
1147
1147
|
<td>${p.description||"-"}</td>
|
|
1148
1148
|
<td>${p.hasEndTag?"Yes":"No"}</td>
|
|
1149
|
-
</tr>`;r+="</tbody></table>";for(let p of o)if(p.example)r+=`<h3>@${p.name}</h3>`,r+=`<p>${p.description||""}</p>`,r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return r+="</body></html>",r}function or(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function sr(n){try{let{componentsDir:t,templatesDir:o,webComponentsConfig:d,customDirectives:r,config:p}=n;if(!p.enabled)return!1;let u=p.outputDir||"docs";if(await At.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),t)console.log(`Components directory: ${t}`);if(o)console.log(`Templates directory: ${o}`);console.log(`Output directory: ${u}`);let m=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),m=await Zn(t,d),console.log(`Found ${m.length} components`);let x=[];if(p.templates!==!1&&o)console.log("Generating template documentation..."),x=await er(o),console.log(`Found ${x.length} templates`);let h=[];if(p.directives!==!1)console.log("Generating directive documentation..."),h=await tr(r),console.log(`Found ${h.length} directives`);let b=p.format||"markdown",C=p.extraContent,R="",O="";switch(b){case"markdown":R=nr(m,x,h,C),O="md";break;case"html":R=rr(m,x,h,C),O="html";break;case"json":R=or(m,x,h,C),O="json";break;default:throw Error(`Unsupported documentation format: ${b}`)}let v=it.join(u,`stx-docs.${O}`);return await Bun.write(v,R),console.log(`Documentation generated: ${v}`),!0}catch(t){return console.error("Error generating documentation:",t),!1}}async function
|
|
1149
|
+
</tr>`;r+="</tbody></table>";for(let p of o)if(p.example)r+=`<h3>@${p.name}</h3>`,r+=`<p>${p.description||""}</p>`,r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return r+="</body></html>",r}function or(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function sr(n){try{let{componentsDir:t,templatesDir:o,webComponentsConfig:d,customDirectives:r,config:p}=n;if(!p.enabled)return!1;let u=p.outputDir||"docs";if(await At.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),t)console.log(`Components directory: ${t}`);if(o)console.log(`Templates directory: ${o}`);console.log(`Output directory: ${u}`);let m=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),m=await Zn(t,d),console.log(`Found ${m.length} components`);let x=[];if(p.templates!==!1&&o)console.log("Generating template documentation..."),x=await er(o),console.log(`Found ${x.length} templates`);let h=[];if(p.directives!==!1)console.log("Generating directive documentation..."),h=await tr(r),console.log(`Found ${h.length} directives`);let b=p.format||"markdown",C=p.extraContent,R="",O="";switch(b){case"markdown":R=nr(m,x,h,C),O="md";break;case"html":R=rr(m,x,h,C),O="html";break;case"json":R=or(m,x,h,C),O="json";break;default:throw Error(`Unsupported documentation format: ${b}`)}let v=it.join(u,`stx-docs.${O}`);return await Bun.write(v,R),console.log(`Documentation generated: ${v}`),!0}catch(t){return console.error("Error generating documentation:",t),!1}}async function ka(n){let t={enabled:!0,outputDir:n.output||"docs",format:n.format||"markdown",components:n.components!==!1,templates:n.templates!==!1,directives:n.directives!==!1,extraContent:n.extraContent},o=n.componentsDir||j.componentsDir,d=n.templatesDir||".";return sr({componentsDir:o,templatesDir:d,webComponentsConfig:j.webComponents,customDirectives:j.customDirectives,config:t})}var Zt={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function $o(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1150
1150
|
`;let d=n;if(o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=cr(d,o),d=ur(d,o),d=lr(d,o),o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,""),d=d.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(d=d.replace(/\r\n/g,`
|
|
1151
1151
|
`).replace(/\r/g,`
|
|
1152
1152
|
`),!d.endsWith(`
|
|
1153
1153
|
`))d+=`
|
|
1154
|
-
`;return d}function
|
|
1154
|
+
`;return d}function _a(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1155
1155
|
`;let d=n;if(d=d.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(r,p,u,m,x)=>{let h=m.split(`
|
|
1156
1156
|
`),b=h.filter((w)=>w.trim().length>0);if(b.length===0)return r;let C=Math.min(...b.map((w)=>{let A=w.match(/^( *)/);return A?A[1].length:0})),R=h.map((w)=>{if(w.trim().length===0)return"";return w.substring(C)}).join(`
|
|
1157
|
-
`),v
|
|
1157
|
+
`),v=$o(R,o).trimEnd().split(`
|
|
1158
1158
|
`).map((w)=>{if(w.trim().length===0)return"";return p+w}).join(`
|
|
1159
1159
|
`);return`${p}\`\`\`${u}
|
|
1160
1160
|
${v}
|
|
@@ -1179,7 +1179,7 @@ ${u}`}),t=t.replace(/(<\/[^>]+>)(?=<|$)/g,(r,p,u,m)=>{let x=m.substring(Math.max
|
|
|
1179
1179
|
`),t=t.replace(/^\n+/,"").replace(/\n+$/,""),t}function cr(n,t){let d=ar(n).split(`
|
|
1180
1180
|
`),r=[],p=0,u=!1,m=t.useTabs?"\t":" ".repeat(t.indentSize);for(let x=0;x<d.length;x++){let h=d[x],b=h.trim();if(b===""){r.push("");continue}let C=b.match(/<script\b/i),R=b.match(/<\/script>/i);if(u&&!R){r.push(h);continue}let O=b===">";if(Qt(b)&&!b.startsWith("<")&&!b.startsWith("@")){r.push(m.repeat(p)+b);continue}let v=b.startsWith("@end"),w=b.startsWith("@else")||b.startsWith("@elseif"),A=b.startsWith("@")&&pr(b),W=b.startsWith("<!DOCTYPE")||b.startsWith("<!doctype"),oe=b.startsWith("<!--"),I=b.startsWith("</"),L=b.startsWith("<")&&!I&&!oe&&!W,k=b.includes("/>")||dr(b),P=Qt(b);if(I||v)p=Math.max(0,p-1);let D=w?Math.max(0,p-1):p;if(O)r.push(h);else r.push(m.repeat(D)+b);if(L&&!k&&!P&&!O||A)p++;if(C)u=!0;if(R)u=!1}return r.join(`
|
|
1181
1181
|
`)}function lr(n,t){if(n=n.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(o,d,r)=>{let p=r.trim().replace(/\s+/g," ");return`@${d}(${p})`}),n=n.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(o,d,r)=>{if(r.trim()==="")return`@${d}`;return`@${d}(${r.trim()})`}),t.normalizeWhitespace)n=n.replace(/\{\{\s*([^}]+)\s*\}\}/g,(o,d)=>`{{ ${d.trim()} }}`),n=n.replace(/\{!!\s*([^!]+)\s*!!\}/g,(o,d)=>`{!! ${d.trim()} !!}`);return n}function dr(n){let t=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if(n.includes("/>"))return!0;let o=n.match(/<(\w+)/);if(o){let d=o[1];return t.includes(d.toLowerCase())}return!1}function Qt(n){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test(n)}function pr(n){let t=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let o of t)if(n.startsWith(`@${o}`))return!n.includes(`@end${o}`);return!1}function ur(n,t){if(!t.sortAttributes)return n;return n.replace(/<(\w+)([^>]*)>/g,(o,d,r)=>{if(!r.trim())return o;if(r.includes("<")||r.includes(`
|
|
1182
|
-
`)||r.includes("@"))return o;let p=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],m;while((m=p.exec(r))!==null)u.push({name:m[1],value:m[2]});u.sort((h,b)=>{if(h.name==="id")return-1;if(b.name==="id")return 1;if(h.name==="class")return-1;if(b.name==="class")return 1;return h.name.localeCompare(b.name)});let x=u.map((h)=>h.value?`${h.name}=${h.value}`:h.name).join(" ");return`<${d}${x?` ${x}`:""}>`})}import en from"fs";import Mt from"path";async function
|
|
1182
|
+
`)||r.includes("@"))return o;let p=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],m;while((m=p.exec(r))!==null)u.push({name:m[1],value:m[2]});u.sort((h,b)=>{if(h.name==="id")return-1;if(b.name==="id")return 1;if(h.name==="class")return-1;if(b.name==="class")return 1;return h.name.localeCompare(b.name)});let x=u.map((h)=>h.value?`${h.name}=${h.value}`:h.name).join(" ");return`<${d}${x?` ${x}`:""}>`})}import en from"fs";import Mt from"path";async function Ca(n="index.stx",t={}){try{let o=t.force||!1,d=Mt.resolve(process.cwd(),n);if(await Bun.file(d).exists()){if(!o)throw Error(`File ${n} already exists. Use --force to overwrite.`);console.warn(`File ${n} already exists. Overwriting...`)}let r=Mt.dirname(d);if(!en.existsSync(r))en.mkdirSync(r,{recursive:!0});let p;if(t.template){let u=Mt.resolve(process.cwd(),t.template);if(!await Bun.file(u).exists())throw Error(`Template file ${t.template} does not exist.`);if(!u.endsWith(".stx"))console.warn(`Warning: Template file ${t.template} does not have a .stx extension. Using it anyway.`);p=await Bun.file(u).text(),console.warn(`Using template from ${t.template}`)}else if(t.preset)p=tn(t.preset),console.warn(`Using '${t.preset}' preset template`);else p=tn("basic");return await Bun.write(d,p),console.warn(`Created new stx file: ${n}`),!0}catch(o){return console.error(`Error creating file: ${o instanceof Error?o.message:String(o)}`),!1}}function tn(n){switch(n){case"basic":return nn();case"component":return fr();case"layout":return mr();case"blog":return gr();case"api":return hr();case"app":return yr();default:return nn()}}function nn(){return`<script>
|
|
1183
1183
|
const title = "My stx Page"
|
|
1184
1184
|
const description = "A page built with stx"
|
|
1185
1185
|
const features = [
|
|
@@ -1605,5 +1605,5 @@ const features = [
|
|
|
1605
1605
|
})();
|
|
1606
1606
|
</script>
|
|
1607
1607
|
</body>
|
|
1608
|
-
</html>`}var
|
|
1609
|
-
`)}export{
|
|
1608
|
+
</html>`}var Ea="f9c3713";function nu(n){return n}function ru(n){return n}function xa(n,t){let o=[],d=`${t}=`;for(let r=0;r<n.length;r++){let p=n[r];if(p.startsWith(d)){let u=p.slice(d.length);if(u)o.push(u);continue}if(p===t){let u=n[r+1];if(u!==void 0&&!u.startsWith("-"))o.push(u),r++}}return o}import Ee from"fs";import ye from"path";function un(n){try{return Ee.statSync(n).mtimeMs}catch{return null}}function wt(n,t){let o=Math.max(0,Math.round((t-n)/1000));if(o<60)return`${o}s ago`;if(o<3600)return`${Math.round(o/60)}m ago`;return`${Math.round(o/3600)}h ago`}function As(n,t){try{return globalThis.Bun?.resolveSync(n,t)??null}catch{return null}}function fn(n,t="stx"){let o=ye.resolve(n);for(let d=0;d<10;d++){let r=ye.join(o,"pantry","@stacksjs",t);if(Ee.existsSync(r))return r;let p=ye.dirname(o);if(p===o)break;o=p}return null}var mn=["@stacksjs/stx","bun-plugin-stx"];function Ds(n){try{let t=Ee.readFileSync(ye.join(n,"package.json"),"utf8"),o=JSON.parse(t)?.version;return typeof o==="string"?o:null}catch{return null}}function Ms(n,t=6){let o=ye.resolve(n),d=[],r=new Set;function p(m,x){if(x>t)return;let h;try{h=Ee.realpathSync(m)}catch{return}if(r.has(h))return;r.add(h);for(let C of mn){let R=ye.join(m,C),O=Ds(R);if(O!==null)d.push({name:C,version:O,dir:ye.relative(o,R)||R,nested:x>0})}let b;try{b=Ee.readdirSync(m,{withFileTypes:!0})}catch{return}for(let C of b){if(!C.isDirectory()&&!C.isSymbolicLink())continue;if(C.name===".bin"||C.name===".cache")continue;let R=ye.join(m,C.name);if(C.name.startsWith("@")){let v;try{v=Ee.readdirSync(R,{withFileTypes:!0})}catch{continue}for(let w of v){let A=ye.join(R,w.name,"node_modules");if(Ee.existsSync(A))p(A,x+1)}continue}let O=ye.join(R,"node_modules");if(Ee.existsSync(O))p(O,x+1)}}let u=ye.join(o,"node_modules");if(Ee.existsSync(u))p(u,0);return d}function Ls(n){let t=[];for(let o of mn){let d=n.filter((u)=>u.name===o);if(d.length<=1)continue;let r=[...new Set(d.map((u)=>u.version))],p=d.map((u)=>`${u.version} at ${u.dir}`).join("; ");if(r.length===1){t.push({name:`${o} copies`,status:"info",detail:`${d.length} copies, all ${r[0]} \u2014 duplicated but in agreement`});continue}t.push({name:`${o} copies disagree`,status:"error",detail:`${r.length} versions installed, so which one runs depends on who imports it: ${p}`,fix:`remove the nested copies, or add an overrides entry pinning ${o}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${o}/package.json' -exec grep -H '"version"' {} +`})}return t}async function Ro(n={}){let t=n.cwd?ye.resolve(n.cwd):process.cwd(),o=n.resolve??As,d=Date.now(),r=[],p=o("@stacksjs/stx",t);r.push(p?{name:"@stacksjs/stx resolves to",status:"ok",detail:p}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let u=o("bun-plugin-stx",t);if(u)r.push({name:"bun-plugin-stx resolves to",status:"ok",detail:u});for(let x of Ls(Ms(t)))r.push(x);let m=fn(t,"stx");if(!m)r.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let x=ye.join(m,"src/signals.ts"),h=[ye.join(m,"dist/index.js"),ye.join(m,"dist/signals.js")].find((v)=>Ee.existsSync(v))||null,b=un(x),C=h?un(h):null;if(b==null)r.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${m} but no src/signals.ts to compare`});else if(C==null)r.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${m} && bun build.ts`});else if(C<b){let v=Math.round((b-C)/1000);r.push({name:"pantry dist freshness",status:"error",detail:`dist (${wt(C,d)}) is OLDER than src/signals.ts (${wt(b,d)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${m} && bun build.ts`})}else r.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${wt(b,d)}, dist ${wt(C,d)})`});let R=ye.join(t,"node_modules/@stacksjs/stx"),O=null;try{O=Ee.lstatSync(R)}catch{O=null}if(!O)r.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(O.isSymbolicLink()){let v=null;try{v=Ee.realpathSync(R)}catch{}let w=(()=>{try{return Ee.realpathSync(m)}catch{return m}})();r.push(v===w?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else r.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(r.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),n.generateRuntime)try{let h=n.generateRuntime().length;r.push(h>1000?{name:"signals runtime",status:"ok",detail:`generated ${h.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${h} chars \u2014 suspiciously short`})}catch(x){r.push({name:"signals runtime",status:"error",detail:`failed to generate: ${x.message}`})}return{checks:r,ok:!r.some((x)=>x.status==="error")}}function Ao(n){let t={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},o=["stx runtime resolution:"];for(let d of n.checks)if(o.push(` ${t[d.status]} ${d.name}: ${d.detail}`),d.fix)o.push(` \u2192 ${d.fix}`);return o.push(""),o.push(n.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),o.join(`
|
|
1609
|
+
`)}export{xa,Sa,ka,$o,_a,Ca,Ea,nu,ru,Ro,Ao,ss,os,is};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{vn,Zo,Qo,ei,ry,ti}from"./chunk-becs8132.js";import"./chunk-vw7crz0z.js";import"./chunk-0b57fgpn.js";import"./chunk-esm0pnpz.js";export{Qo as buildServerApi,ry as createServerApi,vn as discoverServerApi,Zo as generateApiTypes,ti as isServerApiSource,ei as productionApiDispatcher};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import l from"fs";import u from"path";var m=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,g=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,b=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],x=3;function h(e,t){let r=u.resolve(u.dirname(t),e);for(let o of b){let s=r+o;try{if(l.statSync(s).isFile())return s}catch{}}return null}function
|
|
3
|
-
export{
|
|
2
|
+
import l from"fs";import u from"path";var m=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,g=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,b=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],x=3;function h(e,t){let r=u.resolve(u.dirname(t),e);for(let o of b){let s=r+o;try{if(l.statSync(s).isFile())return s}catch{}}return null}function Yr(e,t,r=0,o=new Set){if(!t||r>=x)return!1;for(let s of e.matchAll(g)){let n=h(s[1],t);if(!n||o.has(n))continue;o.add(n);let i;try{i=l.readFileSync(n,"utf8")}catch{continue}if(m.test(i))return!0;if(Yr(i,n,r+1,o))return!0}return!1}var C=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"],Fl=["onMount","onDestroy"];function xt(e="const",t=[],r){let o=t.length?C.filter((s)=>!t.includes(s)):C;if(r!==void 0)o=o.filter((s)=>{let n=s.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${n}(?![\\w$])`).test(r)});return`${e} { ${o.join(", ")} } = window.stx;`}var y=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var S=C.filter((e)=>!y.includes(e));function na(e){if(!e)return!1;return S.some((t)=>new RegExp(`\\b${t}\\s*(?:<[^>]*>)?\\s*\\(`).test(e))}var v=[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\s:[a-z][\w-]*\s*=\s*["']/i,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/],E=/\s@[a-z][\w.:-]*\s*=/i;function zl(e,t){if(!e)return!1;let r=f(e);return d(r,t)}function d(e,t){if(v.some((r)=>r.test(e)))return!0;if(na(e))return!0;return T(e,t)}function T(e,t){if(!t)return!1;for(let r of e.matchAll(/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script\s*>/gi))if(Yr(r[1],t))return!0;return!1}function Hl(e,t){if(!e)return!1;let r=f(e);return E.test(r)||d(r,t)}var R=["if","else-if","elseif","else","for","show","key","text","html","model","ref"];function Vl(e){return R.includes(e.toLowerCase())}var vo=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],_=["x-init","x-transition","x-effect","x-on"],Ul=[...vo,..._];function Wl(){return`{${vo.map((e)=>`'${e}':1`).join(",")}}`}var ra=["class","style","text","html","show","model","if","ref"];function ql(){return`{${ra.map((e)=>e==="if"?"'if':1":`${e}:1`).join(",")}}`}var p=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","keydown","keyup","keypress","input","change","submit","focus","blur","scroll","resize","touchstart","touchend","touchmove","contextmenu","wheel","pointerdown","pointerup","pointermove"];function Kl(){return`/^(${p.join("|")})(?:\\.|$)/`}function Gl(e){return p.some((t)=>e===t||e.startsWith(`${t}.`))}var w=65536,A=4,c=new Map;function f(e){if(!e)return e;if(!e.includes("<!--")&&!/<(?:pre|code)\b/i.test(e))return e;let t=e.length>=w;if(t){let s=c.get(e);if(s!==void 0)return s}let r=(s)=>s.replace(/(<[^>]*>)|([^<]+)/g,(n,i,a)=>i??" ".repeat(a.length)),o=e.replace(/(<pre\b[^>]*>)([\s\S]*?)(<\/pre>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/(<code\b[^>]*>)([\s\S]*?)(<\/code>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/<!--[\s\S]*?-->/g,(s)=>" ".repeat(s.length));if(t){while(c.size>=A){let s=c.keys().next();if(s.done)break;c.delete(s.value)}c.set(e,o)}return o}
|
|
3
|
+
export{Yr,C,Fl,xt,na,zl,Hl,Vl,vo,Ul,Wl,ra,ql,Kl,Gl};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as
|
|
3
|
-
export{
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as Vm}from"ts-broadcasting";import{Broadcast as Um,BroadcastServer as Wm}from"ts-broadcasting";var e=null,u=[];function Mm(){return e}async function Dm(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Lm(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function jm(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();mu(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function mu(n,t,r){if(!i())return;s.send(n,t,r)}function Bm(n,t,r){if(!i())return;s.toUser(n,t,r)}function Fm(n,t,r){if(!i())return;s.toUsers(n,t,r)}function zm(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function Hm(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{Mm,Dm,Lm,jm,mu,Bm,Fm,zm,Hm,Vm,Um,Wm};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{fy,Ps,pi,Is,Sr,fi,gi,gg,Os,Ns,Ms,mi,Mc,mg,Ot}from"./chunk-8rgy17fj.js";import"./chunk-e0bwzxfd.js";import"./chunk-vbmvft7g.js";import"./chunk-40fpt0r6.js";import"./chunk-rapr0m13.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{X}from"./chunk-9m45t60c.js";import"./chunk-472w7t7p.js";import"./chunk-esm0pnpz.js";import"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{gg as bindLoopInterpolations,fy as clearScriptScanCache,Os as convertServerLoopAttributesToDirectives,fi as convertSignalDirectivesToAttributes,Ns as convertSignalLoopsToAttributes,Sr as extractClientSignalNames,X as extractExports,Mc as findMarkupIndexOutsideScripts,Is as hasSignalsSyntax,pi as parseLoopExpression,gi as preEvalLiteralReactiveIfs,Ms as processScriptSetup,mi as processSignals,mg as rewriteStxImportSpecifiers,Ps as scanScriptTags,Ot as stripStxRuntimeImports};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ci,Ei,Dt,Se,$r,Ws,Rr,qs,Ks,xg,Sg,kg,Ar,_g,Cg,Eg,Tg,Yc,Zc,Qc,Ti,el,$g,Lt,jt,Bt,Ft,zt,Ht,ft,Rg}from"./chunk-0b57fgpn.js";export{Rr as Router,Eg as abortNavigation,Ws as bracketPathToRegex,Lt as clearMiddleware,Zc as createClientCookieManager,zt as createMiddlewareContext,Ft as createRouteLocation,Yc as createServerCookieManager,Qc as createStorageManager,Tg as defineMiddleware,Sg as defineRoute,kg as defineRoutes,qs as findErrorPage,Ks as formatRoutes,Ei as generateRouteManifest,Ci as generateRouteTypes,el as getMiddleware,jt as getMiddlewareNames,ft as getRouterScript,Rg as getRouterScriptDev,$g as hasMiddleware,Dt as isFileRequestPath,Bt as loadMiddlewareFromDirectory,$r as matchRoute,Cg as navigateTo,Se as patternToRegex,Ti as registerMiddleware,_g as resetRoutes,Ar as route,Ht as runMiddleware,xg as setAppUrl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B,
|
|
2
|
+
import{B,dl,io,An,y,Ke,Ge}from"./chunk-9m45t60c.js";import{Tr,dt,q}from"./chunk-40fpt0r6.js";import{yr,i}from"./chunk-r9n86na1.js";import{Ae}from"./chunk-e0bwzxfd.js";import{ia}from"./chunk-p92272k0.js";function h(s){return s.endsWith(".md")||s.endsWith(".markdown")}function C(s){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let g;while((g=n.exec(s))!==null){let t=g.index,o=t+g[0].length;if(p?.some((l)=>t>=l.start&&o<=l.end))continue;e.push({start:t,end:o})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function b(s,e={}){let{data:r,content:m}=Tr(s),a=await(e.renderer??((n)=>dt(n)))(m);return{html:C(a),frontmatter:r??{}}}import{dirname as k,resolve as R}from"path";function v(s){let e=s,r=B(s);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(o)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(o),g;while((g=m.exec(s))!==null){let o=g[1],l=g[2],d=g[0],u=o.includes("server");if(p(l))n.push(d);else if(u)a.push(l);else c.push(d)}let t=e;{let o=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=o.exec(t))!==null){let u=l.index+l[0].length,f=t.indexOf("</script>",u);if(f===-1)continue;d.push({start:l.index,end:f+9}),o.lastIndex=f+9}for(let u=d.length-1;u>=0;u--)t=t.substring(0,d[u].start)+t.substring(d[u].end)}for(let o of c)t=t.replace(o,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function M(s,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -9,8 +9,8 @@ import{B,ul,oo,Rn,y,Ke,Ge}from"./chunk-0vrt55pp.js";import{Er,dt,q}from"./chunk-
|
|
|
9
9
|
<body>
|
|
10
10
|
${s}
|
|
11
11
|
</body>
|
|
12
|
-
</html>`}async function
|
|
12
|
+
</html>`}async function xc(s,e={}){let r=R(s),m=Bun.file(r);if(!await m.exists())throw Error(`Template file not found: ${r}`);let c=await m.text(),a=null;if(h(r)){let n=await b(c,{renderer:e.markdownRenderer});c=n.html,a=n.frontmatter}if(a)e={...e,context:{...a,...e.context||{}}};if(e.layout){let n=R(e.layout),p=Bun.file(n);if(!await p.exists())throw Error(`Layout template not found: ${n}`);let{layout:g,injectCSS:t,...o}=e,l={...e.context||{}};An(l);let d=await w(c,r,{...o,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),u=await p.text(),f={...l,content:d},x={...o,context:f,injectCSS:t};return w(u,n,x)}return w(c,r,e)}async function w(s,e,r={}){let{templateContent:m,serverScripts:c,clientScripts:a}=v(s),n={...q,...r.options},p={__filename:e,__dirname:k(e),__stx:{},__stx_options:n,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...io(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let o of c)await y(o,p,e);let g=new Set,t=m;if(t=await i(t,p,e,n,g),dl(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),a.length>0)t+=`
|
|
13
13
|
${a.join(`
|
|
14
|
-
`)}`}else{if(r.processClientScripts!==!1&&a.length>0){let o=p.__stx_event_bindings||[],l=Ke(p),d=await Promise.all(a.map(async(x)=>{let _=x.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(_))return x;let S=x.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!S)return x;return await Ge(S[1],{eventBindings:o,templateContent:t,serverData:l,filePath:e})})),f=[await
|
|
15
|
-
`);t=
|
|
16
|
-
export{
|
|
14
|
+
`)}`}else{if(r.processClientScripts!==!1&&a.length>0){let o=p.__stx_event_bindings||[],l=Ke(p),d=await Promise.all(a.map(async(x)=>{let _=x.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(_))return x;let S=x.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!S)return x;return await Ge(S[1],{eventBindings:o,templateContent:t,serverData:l,filePath:e})})),f=[await yr(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
|
|
15
|
+
`);t=ia(t,f)}t=await Ae(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:o}=await import("./chunk-p4hm5srd.js");t=await o(t)}catch{}return t}
|
|
16
|
+
export{xc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{dy,py,dg,Rs}from"./chunk-eka2e4cm.js";import"./chunk-9vafweyd.js";import"./chunk-5jrpzepc.js";import"./chunk-vbmvft7g.js";import{Br}from"./chunk-9m45t60c.js";import"./chunk-472w7t7p.js";import"./chunk-esm0pnpz.js";import{yt}from"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{yt as freeIdentifiers,Rs as processComponents,dg as processESImports,Br as rendersAsElement,dy as resetMarginStackWarnings,py as resetTemplateLoopWarnings};
|