@stacksjs/stx 0.2.917 → 0.2.919
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-shell.js +3 -2
- package/dist/{chunk-frpsrv1e.js → chunk-09xqy448.js} +2 -2
- package/dist/chunk-0ebaf0pr.js +2 -0
- package/dist/chunk-0jjq552g.js +2 -0
- package/dist/chunk-0wctbtad.js +7 -0
- package/dist/{chunk-r7y1196g.js → chunk-0xyfs691.js} +4 -4
- package/dist/{chunk-w98yt4d4.js → chunk-14df2jzs.js} +2 -2
- package/dist/chunk-15rc8t28.js +2 -0
- package/dist/chunk-1a2c4pv8.js +54 -0
- package/dist/{chunk-ezqfrea9.js → chunk-1baxccfq.js} +18 -18
- package/dist/{chunk-0vyytd9v.js → chunk-1bf0grbf.js} +3 -3
- package/dist/chunk-1jrhjn2b.js +2 -0
- package/dist/chunk-1svffhzq.js +2 -0
- package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
- package/dist/{chunk-88fx8xc1.js → chunk-1vsjmwr1.js} +2 -2
- package/dist/{chunk-cxsc37fg.js → chunk-2f46pcg0.js} +2 -2
- package/dist/{chunk-ma5ptt4m.js → chunk-2jm7map2.js} +2 -2
- package/dist/chunk-2m4ydym0.js +33 -0
- package/dist/chunk-2mv29s6w.js +9 -0
- package/dist/{chunk-h0aw9hmc.js → chunk-2szhk8mh.js} +5 -5
- package/dist/{chunk-gg715pj6.js → chunk-2zb642qr.js} +6 -6
- package/dist/chunk-3aayrnbh.js +21 -0
- package/dist/chunk-3br07y64.js +20 -0
- package/dist/{chunk-2f5jjxcj.js → chunk-3efpqm1f.js} +2 -2
- package/dist/{chunk-fn1reean.js → chunk-3ftrv1f7.js} +7 -7
- package/dist/{chunk-yq2krsc9.js → chunk-3hfv217t.js} +6 -6
- package/dist/{chunk-eptzpvn0.js → chunk-3kpxkjgm.js} +3 -3
- package/dist/{chunk-mf5cqv1k.js → chunk-3tcy9r6r.js} +27 -27
- package/dist/{chunk-zv3rn0ch.js → chunk-40j2pmnb.js} +6 -6
- package/dist/chunk-426gq0g5.js +2 -0
- package/dist/chunk-4ge80k8j.js +2 -0
- package/dist/chunk-4vdfqr64.js +2 -0
- package/dist/chunk-4yz33vzb.js +2 -0
- package/dist/chunk-4zcswx6x.js +2 -0
- package/dist/{chunk-w6ydg43d.js → chunk-50zzar2c.js} +3 -3
- package/dist/{chunk-vayzmvf5.js → chunk-514yg4dr.js} +6 -6
- package/dist/{chunk-388xpdw5.js → chunk-5fdc8pej.js} +73 -33
- package/dist/chunk-5ht628zp.js +2 -0
- package/dist/chunk-67zy5p7x.js +2 -0
- package/dist/chunk-6bm7t0hm.js +3 -0
- package/dist/{chunk-wj9bqkc0.js → chunk-6n6kndk0.js} +1 -1
- package/dist/chunk-6x5a2w5a.js +3 -0
- package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
- package/dist/{chunk-23x3k751.js → chunk-7axtwg1f.js} +2 -2
- package/dist/chunk-8153bfpx.js +2 -0
- package/dist/{chunk-16sfjkc4.js → chunk-858p3hkz.js} +2 -2
- package/dist/chunk-86p0m920.js +2 -0
- package/dist/chunk-88texeh4.js +2 -0
- package/dist/chunk-8mye65n9.js +2 -0
- package/dist/chunk-8ycgk8w6.js +2 -0
- package/dist/{chunk-npj20tj9.js → chunk-9707zz6v.js} +2 -2
- package/dist/{chunk-pyyda92j.js → chunk-9gr7m3tb.js} +1 -1
- package/dist/{chunk-952dfmcb.js → chunk-9mack1g8.js} +3 -3
- package/dist/chunk-9xcsn4pb.js +2 -0
- package/dist/{chunk-3jc6yb02.js → chunk-9zwmfkfg.js} +9 -9
- package/dist/chunk-a5tg553d.js +2 -0
- package/dist/chunk-agxxqjjt.js +2 -0
- package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
- package/dist/chunk-b44pvac7.js +2 -0
- package/dist/chunk-b4yp16a2.js +2 -0
- package/dist/{chunk-95j8660f.js → chunk-cbqe84g3.js} +2 -2
- package/dist/{chunk-qsexsrw2.js → chunk-d4xjwebv.js} +5 -5
- package/dist/{chunk-0v7555tr.js → chunk-d69k67bn.js} +11 -11
- package/dist/chunk-ex6dne7e.js +3 -0
- package/dist/chunk-fb63xppz.js +2 -0
- package/dist/chunk-ffqqkeye.js +2 -0
- package/dist/chunk-fjpt8arw.js +3 -0
- package/dist/{chunk-mgj074y2.js → chunk-fn0y9z1t.js} +5 -5
- package/dist/{chunk-ar6jeqmm.js → chunk-ft34x0h1.js} +4 -4
- package/dist/{chunk-t65f98qv.js → chunk-fwxgzktt.js} +2 -2
- package/dist/chunk-g1v12bjm.js +2 -0
- package/dist/chunk-gg0kkn2e.js +2 -0
- package/dist/chunk-ggg8b8n1.js +2 -0
- package/dist/chunk-ggrcg7k7.js +2 -0
- package/dist/{chunk-11c7xg1z.js → chunk-gjyz5ma7.js} +1 -1
- package/dist/chunk-gmn9ba8f.js +3 -0
- package/dist/chunk-gqe574d9.js +2 -0
- package/dist/chunk-h4nqjks2.js +2 -0
- package/dist/chunk-hajamm16.js +2 -0
- package/dist/chunk-hg2n2264.js +2 -0
- package/dist/{chunk-wm24jx3t.js → chunk-hht7n4zd.js} +2 -2
- package/dist/chunk-hxabvt31.js +2 -0
- package/dist/chunk-j3sat6vn.js +2 -0
- package/dist/chunk-j9gbnqxq.js +2 -0
- package/dist/{chunk-1hbf5e1h.js → chunk-jgtn9t5n.js} +2 -2
- package/dist/chunk-jj2z4nxa.js +2 -0
- package/dist/{chunk-0jdz31q1.js → chunk-jjq7c8s2.js} +3 -3
- package/dist/chunk-k289127j.js +2 -0
- package/dist/{chunk-p3fepzt9.js → chunk-kk9h53xg.js} +3 -3
- package/dist/{chunk-xnp031ba.js → chunk-ktv65e3n.js} +7 -7
- package/dist/chunk-m1hfh2t4.js +2 -0
- package/dist/{chunk-ngqb22wj.js → chunk-m390z8w8.js} +9 -9
- package/dist/chunk-m3qwqhxp.js +2 -0
- package/dist/{chunk-da05660m.js → chunk-m6hrb7rm.js} +58 -58
- package/dist/{chunk-789yp1tg.js → chunk-m86sjbx7.js} +3 -3
- package/dist/chunk-m9smh7fs.js +2 -0
- package/dist/{chunk-1jvt9t3r.js → chunk-m9ta0640.js} +2 -2
- package/dist/chunk-mhnjtc42.js +2 -0
- package/dist/{chunk-hhspwfva.js → chunk-mn9t5fnv.js} +2 -2
- package/dist/{chunk-36cz2v8k.js → chunk-mnpfvxpa.js} +31 -31
- package/dist/{chunk-2vx2ben8.js → chunk-mr9pp5cf.js} +2 -2
- package/dist/{chunk-1jxkc6d0.js → chunk-mztjpp7m.js} +2 -2
- package/dist/chunk-n4bxb2hx.js +2 -0
- package/dist/chunk-n958bxm6.js +2 -0
- package/dist/{chunk-8wqhzzkn.js → chunk-neymp1bb.js} +3 -3
- package/dist/chunk-nkbnsbb0.js +3 -0
- package/dist/chunk-nkr1aa5z.js +2 -0
- package/dist/{chunk-nhyv3w4r.js → chunk-p0xqm2ne.js} +1 -1
- package/dist/chunk-p3vswt0f.js +2 -0
- package/dist/{chunk-z110bf2c.js → chunk-p3x7kwb5.js} +7 -7
- package/dist/chunk-p4twxjfs.js +6 -0
- package/dist/chunk-p8wnp4p1.js +2 -0
- package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
- package/dist/chunk-pjv4dskp.js +2 -0
- package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
- package/dist/chunk-pxvp0cc9.js +3 -0
- package/dist/chunk-q3z252d9.js +2 -0
- package/dist/{chunk-p3x84jj0.js → chunk-qda8tmk9.js} +2 -2
- package/dist/chunk-qfkak3jb.js +2 -0
- package/dist/chunk-qnytvyy0.js +2 -0
- package/dist/{chunk-fznjm7qt.js → chunk-qsnw0qyp.js} +2 -2
- package/dist/{chunk-ftvpz1j4.js → chunk-qtzfbv7e.js} +5 -5
- package/dist/{chunk-dwt2drzf.js → chunk-qzqqzraq.js} +8 -8
- package/dist/{chunk-v78hjbz0.js → chunk-rk16391e.js} +3 -3
- package/dist/chunk-rt7xy537.js +2 -0
- package/dist/chunk-rwjye578.js +2 -0
- package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
- package/dist/{chunk-n4m50dpk.js → chunk-sbr3wg75.js} +65 -65
- package/dist/chunk-sftznswb.js +2 -0
- package/dist/{chunk-cq4cwfqf.js → chunk-sxrcac01.js} +2 -2
- package/dist/{chunk-fzcqw147.js → chunk-tb4be5ct.js} +3 -3
- package/dist/{chunk-m8n14s3z.js → chunk-tnbzg7fd.js} +2 -2
- package/dist/{chunk-jr2r2nh5.js → chunk-txk2z7v0.js} +4 -4
- package/dist/chunk-tz5ktd6d.js +2 -0
- package/dist/{chunk-302nw40c.js → chunk-v060015m.js} +1 -1
- package/dist/chunk-v1a5h1tc.js +38 -0
- package/dist/{chunk-8b8az19t.js → chunk-v1x96kjr.js} +8 -8
- package/dist/chunk-vb609vbj.js +1323 -0
- package/dist/chunk-vf7tpgqz.js +70 -0
- package/dist/chunk-vtcyber4.js +2 -0
- package/dist/chunk-vtj3dwhh.js +4 -0
- package/dist/{chunk-bm6y085n.js → chunk-whnzf9hn.js} +5 -5
- package/dist/chunk-wq2bpt0w.js +2 -0
- package/dist/{chunk-sdmq09jw.js → chunk-wv0wsavj.js} +2 -2
- package/dist/chunk-wv8zt78c.js +2 -0
- package/dist/{chunk-nwef47nx.js → chunk-wxqay5c2.js} +1 -1
- package/dist/{chunk-gfp39bzr.js → chunk-x40j67z1.js} +2 -2
- package/dist/chunk-xakqpa4z.js +3 -0
- package/dist/{chunk-0asdv3hk.js → chunk-xap1f1bw.js} +2 -2
- package/dist/{chunk-ywrpmyzj.js → chunk-xk7hdpq5.js} +3 -3
- package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
- package/dist/{chunk-0sj79ha5.js → chunk-xpsg91dh.js} +5 -5
- package/dist/{chunk-va4xam1q.js → chunk-xq5s4vc1.js} +1 -1
- package/dist/chunk-xy3ex6ht.js +2 -0
- package/dist/chunk-y899wtm8.js +2 -0
- package/dist/chunk-ye45znz5.js +2 -0
- package/dist/chunk-yegp50jb.js +2 -0
- package/dist/chunk-yq9aqpk8.js +2 -0
- package/dist/{chunk-f0sxbgbm.js → chunk-yvaqgdv1.js} +2 -2
- package/dist/{chunk-c13dv3wm.js → chunk-yye2pec5.js} +14 -14
- package/dist/{chunk-mt5ewkbg.js → chunk-yzqb7y45.js} +6 -6
- package/dist/{chunk-91p8p2cc.js → chunk-z6nyyt3n.js} +6 -6
- package/dist/{chunk-fs43342z.js → chunk-zaj3nnvv.js} +2 -2
- package/dist/{chunk-2qk2ppgm.js → chunk-zb6my502.js} +1 -1
- package/dist/{chunk-ra2tzsvz.js → chunk-zrxvj3zf.js} +5 -5
- package/dist/chunk-zt45dqfx.js +2 -0
- package/dist/cli.js +38 -38
- package/dist/color-mode-boot.d.ts +1 -8
- package/dist/color-mode-boot.js +46 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/document-shell.d.ts +2 -0
- package/dist/document-shell.js +15 -3
- package/dist/document-tags.d.ts +2 -0
- package/dist/document-tags.js +9 -0
- package/dist/head-injection.d.ts +2 -0
- package/dist/head-injection.js +1 -0
- package/dist/head.d.ts +2 -0
- package/dist/head.js +2 -2
- package/dist/native/compiler/html-to-ir.js +1 -0
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/native/event-names.js +2 -0
- package/dist/native/runtime/browser-renderer.d.ts +1 -0
- package/dist/native/runtime/browser-renderer.js +23 -6
- package/dist/native/testing.d.ts +1 -0
- package/dist/native/testing.js +33 -0
- package/dist/page-head.js +1 -9
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +13 -13
- package/dist/types/config-types.d.ts +1 -1
- package/dist/variable-extractor.js +6 -1
- package/package.json +5 -5
- package/dist/chunk-0adc8x2h.js +0 -9
- package/dist/chunk-0atz8fjx.js +0 -20
- package/dist/chunk-0fm6avxt.js +0 -3
- package/dist/chunk-11rnqey0.js +0 -2
- package/dist/chunk-1mx3j280.js +0 -2
- package/dist/chunk-20hy5p3p.js +0 -2
- package/dist/chunk-29v3b5ks.js +0 -2
- package/dist/chunk-2cay3heb.js +0 -2
- package/dist/chunk-31yx4sjh.js +0 -2
- package/dist/chunk-33fnbw33.js +0 -2
- package/dist/chunk-357qjcj1.js +0 -3
- package/dist/chunk-38kerh2r.js +0 -2
- package/dist/chunk-38y11q8x.js +0 -2
- package/dist/chunk-3h4db9yb.js +0 -33
- package/dist/chunk-3q80f7mt.js +0 -2
- package/dist/chunk-43kz6rx9.js +0 -2
- package/dist/chunk-43sgpy4e.js +0 -54
- package/dist/chunk-4e18r89n.js +0 -3
- package/dist/chunk-4pve3r5a.js +0 -2
- package/dist/chunk-4vz17ytv.js +0 -68
- package/dist/chunk-5afnyvw5.js +0 -2
- package/dist/chunk-5d5dxts6.js +0 -2
- package/dist/chunk-5fdsyyfe.js +0 -2
- package/dist/chunk-67yr4m5h.js +0 -2
- package/dist/chunk-6aqr0e6s.js +0 -2
- package/dist/chunk-6bw02d1t.js +0 -2
- package/dist/chunk-76mn123c.js +0 -2
- package/dist/chunk-7ar11ccn.js +0 -2
- package/dist/chunk-7fc0vrs5.js +0 -2
- package/dist/chunk-82fg5gp6.js +0 -2
- package/dist/chunk-89r7bbsk.js +0 -2
- package/dist/chunk-8egbh6z1.js +0 -2
- package/dist/chunk-8n9jd8cz.js +0 -2
- package/dist/chunk-8tfpv6zf.js +0 -6
- package/dist/chunk-8x3yaahc.js +0 -2
- package/dist/chunk-94qc4zwb.js +0 -2
- package/dist/chunk-9928zdej.js +0 -3
- package/dist/chunk-9ay18k46.js +0 -2
- package/dist/chunk-9kn81bmp.js +0 -2
- package/dist/chunk-9tv0tw7f.js +0 -3
- package/dist/chunk-9w9y84t5.js +0 -21
- package/dist/chunk-a5h9bwrc.js +0 -2
- package/dist/chunk-b5qzed8y.js +0 -1323
- package/dist/chunk-bej9kz05.js +0 -2
- package/dist/chunk-bh2khcet.js +0 -2
- package/dist/chunk-c6096ssb.js +0 -2
- package/dist/chunk-ccgabq3a.js +0 -2
- package/dist/chunk-e0tvd7jj.js +0 -2
- package/dist/chunk-e5rag6rh.js +0 -3
- package/dist/chunk-fvr3h2fr.js +0 -7
- package/dist/chunk-gmmqz698.js +0 -2
- package/dist/chunk-hxftzw0x.js +0 -2
- package/dist/chunk-js1wayhb.js +0 -2
- package/dist/chunk-jz37h2z0.js +0 -4
- package/dist/chunk-k2t0w8z1.js +0 -2
- package/dist/chunk-k8s3hyh2.js +0 -2
- package/dist/chunk-kcpxqsdj.js +0 -2
- package/dist/chunk-mjr5fkc2.js +0 -2
- package/dist/chunk-na0e3s88.js +0 -2
- package/dist/chunk-new89wh2.js +0 -2
- package/dist/chunk-nrap20qt.js +0 -2
- package/dist/chunk-p9bghe13.js +0 -2
- package/dist/chunk-q2cwzgd0.js +0 -2
- package/dist/chunk-q60afqr7.js +0 -2
- package/dist/chunk-q9yahsww.js +0 -2
- package/dist/chunk-qdwtemy1.js +0 -2
- package/dist/chunk-qp0ndbk6.js +0 -2
- package/dist/chunk-rzsvxjse.js +0 -2
- package/dist/chunk-s2c0ynn9.js +0 -2
- package/dist/chunk-senrtnx2.js +0 -2
- package/dist/chunk-v1wr2vdx.js +0 -2
- package/dist/chunk-v6gkjg5f.js +0 -3
- package/dist/chunk-wc10m4tp.js +0 -38
- package/dist/chunk-wcxa8xy2.js +0 -2
- package/dist/chunk-wgrj0cvs.js +0 -2
- package/dist/chunk-wpkwx3wq.js +0 -2
- package/dist/chunk-wq17dce6.js +0 -2
- package/dist/chunk-wvc6eayq.js +0 -2
- package/dist/chunk-xa98a901.js +0 -2
- package/dist/chunk-xjt5129x.js +0 -2
- package/dist/chunk-yc3frw0z.js +0 -3
- package/dist/chunk-yn02d599.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B,
|
|
2
|
+
import{B,In,Kt,Xt,b,s,Ce,m}from"./chunk-vb609vbj.js";import{It,Ue,Lc,Ts,ii,ai,i}from"./chunk-sbr3wg75.js";import{ve}from"./chunk-jjq7c8s2.js";import{ce,Kr,Me,K,Fn,nn,nt,Le,X}from"./chunk-vf7tpgqz.js";import{Ar,Pr}from"./chunk-fwxgzktt.js";import{Lt,Or,Xs,Gs,Js,jt,Bt,Ft,zt,Ht,Ut,We}from"./chunk-5fdc8pej.js";import{Hs,a,j}from"./chunk-3tcy9r6r.js";import{ja,zo,gs,it,Ba,$t,Fe}from"./chunk-2m4ydym0.js";import{e,Cn,Cr,S}from"./chunk-m390z8w8.js";import{ut}from"./chunk-1a2c4pv8.js";import{He}from"./chunk-s1x2pc9b.js";import{Gn}from"./chunk-nkbnsbb0.js";import{se,Ae,Pe}from"./chunk-v1x96kjr.js";import{l}from"./chunk-6x5a2w5a.js";import{re}from"./chunk-gmn9ba8f.js";import{c,f}from"./chunk-p4twxjfs.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
|
-
`).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,
|
|
5
|
-
`).filter((
|
|
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,g=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length,y=(n.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+g+y,x=(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+x*0.3+(r>10?r*0.05:0)+v));return{lines:t.length,characters:n.length,directives:p,expressions:h,components:x,layouts:C,scriptLines:r,complexity:w}}function On(n,t){let o=[],d=Nt(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=Nt(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 g=n.match(/<img[^>]*>/g);if(g){let x=g.filter((C)=>!C.includes("alt="));if(x.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${x.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let y=n.split(`
|
|
5
|
+
`).filter((x)=>x.length>120);if(y.length>0)o.push({type:"info",category:"maintainability",message:`Found ${y.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 Nt(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 Ta(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((g)=>g.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,x)=>h+x.metrics.lines,0),d=t>0?n.reduce((h,x)=>h+x.metrics.complexity,0)/t:0,r=n.reduce((h,x)=>h+x.issues.length,0),p={};n.forEach((h)=>{h.issues.forEach((x)=>{p[x.category]=(p[x.category]||0)+1})});let u=t>0?n.reduce((h,x)=>h+x.performance.estimatedRenderTime,0)/t:0,g=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),y=[];if(d>6)y.push("Project has high average complexity. Consider refactoring complex templates.");if(r>t*2)y.push("High number of issues detected. Run detailed analysis on individual files.");if(p.security>0)y.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:g,recommendations:y}}var{serve:Wn}=globalThis.Bun;import Rt from"fs";import Ze from"path";function dt(){return`
|
|
6
6
|
/* Theme selector for code blocks */
|
|
7
7
|
.theme-selector {
|
|
8
8
|
margin: 1rem 0;
|
|
@@ -58,7 +58,7 @@ import{B,An,Kt,Xt,y,s,Ce,g}from"./chunk-b5qzed8y.js";import{Pt,Ue,Mc,Es,si,oi,i}
|
|
|
58
58
|
<select id="themeSelector" onchange="changeTheme()">
|
|
59
59
|
${n}
|
|
60
60
|
</select>
|
|
61
|
-
</div>`}function
|
|
61
|
+
</div>`}function ft(){return`
|
|
62
62
|
function changeTheme() {
|
|
63
63
|
const theme = document.getElementById('themeSelector').value;
|
|
64
64
|
|
|
@@ -74,7 +74,7 @@ else {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Initialize theme on page load
|
|
77
|
-
document.addEventListener('DOMContentLoaded', changeTheme);`}function
|
|
77
|
+
document.addEventListener('DOMContentLoaded', changeTheme);`}function mt(n){if(Object.keys(n).length===0)return"";return`
|
|
78
78
|
<div class="frontmatter">
|
|
79
79
|
<h3>Frontmatter</h3>
|
|
80
80
|
${Object.entries(n).map(([t,o])=>`
|
|
@@ -82,19 +82,19 @@ 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 Ln(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 Ln(n)}async function qe(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-426gq0g5.js");if(typeof n.openDevWindow!=="function")return null;return n}catch{return null}}async function Qe(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
|
+
`,y=Function(u)();if(y)return y}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 Ct(){console.log(`
|
|
89
89
|
Keyboard shortcuts:`),console.log(` ${e.cyan}o${e.reset} + Enter - Open in browser`),console.log(` ${e.cyan}c${e.reset} + Enter - Clear console`),console.log(` ${e.cyan}q${e.reset} + Enter (or ${e.cyan}Ctrl+C${e.reset}) - Quit server`),console.log(` ${e.cyan}h${e.reset} + Enter - Show this help`)}function zn(n){console.log(`${e.green}Server running at ${e.cyan}${n}${e.reset}`),console.log(`Press ${e.cyan}Ctrl+C${e.reset} to stop the server`),Ct()}function Nn(n){console.log(`${e.dim}Opening ${e.cyan}${n}${e.dim} in your browser...${e.reset}`),Bun.spawn(["open",n],{stderr:"inherit"})}function Ke(n,t,o){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),Ct();let d="";process.stdin.on("data",(r)=>{if(r==="\x03"){if(o?.onQuit)o.onQuit();t(),process.exit(0)}if(d+=r,d.endsWith("\r")||d.endsWith(`
|
|
90
|
-
`)){let p=d.trim().toLowerCase();d="",Un(p,n,t,o)}})}function Un(n,t,o,d){switch(n){case"o":if(d?.onOpen)d.onOpen();else Nn(t);break;case"c":if(d?.onClear)d.onClear();else console.clear(),zn(t);break;case"q":if(d?.onQuit)d.onQuit();console.log(`${e.yellow}Stopping server...${e.reset}`),o(),process.exit(0);break;case"h":if(d?.onHelp)d.onHelp();else Ct();break;default:break}}async function
|
|
90
|
+
`)){let p=d.trim().toLowerCase();d="",Un(p,n,t,o)}})}function Un(n,t,o,d){switch(n){case"o":if(d?.onOpen)d.onOpen();else Nn(t);break;case"c":if(d?.onClear)d.onClear();else console.clear(),zn(t);break;case"q":if(d?.onQuit)d.onQuit();console.log(`${e.yellow}Stopping server...${e.reset}`),o(),process.exit(0);break;case"h":if(d?.onHelp)d.onHelp();else Ct();break;default:break}}async function Pt(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=Ze.resolve(n);if(!Rt.existsSync(r))return console.error(`${e.red}Error: File not found: ${e.bright}${r}${e.reset}`),!1;if(!r.endsWith(".md"))return console.error(`${e.red}Error: File must have .md extension: ${e.bright}${r}${e.reset}`),!1;console.log(`${e.blue}Processing${e.reset} ${e.bright}${n}${e.reset}...`);let p=null,u=async()=>{try{let{content:C,data:R}=await Ue(r,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:j.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),O=t.markdown?.syntaxHighlighting||j.markdown?.syntaxHighlighting,v=O?.defaultTheme||"github-dark",w=["github-dark"],A=O?.additionalThemes||[],oe=[...new Set([...w,...A])].map((L)=>`<option value="${L}"${L===v?" selected":""}>${L}</option>`).join(`
|
|
91
91
|
`);return p=`
|
|
92
92
|
<!DOCTYPE html>
|
|
93
93
|
<html lang="en">
|
|
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||Ze.basename(r))}</title>
|
|
98
98
|
<!-- Syntax highlighting styles -->
|
|
99
99
|
<style id="syntax-theme">
|
|
100
100
|
:root {
|
|
@@ -240,22 +240,22 @@ Keyboard shortcuts:`),console.log(` ${e.cyan}o${e.reset} + Enter - Open in brow
|
|
|
240
240
|
</style>
|
|
241
241
|
</head>
|
|
242
242
|
<body>
|
|
243
|
-
${
|
|
244
|
-
${pt(
|
|
243
|
+
${mt(R)}
|
|
244
|
+
${pt(oe)}
|
|
245
245
|
|
|
246
246
|
${C}
|
|
247
247
|
|
|
248
248
|
<script>
|
|
249
|
-
${
|
|
249
|
+
${ft()}
|
|
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
|
|
253
|
+
`,!0}catch(C){return console.error(`${e.red}Error processing Markdown file:${e.reset}`,C),!1}};if(!await u())return!1;let y=o;try{if(y=await qe(o),y!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${y} 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:${y}/${e.reset}...`);let h=Wn({port:y,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
|
-
${e.bright}\u2192 ${e.cyan}http://localhost:${
|
|
257
|
-
${e.yellow}Routes:${e.reset}`);let
|
|
258
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(h.url.toString(),()=>{if(d)
|
|
256
|
+
${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
|
|
257
|
+
${e.yellow}Routes:${e.reset}`);let x=Ze.relative(process.cwd(),r);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${x}${e.reset}`),console.log(`
|
|
258
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(h.url.toString(),()=>{if(d)Rt.watch(Ze.dirname(r),{recursive:!0}).close();h.stop()}),t.native)await Qe(y,{title:Ze.basename(r,".md")});if(d){let C=Ze.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 je 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 g=JSON.parse(u);if(g.type==="console"&&Array.isArray(g.args)){let y=g.args.join(" "),x={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[g.level]??"\x1B[36m";console.log(`${x}[browser]${g.level!=="log"?` ${g.level}`:""}\x1B[0m ${y}`)}}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 Ne(n,t,o={}){let d=
|
|
457
|
+
`}function Ne(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 et=null;function bt(n){if(!et)et=new Wt(n);return et}function st(){if(et)et.stop(),et=null}import vt from"path";var tt={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 Hs(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 g=new Set;if(o.cache&&o.cachePath){let w=await Ar(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let y=await Me(()=>Bun.file(u).text(),"",(w)=>{throw new Kr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${w.message}`)});if(!y)throw new Kr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:C}=ve.time("script-extraction",()=>{let w=y,A=B(y);if(A)w=A.content.trim();let U=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],oe="",L=[];for(let k of U){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),V=D?D[1]:"";if(/\bserver\b/i.test(V))oe=P;else L.push(k)}let I=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:oe,templateContent:I,allScripts:L}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Me(()=>b(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 ve.timeAsync("directive-processing",async()=>await i(x,R,u,o,g));if(C.length>0){let{interpolateScriptsInTemplate:w}=await import("./chunk-p8wnp4p1.js"),A=w(C.join(`
|
|
458
458
|
`),R),U=v.search(/<\/body>/i);if(U!==-1)v=v.slice(0,U)+A+`
|
|
459
459
|
`+v.slice(U);else v+=`
|
|
460
|
-
${A}`}if(v=await Pe(v),
|
|
460
|
+
${A}`}if(v=await Pe(v),g.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await Pr(u,v,g,o),o.debug)console.log(`Cached template ${u} with ${g.size} dependencies`)}return{contents:v,loader:"html"}}catch(g){let y=g instanceof Error?g:new ce(`Plugin processing failed: ${String(g)}`,u);if(K.log(y,{filePath:u,buildConfig:n.config}),Fn.logDetailedError(y,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",y);let h=y,x=h.line||null,C=h.context||null;return{contents:o.debug||re()?`<!DOCTYPE html>
|
|
461
461
|
<html lang="en">
|
|
462
462
|
<head>
|
|
463
463
|
<meta charset="UTF-8">
|
|
@@ -480,16 +480,16 @@ ${A}`}if(v=await Pe(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await T
|
|
|
480
480
|
|
|
481
481
|
<div class="error-details">
|
|
482
482
|
<h3>Error Details</h3>
|
|
483
|
-
<p><strong>File:</strong> <span class="file-path">${
|
|
484
|
-
<p><strong>Error:</strong> ${
|
|
485
|
-
${
|
|
486
|
-
${C?`<p><strong>Context:</strong> ${
|
|
483
|
+
<p><strong>File:</strong> <span class="file-path">${m(u)}</span></p>
|
|
484
|
+
<p><strong>Error:</strong> ${m(y.message)}</p>
|
|
485
|
+
${x?`<p><strong>Line:</strong> ${m(String(x))}</p>`:""}
|
|
486
|
+
${C?`<p><strong>Context:</strong> ${m(String(C))}</p>`:""}
|
|
487
487
|
</div>
|
|
488
488
|
|
|
489
|
-
${
|
|
489
|
+
${y.stack?`
|
|
490
490
|
<div class="error-details">
|
|
491
491
|
<h3>Stack Trace</h3>
|
|
492
|
-
<pre class="error-code">${
|
|
492
|
+
<pre class="error-code">${m(y.stack)}</pre>
|
|
493
493
|
</div>`:""}
|
|
494
494
|
|
|
495
495
|
<div class="help-section">
|
|
@@ -498,7 +498,7 @@ ${A}`}if(v=await Pe(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await T
|
|
|
498
498
|
<li>Check the syntax of your stx directives (e.g., @if, @foreach)</li>
|
|
499
499
|
<li>Verify that all variables used in the template are properly defined</li>
|
|
500
500
|
<li>Ensure script tags have valid JavaScript/TypeScript syntax</li>
|
|
501
|
-
<li>Run <code>stx debug ${
|
|
501
|
+
<li>Run <code>stx debug ${m(vt.basename(u))}</code> for detailed analysis</li>
|
|
502
502
|
<li>Enable debug mode in your stx config for more detailed error messages</li>
|
|
503
503
|
</ul>
|
|
504
504
|
</div>
|
|
@@ -517,12 +517,12 @@ ${A}`}if(v=await Pe(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await T
|
|
|
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 as(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,g=ge.resolve(n);if(!je.existsSync(g))return console.error(`${e.red}Error: File not found: ${e.bright}${g}${e.reset}`),!1;if(g.endsWith(".md"))return Pt(g,t);else if(!g.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${g}${e.reset}. Only .stx and .md files are supported.`),!1;let y=l(process.cwd(),"output");je.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${n}${e.reset}...`);let h=null,x=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:[g],outdir:y,plugins:[P,tt],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 V=D.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(P){return console.error(`${e.red}Error building stx file:${e.reset}`,P),!1}};if(!await x())return!1;let R=ge.dirname(g);await Cn(R);let O=o;try{if(O=await qe(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-vtcyber4.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 V=Object.keys(v).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Q}=await import("./chunk-4yz33vzb.js"),xe=D.broadcasting;await V(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(je.existsSync(ke))try{let ie=await Q(ke);console.log(`${e.blue}Loaded ${e.bright}${ie} broadcast channel${ie!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ie){console.warn(`${e.yellow}Failed to load channels.ts: ${ie.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:U,isServerApiSource:oe}=await import("./chunk-rwjye578.js"),L=await U(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 I=Kn({port:O,async fetch(P){return Gn(P,await(async()=>{let D=new URL(P.url);if([y,ge.dirname(g),ge.join(process.cwd(),"public")].some((ie)=>oe(ge.join(ie,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(w)try{let ie=await w.handleRequest(P);if(ie.status!==404)return ie}catch{}if(v[D.pathname])try{return await v[D.pathname](P)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await L(P);if(V)return V;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ne(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 Q=ge.join(y,D.pathname);if(je.existsSync(Q)&&je.statSync(Q).isFile()){let ie=Bun.file(Q),F=ge.extname(Q).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Be=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=Be.transformSync(ze);return new Response(Je,{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(ie,{headers:{"Content-Type":E}})}let xe=ge.dirname(g),pe=ge.join(xe,D.pathname);if(je.existsSync(pe)&&je.statSync(pe).isFile()){let ie=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Be=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=Be.transformSync(ze);return new Response(Je,{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(ie,{headers:{"Content-Type":E}})}let ke=ge.join(process.cwd(),"public",D.pathname);if(je.existsSync(ke)&&je.statSync(ke).isFile()){let ie=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let Be=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=Be.transformSync(ze);return new Response(Je,{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(ie,{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
|
-
${e.yellow}Routes:${e.reset}`);let k=ge.relative(process.cwd(),
|
|
525
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(I.url.toString(),()=>{if(d)
|
|
524
|
+
${e.yellow}Routes:${e.reset}`);let k=ge.relative(process.cwd(),g);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`),Ke(I.url.toString(),()=>{if(d)je.watch(ge.dirname(g),{recursive:!0}).close();I.stop()}),t.native){let P=await Bun.file(g).text(),D=gt(P);await Qe(O,{title:ge.basename(g,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=ge.dirname(g);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=je.watch(P,{recursive:!0},async(V,Q)=>{if(!Q||xt(Q))return;if(yt(Q)){console.log(`${e.yellow}File ${e.bright}${Q}${e.yellow} changed, rebuilding...${e.reset}`),ut.clear(),Ce();let xe=await x();if(await Cr(R),r&&p)if(xe)p.reload(Q);else p.error("Build failed - check console for details")}else if(ht(Q)){if(console.log(`${e.cyan}CSS ${e.bright}${Q}${e.cyan} changed${e.reset}`),r&&p)p.updateCss(Q)}});process.on("SIGINT",()=>{if(D.close(),p)st();I.stop(),process.exit(0)})}return!0}var{serve:Xn}=globalThis.Bun;import Xe from"fs";import Se from"path";var Vt=`
|
|
526
526
|
<script data-stx-helpers>
|
|
527
527
|
(function() {
|
|
528
528
|
'use strict'
|
|
@@ -833,14 +833,14 @@ else {
|
|
|
833
833
|
|
|
834
834
|
})()
|
|
835
835
|
</script>
|
|
836
|
-
`;function Gt(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 Gt(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 cs(n,t={}){let o=t.port||3000,d=t.watch!==!1;for(let v of n){let w=Se.resolve(v);if(!Xe.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");Xe.mkdirSync(r,{recursive:!0});let p=Gt(n.map((v)=>Se.dirname(Se.resolve(v))));console.log(`${e.blue}Processing ${e.bright}${n.length}${e.reset} files...`);let u={},g=[],y=async()=>{try{for(let v of n){let w=Se.resolve(v);if(w.endsWith(".md"))try{let{content:U,data:oe}=await Ue(w,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:j.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),L=t.markdown?.syntaxHighlighting||j.markdown?.syntaxHighlighting,I=L?.defaultTheme||"github-dark",k=["github-dark"],P=L?.additionalThemes||[],V=[...new Set([...k,...P])].map((ke)=>`<option value="${ke}"${ke===I?" selected":""}>${ke}</option>`).join(`
|
|
837
837
|
`),Q=`
|
|
838
838
|
<!DOCTYPE html>
|
|
839
839
|
<html lang="en">
|
|
840
840
|
<head>
|
|
841
841
|
<meta charset="UTF-8">
|
|
842
842
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
843
|
-
<title>${qt(
|
|
843
|
+
<title>${qt(oe.title||Se.basename(w))}</title>
|
|
844
844
|
<!-- Syntax highlighting styles -->
|
|
845
845
|
<style id="syntax-theme">
|
|
846
846
|
:root {
|
|
@@ -986,34 +986,34 @@ else {
|
|
|
986
986
|
</style>
|
|
987
987
|
</head>
|
|
988
988
|
<body>
|
|
989
|
-
${
|
|
990
|
-
${pt(
|
|
989
|
+
${mt(oe)}
|
|
990
|
+
${pt(V)}
|
|
991
991
|
|
|
992
992
|
${U}
|
|
993
993
|
|
|
994
994
|
<script>
|
|
995
|
-
${
|
|
995
|
+
${ft()}
|
|
996
996
|
</script>
|
|
997
997
|
</body>
|
|
998
998
|
</html>
|
|
999
|
-
`,pe=`/${Se.relative(p,w).replace(/\.md$/,"")}`;if(pe.endsWith("/index"))pe=pe.slice(0,-6)||"/";u[pe||"/"]={filePath:w,content:Q,fileType:"md"}}catch(U){console.error(`${e.red}Error processing Markdown file ${e.bright}${v}${e.reset}:`,U);continue}else{let U={name:"public-assets",setup(k){k.onResolve({filter:/^\/(images|fonts|assets|public)\//},(P)=>({path:P.path,external:!0}))}},
|
|
1000
|
-
${He(k,w)}`);continue}let I=`/${Se.relative(p,w).replace(/\.stx$/,"")}`;if(I.endsWith("/index"))I=I.slice(0,-6)||"/";if(I.includes("[")){let{regex:k,params:P}=
|
|
999
|
+
`,pe=`/${Se.relative(p,w).replace(/\.md$/,"")}`;if(pe.endsWith("/index"))pe=pe.slice(0,-6)||"/";u[pe||"/"]={filePath:w,content:Q,fileType:"md"}}catch(U){console.error(`${e.red}Error processing Markdown file ${e.bright}${v}${e.reset}:`,U);continue}else{let U={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:[U,tt],define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!k.success){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:`,He(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
|
+
${He(k,w)}`);continue}let I=`/${Se.relative(p,w).replace(/\.stx$/,"")}`;if(I.endsWith("/index"))I=I.slice(0,-6)||"/";if(I.includes("[")){let{regex:k,params:P}=Xs(I,{page:!0});g.push({pattern:k,paramNames:P,filePath:w,routeTemplate:I,fileType:"stx"}),u[I]={filePath:w,content:oe,fileType:"stx"}}else u[I||"/"]={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}`,He(v)),!1}};if(!await y())return!1;let x=o;try{if(x=await qe(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 C=Xn({port:x,async fetch(v){let w=new URL(v.url),A=Se.join(process.cwd(),"public",w.pathname);if(Xe.existsSync(A)&&Xe.statSync(A).isFile()){let L=Bun.file(A),I=Se.extname(A).toLowerCase(),k="application/octet-stream";if(I===".ts"||I===".tsx"){let P=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),D=await L.text(),V=P.transformSync(D);return new Response(V,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(L,{headers:{"Content-Type":k}})}let U=u[w.pathname];if(!U&&!w.pathname.endsWith("/"))U=u[`${w.pathname}/`];if(!U)for(let L of g){let I=w.pathname.match(L.pattern);if(I){let k=u[L.routeTemplate];if(k){let P={};for(let Q=0;Q<L.paramNames.length;Q++)P[L.paramNames[Q]]=decodeURIComponent(I[Q+1]);let D=k.content,V=`<script>window.__routeParams = ${JSON.stringify(P)};</script>`;if(D.includes("</head>"))D=f(D,V);else D=V+D;U={...k,content:D}}break}}if(U)return S(U.content).then((L)=>{if(L.includes("</head>"))L=f(L,Vt);return new Response(L,{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(Xe.existsSync(oe)&&Xe.statSync(oe).isFile()){let L=Bun.file(oe),I=Se.extname(oe).toLowerCase(),k="text/plain";if(I===".ts"||I===".tsx"){let P=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),D=await L.text(),V=P.transformSync(D);return new Response(V,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(L,{headers:{"Content-Type":k}})}if(w.pathname!=="/"&&u["/"]){let L=Le(v);return S(u["/"].content).then((I)=>{if(L){let k=I.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(k){let P=I.match(/<title[^>]*>([\s\S]*?)<\/title>/i),D=P?P[1]:"",V=`<!DOCTYPE html><html><head><title>${qt(D)}</title></head><body><main>${k[1]}</main></body></html>`;return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...X(),"Cache-Control":nn,Pragma:"no-cache",Expires:"0"}})}}return new Response(I,{headers:{"Content-Type":"text/html",...X(),"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
|
-
${e.bright}\u2192 ${e.cyan}http://localhost:${
|
|
1004
|
-
${e.yellow}Routes:${e.reset}`);let R=new Set(
|
|
1005
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(C.url.toString(),()=>{if(d)Xe.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Xe.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}`),lt.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:Jn}=globalThis.Bun;import me from"fs";import oe from"path";async function Jt(n){try{return An(await Bun.file(n).text())}catch{return}}function Ot(n){let t=Bun.file(n),o=oe.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 as(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=oe.resolve(n),{loadStxConfig:x}=await import("./chunk-k2t0w8z1.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-6bw02d1t.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await b(m,R),v=h.root&&h.root!=="."?oe.join(m,h.root):m,w=t.pagesDir||h.pagesDir||"pages",A=oe.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 U=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(U.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}${U.length}${e.blue} routes${e.reset}`);let se=h?._pluginPageDirs||[],L=[];for(let{dir:T,prefix:_}of se)if(me.existsSync(T)){let z=re(oe.dirname(T),{pagesDir:oe.basename(T)});for(let Z of z){let X=_==="/"?Z.pattern:`${_}${Z.pattern==="/"?"":Z.pattern}`;L.push({route:{...Z,pattern:X},prefix:_})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${_}${e.reset}`)}let I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Da(m,t.stxOptions?.shell),P){if(k=await Bo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${oe.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={},Q=null;try{let{loadStxConfig:T}=await import("./chunk-k2t0w8z1.js"),_=await T(m);if(_?.apiRouter)Q=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){q=_.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(_?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Z}=await import("./chunk-38y11q8x.js"),X=_.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=oe.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Z(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,ie=async(T)=>{let _=Xs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[tt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Z=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Z)return null;return await Bun.file(Z.path).text()}catch{return null}},F=new Map,E=async(T,_)=>{try{let{processDirectives:z,extractVariables:Z,defaultConfig:X,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-k2t0w8z1.js"),{checkCache:N,cacheTemplate:Y,readFileCached:W,templateCache:ue}=await import("./chunk-e0tvd7jj.js"),G=await Te(m),Ve=(le)=>{if(!le)return le;if(oe.isAbsolute(le))return le;return oe.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(de.cachePath)??l(m,"cache");let M=!_&&!t.profile,J=de.cache!==!1;if(J&&M){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Ie=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Ie=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Ie=!1;break}}if(Ie){let ve=le.output;if(k)ve=ot(ve,{preserveHead:!0});let rt=F.get(T.filePath);return{route:T,content:ve,status:rt?.status??await Jt(T.filePath),headers:rt?.headers}}}}catch{}let Me=await N(T.filePath,de);if(Me){let _e=Me;if(k)_e=ot(_e,{preserveHead:!0});let Ie=F.get(T.filePath);return{route:T,content:_e,status:Ie?.status??await Jt(T.filePath),headers:Ie?.headers}}}let ee=J?await W(T.filePath):await Bun.file(T.filePath).text(),ae=An(ee),{classifyAllScripts:fe}=await import("./chunk-k2t0w8z1.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Re=ee;for(let le of H.server)Re=Re.replace(le.fullTag,"");let te={__filename:T.filePath,__dirname:oe.dirname(T.filePath),__stx_options:de,params:_??{},__stx_runtime_head:{}};for(let le of Oe)try{await Z(le,te,T.filePath)}catch(Me){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,Me?.message||Me)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Re,te,T.filePath,de,$e);let Me=performance.now()-le,_e=oe.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${Me.toFixed(2)}ms`)}else he=await z(Re,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-kcpxqsdj.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Me,_e,Ie)=>{if(!/function\s+__stx_setup_/.test(Ie))return Me;return`<script${_e}>${le(Ie,te)}</script>`})}if(k)he=ot(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:ct}=await import("./chunk-6aqr0e6s.js"),Ye=ct(te),nt=te.__streamTemplates;if(nt&&typeof nt==="object"&&Object.keys(nt).length>0){let le=te.streamBoundaries||{},Me={...de,autoShell:!1},_e=Object.keys(nt).map((ve)=>({id:ve,render:async()=>{let rt=typeof le[ve]==="function"?await le[ve]():void 0;return z(nt[ve],{...te,$boundary:rt},T.filePath,Me,new Set)}})),Ie=new Set(_e.map((ve)=>ve.id));Ye=[...(Ye||[]).filter((ve)=>!Ie.has(ve.id)),..._e]}if(Ye&&Ye.length>0)ke.add(T.pattern);else Ye=void 0;let _t=Kt(te),It=Xt(te);if(M)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},je=8,ze=async()=>{let T=new Set(pe.keys()),_=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((X)=>T.has(X.pattern)):U,Z=t.prebuild===!1?L.filter(({route:X})=>_.has(X.pattern)):L;for(let X=0;X<z.length;X+=je){let Te=z.slice(X,X+je),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<Z.length;X+=je){let Te=Z.slice(X,X+je),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)I.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?U.length+L.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Ge=o;try{if(Ge=await qe(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Ge+1;p=xt({wsPort:T,verbose:!1}),u=p.start(T)}let wt=(T,_)=>{let Z=`<script data-stx-route-params>(function(){var p=${JSON.stringify(_).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,Z,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Z}`);return Z+T};console.log(`${e.blue}Starting server...${e.reset}`);let St=Jn({port:Ge,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===si&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...U,...L.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:oi(z,Es(),M),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Z=h?.publicDir||"public",X=oe.join(m,Z,_.pathname),Te=oe.join(m,_.pathname),be=oe.join(xe,_.pathname);if([X,Te,be].some((M)=>C(M,m,R)))return new Response("Not Found",{status:404});let[N,Y,W]=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(Y?.isFile()&&!C(Te,m,R))return Ot(Te);if(W?.isFile()&&!C(be,m,R))return Ot(be);if(_.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(_.pathname.slice(16));if(M)try{let J=`<${M} />`,ee={...buildConfig,autoShell:!1},ae=await processDirectives(J,{},oe.join(m,"components",`${M}.stx`),ee,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(J){return new Response(`<div class="stx-async-error">${J.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(_.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-xa98a901.js"),J=await M(T,{publicDir:oe.join(m,Z),cacheDir:l(m,"cache","img")});if(J)return J}if(Q)try{let M=await Q.handleRequest(T);if(M.status!==404)return M}catch{}if(q[_.pathname])try{return await q[_.pathname](T)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=Rr(_.pathname,U);if(G){let M=pe.get(G.route.pattern),J=ke.has(G.route.pattern);if(!M||G.route.isDynamic&&Object.keys(G.params).length>0||J){let ee=await E(G.route,G.params);if(ee){if(M=ee,!G.route.isDynamic&&!J)pe.set(G.route.pattern,ee)}}if(M){let ee=M.status??200,ae=M.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 Re=await ie(404);if(Re){let te=Re;if(te=await S(te,m),r)te=Ne(te,u);return new Response(te,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=Ft(_.pathname,G.params,fe,_.search),Re=zt(Oe,null,T,{isServer:!0}),te=await Ht(fe.middleware,Re);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,ct=new Headers(te.responseHeaders);return ct.set("Location",$e),new Response(null,{status:he,headers:ct})}if(te.abort){let{statusCode:$e,message:he}=te.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(te.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(te.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=f(M.content,$e,"")}}let H=M.content;if(k&&La(T)&&Tt(H,h?.router?.container||"main")){let Oe=We(H),Re=Ae(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?cn(te[1].trim()):"";if(Object.keys(G.params).length>0)H=wt(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Fe(H,he,!0),new Response(H,{status:ee,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Re?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Mc]:Es(),...V(),"Cache-Control":Et}})}if(k)H=ps(k,H);if(Object.keys(G.params).length>0)H=wt(H,G.params);if(H=await S(H,m),r)H=Ne(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(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Re}=await import("./chunk-6aqr0e6s.js");return Re(Oe(H,M.boundaries,{timeoutMs:30000}),{status:ee,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:ee,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(L.length>0){let M=L.map((ee)=>ee.route),J=Rr(_.pathname,M);if(J){let ee=I.get(J.route.pattern);if(!ee||J.route.isDynamic){let ae=await E(J.route,J.params);if(ae){if(ee=ae,!J.route.isDynamic)I.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=ps(k,ae);if(Object.keys(J.params).length>0)ae=wt(ae,J.params);if(ae=await S(ae,m),r)ae=Ne(ae,u);return new Response(ae,{status:ee.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ee}of se)if(ee!=="/"&&_.pathname.startsWith(ee)){let ae=I.get(ee)||I.get(ee+"/");if(!ae){let fe=L.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,I.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=ps(k,fe);if(fe=await S(fe,m),r)fe=Ne(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(_.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=pe.get("/");if(Ve){let M=Ve.content;if(M=await S(M,m),r)M=Ne(M,u);if(t.native)if(M.includes("<head>"))M=M.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 M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let M=de;if(M=await S(M,m),r)M=Ne(M,u);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let _=await ie(500);if(_)return new Response(_,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
|
|
1003
|
+
${e.bright}\u2192 ${e.cyan}http://localhost:${x}/${e.reset}`),console.log(`
|
|
1004
|
+
${e.yellow}Routes:${e.reset}`);let R=new Set(g.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 g){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 U=w===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",oe=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${U}${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`),Ke(C.url.toString(),()=>{if(d)Xe.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Xe.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}`),ut.clear(),Ce(),await y()});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:Jn}=globalThis.Bun;import me from"fs";import ne from"path";async function Jt(n){try{return In(await Bun.file(n).text())}catch{return}}function Et(n){let t=Bun.file(n),o=ne.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 ls(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,g=ne.resolve(n),{loadStxConfig:y}=await import("./chunk-vtcyber4.js"),h=await y(g),{createServerApi:x,isServerApiSource:C}=await import("./chunk-rwjye578.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await x(g,R),v=h.root&&h.root!=="."?ne.join(g,h.root):g,w=t.pagesDir||h.pagesDir||"pages",A=ne.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 U=se(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(U.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}${U.length}${e.blue} routes${e.reset}`);let oe=h?._pluginPageDirs||[],L=[];for(let{dir:T,prefix:_}of oe)if(me.existsSync(T)){let z=se(ne.dirname(T),{pagesDir:ne.basename(T)});for(let Z of z){let q=_==="/"?Z.pattern:`${_}${Z.pattern==="/"?"":Z.pattern}`;L.push({route:{...Z,pattern:q},prefix:_})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${_}${e.reset}`)}let I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await ja(g,t.stxOptions?.shell),P){if(k=await zo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${ne.relative(g,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}jt(),await Ft(g);let D=Bt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let V={},Q=null;try{let{loadStxConfig:T}=await import("./chunk-vtcyber4.js"),_=await T(g);if(_?.apiRouter)Q=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){V=_.apiRoutes;let z=Object.keys(V).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Z}=await import("./chunk-4yz33vzb.js"),q=_.broadcasting;await z(q);let Te=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let be=ne.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Z(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(g,"output");me.mkdirSync(xe,{recursive:!0});let pe=new Map,ke=new Set,ie=async(T)=>{let _=Gs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[tt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Z=z.outputs.find((q)=>q.path.endsWith(".html"));if(!Z)return null;return await Bun.file(Z.path).text()}catch{return null}},F=new Map,E=async(T,_)=>{try{let{processDirectives:z,extractVariables:Z,defaultConfig:q,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-vtcyber4.js"),{checkCache:N,cacheTemplate:Y,readFileCached:W,templateCache:ue}=await import("./chunk-tz5ktd6d.js"),G=await Te(g),Ve=(le)=>{if(!le)return le;if(ne.isAbsolute(le))return le;return ne.resolve(g,le)},de={...q,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(de.cachePath)??l(g,"cache");let M=!_&&!t.profile,J=de.cache!==!1;if(J&&M){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Ie=!0;for(let we of le.dependencies){if(!me.existsSync(we)){Ie=!1;break}if((await me.promises.stat(we)).mtime.getTime()>le.mtime){Ie=!1;break}}if(Ie){let we=le.output;if(k)we=it(we,{preserveHead:!0});let ot=F.get(T.filePath);return{route:T,content:we,status:ot?.status??await Jt(T.filePath),headers:ot?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let _e=De;if(k)_e=it(_e,{preserveHead:!0});let Ie=F.get(T.filePath);return{route:T,content:_e,status:Ie?.status??await Jt(T.filePath),headers:Ie?.headers}}}let ee=J?await W(T.filePath):await Bun.file(T.filePath).text(),ae=In(ee),{classifyAllScripts:fe}=await import("./chunk-vtcyber4.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Re=ee;for(let le of H.server)Re=Re.replace(le.fullTag,"");let te={__filename:T.filePath,__dirname:ne.dirname(T.filePath),__stx_options:de,params:_??{},__stx_runtime_head:{}};for(let le of Oe)try{await Z(le,te,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(Re,te,T.filePath,de,$e);let De=performance.now()-le,_e=ne.relative(g,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Re,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-p8wnp4p1.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,_e,Ie)=>{if(!/function\s+__stx_setup_/.test(Ie))return De;return`<script${_e}>${le(Ie,te)}</script>`})}if(k)he=it(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:lt}=await import("./chunk-m1hfh2t4.js"),Ye=lt(te),rt=te.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let le=te.streamBoundaries||{},De={...de,autoShell:!1},_e=Object.keys(rt).map((we)=>({id:we,render:async()=>{let ot=typeof le[we]==="function"?await le[we]():void 0;return z(rt[we],{...te,$boundary:ot},T.filePath,De,new Set)}})),Ie=new Set(_e.map((we)=>we.id));Ye=[...(Ye||[]).filter((we)=>!Ie.has(we.id)),..._e]}if(Ye&&Ye.length>0)ke.add(T.pattern);else Ye=void 0;let Dt=Kt(te),Mt=Xt(te);if(M)F.set(T.filePath,{status:Dt,headers:Mt});return{route:T,content:he,status:Dt??ae,headers:Mt,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},Be=8,ze=async()=>{let T=new Set(pe.keys()),_=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((q)=>T.has(q.pattern)):U,Z=t.prebuild===!1?L.filter(({route:q})=>_.has(q.pattern)):L;for(let q=0;q<z.length;q+=Be){let Te=z.slice(q,q+Be),be=await Promise.all(Te.map((N)=>E(N)));for(let N of be)if(N)pe.set(N.route.pattern,N)}for(let q=0;q<Z.length;q+=Be){let Te=Z.slice(q,q+Be),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)I.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?U.length+L.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Cn(g);let Ge=o;try{if(Ge=await qe(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Ge+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,_)=>{let Z=`<script data-stx-route-params>(function(){var p=${JSON.stringify(_).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,Z,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Z}`);return Z+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Jn({port:Ge,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===ii&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...U,...L.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:ai(z,Ts(),M),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Z=h?.publicDir||"public",q=ne.join(g,Z,_.pathname),Te=ne.join(g,_.pathname),be=ne.join(xe,_.pathname);if([q,Te,be].some((M)=>C(M,g,R)))return new Response("Not Found",{status:404});let[N,Y,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(be).catch(()=>null)]);if(N?.isFile()&&!C(q,g,R))return Et(q);if(Y?.isFile()&&!C(Te,g,R))return Et(Te);if(W?.isFile()&&!C(be,g,R))return Et(be);if(_.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(_.pathname.slice(16));if(M)try{let J=`<${M} />`,ee={...buildConfig,autoShell:!1},ae=await processDirectives(J,{},ne.join(g,"components",`${M}.stx`),ee,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(J){return new Response(`<div class="stx-async-error">${J.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(_.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-wq2bpt0w.js"),J=await M(T,{publicDir:ne.join(g,Z),cacheDir:l(g,"cache","img")});if(J)return J}if(Q)try{let M=await Q.handleRequest(T);if(M.status!==404)return M}catch{}if(V[_.pathname])try{return await V[_.pathname](T)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=Or(_.pathname,U);if(G){let M=pe.get(G.route.pattern),J=ke.has(G.route.pattern);if(!M||G.route.isDynamic&&Object.keys(G.params).length>0||J){let ee=await E(G.route,G.params);if(ee){if(M=ee,!G.route.isDynamic&&!J)pe.set(G.route.pattern,ee)}}if(M){let ee=M.status??200,ae=M.headers??{},fe=(G.route.filePath?It(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Re=await ie(404);if(Re){let te=Re;if(te=await S(te,g),r)te=Ne(te,u);return new Response(te,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=zt(_.pathname,G.params,fe,_.search),Re=Ht(Oe,null,T,{isServer:!0}),te=await Ut(fe.middleware,Re);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,lt=new Headers(te.responseHeaders);return lt.set("Location",$e),new Response(null,{status:he,headers:lt})}if(te.abort){let{statusCode:$e,message:he}=te.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(te.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(te.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=f(M.content,$e,"")}}let H=M.content;if(k&&Ba(T)&&$t(H,h?.router?.container||"main")){let Oe=We(H),Re=Ae(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?nt(te[1].trim()):"";if(Object.keys(G.params).length>0)H=St(H,G.params);H=await S(H,g);let he=h?.router?.container||"main";return H=Fe(H,he,!0),new Response(H,{status:ee,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Re?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Lc]:Ts(),...X(),"Cache-Control":nn}})}if(k)H=gs(k,H);if(Object.keys(G.params).length>0)H=St(H,G.params);if(H=await S(H,g),r)H=Ne(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(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Re}=await import("./chunk-m1hfh2t4.js");return Re(Oe(H,M.boundaries,{timeoutMs:30000}),{status:ee,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:ee,headers:{"Content-Type":"text/html",...X(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(L.length>0){let M=L.map((ee)=>ee.route),J=Or(_.pathname,M);if(J){let ee=I.get(J.route.pattern);if(!ee||J.route.isDynamic){let ae=await E(J.route,J.params);if(ae){if(ee=ae,!J.route.isDynamic)I.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=gs(k,ae);if(Object.keys(J.params).length>0)ae=St(ae,J.params);if(ae=await S(ae,g),r)ae=Ne(ae,u);return new Response(ae,{status:ee.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ee}of oe)if(ee!=="/"&&_.pathname.startsWith(ee)){let ae=I.get(ee)||I.get(ee+"/");if(!ae){let fe=L.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,I.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=gs(k,fe);if(fe=await S(fe,g),r)fe=Ne(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(Lt(_.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=pe.get("/");if(Ve){let M=Ve.content;if(M=await S(M,g),r)M=Ne(M,u);if(t.native)if(M.includes("<head>"))M=M.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 M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let M=de;if(M=await S(M,g),r)M=Ne(M,u);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let _=await ie(500);if(_)return new Response(_,{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:${Ge}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1009
|
-
${e.yellow}Routes:${e.reset}`);let
|
|
1010
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(
|
|
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
|
|
1012
|
-
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Zn(n,t=!1,o){let d=
|
|
1009
|
+
${e.yellow}Routes:${e.reset}`);let Tt=[...Js(U,g)];for(let{route:T}of L)Tt.push(`${T.pattern}`);if(Tt.forEach((T,_)=>{let Z=_===Tt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Z}${e.reset}${T}`)}),console.log(`
|
|
1010
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(kt.url.toString(),()=>{if(p)st();kt.stop()}),t.native){let T,_=ne.join(A,"index.stx");if(me.existsSync(_)){let Z=await Bun.file(_).text();T=gt(Z)}let z=h?.app?.window??{};await Qe(Ge,{title:h?.app?.head?.title||ne.basename(g)||"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\\"),_=(N)=>{let Y=N.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},z=new Map,Z=()=>{let N=new Set([g,...h._layerGraph?.layers.map((Y)=>Y.root)??[],...h._layerGraph?.configDependencies.map((Y)=>ne.dirname(Y))??[]].filter((Y)=>me.existsSync(Y)).map((Y)=>me.realpathSync(Y)));for(let Y of h._layerGraph?.layers??[])for(let W of Object.values(Y.resources)){if(!me.existsSync(W))continue;let ue=me.realpathSync(W);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${ne.sep}`)))N.add(ue)}for(let[Y,W]of z)if(!N.has(Y))W.close(),z.delete(Y);for(let Y of N)if(!z.has(Y)&&me.existsSync(Y))z.set(Y,me.watch(Y,{recursive:!0},(W,ue)=>{Te(Y,W,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Te=(N,Y,W)=>(q=q.catch(()=>{}).then(()=>be(N,Y,W)),q),be=async(N,Y,W)=>{if(!W||xt(W))return;if(yt(W)){if(h._layerGraph){let ue=await y(g);Object.assign(h,ue),U.splice(0,U.length,...se(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Z()}if(T(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),r&&p)p.reload(W)}else if(_(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),ut.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-tz5ktd6d.js");ue(ne.resolve(N,W)),G.delete(ne.resolve(N,W))}catch{}if(P&&W){if(ne.resolve(N,W)===P||ne.basename(P)===W){let G=await zo(P,t.stxOptions||{});if(G)k=G}}if(await ze(),await Cr(g),r&&p)p.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),ut.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-tz5ktd6d.js");ue(ne.resolve(N,W)),G.delete(ne.resolve(N,W))}catch{}if(await ze(),r&&p)p.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),r&&p)p.updateCss(W)}};Z(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)st();kt.stop(),process.exit(0)})}return!0}import Ot from"fs";import at from"path";async function Yn(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 g=u[1],y=u[2]||u[3]||u[4];if(!y)continue;let h={name:y},x=g.match(/@type\s+\{([^}]+)\}/i);if(x)h.type=x[1].trim();if(g.match(/@required/i))h.required=!0;let R=g.match(/@default\s+(.+?)(?:\s+|$)/i);if(R)h.default=R[1].trim();let O=g.split(`
|
|
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 g=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(g){let h=g[1].split(",").map((x)=>x.trim()).filter(Boolean);for(let x of h){let[C]=x.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 Qn(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
|
+
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Zn(n,t=!1,o){let d=at.basename(n,".stx"),r=await Yn(n),p=await Qn(n),u="";if(t&&o)u=`<${o}></${o}>`;else{let g=r.map((y)=>{if(y.type==="boolean")return`:${y.name}="true"`;return`${y.name}="value"`}).join(`
|
|
1013
1013
|
`);u=`<${d}
|
|
1014
|
-
${
|
|
1015
|
-
/>`}return{name:d,path:n,description:p,props:r,example:u,isWebComponent:t,tag:o}}async function Yt(n){try{if(!await s(n))return console.warn(`Components directory does not exist: ${n}`),[];let t=await
|
|
1016
|
-
`).map((w)=>w.trim().replace(/^\*\s*/,"")).join(" ").trim():"",h=/@component\(\s*['"]([^'"]+)['"]/g,
|
|
1014
|
+
${g}
|
|
1015
|
+
/>`}return{name:d,path:n,description:p,props:r,example:u,isWebComponent:t,tag:o}}async function Yt(n){try{if(!await s(n))return console.warn(`Components directory does not exist: ${n}`),[];let t=await Ot.promises.readdir(n,{withFileTypes:!0}),o=[];for(let d of t){let r=at.join(n,d.name);if(d.isDirectory()){let p=await Yt(r);o.push(...p)}else if(d.isFile()&&d.name.endsWith(".stx"))o.push(r)}return o}catch(t){return console.error(`Error finding component files in ${n}:`,t),[]}}async function er(n,t){try{if(!await s(n))return[];let o=await Yt(n),d=[],r=new Map;if(t?.components?.length)for(let p of t.components)r.set(p.file,p);for(let p of o){let u=r.get(p),g=!!u,y=u?.tag,h=await Zn(p,g,y);d.push(h)}return d}catch(o){return console.error("Error generating component docs:",o),[]}}async function tr(n){try{if(!await s(n))return[];let t=await Ot.promises.readdir(n,{withFileTypes:!0}),o=[];for(let d of t){if(!d.isFile()||!d.name.endsWith(".stx"))continue;let r=at.join(n,d.name),p=await Bun.file(r).text(),u=at.basename(r,".stx"),g=p.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||p.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),y=g?g[1].split(`
|
|
1016
|
+
`).map((w)=>w.trim().replace(/^\*\s*/,"")).join(" ").trim():"",h=/@component\(\s*['"]([^'"]+)['"]/g,x=/<([A-Z][a-zA-Z0-9]*|[a-z]+-[a-z0-9-]+)(?:\s[^>]*)?\/?>|\{\{\s*slot\s*\}\}/g,C=new Set,R;while((R=h.exec(p))!==null)C.add(R[1]);while((R=x.exec(p))!==null)if(R[1]&&R[1]!=="slot")C.add(R[1]);let O=/@([a-z]+)(?:\s*\(|\s+|$)/g,v=new Set;while((R=O.exec(p))!==null)v.add(R[1]);o.push({name:u,path:r,description:y,components:[...C],directives:[...v]})}return o}catch(t){return console.error("Error generating template docs:",t),[]}}async function nr(n=[]){try{let t=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
|
|
1017
1017
|
<p>Welcome, {{ user.name }}!</p>
|
|
1018
1018
|
@endif`},{name:"else",description:"Provides an alternative if a condition is not met",hasEndTag:!1,example:`@if(user.isLoggedIn)
|
|
1019
1019
|
<p>Welcome back!</p>
|
|
@@ -1146,15 +1146,15 @@ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(St.
|
|
|
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 sr(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function ir(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
|
|
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 sr(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function ir(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 Ot.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 g=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),g=await er(t,d),console.log(`Found ${g.length} components`);let y=[];if(p.templates!==!1&&o)console.log("Generating template documentation..."),y=await tr(o),console.log(`Found ${y.length} templates`);let h=[];if(p.directives!==!1)console.log("Generating directive documentation..."),h=await nr(r),console.log(`Found ${h.length} directives`);let x=p.format||"markdown",C=p.extraContent,R="",O="";switch(x){case"markdown":R=rr(g,y,h,C),O="md";break;case"html":R=or(g,y,h,C),O="html";break;case"json":R=sr(g,y,h,C),O="json";break;default:throw Error(`Unsupported documentation format: ${x}`)}let v=at.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 $a(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 ir({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 Io(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=lr(d,o),d=fr(d,o),d=dr(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
|
|
1155
|
-
`;let d=n;if(d=d.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(r,p,u,
|
|
1156
|
-
`),
|
|
1157
|
-
`),v=
|
|
1154
|
+
`;return d}function Ra(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1155
|
+
`;let d=n;if(d=d.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(r,p,u,g,y)=>{let h=g.split(`
|
|
1156
|
+
`),x=h.filter((w)=>w.trim().length>0);if(x.length===0)return r;let C=Math.min(...x.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=Io(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}
|
|
@@ -1170,16 +1170,16 @@ $1
|
|
|
1170
1170
|
$1
|
|
1171
1171
|
`),t=t.replace(/(@(?:csrf|method|include|extends|yield|stack|vite|asset)(?:\([^)]*\))?)/g,`
|
|
1172
1172
|
$1
|
|
1173
|
-
`),t=t.replace(/(?<=>)(<(?!\/)[^>]+>)/g,(r,p,u,
|
|
1174
|
-
${r}`}),t=t.replace(/(>)(<\/)/g,(r,p,u,
|
|
1175
|
-
${u}`}),t=t.replace(/(<\/[^>]+>)(?=<|$)/g,(r,p,u,
|
|
1173
|
+
`),t=t.replace(/(?<=>)(<(?!\/)[^>]+>)/g,(r,p,u,g)=>{let y=g.substring(u+r.length,Math.min(g.length,u+r.length+20)),h=r.match(/<(\w+)/)?.[1];if(h&&y.match(new RegExp(`^</${h}>`)))return r;return`
|
|
1174
|
+
${r}`}),t=t.replace(/(>)(<\/)/g,(r,p,u,g,y)=>{let h=y.substring(Math.max(0,g-50),g),C=y.substring(g+r.length,Math.min(y.length,g+r.length+20)).match(/^(\w+)>/)?.[1],R=h.match(/<(\w+)[^>]*$/)?.[1];if(R&&C&&R===C)return r;return`${p}
|
|
1175
|
+
${u}`}),t=t.replace(/(<\/[^>]+>)(?=<|$)/g,(r,p,u,g)=>{let y=g.substring(Math.max(0,u-20),u),h=r.match(/<\/(\w+)>/)?.[1],x=new RegExp(`<${h}[^>]*>$`);if(h&&y.match(x))return r;return`${r}
|
|
1176
1176
|
`}),t=t.replace(new RegExp(`${d}(\\d+)__`,"g"),(r,p)=>o[Number.parseInt(p,10)]),t=t.replace(/\n{2,}/g,`
|
|
1177
1177
|
`),t=t.split(`
|
|
1178
1178
|
`).map((r)=>r.trim()).join(`
|
|
1179
1179
|
`),t=t.replace(/^\n+/,"").replace(/\n+$/,""),t}function lr(n,t){let d=cr(n).split(`
|
|
1180
|
-
`),r=[],p=0,u=!1,
|
|
1180
|
+
`),r=[],p=0,u=!1,g=t.useTabs?"\t":" ".repeat(t.indentSize);for(let y=0;y<d.length;y++){let h=d[y],x=h.trim();if(x===""){r.push("");continue}let C=x.match(/<script\b/i),R=x.match(/<\/script>/i);if(u&&!R){r.push(h);continue}let O=x===">";if(Qt(x)&&!x.startsWith("<")&&!x.startsWith("@")){r.push(g.repeat(p)+x);continue}let v=x.startsWith("@end"),w=x.startsWith("@else")||x.startsWith("@elseif"),A=x.startsWith("@")&&ur(x),U=x.startsWith("<!DOCTYPE")||x.startsWith("<!doctype"),oe=x.startsWith("<!--"),L=x.startsWith("</"),I=x.startsWith("<")&&!L&&!oe&&!U,k=x.includes("/>")||pr(x),P=Qt(x);if(L||v)p=Math.max(0,p-1);let D=w?Math.max(0,p-1):p;if(O)r.push(h);else r.push(g.repeat(D)+x);if(I&&!k&&!P&&!O||A)p++;if(C)u=!0;if(R)u=!1}return r.join(`
|
|
1181
1181
|
`)}function dr(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 pr(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 ur(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 fr(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=[],
|
|
1182
|
+
`)||r.includes("@"))return o;let p=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],g;while((g=p.exec(r))!==null)u.push({name:g[1],value:g[2]});u.sort((h,x)=>{if(h.name==="id")return-1;if(x.name==="id")return 1;if(h.name==="class")return-1;if(x.name==="class")return 1;return h.name.localeCompare(x.name)});let y=u.map((h)=>h.value?`${h.name}=${h.value}`:h.name).join(" ");return`<${d}${y?` ${y}`:""}>`})}import en from"fs";import At from"path";async function Aa(n="index.stx",t={}){try{let o=t.force||!1,d=At.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=At.dirname(d);if(!en.existsSync(r))en.mkdirSync(r,{recursive:!0});let p;if(t.template){let u=At.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 rn();case"component":return mr();case"layout":return gr();case"blog":return hr();case"api":return yr();case"app":return xr();default:return rn()}}function rn(){return`<script>
|
|
1183
1183
|
const title = "My stx Page"
|
|
1184
1184
|
const description = "A page built with stx"
|
|
1185
1185
|
const features = [
|
|
@@ -1380,7 +1380,7 @@ const features = [
|
|
|
1380
1380
|
}
|
|
1381
1381
|
@else
|
|
1382
1382
|
{{ JSON.stringify(data, null, 2) }}
|
|
1383
|
-
@endif`}function
|
|
1383
|
+
@endif`}function xr(){return`<!DOCTYPE html>
|
|
1384
1384
|
<html lang="en">
|
|
1385
1385
|
<head>
|
|
1386
1386
|
<meta charset="UTF-8">
|
|
@@ -1605,5 +1605,5 @@ const features = [
|
|
|
1605
1605
|
})();
|
|
1606
1606
|
</script>
|
|
1607
1607
|
</body>
|
|
1608
|
-
</html>`}var
|
|
1609
|
-
`)}export{
|
|
1608
|
+
</html>`}var Pa="f9c3713";function uu(n){return n}function du(n){return n}function Ea(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 Ms(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 _s(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 Is(n,t=6){let o=ye.resolve(n),d=[],r=new Set;function p(g,y){if(y>t)return;let h;try{h=Ee.realpathSync(g)}catch{return}if(r.has(h))return;r.add(h);for(let C of mn){let R=ye.join(g,C),O=_s(R);if(O!==null)d.push({name:C,version:O,dir:ye.relative(o,R)||R,nested:y>0})}let x;try{x=Ee.readdirSync(g,{withFileTypes:!0})}catch{return}for(let C of x){if(!C.isDirectory()&&!C.isSymbolicLink())continue;if(C.name===".bin"||C.name===".cache")continue;let R=ye.join(g,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,y+1)}continue}let O=ye.join(R,"node_modules");if(Ee.existsSync(O))p(O,y+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 Oo(n={}){let t=n.cwd?ye.resolve(n.cwd):process.cwd(),o=n.resolve??Ms,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 y of Ls(Is(t)))r.push(y);let g=fn(t,"stx");if(!g)r.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let y=ye.join(g,"src/signals.ts"),h=[ye.join(g,"dist/index.js"),ye.join(g,"dist/signals.js")].find((v)=>Ee.existsSync(v))||null,x=un(y),C=h?un(h):null;if(x==null)r.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${g} 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 ${g} && bun build.ts`});else if(C<x){let v=Math.round((x-C)/1000);r.push({name:"pantry dist freshness",status:"error",detail:`dist (${wt(C,d)}) is OLDER than src/signals.ts (${wt(x,d)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${g} && bun build.ts`})}else r.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${wt(x,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(g)}catch{return g}})();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(y){r.push({name:"signals runtime",status:"error",detail:`failed to generate: ${y.message}`})}return{checks:r,ok:!r.some((y)=>y.status==="error")}}function No(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{Ea,Ta,$a,Io,Ra,Aa,Pa,uu,du,Oo,No,as,cs,ls};
|