@stacksjs/stx 0.2.874 → 0.2.875
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-003ph86a.js +2 -0
- package/dist/chunk-027meh1k.js +2 -0
- package/dist/chunk-0bc3mwqd.js +2 -0
- package/dist/{chunk-gbtbfg7e.js → chunk-0g2mg8cw.js} +3 -3
- package/dist/chunk-0gv2mmr0.js +2 -0
- package/dist/{chunk-c8jhskx8.js → chunk-0h6r7nvn.js} +38 -38
- package/dist/chunk-0j8zre1m.js +2 -0
- package/dist/{chunk-vxtx0khv.js → chunk-0qwbhv3f.js} +9 -9
- package/dist/{chunk-6mkn81pd.js → chunk-0sa9gqmc.js} +7 -7
- package/dist/chunk-1gfg6qmr.js +2 -0
- package/dist/{chunk-6ftee542.js → chunk-1q5w3xav.js} +2 -2
- package/dist/chunk-1tqp2s13.js +2 -0
- package/dist/chunk-1y7kfp5d.js +2 -0
- package/dist/chunk-1ztp5vkh.js +3 -0
- package/dist/chunk-24e4dapm.js +2 -0
- package/dist/{chunk-c3kanj1m.js → chunk-2qb9kp21.js} +3 -3
- package/dist/{chunk-01mwbg1r.js → chunk-2zaatnnh.js} +4 -4
- package/dist/chunk-32wvc376.js +2 -0
- package/dist/{chunk-gxan9w4e.js → chunk-3f9wctns.js} +2 -2
- package/dist/{chunk-v4xes880.js → chunk-3mz9bdf7.js} +3 -3
- package/dist/chunk-3te2y9qf.js +2 -0
- package/dist/{chunk-farh4p7f.js → chunk-3w7gacva.js} +2 -2
- package/dist/chunk-447jc6zc.js +2 -0
- package/dist/{chunk-s584xnzx.js → chunk-4517hny7.js} +2 -2
- package/dist/chunk-45rzd16g.js +1609 -0
- package/dist/{chunk-p1a1kbhz.js → chunk-4m11kcxz.js} +8 -8
- package/dist/chunk-51ymssz5.js +2 -0
- package/dist/{chunk-a0dsp485.js → chunk-644ckv6e.js} +10 -10
- package/dist/{chunk-2xc457bf.js → chunk-6az66mrc.js} +14 -14
- package/dist/chunk-6dz5za5z.js +2 -0
- package/dist/{chunk-fr72bsqd.js → chunk-6ezt9kbe.js} +11 -11
- package/dist/chunk-6grkdknk.js +2 -0
- package/dist/chunk-6q9a5bph.js +2 -0
- package/dist/chunk-6rqef7wp.js +2 -0
- package/dist/{chunk-atpscb2m.js → chunk-6ykfy7eh.js} +2 -2
- package/dist/{chunk-wa3z5c8j.js → chunk-72p5annm.js} +4 -4
- package/dist/chunk-74x6j229.js +4 -0
- package/dist/{chunk-n3jw3xpj.js → chunk-75v0yxeh.js} +2 -2
- package/dist/chunk-7j11vgm1.js +3 -0
- package/dist/chunk-7ngfcdv9.js +2 -0
- package/dist/chunk-7njy024g.js +2 -0
- package/dist/{chunk-b8z3vepm.js → chunk-88xayf21.js} +9 -9
- package/dist/{chunk-w5nw8e2p.js → chunk-95hbmv7k.js} +7 -7
- package/dist/{chunk-nack2xs5.js → chunk-976kgb3r.js} +5 -5
- package/dist/{chunk-ykapdv6d.js → chunk-9anqwafq.js} +3 -3
- package/dist/chunk-9e3ggwk7.js +2 -0
- package/dist/chunk-9mz2n39m.js +2 -0
- package/dist/chunk-a262spx7.js +2 -0
- package/dist/{chunk-xakypz4t.js → chunk-a5yb8w7s.js} +3 -3
- package/dist/chunk-a8wn0snv.js +2 -0
- package/dist/{chunk-55zq2ha8.js → chunk-ae8q4gze.js} +5 -5
- package/dist/{chunk-n56x7jg8.js → chunk-af6m1s2b.js} +1 -1
- package/dist/{chunk-hev4t4d5.js → chunk-afxfkb60.js} +6 -6
- package/dist/{chunk-kdmwy40c.js → chunk-az5rh7fs.js} +2 -2
- package/dist/chunk-b1tcym2x.js +2 -0
- package/dist/{chunk-j1efsjsb.js → chunk-b4d4tjvx.js} +5 -5
- package/dist/{chunk-pqgc8k6k.js → chunk-b61dq7pz.js} +1 -1
- package/dist/{chunk-j89p53vx.js → chunk-bdh73gxd.js} +2 -2
- package/dist/{chunk-4068rmzv.js → chunk-bjjfr7qt.js} +2 -2
- package/dist/chunk-bs7g6jtt.js +2 -0
- package/dist/chunk-bspj1rf1.js +2 -0
- package/dist/chunk-bx3hpsxn.js +2 -0
- package/dist/chunk-byq488g4.js +2 -0
- package/dist/chunk-c8pzj57b.js +2 -0
- package/dist/{chunk-79mmzprp.js → chunk-cmh0bfkb.js} +5 -5
- package/dist/{chunk-7j0qkye5.js → chunk-d3q0cg47.js} +2 -2
- package/dist/{chunk-b666d8m6.js → chunk-d6gqh2wv.js} +1 -1
- package/dist/{chunk-vvxcebpn.js → chunk-dbvsa5ya.js} +2 -2
- package/dist/{chunk-zt9j94ak.js → chunk-dw0ttj6p.js} +2 -2
- package/dist/chunk-e2b2f502.js +2 -0
- package/dist/chunk-ec6mrad6.js +2 -0
- package/dist/chunk-eh2gec79.js +2 -0
- package/dist/{chunk-8hhhmscy.js → chunk-eknm4jrm.js} +2 -2
- package/dist/chunk-em31p5pb.js +2 -0
- package/dist/chunk-eqfsw6x4.js +2 -0
- package/dist/{chunk-4nb7egk0.js → chunk-esjr9qhe.js} +2 -2
- package/dist/chunk-ey1vwfpc.js +24 -0
- package/dist/{chunk-wk2rge05.js → chunk-f4vgagjb.js} +3 -3
- package/dist/chunk-fa57bncd.js +2 -0
- package/dist/{chunk-qjey0jk6.js → chunk-fdjx4vs3.js} +2 -2
- package/dist/chunk-fk79jbzn.js +2 -0
- package/dist/{chunk-pqy58ps0.js → chunk-fnjm3xbf.js} +6 -6
- package/dist/{chunk-zfrzdje6.js → chunk-ft6em3wm.js} +6 -6
- package/dist/{chunk-bv9dbf4m.js → chunk-fy6ts0n4.js} +2 -2
- package/dist/{chunk-hr147ys5.js → chunk-g33ycxe3.js} +5 -5
- package/dist/{chunk-p219rr27.js → chunk-g7qpnmbm.js} +14 -14
- package/dist/chunk-g97krv0d.js +2 -0
- package/dist/chunk-gn16yq49.js +2 -0
- package/dist/{chunk-qcxrcypb.js → chunk-gqtb53s8.js} +2 -2
- package/dist/chunk-gvs61tqn.js +2 -0
- package/dist/chunk-h2928108.js +2 -0
- package/dist/chunk-hd5bny2c.js +2 -0
- package/dist/chunk-j1ytbd6r.js +1184 -0
- package/dist/chunk-jm7qa3v3.js +2 -0
- package/dist/chunk-jmjgj3nh.js +2 -0
- package/dist/chunk-jqtpzzz4.js +12 -0
- package/dist/{chunk-hmdkf6c6.js → chunk-jqxerj6k.js} +2 -2
- package/dist/{chunk-3z1mmar2.js → chunk-jt5tzddc.js} +2 -2
- package/dist/{chunk-q50x1gfd.js → chunk-k1ew643q.js} +2 -2
- package/dist/chunk-kq8mffgf.js +2 -0
- package/dist/chunk-kx06jzdw.js +2 -0
- package/dist/{chunk-ysfeg3cn.js → chunk-kywe0f1v.js} +2 -2
- package/dist/{chunk-60yppcbb.js → chunk-kzc2tqzr.js} +2 -2
- package/dist/{chunk-9zrvh3pz.js → chunk-mce3g2wb.js} +2 -2
- package/dist/{chunk-bbq79tap.js → chunk-mw0rb1sf.js} +4 -4
- package/dist/chunk-n344ss97.js +2 -0
- package/dist/chunk-n5pvdrkb.js +2 -0
- package/dist/chunk-ne8q191s.js +2 -0
- package/dist/{chunk-e7s109j6.js → chunk-nnp6rf4c.js} +1 -1
- package/dist/chunk-np8wgbsa.js +3 -0
- package/dist/{chunk-tyvm49be.js → chunk-nv4c25zj.js} +3 -3
- package/dist/{chunk-xdfmrv49.js → chunk-p4e8myzj.js} +6 -6
- package/dist/{chunk-dhbpbjt3.js → chunk-p5m1z6e1.js} +6 -6
- package/dist/{chunk-18a3vdnq.js → chunk-pk714ynv.js} +4 -4
- package/dist/{chunk-csymxc5a.js → chunk-pp99rmjm.js} +15 -15
- package/dist/chunk-pqmjeea6.js +2 -0
- package/dist/chunk-q0k2gmva.js +2 -0
- package/dist/{chunk-3z4p70t5.js → chunk-q7zc78az.js} +6 -6
- package/dist/chunk-qggwr60r.js +2 -0
- package/dist/chunk-qm3v4qb7.js +2 -0
- package/dist/{chunk-40h07m5w.js → chunk-qnwd5bz4.js} +1 -1
- package/dist/chunk-qrn1nza9.js +2 -0
- package/dist/chunk-qty0t69x.js +2 -0
- package/dist/{chunk-tabkp672.js → chunk-qvrew79n.js} +1 -1
- package/dist/{chunk-tnp2ta5q.js → chunk-r09kz9bf.js} +2 -2
- package/dist/{chunk-q1wxgw5s.js → chunk-r2bxjna3.js} +2 -2
- package/dist/chunk-rzadf7vx.js +20 -0
- package/dist/{chunk-6vgr5g6d.js → chunk-rzd9hyhv.js} +2 -2
- package/dist/{chunk-8tk8yf91.js → chunk-s7fhpkvf.js} +6 -6
- package/dist/{chunk-ew5cey88.js → chunk-saqzk45g.js} +1 -1
- package/dist/{chunk-srgnevws.js → chunk-stn7p7f1.js} +2 -2
- package/dist/{chunk-bast33qy.js → chunk-t4g3ka8c.js} +6 -6
- package/dist/chunk-ts37jw3s.js +2 -0
- package/dist/{chunk-cqhwzd9y.js → chunk-v0tdg16k.js} +5 -5
- package/dist/{chunk-0k11nsv1.js → chunk-vmssv78v.js} +3 -3
- package/dist/{chunk-ymdw4fhd.js → chunk-vnrbjbrw.js} +2 -2
- package/dist/{chunk-ttm0gvrc.js → chunk-vznf808n.js} +5 -5
- package/dist/chunk-wkb7dhp7.js +2 -0
- package/dist/{chunk-m131znxe.js → chunk-wm029dh0.js} +13 -13
- package/dist/{chunk-hhbt8grm.js → chunk-wp0qpa50.js} +4 -4
- package/dist/chunk-wxyqp6g9.js +2 -0
- package/dist/{chunk-01c16zw4.js → chunk-wzvdr4ta.js} +2 -2
- package/dist/{chunk-e2t7mk29.js → chunk-x2ftkaz3.js} +2 -2
- package/dist/chunk-x76qvq1n.js +2 -0
- package/dist/{chunk-v37zmez0.js → chunk-xmws1gaf.js} +2 -2
- package/dist/{chunk-a8164hnf.js → chunk-xtaq95em.js} +1 -1
- package/dist/{chunk-5a0d3048.js → chunk-y2e2zm6y.js} +3 -3
- package/dist/chunk-y4hn1qh0.js +2 -0
- package/dist/{chunk-pywz8q4k.js → chunk-y75bds1g.js} +31 -31
- package/dist/chunk-yc8ggeh2.js +2 -0
- package/dist/{chunk-r0v2chpn.js → chunk-ydppkb8y.js} +2 -2
- package/dist/chunk-ydy0tfar.js +2 -0
- package/dist/chunk-yfed67yc.js +2 -0
- package/dist/{chunk-7ayvybdy.js → chunk-ysfgabpf.js} +3 -3
- package/dist/{chunk-fd1bpv35.js → chunk-yxdhz4ps.js} +2 -2
- package/dist/{chunk-rw5492e2.js → chunk-zc8a2erc.js} +4 -4
- package/dist/{chunk-7cvbz4eq.js → chunk-zn6n075d.js} +3 -3
- package/dist/cli.js +22 -22
- package/dist/component-library.d.ts +31 -1
- package/dist/component-library.js +74 -54
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/inherited-context.d.ts +14 -0
- package/dist/inherited-context.js +102 -0
- package/dist/native-component-context.d.ts +10 -0
- package/dist/native-component-context.js +94 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +12 -12
- package/dist/stx-virtual-ts.d.ts +14 -2
- package/dist/stx-virtual-ts.js +64 -34
- package/dist/typecheck.d.ts +5 -2
- package/dist/typecheck.js +29 -19
- package/package.json +5 -5
- package/dist/chunk-09jz09k9.js +0 -20
- package/dist/chunk-10h8v5d4.js +0 -2
- package/dist/chunk-19dsn6tp.js +0 -2
- package/dist/chunk-26vxgd2w.js +0 -2
- package/dist/chunk-277dpq3b.js +0 -2
- package/dist/chunk-2asyyky3.js +0 -2
- package/dist/chunk-2r9s38f6.js +0 -2
- package/dist/chunk-2xhwadvn.js +0 -2
- package/dist/chunk-46pxmpeb.js +0 -3
- package/dist/chunk-4es07dwb.js +0 -2
- package/dist/chunk-4pr29yrx.js +0 -2
- package/dist/chunk-4v70bs2q.js +0 -2
- package/dist/chunk-4ygesqbx.js +0 -2
- package/dist/chunk-54jx5hqh.js +0 -2
- package/dist/chunk-5nj2k8zf.js +0 -2
- package/dist/chunk-6pczzq5f.js +0 -2
- package/dist/chunk-73k579v7.js +0 -2
- package/dist/chunk-7c9pzpsw.js +0 -2
- package/dist/chunk-7etvn4dx.js +0 -2
- package/dist/chunk-7wqevtks.js +0 -2
- package/dist/chunk-93538x9s.js +0 -2
- package/dist/chunk-9fyw1xkh.js +0 -3
- package/dist/chunk-9waxasf6.js +0 -712
- package/dist/chunk-a5qxcz86.js +0 -4
- package/dist/chunk-asrzmw7w.js +0 -2
- package/dist/chunk-awmfyb3t.js +0 -2
- package/dist/chunk-ba91r7q9.js +0 -2
- package/dist/chunk-cvgbtmxp.js +0 -2
- package/dist/chunk-d0h18m2r.js +0 -2
- package/dist/chunk-d5zh2663.js +0 -2
- package/dist/chunk-djdganvr.js +0 -2
- package/dist/chunk-dmcmxf3a.js +0 -2
- package/dist/chunk-eczy00w6.js +0 -2
- package/dist/chunk-esb34a1r.js +0 -20
- package/dist/chunk-f4wezqh4.js +0 -2
- package/dist/chunk-f52b9hjv.js +0 -2
- package/dist/chunk-f8pp58kw.js +0 -2
- package/dist/chunk-g3tfct27.js +0 -2
- package/dist/chunk-g9m84nqk.js +0 -2
- package/dist/chunk-gc4bgven.js +0 -2
- package/dist/chunk-gvh45ddc.js +0 -2
- package/dist/chunk-gvz0kqkz.js +0 -2
- package/dist/chunk-h2qgqjkn.js +0 -2
- package/dist/chunk-hcaedzck.js +0 -2
- package/dist/chunk-j4zrq17p.js +0 -2
- package/dist/chunk-kz0txvqb.js +0 -2
- package/dist/chunk-m9cperj4.js +0 -2
- package/dist/chunk-me7cxs0e.js +0 -2
- package/dist/chunk-meqsd5bt.js +0 -2
- package/dist/chunk-p2kqsb5k.js +0 -2
- package/dist/chunk-pvrgv5cx.js +0 -2051
- package/dist/chunk-rqa92xm4.js +0 -2
- package/dist/chunk-s54e61xt.js +0 -2
- package/dist/chunk-s92j8k4z.js +0 -2
- package/dist/chunk-sw8ms82g.js +0 -2
- package/dist/chunk-swfvh1cz.js +0 -3
- package/dist/chunk-tp2ftck2.js +0 -2
- package/dist/chunk-vd679g2w.js +0 -2
- package/dist/chunk-vk98r75z.js +0 -2
- package/dist/chunk-vmq773pb.js +0 -2
- package/dist/chunk-vv65gsys.js +0 -2
- package/dist/chunk-w6ry02z8.js +0 -2
- package/dist/chunk-w8qr5414.js +0 -2
- package/dist/chunk-xjxcwrqs.js +0 -2
- package/dist/chunk-xye2mkbh.js +0 -2
- package/dist/chunk-ytzzth34.js +0 -2
- package/dist/chunk-yxpjj003.js +0 -2
- package/dist/chunk-z6c4c951.js +0 -2
- package/dist/chunk-z9xe3xkg.js +0 -12
- package/dist/chunk-zmfqx1b1.js +0 -2
- package/dist/chunk-zze8tw0h.js +0 -2
|
@@ -0,0 +1,1609 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{L,xn,Bt,Ft,h,s,xe,g}from"./chunk-j1ytbd6r.js";import{kt,Me,wc,gs,Wo,qo,i}from"./chunk-0h6r7nvn.js";import{me,oe,Nr,Ae,W,An}from"./chunk-pp99rmjm.js";import{$t,vr,Ds,Ms,Ls,Rt,At,Pt,It,Ot,Nt,it}from"./chunk-wp0qpa50.js";import{Rs,a,M}from"./chunk-6az66mrc.js";import{wt,en,Ie,H,Sa,Eo,es,Ye,ka,Ze,Oe}from"./chunk-0qwbhv3f.js";import{yr,br}from"./chunk-dw0ttj6p.js";import{e,mn,pr,x}from"./chunk-644ckv6e.js";import{nt}from"./chunk-6ezt9kbe.js";import{De}from"./chunk-mce3g2wb.js";import{Mn}from"./chunk-3f9wctns.js";import{Q,Ce,Ee}from"./chunk-95hbmv7k.js";import{l}from"./chunk-np8wgbsa.js";import{Z}from"./chunk-1ztp5vkh.js";import{c,f}from"./chunk-yxdhz4ps.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=Dn(t,o),p=_n(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
|
+
`),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,m=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length,b=(n.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,y=u+m+b,v=(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 w=R>=4?3:0,S=Math.min(10,Math.ceil(p.total*0.5+y*0.1+v*0.3+(r>10?r*0.05:0)+w));return{lines:t.length,characters:n.length,directives:p,expressions:y,components:v,layouts:C,scriptLines:r,complexity:S}}function On(n,t){let o=[],d=Vt(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=Vt(n,"foreach","endforeach");if(r>0)o.push({type:"error",category:"syntax",message:`Found ${r} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let p=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=n.match(/<img[^>]*>/g);if(m){let v=m.filter((C)=>!C.includes("alt="));if(v.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${v.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let b=n.split(`
|
|
5
|
+
`).filter((v)=>v.length>120);if(b.length>0)o.push({type:"info",category:"maintainability",message:`Found ${b.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let y=(n.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(y>3)o.push({type:"info",category:"maintainability",message:`Found ${y} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function Dn(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 _n(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 Vt(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 da(n=["**/*.stx"],t){let o=[],d=[];for(let p of n){let u=await Array.fromAsync(new Bun.Glob(p).scan({cwd:t||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((m)=>m.endsWith(".stx")))}for(let p of d)try{let u=await Pn(p);o.push(u)}catch(u){console.warn(`Failed to analyze ${p}:`,u)}let r=Ln(o);return{results:o,summary:r}}function Ln(n){let t=n.length,o=n.reduce((y,v)=>y+v.metrics.lines,0),d=t>0?n.reduce((y,v)=>y+v.metrics.complexity,0)/t:0,r=n.reduce((y,v)=>y+v.issues.length,0),p={};n.forEach((y)=>{y.issues.forEach((v)=>{p[v.category]=(p[v.category]||0)+1})});let u=t>0?n.reduce((y,v)=>y+v.performance.estimatedRenderTime,0)/t:0,m=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),b=[];if(d>6)b.push("Project has high average complexity. Consider refactoring complex templates.");if(r>t*2)b.push("High number of issues detected. Run detailed analysis on individual files.");if(p.security>0)b.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:t,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:r,issuesByCategory:p,performanceScore:m,recommendations:b}}var{serve:Wn}=globalThis.Bun;import Mt from"fs";import et from"path";function pt(){return`
|
|
6
|
+
/* Theme selector for code blocks */
|
|
7
|
+
.theme-selector {
|
|
8
|
+
margin: 1rem 0;
|
|
9
|
+
padding: 0.5rem;
|
|
10
|
+
background: #f8f8f8;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
text-align: right;
|
|
13
|
+
}
|
|
14
|
+
select {
|
|
15
|
+
padding: 0.25rem 0.5rem;
|
|
16
|
+
border-radius: 3px;
|
|
17
|
+
border: 1px solid #ddd;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Dark mode body styles */
|
|
21
|
+
body.dark-mode {
|
|
22
|
+
background-color: #121212;
|
|
23
|
+
color: #e1e4e8;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
body.dark-mode h1,
|
|
27
|
+
body.dark-mode h2,
|
|
28
|
+
body.dark-mode h3 {
|
|
29
|
+
color: #e1e4e8;
|
|
30
|
+
border-color: #2f363d;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body.dark-mode .theme-selector {
|
|
34
|
+
background: #2f363d;
|
|
35
|
+
color: #e1e4e8;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
body.dark-mode select {
|
|
39
|
+
background: #24292e;
|
|
40
|
+
color: #e1e4e8;
|
|
41
|
+
border-color: #444;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
body.dark-mode blockquote {
|
|
45
|
+
background: #24292e;
|
|
46
|
+
color: #e1e4e8;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
body.dark-mode .frontmatter {
|
|
50
|
+
background: #24292e;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
body.dark-mode a {
|
|
54
|
+
color: #58a6ff;
|
|
55
|
+
}`}function ut(n){return`
|
|
56
|
+
<div class="theme-selector">
|
|
57
|
+
Theme:
|
|
58
|
+
<select id="themeSelector" onchange="changeTheme()">
|
|
59
|
+
${n}
|
|
60
|
+
</select>
|
|
61
|
+
</div>`}function ft(){return`
|
|
62
|
+
function changeTheme() {
|
|
63
|
+
const theme = document.getElementById('themeSelector').value;
|
|
64
|
+
|
|
65
|
+
// Toggle dark mode class based on theme
|
|
66
|
+
// Dark themes typically include these keywords in their names
|
|
67
|
+
if (theme.includes('dark') || theme.includes('night') || theme.includes('monokai') ||
|
|
68
|
+
theme.includes('dracula') || theme.includes('nord') || theme.includes('material')) {
|
|
69
|
+
document.body.classList.add('dark-mode');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
document.body.classList.remove('dark-mode');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Initialize theme on page load
|
|
77
|
+
document.addEventListener('DOMContentLoaded', changeTheme);`}function mt(n){if(Object.keys(n).length===0)return"";return`
|
|
78
|
+
<div class="frontmatter">
|
|
79
|
+
<h3>Frontmatter</h3>
|
|
80
|
+
${Object.entries(n).map(([t,o])=>`
|
|
81
|
+
<div class="frontmatter-item">
|
|
82
|
+
<span class="frontmatter-label">${t}:</span>
|
|
83
|
+
<span>${Array.isArray(o)?o.join(", "):String(o)}</span>
|
|
84
|
+
</div>`).join("")}
|
|
85
|
+
</div>`}async function In(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"0.0.0.0")})}async function jn(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 Hn(n){if(!await In(n))return!1;return await jn(n)}async function Ve(n,t=20){n=Number(n);for(let o=0;o<t;o++){let d=n+o;if(await Hn(d))return d}throw Error(`Could not find an available port between ${n} and ${n+t-1}`)}var Bn={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Fn(){try{let n=await import("./chunk-yc8ggeh2.js");if(typeof n.openDevWindow!=="function")return null;return n}catch{return null}}async function Qe(n,t={}){let o={...Bn,...t},d=await Fn();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
|
+
${p}
|
|
87
|
+
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
88
|
+
`,b=Function(u)();if(b)return b}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 Dt(){console.log(`
|
|
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`),Dt()}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 qe(n,t,o){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),Dt();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 Dt();break;default:break}}async function _t(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=et.resolve(n);if(!Mt.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 Me(r,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),O=t.markdown?.syntaxHighlighting||M.markdown?.syntaxHighlighting,w=O?.defaultTheme||"github-dark",S=["github-dark"],A=O?.additionalThemes||[],se=[...new Set([...S,...A])].map((B)=>`<option value="${B}"${B===w?" selected":""}>${B}</option>`).join(`
|
|
91
|
+
`);return p=`
|
|
92
|
+
<!DOCTYPE html>
|
|
93
|
+
<html lang="en">
|
|
94
|
+
<head>
|
|
95
|
+
<meta charset="UTF-8">
|
|
96
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
97
|
+
<title>${Vn(R.title||et.basename(r))}</title>
|
|
98
|
+
<!-- Syntax highlighting styles -->
|
|
99
|
+
<style id="syntax-theme">
|
|
100
|
+
:root {
|
|
101
|
+
--shiki-color-text: #24292e;
|
|
102
|
+
--shiki-color-background: #ffffff;
|
|
103
|
+
--shiki-token-constant: #005cc5;
|
|
104
|
+
--shiki-token-string: #032f62;
|
|
105
|
+
--shiki-token-comment: #6a737d;
|
|
106
|
+
--shiki-token-keyword: #d73a49;
|
|
107
|
+
--shiki-token-parameter: #24292e;
|
|
108
|
+
--shiki-token-function: #6f42c1;
|
|
109
|
+
--shiki-token-string-expression: #032f62;
|
|
110
|
+
--shiki-token-punctuation: #24292e;
|
|
111
|
+
--shiki-token-link: #032f62;
|
|
112
|
+
}
|
|
113
|
+
pre {
|
|
114
|
+
background-color: var(--shiki-color-background);
|
|
115
|
+
padding: 1rem;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
}
|
|
118
|
+
code {
|
|
119
|
+
color: var(--shiki-color-text);
|
|
120
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
121
|
+
}
|
|
122
|
+
.dark-mode {
|
|
123
|
+
--shiki-color-text: #e1e4e8;
|
|
124
|
+
--shiki-color-background: #24292e;
|
|
125
|
+
--shiki-token-constant: #79b8ff;
|
|
126
|
+
--shiki-token-string: #9ecbff;
|
|
127
|
+
--shiki-token-comment: #6a737d;
|
|
128
|
+
--shiki-token-keyword: #f97583;
|
|
129
|
+
--shiki-token-parameter: #e1e4e8;
|
|
130
|
+
--shiki-token-function: #b392f0;
|
|
131
|
+
--shiki-token-string-expression: #9ecbff;
|
|
132
|
+
--shiki-token-punctuation: #e1e4e8;
|
|
133
|
+
--shiki-token-link: #9ecbff;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
136
|
+
<style>
|
|
137
|
+
body {
|
|
138
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
139
|
+
line-height: 1.6;
|
|
140
|
+
color: #333;
|
|
141
|
+
max-width: 800px;
|
|
142
|
+
margin: 0 auto;
|
|
143
|
+
padding: 2rem;
|
|
144
|
+
}
|
|
145
|
+
pre, code {
|
|
146
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
147
|
+
}
|
|
148
|
+
pre {
|
|
149
|
+
border-radius: 4px;
|
|
150
|
+
padding: 0;
|
|
151
|
+
margin: 1.5rem 0;
|
|
152
|
+
overflow-x: auto;
|
|
153
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
154
|
+
}
|
|
155
|
+
pre code {
|
|
156
|
+
display: block;
|
|
157
|
+
padding: 1rem;
|
|
158
|
+
overflow-x: auto;
|
|
159
|
+
}
|
|
160
|
+
/* Apply background color to code blocks based on theme */
|
|
161
|
+
pre.syntax-highlighter {
|
|
162
|
+
background-color: var(--shiki-color-background) !important;
|
|
163
|
+
}
|
|
164
|
+
.dark-mode pre.syntax-highlighter {
|
|
165
|
+
background-color: var(--shiki-color-background) !important;
|
|
166
|
+
}
|
|
167
|
+
code {
|
|
168
|
+
padding: 0.2rem 0.4rem;
|
|
169
|
+
border-radius: 3px;
|
|
170
|
+
}
|
|
171
|
+
h1, h2, h3, h4 {
|
|
172
|
+
margin-top: 2rem;
|
|
173
|
+
margin-bottom: 1rem;
|
|
174
|
+
}
|
|
175
|
+
h1 { color: #111; border-bottom: 1px solid #eee; padding-bottom: 0.5rem; }
|
|
176
|
+
h2 { color: #333; border-bottom: 1px solid #f0f0f0; padding-bottom: 0.3rem; }
|
|
177
|
+
h3 { color: #444; }
|
|
178
|
+
img {
|
|
179
|
+
max-width: 100%;
|
|
180
|
+
border-radius: 4px;
|
|
181
|
+
margin: 1rem 0;
|
|
182
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
183
|
+
}
|
|
184
|
+
blockquote {
|
|
185
|
+
border-left: 4px solid #ddd;
|
|
186
|
+
padding-left: 1rem;
|
|
187
|
+
margin-left: 0;
|
|
188
|
+
color: #555;
|
|
189
|
+
background: #f9f9f9;
|
|
190
|
+
padding: 0.5rem 1rem;
|
|
191
|
+
margin: 1.5rem 0;
|
|
192
|
+
}
|
|
193
|
+
table {
|
|
194
|
+
border-collapse: collapse;
|
|
195
|
+
width: 100%;
|
|
196
|
+
margin: 1.5rem 0;
|
|
197
|
+
}
|
|
198
|
+
th, td {
|
|
199
|
+
border: 1px solid #ddd;
|
|
200
|
+
padding: 0.5rem;
|
|
201
|
+
}
|
|
202
|
+
th {
|
|
203
|
+
background: #f0f0f0;
|
|
204
|
+
text-align: left;
|
|
205
|
+
}
|
|
206
|
+
tr:nth-child(even) {
|
|
207
|
+
background-color: #f8f8f8;
|
|
208
|
+
}
|
|
209
|
+
a {
|
|
210
|
+
color: #0066cc;
|
|
211
|
+
text-decoration: none;
|
|
212
|
+
}
|
|
213
|
+
a:hover {
|
|
214
|
+
text-decoration: underline;
|
|
215
|
+
}
|
|
216
|
+
hr {
|
|
217
|
+
border: 0;
|
|
218
|
+
border-top: 1px solid #eee;
|
|
219
|
+
margin: 2rem 0;
|
|
220
|
+
}
|
|
221
|
+
.frontmatter {
|
|
222
|
+
background: #f8f8f8;
|
|
223
|
+
border-radius: 4px;
|
|
224
|
+
padding: 1.5rem;
|
|
225
|
+
margin-bottom: 2rem;
|
|
226
|
+
font-size: 0.9rem;
|
|
227
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
228
|
+
border-left: 4px solid #ddd;
|
|
229
|
+
}
|
|
230
|
+
.frontmatter-item {
|
|
231
|
+
margin-bottom: 0.5rem;
|
|
232
|
+
display: flex;
|
|
233
|
+
}
|
|
234
|
+
.frontmatter-label {
|
|
235
|
+
font-weight: bold;
|
|
236
|
+
min-width: 100px;
|
|
237
|
+
color: #555;
|
|
238
|
+
}
|
|
239
|
+
${pt()}
|
|
240
|
+
</style>
|
|
241
|
+
</head>
|
|
242
|
+
<body>
|
|
243
|
+
${mt(R)}
|
|
244
|
+
${ut(se)}
|
|
245
|
+
|
|
246
|
+
${C}
|
|
247
|
+
|
|
248
|
+
<script>
|
|
249
|
+
${ft()}
|
|
250
|
+
</script>
|
|
251
|
+
</body>
|
|
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 b=o;try{if(b=await Ve(o),b!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${b} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${b}/${e.reset}...`);let y=Wn({port:b,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
|
+
${C.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
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:${b}/${e.reset}`),console.log(`
|
|
257
|
+
${e.yellow}Routes:${e.reset}`);let v=et.relative(process.cwd(),r);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${v}${e.reset}`),console.log(`
|
|
258
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(y.url.toString(),()=>{if(d)Mt.watch(et.dirname(r),{recursive:!0}).close();y.stop()}),t.native)await Qe(b,{title:et.basename(r,".md")});if(d){let C=et.dirname(r);console.log(`${e.blue}Watching ${e.bright}${C}${e.reset} for changes...`);let R=Mt.watch(C,{recursive:!0},async(O,w)=>{if(w&&w.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${w}${e.yellow} changed, reprocessing...${e.reset}`),await u()});process.on("SIGINT",()=>{R.close(),y.stop(),process.exit(0)})}return!0}function Vn(n){return String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Kn}=globalThis.Bun;import Fe from"fs";import he from"path";class qt{clients=new Set;server=null;options;constructor(n={}){this.options={wsPort:n.wsPort??3001,showOverlay:n.showOverlay??!0,reconnectInterval:n.reconnectInterval??1000,maxReconnectAttempts:n.maxReconnectAttempts??10,verbose:n.verbose??!1}}start(n){let t=n??this.options.wsPort,o=20;for(let d=0;d<o;d++)try{if(this.server=Bun.serve({port:t,fetch(r,p){if(p.upgrade(r,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(r)=>{if(this.clients.add(r),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);r.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(r)=>{if(this.clients.delete(r),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(r,p)=>{let u=typeof p==="string"?p:p.toString();if(u==="ping")return;try{let m=JSON.parse(u);if(m.type==="console"&&Array.isArray(m.args)){let b=m.args.join(" "),v={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[m.level]??"\x1B[36m";console.log(`${v}[browser]${m.level!=="log"?` ${m.level}`:""}\x1B[0m ${b}`)}}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
|
+
<script>
|
|
260
|
+
(function() {
|
|
261
|
+
// stx Hot Reload Client
|
|
262
|
+
var wsUrl = 'ws://' + window.location.hostname + ':${n}';
|
|
263
|
+
var reconnectAttempts = 0;
|
|
264
|
+
var maxAttempts = ${r};
|
|
265
|
+
var reconnectInterval = ${d};
|
|
266
|
+
var socket = null;
|
|
267
|
+
var overlay = null;
|
|
268
|
+
var wasConnected = false; // Track if we ever connected successfully
|
|
269
|
+
|
|
270
|
+
${o?`
|
|
271
|
+
// Create connection status overlay
|
|
272
|
+
function createOverlay() {
|
|
273
|
+
overlay = document.createElement('div');
|
|
274
|
+
overlay.id = 'stx-hmr-overlay';
|
|
275
|
+
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;padding:8px 16px;background:#f59e0b;color:#000;font-family:system-ui,sans-serif;font-size:14px;text-align:center;z-index:999999;display:none;';
|
|
276
|
+
document.body.appendChild(overlay);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function showOverlay(message, isError) {
|
|
280
|
+
// Only show overlay if we were previously connected (don't show during initial connection)
|
|
281
|
+
if (!wasConnected && !isError) return;
|
|
282
|
+
if (!overlay) createOverlay();
|
|
283
|
+
overlay.textContent = message;
|
|
284
|
+
overlay.style.background = isError ? '#ef4444' : '#f59e0b';
|
|
285
|
+
overlay.style.color = isError ? '#fff' : '#000';
|
|
286
|
+
overlay.style.display = 'block';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function hideOverlay() {
|
|
290
|
+
if (overlay) overlay.style.display = 'none';
|
|
291
|
+
}
|
|
292
|
+
`:`
|
|
293
|
+
function showOverlay() {}
|
|
294
|
+
function hideOverlay() {}
|
|
295
|
+
`}
|
|
296
|
+
|
|
297
|
+
function connect() {
|
|
298
|
+
try {
|
|
299
|
+
socket = new WebSocket(wsUrl);
|
|
300
|
+
}
|
|
301
|
+
catch (e) {
|
|
302
|
+
// Silent fail for initial connection attempts
|
|
303
|
+
if (wasConnected) {
|
|
304
|
+
scheduleReconnect();
|
|
305
|
+
}
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
socket.onopen = function() {
|
|
310
|
+
// connected silently
|
|
311
|
+
wasConnected = true;
|
|
312
|
+
reconnectAttempts = 0;
|
|
313
|
+
hideOverlay();
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
socket.onmessage = function(event) {
|
|
317
|
+
try {
|
|
318
|
+
var msg = JSON.parse(event.data);
|
|
319
|
+
|
|
320
|
+
switch (msg.type) {
|
|
321
|
+
case 'reload':
|
|
322
|
+
console.log('[stx] Reloading...', msg.path || '');
|
|
323
|
+
// Use SPA router for progressive update instead of full page reload.
|
|
324
|
+
// Falls back to hard reload only when the router isn't available.
|
|
325
|
+
// Call the ROUTER directly, not window.navigate: the runtime helper
|
|
326
|
+
// takes (url, options) and silently dropped the third argument, so
|
|
327
|
+
// force never arrived and the same-URL early return made this a
|
|
328
|
+
// no-op on every page that had the router (#1807). pushState=false
|
|
329
|
+
// keeps the address bar untouched (this is a reload, not a
|
|
330
|
+
// navigation) and force=true bypasses the early return.
|
|
331
|
+
if (window.stxRouter && typeof window.stxRouter.navigate === 'function') {
|
|
332
|
+
window.stxRouter.navigate(window.location.pathname + window.location.search, false, true);
|
|
333
|
+
} else {
|
|
334
|
+
window.location.reload();
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
|
|
338
|
+
case 'css-update':
|
|
339
|
+
console.log('[stx] CSS update:', msg.path);
|
|
340
|
+
updateCss(msg.path, msg.content);
|
|
341
|
+
break;
|
|
342
|
+
|
|
343
|
+
case 'error':
|
|
344
|
+
console.error('[stx] Error:', msg.content);
|
|
345
|
+
showOverlay('Build Error: ' + msg.content, true);
|
|
346
|
+
break;
|
|
347
|
+
|
|
348
|
+
case 'connected':
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
console.error('[stx] Invalid message:', e);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
socket.onclose = function() {
|
|
358
|
+
socket = null;
|
|
359
|
+
// Only log and show overlay if we were previously connected
|
|
360
|
+
if (wasConnected) {
|
|
361
|
+
console.log('[stx] Connection closed, reconnecting...');
|
|
362
|
+
scheduleReconnect();
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
// Silently retry initial connection
|
|
366
|
+
setTimeout(connect, reconnectInterval);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
socket.onerror = function() {
|
|
371
|
+
// Errors are handled in onclose
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function scheduleReconnect() {
|
|
376
|
+
if (reconnectAttempts < maxAttempts) {
|
|
377
|
+
reconnectAttempts++;
|
|
378
|
+
showOverlay('Reconnecting... (' + reconnectAttempts + '/' + maxAttempts + ')');
|
|
379
|
+
setTimeout(connect, reconnectInterval);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
showOverlay('Connection lost. Refresh to reconnect.', true);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// CSS hot update without full reload
|
|
387
|
+
function updateCss(path, content) {
|
|
388
|
+
// Try to find and update existing stylesheet
|
|
389
|
+
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
|
390
|
+
for (var i = 0; i < links.length; i++) {
|
|
391
|
+
var href = links[i].getAttribute('href');
|
|
392
|
+
if (href && href.indexOf(path) !== -1) {
|
|
393
|
+
// Add cache-busting query param
|
|
394
|
+
var newHref = href.split('?')[0] + '?t=' + Date.now();
|
|
395
|
+
links[i].setAttribute('href', newHref);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// If content provided, inject as style tag
|
|
401
|
+
if (content) {
|
|
402
|
+
var style = document.createElement('style');
|
|
403
|
+
style.setAttribute('data-stx-hmr', path);
|
|
404
|
+
style.textContent = content;
|
|
405
|
+
|
|
406
|
+
// Remove old injected style
|
|
407
|
+
var old = document.querySelector('style[data-stx-hmr="' + path + '"]');
|
|
408
|
+
if (old) old.remove();
|
|
409
|
+
|
|
410
|
+
document.head.appendChild(style);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Start connection when DOM is ready
|
|
415
|
+
if (document.readyState === 'loading') {
|
|
416
|
+
document.addEventListener('DOMContentLoaded', connect);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
connect();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Forward browser console to the dev server terminal
|
|
423
|
+
var _origLog = console.log;
|
|
424
|
+
var _origError = console.error;
|
|
425
|
+
var _origWarn = console.warn;
|
|
426
|
+
var _origInfo = console.info;
|
|
427
|
+
|
|
428
|
+
function _fwd(level, args) {
|
|
429
|
+
if (socket && socket.readyState === 1) {
|
|
430
|
+
try {
|
|
431
|
+
socket.send(JSON.stringify({
|
|
432
|
+
type: 'console',
|
|
433
|
+
level: level,
|
|
434
|
+
args: Array.prototype.slice.call(args).map(function(a) {
|
|
435
|
+
if (a === null) return 'null';
|
|
436
|
+
if (a === undefined) return 'undefined';
|
|
437
|
+
if (typeof a === 'object') { try { return JSON.stringify(a); } catch(e) { return String(a); } }
|
|
438
|
+
return String(a);
|
|
439
|
+
})
|
|
440
|
+
}));
|
|
441
|
+
} catch(e) {}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
console.log = function() { _origLog.apply(console, arguments); _fwd('log', arguments); };
|
|
446
|
+
console.error = function() { _origError.apply(console, arguments); _fwd('error', arguments); };
|
|
447
|
+
console.warn = function() { _origWarn.apply(console, arguments); _fwd('warn', arguments); };
|
|
448
|
+
console.info = function() { _origInfo.apply(console, arguments); _fwd('info', arguments); };
|
|
449
|
+
|
|
450
|
+
// Expose for debugging
|
|
451
|
+
window.__stxHmr = {
|
|
452
|
+
reconnect: connect,
|
|
453
|
+
status: function() { return socket ? socket.readyState : -1; }
|
|
454
|
+
};
|
|
455
|
+
})();
|
|
456
|
+
</script>
|
|
457
|
+
`}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var tt=null;function bt(n){if(!tt)tt=new qt(n);return tt}function at(){if(tt)tt.stop(),tt=null}import vt from"path";var rt={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 Rs(o,d);if(p.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}n.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(o.cache&&o.cachePath){let S=await yr(u,o);if(S){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:S,loader:"html"}}}let b=await Ae(()=>Bun.file(u).text(),"",(S)=>{throw new Nr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${S.message}`)});if(!b)throw new Nr(`stx file is empty: ${u}`,u);let{scriptContent:y,templateContent:v,allScripts:C}=me.time("script-extraction",()=>{let S=b,A=L(b);if(A)S=A.content.trim();let V=b.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],se="",B=[];for(let k of V){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),K=D?D[1]:"";if(/\bserver\b/i.test(K))se=P;else B.push(k)}let j=S.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:se,templateContent:j,allScripts:B}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Ae(()=>h(y,R,u),void 0,(S)=>{let A=new oe(`Script execution failed in ${u}: ${S.message}`,u,void 0,void 0,y.substring(0,100));if(W.log(A,{filePath:u,scriptContent:y}),o.debug)throw A});let w=await me.timeAsync("directive-processing",async()=>await i(v,R,u,o,m));if(C.length>0){let{interpolateScriptsInTemplate:S}=await import("./chunk-9e3ggwk7.js"),A=S(C.join(`
|
|
458
|
+
`),R),V=w.search(/<\/body>/i);if(V!==-1)w=w.slice(0,V)+A+`
|
|
459
|
+
`+w.slice(V);else w+=`
|
|
460
|
+
${A}`}if(w=await Ee(w),m.forEach((S)=>d.add(S)),o.cache&&o.cachePath){if(await br(u,w,m,o),o.debug)console.log(`Cached template ${u} with ${m.size} dependencies`)}return{contents:w,loader:"html"}}catch(m){let b=m instanceof Error?m:new oe(`Plugin processing failed: ${String(m)}`,u);if(W.log(b,{filePath:u,buildConfig:n.config}),An.logDetailedError(b,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",b);let y=b,v=y.line||null,C=y.context||null;return{contents:o.debug||Z()?`<!DOCTYPE html>
|
|
461
|
+
<html lang="en">
|
|
462
|
+
<head>
|
|
463
|
+
<meta charset="UTF-8">
|
|
464
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
465
|
+
<title>stx Rendering Error</title>
|
|
466
|
+
<style>
|
|
467
|
+
body { font-family: system-ui, -apple-system, sans-serif; max-width: 800px; margin: 40px auto; padding: 20px; line-height: 1.6; }
|
|
468
|
+
.error-header { color: #dc3545; border-left: 4px solid #dc3545; padding-left: 16px; margin-bottom: 24px; }
|
|
469
|
+
.error-details { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; padding: 16px; margin: 16px 0; }
|
|
470
|
+
.error-code { background: #2d3748; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-family: 'Monaco', 'Menlo', monospace; font-size: 14px; }
|
|
471
|
+
.help-section { background: #e3f2fd; border-left: 4px solid #2196f3; padding: 16px; margin-top: 24px; }
|
|
472
|
+
.file-path { font-family: monospace; background: #f1f3f4; padding: 2px 6px; border-radius: 4px; }
|
|
473
|
+
</style>
|
|
474
|
+
</head>
|
|
475
|
+
<body>
|
|
476
|
+
<div class="error-header">
|
|
477
|
+
<h1>stx Template Error</h1>
|
|
478
|
+
<p>An error occurred while processing your stx template.</p>
|
|
479
|
+
</div>
|
|
480
|
+
|
|
481
|
+
<div class="error-details">
|
|
482
|
+
<h3>Error Details</h3>
|
|
483
|
+
<p><strong>File:</strong> <span class="file-path">${g(u)}</span></p>
|
|
484
|
+
<p><strong>Error:</strong> ${g(b.message)}</p>
|
|
485
|
+
${v?`<p><strong>Line:</strong> ${g(String(v))}</p>`:""}
|
|
486
|
+
${C?`<p><strong>Context:</strong> ${g(String(C))}</p>`:""}
|
|
487
|
+
</div>
|
|
488
|
+
|
|
489
|
+
${b.stack?`
|
|
490
|
+
<div class="error-details">
|
|
491
|
+
<h3>Stack Trace</h3>
|
|
492
|
+
<pre class="error-code">${g(b.stack)}</pre>
|
|
493
|
+
</div>`:""}
|
|
494
|
+
|
|
495
|
+
<div class="help-section">
|
|
496
|
+
<h3>Troubleshooting Tips</h3>
|
|
497
|
+
<ul>
|
|
498
|
+
<li>Check the syntax of your stx directives (e.g., @if, @foreach)</li>
|
|
499
|
+
<li>Verify that all variables used in the template are properly defined</li>
|
|
500
|
+
<li>Ensure script tags have valid JavaScript/TypeScript syntax</li>
|
|
501
|
+
<li>Run <code>stx debug ${g(vt.basename(u))}</code> for detailed analysis</li>
|
|
502
|
+
<li>Enable debug mode in your stx config for more detailed error messages</li>
|
|
503
|
+
</ul>
|
|
504
|
+
</div>
|
|
505
|
+
</body>
|
|
506
|
+
</html>`:`<!DOCTYPE html>
|
|
507
|
+
<html lang="en">
|
|
508
|
+
<head>
|
|
509
|
+
<meta charset="UTF-8">
|
|
510
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
511
|
+
<title>Error</title>
|
|
512
|
+
<style>
|
|
513
|
+
body { font-family: system-ui, -apple-system, sans-serif; max-width: 600px; margin: 80px auto; padding: 20px; text-align: center; color: #333; }
|
|
514
|
+
</style>
|
|
515
|
+
</head>
|
|
516
|
+
<body>
|
|
517
|
+
<h1>Something went wrong</h1>
|
|
518
|
+
<p>An internal error occurred. Please try again later.</p>
|
|
519
|
+
</body>
|
|
520
|
+
</html>`,loader:"html"}}})}};async function Gr(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=he.resolve(n);if(!Fe.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return _t(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let b=l(process.cwd(),"output");Fe.mkdirSync(b,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${n}${e.reset}...`);let y=null,v=async()=>{try{let P={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:b,plugins:[P,rt],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 K=D.outputs.find((ve)=>ve.path.endsWith(".html"));if(!K)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return y=await Bun.file(K.path).text(),!0}catch(P){return console.error(`${e.red}Error building stx file:${e.reset}`,P),!1}};if(!await v())return!1;let R=he.dirname(m);await mn(R);let O=o;try{if(O=await Ve(o),O!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${O} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let P=t.hmrPort||O+1;p=bt({wsPort:P,verbose:!1}),u=p.start(P)}let w={},S=null,A;try{let{loadStxConfig:P}=await import("./chunk-eqfsw6x4.js"),D=await P();if(A=t.stxOptions?.serverApi??D.serverApi,D?.apiRouter)S=D?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(D?.apiRoutes){w=D.apiRoutes;let K=Object.keys(w).length;if(K>0)console.log(`${e.blue}Loaded ${e.bright}${K} API route${K>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:K,loadChannels:Y}=await import("./chunk-3te2y9qf.js"),ve=D.broadcasting;await K(ve);let pe=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let Te=he.join(process.cwd(),"channels.ts");if(Fe.existsSync(Te))try{let ie=await Y(Te);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(K){console.warn(`${e.yellow}Broadcasting failed to start: ${K.message}${e.reset}`)}}catch{}let{createServerApi:V,isServerApiSource:se}=await import("./chunk-ydy0tfar.js"),B=await V(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 j=Kn({port:O,async fetch(P){return Mn(P,await(async()=>{let D=new URL(P.url);if([b,he.dirname(m),he.join(process.cwd(),"public")].some((ie)=>se(he.join(ie,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(S)try{let ie=await S.handleRequest(P);if(ie.status!==404)return ie}catch{}if(w[D.pathname])try{return await w[D.pathname](P)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let K=await B(P);if(K)return K;if(D.pathname==="/")return(async()=>{let z=await x(y||"");if(r)z=Ue(z,u);if(t.native)if(z.includes("<head>"))z=z.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(z.includes("<html"))z=z.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 z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;if(t.titlebarHidden)if(z.includes("<head>"))z=z.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(z.includes("<html"))z=z.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 z=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${z}`;return z})().then((z)=>new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=he.join(b,D.pathname);if(Fe.existsSync(Y)&&Fe.statSync(Y).isFile()){let ie=Bun.file(Y),z=he.extname(Y).toLowerCase(),E="text/plain";if(z===".ts"||z===".tsx"){let ze=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=ze.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){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 ve=he.dirname(m),pe=he.join(ve,D.pathname);if(Fe.existsSync(pe)&&Fe.statSync(pe).isFile()){let ie=Bun.file(pe),z=he.extname(pe).toLowerCase(),E="text/plain";if(z===".ts"||z===".tsx"){let ze=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=ze.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){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 Te=he.join(process.cwd(),"public",D.pathname);if(Fe.existsSync(Te)&&Fe.statSync(Te).isFile()){let ie=Bun.file(Te),z=he.extname(Te).toLowerCase(),E="application/octet-stream";if(z===".ts"||z===".tsx"){let ze=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=ze.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){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
|
+
${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
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
|
+
${e.bright}\u2192 ${e.cyan}http://localhost:${O}/${e.reset}`),console.log(`
|
|
524
|
+
${e.yellow}Routes:${e.reset}`);let k=he.relative(process.cwd(),m);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${k}${e.reset}`),console.log(`
|
|
525
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(j.url.toString(),()=>{if(d)Fe.watch(he.dirname(m),{recursive:!0}).close();j.stop()}),t.native){let P=await Bun.file(m).text(),D=gt(P);await Qe(O,{title:he.basename(m,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=he.dirname(m);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=Fe.watch(P,{recursive:!0},async(K,Y)=>{if(!Y||xt(Y))return;if(yt(Y)){console.log(`${e.yellow}File ${e.bright}${Y}${e.yellow} changed, rebuilding...${e.reset}`),nt.clear(),xe();let ve=await v();if(await pr(R),r&&p)if(ve)p.reload(Y);else p.error("Build failed - check console for details")}else if(ht(Y)){if(console.log(`${e.cyan}CSS ${e.bright}${Y}${e.cyan} changed${e.reset}`),r&&p)p.updateCss(Y)}});process.on("SIGINT",()=>{if(D.close(),p)at();j.stop(),process.exit(0)})}return!0}var{serve:Xn}=globalThis.Bun;import Ke from"fs";import ke from"path";var Kt=`
|
|
526
|
+
<script data-stx-helpers>
|
|
527
|
+
(function() {
|
|
528
|
+
'use strict'
|
|
529
|
+
|
|
530
|
+
if (window.__stxHelpers) return
|
|
531
|
+
window.__stxHelpers = true
|
|
532
|
+
|
|
533
|
+
window.stx = window.stx || {}
|
|
534
|
+
|
|
535
|
+
// ===== FORMATTERS =====
|
|
536
|
+
|
|
537
|
+
stx.formatCurrency = function(val, currency, locale) {
|
|
538
|
+
return new Intl.NumberFormat(locale || 'en-US', {
|
|
539
|
+
style: 'currency',
|
|
540
|
+
currency: currency || 'USD',
|
|
541
|
+
}).format(val)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
stx.formatNumber = function(val, decimals, locale) {
|
|
545
|
+
var opts = {}
|
|
546
|
+
if (typeof decimals === 'number') {
|
|
547
|
+
opts.minimumFractionDigits = decimals
|
|
548
|
+
opts.maximumFractionDigits = decimals
|
|
549
|
+
}
|
|
550
|
+
return new Intl.NumberFormat(locale || 'en-US', opts).format(val)
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
stx.formatDate = function(val, format, locale) {
|
|
554
|
+
locale = locale || 'en-US'
|
|
555
|
+
var d = val instanceof Date ? val : new Date(val)
|
|
556
|
+
if (isNaN(d.getTime())) return String(val)
|
|
557
|
+
|
|
558
|
+
if (format === 'long') return d.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })
|
|
559
|
+
if (format === 'relative') {
|
|
560
|
+
var diff = Date.now() - d.getTime()
|
|
561
|
+
var mins = Math.floor(diff / 60000)
|
|
562
|
+
if (mins < 1) return 'just now'
|
|
563
|
+
if (mins < 60) return mins + 'm ago'
|
|
564
|
+
var hrs = Math.floor(mins / 60)
|
|
565
|
+
if (hrs < 24) return hrs + 'h ago'
|
|
566
|
+
var days = Math.floor(hrs / 24)
|
|
567
|
+
if (days < 7) return days + 'd ago'
|
|
568
|
+
return d.toLocaleDateString(locale)
|
|
569
|
+
}
|
|
570
|
+
return d.toLocaleDateString(locale)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
stx.formatPhone = function(phone) {
|
|
574
|
+
var n = String(phone).replace(/\\D/g, '')
|
|
575
|
+
if (n.length === 10) return \`(\${n.slice(0,3)}) \${n.slice(3,6)}-\${n.slice(6)}\`
|
|
576
|
+
if (n.length === 11 && n[0] === '1') return \`+1 (\${n.slice(1,4)}) \${n.slice(4,7)}-\${n.slice(7)}\`
|
|
577
|
+
return phone
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
stx.renderStars = function(rating, max) {
|
|
581
|
+
max = max || 5
|
|
582
|
+
var full = Math.floor(rating)
|
|
583
|
+
var half = rating - full >= 0.5
|
|
584
|
+
var h = ''
|
|
585
|
+
for (var i = 0; i < max; i++) {
|
|
586
|
+
if (i < full || (i === full && half))
|
|
587
|
+
h += '<span style="color: var(--badge-amber-text, #f59e0b)">\\u2605</span>'
|
|
588
|
+
else
|
|
589
|
+
h += '<span style="color: var(--text-muted, #6b7280)">\\u2606</span>'
|
|
590
|
+
}
|
|
591
|
+
return h
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ===== BADGE SYSTEM =====
|
|
595
|
+
|
|
596
|
+
var badgeMaps = {
|
|
597
|
+
status: {
|
|
598
|
+
'Active Repair': 'badge-amber', 'Completed': 'badge-emerald',
|
|
599
|
+
'Pending Pickup': 'badge-blue', 'Pending Estimate': 'badge-slate',
|
|
600
|
+
'Approved': 'badge-emerald', 'In Review': 'badge-blue',
|
|
601
|
+
'Supplement': 'badge-amber', 'Draft': 'badge-slate', 'Rejected': 'badge-red',
|
|
602
|
+
'Delivered': 'badge-emerald', 'Shipped': 'badge-blue', 'Processing': 'badge-amber',
|
|
603
|
+
'In Stock': 'badge-emerald', 'Backordered': 'badge-red', 'Low Stock': 'badge-amber',
|
|
604
|
+
},
|
|
605
|
+
priority: { 'Rush': 'badge-red', 'High': 'badge-amber', 'Normal': 'badge-blue', 'Low': 'badge-slate' },
|
|
606
|
+
severity: { 'light': 'severity-light', 'moderate': 'severity-moderate', 'heavy': 'severity-heavy' },
|
|
607
|
+
type: { 'OEM': 'badge-blue', 'Aftermarket': 'badge-amber', 'Recycled': 'badge-emerald', 'Reman': 'badge-slate' },
|
|
608
|
+
drp: { 'Active DRP': 'badge-emerald', 'Preferred': 'badge-blue', 'Standard': 'badge-slate' },
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
stx.registerBadgeMap = function(name, map) {
|
|
612
|
+
badgeMaps[name] = Object.assign(badgeMaps[name] || {}, map)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
stx.badgeClass = function(value, mapName) {
|
|
616
|
+
var map = badgeMaps[mapName || 'status'] || badgeMaps.status
|
|
617
|
+
return map[value] || 'badge-slate'
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
stx.badge = function(value, mapName) {
|
|
621
|
+
return \`<span class="inline-flex px-2.5 py-1 rounded-full text-xs font-medium \${stx.badgeClass(value, mapName)}">\${value}</span>\`
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ===== DETAIL PANEL BUILDER =====
|
|
625
|
+
|
|
626
|
+
function esc(v) { return v != null ? v : '\\u2014' }
|
|
627
|
+
|
|
628
|
+
stx.detail = {
|
|
629
|
+
panel: function(opts) {
|
|
630
|
+
if (!opts || !opts.title) return ''
|
|
631
|
+
var badges = ''
|
|
632
|
+
if (opts.badges) {
|
|
633
|
+
opts.badges.forEach(function(b) { badges += stx.badge(b.text, b.map) })
|
|
634
|
+
}
|
|
635
|
+
return \`
|
|
636
|
+
<div style="display:flex;align-items:center;justify-content:space-between;padding:1.25rem 1.5rem;border-bottom:1px solid var(--border-main)">
|
|
637
|
+
<div>
|
|
638
|
+
<h2 style="font-size:1.25rem;font-weight:700;color:var(--text-primary)">\${opts.title}</h2>
|
|
639
|
+
\${opts.subtitle ? \`<p style="font-size:0.75rem;color:var(--text-muted);margin-top:0.25rem">\${opts.subtitle}</p>\` : ''}
|
|
640
|
+
</div>
|
|
641
|
+
<div style="display:flex;align-items:center;gap:0.75rem">
|
|
642
|
+
\${badges}
|
|
643
|
+
<button onclick="closeSlideOver()" style="padding:0.5rem;border-radius:0.5rem;color:var(--text-muted);background:none;border:none;cursor:pointer;font-size:1.5rem;line-height:1" aria-label="Close">×</button>
|
|
644
|
+
</div>
|
|
645
|
+
</div>\`
|
|
646
|
+
},
|
|
647
|
+
|
|
648
|
+
section: function(label, rows) {
|
|
649
|
+
var inner = ''
|
|
650
|
+
if (rows) {
|
|
651
|
+
if (!Array.isArray(rows) && typeof rows === 'object') {
|
|
652
|
+
Object.keys(rows).forEach(function(k) { inner += stx.detail.row(k, rows[k]) })
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
rows.forEach(function(r) {
|
|
656
|
+
if (Array.isArray(r)) inner += stx.detail.row(r[0], r[1])
|
|
657
|
+
else inner += stx.detail.row(r.label, r.value)
|
|
658
|
+
})
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return \`
|
|
662
|
+
<div class="detail-section">
|
|
663
|
+
<div class="detail-label">\${label}</div>
|
|
664
|
+
\${inner}
|
|
665
|
+
</div>\`
|
|
666
|
+
},
|
|
667
|
+
|
|
668
|
+
row: function(label, value) {
|
|
669
|
+
return \`
|
|
670
|
+
<div class="detail-row">
|
|
671
|
+
<span class="detail-row-label">\${label}</span>
|
|
672
|
+
<span class="detail-row-value">\${esc(value)}</span>
|
|
673
|
+
</div>\`
|
|
674
|
+
},
|
|
675
|
+
|
|
676
|
+
stats: function(items) {
|
|
677
|
+
var list = Array.isArray(items)
|
|
678
|
+
? items
|
|
679
|
+
: Object.keys(items).map(function(k) { return { label: k, value: items[k] } })
|
|
680
|
+
|
|
681
|
+
var cards = list.map(function(item) {
|
|
682
|
+
return \`
|
|
683
|
+
<div style="padding:0.75rem;border-radius:0.5rem;background:var(--bg-subtle);text-align:center">
|
|
684
|
+
<div style="font-size:1.25rem;font-weight:700;color:var(--text-primary)">\${item.value}</div>
|
|
685
|
+
<div style="font-size:0.6875rem;color:var(--text-muted);margin-top:0.25rem">\${item.label}</div>
|
|
686
|
+
</div>\`
|
|
687
|
+
}).join('')
|
|
688
|
+
|
|
689
|
+
return \`<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:0.75rem;padding:0 1.5rem 1rem">\${cards}</div>\`
|
|
690
|
+
},
|
|
691
|
+
|
|
692
|
+
timeline: function(items) {
|
|
693
|
+
var entries = items.map(function(item, i) {
|
|
694
|
+
var color = item.color || 'var(--text-accent)'
|
|
695
|
+
var isLast = i === items.length - 1
|
|
696
|
+
|
|
697
|
+
return \`
|
|
698
|
+
<div style="display:flex;gap:0.75rem">
|
|
699
|
+
<div style="display:flex;flex-direction:column;align-items:center;flex-shrink:0">
|
|
700
|
+
<div style="width:10px;height:10px;border-radius:50%;background:\${color};flex-shrink:0"></div>
|
|
701
|
+
\${!isLast ? '<div style="width:2px;flex:1;background:var(--bar-track);min-height:24px"></div>' : ''}
|
|
702
|
+
</div>
|
|
703
|
+
<div style="padding-bottom:\${isLast ? '0' : '1rem'};flex:1">
|
|
704
|
+
<div style="font-size:0.8125rem;font-weight:500;color:var(--text-primary)">\${item.title}</div>
|
|
705
|
+
\${item.description ? \`<div style="font-size:0.75rem;color:var(--text-muted);margin-top:0.125rem">\${item.description}</div>\` : ''}
|
|
706
|
+
\${item.meta ? \`<div style="font-size:0.6875rem;color:var(--text-tertiary);margin-top:0.25rem">\${item.meta}</div>\` : ''}
|
|
707
|
+
</div>
|
|
708
|
+
</div>\`
|
|
709
|
+
}).join('')
|
|
710
|
+
|
|
711
|
+
return \`<div style="padding:0 1.5rem 1rem">\${entries}</div>\`
|
|
712
|
+
},
|
|
713
|
+
|
|
714
|
+
open: function(html) {
|
|
715
|
+
if (typeof openSlideOver === 'function') openSlideOver(html)
|
|
716
|
+
},
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// ===== DATA TABLE HELPERS =====
|
|
720
|
+
|
|
721
|
+
stx.table = {
|
|
722
|
+
filter: function(opts) {
|
|
723
|
+
var searchEl = document.getElementById(opts.searchId)
|
|
724
|
+
var search = searchEl ? searchEl.value.toLowerCase() : ''
|
|
725
|
+
var rows = document.querySelectorAll(opts.rowSelector || 'tbody tr')
|
|
726
|
+
var filters = opts.filters || []
|
|
727
|
+
var matched = []
|
|
728
|
+
|
|
729
|
+
rows.forEach(function(row) {
|
|
730
|
+
var text = row.textContent.toLowerCase()
|
|
731
|
+
var matchSearch = !search || text.indexOf(search) !== -1
|
|
732
|
+
var matchFilters = filters.every(function(f) {
|
|
733
|
+
var el = document.getElementById(f.id)
|
|
734
|
+
if (!el) return true
|
|
735
|
+
var val = el.value
|
|
736
|
+
if (!val || val === f.allValue) return true
|
|
737
|
+
return row.getAttribute(\`data-\${f.attr}\`) === val
|
|
738
|
+
})
|
|
739
|
+
|
|
740
|
+
if (matchSearch && matchFilters) matched.push(row)
|
|
741
|
+
else row.style.display = 'none'
|
|
742
|
+
})
|
|
743
|
+
|
|
744
|
+
return matched
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
sort: function(rows, sortBy, direction) {
|
|
748
|
+
direction = direction || 'asc'
|
|
749
|
+
return rows.slice().sort(function(a, b) {
|
|
750
|
+
var aVal = a.getAttribute(\`data-\${sortBy}\`) || a.textContent
|
|
751
|
+
var bVal = b.getAttribute(\`data-\${sortBy}\`) || b.textContent
|
|
752
|
+
var aNum = parseFloat(aVal.replace(/[^0-9.-]/g, ''))
|
|
753
|
+
var bNum = parseFloat(bVal.replace(/[^0-9.-]/g, ''))
|
|
754
|
+
if (!isNaN(aNum) && !isNaN(bNum)) return direction === 'asc' ? aNum - bNum : bNum - aNum
|
|
755
|
+
return direction === 'asc' ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal)
|
|
756
|
+
})
|
|
757
|
+
},
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// ===== PAGINATION =====
|
|
761
|
+
|
|
762
|
+
stx.pagination = function(opts) {
|
|
763
|
+
var page = opts.page || 1
|
|
764
|
+
var perPage = opts.perPage || 10
|
|
765
|
+
var items = opts.items || []
|
|
766
|
+
var total = items.length
|
|
767
|
+
var totalPages = Math.max(1, Math.ceil(total / perPage))
|
|
768
|
+
if (page > totalPages) page = totalPages
|
|
769
|
+
|
|
770
|
+
var start = (page - 1) * perPage
|
|
771
|
+
var end = Math.min(start + perPage, total)
|
|
772
|
+
|
|
773
|
+
items.forEach(function(el, i) { el.style.display = (i >= start && i < end) ? '' : 'none' })
|
|
774
|
+
|
|
775
|
+
var ids = { count: opts.countId, total: opts.totalId, empty: opts.emptyId, bar: opts.barId }
|
|
776
|
+
if (ids.count) { var el = document.getElementById(ids.count); if (el) el.textContent = total === 0 ? '0' : \`\${start + 1}\\u2013\${end}\` }
|
|
777
|
+
if (ids.total) { var el = document.getElementById(ids.total); if (el) el.textContent = total }
|
|
778
|
+
if (ids.empty) { var el = document.getElementById(ids.empty); if (el) el.style.display = total === 0 ? 'block' : 'none' }
|
|
779
|
+
if (ids.bar) { var el = document.getElementById(ids.bar); if (el) el.style.display = total === 0 ? 'none' : '' }
|
|
780
|
+
|
|
781
|
+
if (opts.buttonsId) {
|
|
782
|
+
var wrap = document.getElementById(opts.buttonsId)
|
|
783
|
+
if (wrap) {
|
|
784
|
+
var go = opts.goToPage
|
|
785
|
+
var pages = stx.pagination.getPages(page, totalPages)
|
|
786
|
+
|
|
787
|
+
var btn = function(label, target, disabled) {
|
|
788
|
+
return \`<button onclick="\${go}(\${target})" \${disabled ? 'disabled' : ''}
|
|
789
|
+
class="px-3 py-1.5 rounded-lg text-sm cursor-pointer"
|
|
790
|
+
style="background:var(--bg-subtle);border:1px solid var(--border-input);color:\${disabled ? 'var(--text-muted)' : 'var(--text-primary)'};opacity:\${disabled ? '0.5' : '1'}">\${label}</button>\`
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
var h = btn('Previous', page - 1, page === 1)
|
|
794
|
+
pages.forEach(function(p) {
|
|
795
|
+
if (p === '...') {
|
|
796
|
+
h += '<span class="px-2 text-sm" style="color:var(--text-muted)">\\u2026</span>'
|
|
797
|
+
}
|
|
798
|
+
else if (p === page) {
|
|
799
|
+
h += \`<button class="w-9 h-9 rounded-lg text-sm font-medium" style="background:var(--btn-primary-bg, var(--text-accent));color:#fff">\${p}</button>\`
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
h += btn(p, p, false)
|
|
803
|
+
}
|
|
804
|
+
})
|
|
805
|
+
h += btn('Next', page + 1, page === totalPages)
|
|
806
|
+
wrap.innerHTML = h
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
return { page: page, totalPages: totalPages, total: total, start: start, end: end }
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
stx.pagination.getPages = function(current, total) {
|
|
814
|
+
if (total <= 7) return Array.from({ length: total }, function(_, i) { return i + 1 })
|
|
815
|
+
var pages = [1]
|
|
816
|
+
if (current > 3) pages.push('...')
|
|
817
|
+
for (var i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i)
|
|
818
|
+
if (current < total - 2) pages.push('...')
|
|
819
|
+
pages.push(total)
|
|
820
|
+
return pages
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// ===== UTILITIES =====
|
|
824
|
+
|
|
825
|
+
stx.debounce = function(fn, delay) {
|
|
826
|
+
var timer
|
|
827
|
+
return function() {
|
|
828
|
+
var args = arguments, ctx = this
|
|
829
|
+
clearTimeout(timer)
|
|
830
|
+
timer = setTimeout(function() { fn.apply(ctx, args) }, delay || 250)
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
})()
|
|
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(ke.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(ke.sep)}async function Xr(n,t={}){let o=t.port||3000,d=t.watch!==!1;for(let w of n){let S=ke.resolve(w);if(!Ke.existsSync(S))return console.error(`${e.red}Error: File not found: ${e.bright}${S}${e.reset}`),!1;if(!S.endsWith(".stx")&&!S.endsWith(".md"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${S}${e.reset}. Only .stx and .md files are supported.`),!1}let r=l(process.cwd(),"output");Ke.mkdirSync(r,{recursive:!0});let p=Gt(n.map((w)=>ke.dirname(ke.resolve(w))));console.log(`${e.blue}Processing ${e.bright}${n.length}${e.reset} files...`);let u={},m=[],b=async()=>{try{for(let w of n){let S=ke.resolve(w);if(S.endsWith(".md"))try{let{content:V,data:se}=await Me(S,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:M.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),B=t.markdown?.syntaxHighlighting||M.markdown?.syntaxHighlighting,j=B?.defaultTheme||"github-dark",k=["github-dark"],P=B?.additionalThemes||[],K=[...new Set([...k,...P])].map((Te)=>`<option value="${Te}"${Te===j?" selected":""}>${Te}</option>`).join(`
|
|
837
|
+
`),Y=`
|
|
838
|
+
<!DOCTYPE html>
|
|
839
|
+
<html lang="en">
|
|
840
|
+
<head>
|
|
841
|
+
<meta charset="UTF-8">
|
|
842
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
843
|
+
<title>${Xt(se.title||ke.basename(S))}</title>
|
|
844
|
+
<!-- Syntax highlighting styles -->
|
|
845
|
+
<style id="syntax-theme">
|
|
846
|
+
:root {
|
|
847
|
+
--shiki-color-text: #24292e;
|
|
848
|
+
--shiki-color-background: #ffffff;
|
|
849
|
+
--shiki-token-constant: #005cc5;
|
|
850
|
+
--shiki-token-string: #032f62;
|
|
851
|
+
--shiki-token-comment: #6a737d;
|
|
852
|
+
--shiki-token-keyword: #d73a49;
|
|
853
|
+
--shiki-token-parameter: #24292e;
|
|
854
|
+
--shiki-token-function: #6f42c1;
|
|
855
|
+
--shiki-token-string-expression: #032f62;
|
|
856
|
+
--shiki-token-punctuation: #24292e;
|
|
857
|
+
--shiki-token-link: #032f62;
|
|
858
|
+
}
|
|
859
|
+
pre {
|
|
860
|
+
background-color: var(--shiki-color-background);
|
|
861
|
+
padding: 1rem;
|
|
862
|
+
border-radius: 4px;
|
|
863
|
+
}
|
|
864
|
+
code {
|
|
865
|
+
color: var(--shiki-color-text);
|
|
866
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
867
|
+
}
|
|
868
|
+
.dark-mode {
|
|
869
|
+
--shiki-color-text: #e1e4e8;
|
|
870
|
+
--shiki-color-background: #24292e;
|
|
871
|
+
--shiki-token-constant: #79b8ff;
|
|
872
|
+
--shiki-token-string: #9ecbff;
|
|
873
|
+
--shiki-token-comment: #6a737d;
|
|
874
|
+
--shiki-token-keyword: #f97583;
|
|
875
|
+
--shiki-token-parameter: #e1e4e8;
|
|
876
|
+
--shiki-token-function: #b392f0;
|
|
877
|
+
--shiki-token-string-expression: #9ecbff;
|
|
878
|
+
--shiki-token-punctuation: #e1e4e8;
|
|
879
|
+
--shiki-token-link: #9ecbff;
|
|
880
|
+
}
|
|
881
|
+
</style>
|
|
882
|
+
<style>
|
|
883
|
+
body {
|
|
884
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
885
|
+
line-height: 1.6;
|
|
886
|
+
color: #333;
|
|
887
|
+
max-width: 800px;
|
|
888
|
+
margin: 0 auto;
|
|
889
|
+
padding: 2rem;
|
|
890
|
+
}
|
|
891
|
+
pre, code {
|
|
892
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
893
|
+
}
|
|
894
|
+
pre {
|
|
895
|
+
border-radius: 4px;
|
|
896
|
+
padding: 0;
|
|
897
|
+
margin: 1.5rem 0;
|
|
898
|
+
overflow-x: auto;
|
|
899
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
900
|
+
}
|
|
901
|
+
pre code {
|
|
902
|
+
display: block;
|
|
903
|
+
padding: 1rem;
|
|
904
|
+
overflow-x: auto;
|
|
905
|
+
}
|
|
906
|
+
/* Apply background color to code blocks based on theme */
|
|
907
|
+
pre.syntax-highlighter {
|
|
908
|
+
background-color: var(--shiki-color-background) !important;
|
|
909
|
+
}
|
|
910
|
+
.dark-mode pre.syntax-highlighter {
|
|
911
|
+
background-color: var(--shiki-color-background) !important;
|
|
912
|
+
}
|
|
913
|
+
code {
|
|
914
|
+
padding: 0.2rem 0.4rem;
|
|
915
|
+
border-radius: 3px;
|
|
916
|
+
}
|
|
917
|
+
h1, h2, h3, h4 {
|
|
918
|
+
margin-top: 2rem;
|
|
919
|
+
margin-bottom: 1rem;
|
|
920
|
+
}
|
|
921
|
+
h1 { color: #111; border-bottom: 1px solid #eee; padding-bottom: 0.5rem; }
|
|
922
|
+
h2 { color: #333; border-bottom: 1px solid #f0f0f0; padding-bottom: 0.3rem; }
|
|
923
|
+
h3 { color: #444; }
|
|
924
|
+
img {
|
|
925
|
+
max-width: 100%;
|
|
926
|
+
border-radius: 4px;
|
|
927
|
+
margin: 1rem 0;
|
|
928
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
929
|
+
}
|
|
930
|
+
blockquote {
|
|
931
|
+
border-left: 4px solid #ddd;
|
|
932
|
+
padding-left: 1rem;
|
|
933
|
+
margin-left: 0;
|
|
934
|
+
color: #555;
|
|
935
|
+
background: #f9f9f9;
|
|
936
|
+
padding: 0.5rem 1rem;
|
|
937
|
+
margin: 1.5rem 0;
|
|
938
|
+
}
|
|
939
|
+
table {
|
|
940
|
+
border-collapse: collapse;
|
|
941
|
+
width: 100%;
|
|
942
|
+
margin: 1.5rem 0;
|
|
943
|
+
}
|
|
944
|
+
th, td {
|
|
945
|
+
border: 1px solid #ddd;
|
|
946
|
+
padding: 0.5rem;
|
|
947
|
+
}
|
|
948
|
+
th {
|
|
949
|
+
background: #f0f0f0;
|
|
950
|
+
text-align: left;
|
|
951
|
+
}
|
|
952
|
+
tr:nth-child(even) {
|
|
953
|
+
background-color: #f8f8f8;
|
|
954
|
+
}
|
|
955
|
+
a {
|
|
956
|
+
color: #0066cc;
|
|
957
|
+
text-decoration: none;
|
|
958
|
+
}
|
|
959
|
+
a:hover {
|
|
960
|
+
text-decoration: underline;
|
|
961
|
+
}
|
|
962
|
+
hr {
|
|
963
|
+
border: 0;
|
|
964
|
+
border-top: 1px solid #eee;
|
|
965
|
+
margin: 2rem 0;
|
|
966
|
+
}
|
|
967
|
+
.frontmatter {
|
|
968
|
+
background: #f8f8f8;
|
|
969
|
+
border-radius: 4px;
|
|
970
|
+
padding: 1.5rem;
|
|
971
|
+
margin-bottom: 2rem;
|
|
972
|
+
font-size: 0.9rem;
|
|
973
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
974
|
+
border-left: 4px solid #ddd;
|
|
975
|
+
}
|
|
976
|
+
.frontmatter-item {
|
|
977
|
+
margin-bottom: 0.5rem;
|
|
978
|
+
display: flex;
|
|
979
|
+
}
|
|
980
|
+
.frontmatter-label {
|
|
981
|
+
font-weight: bold;
|
|
982
|
+
min-width: 100px;
|
|
983
|
+
color: #555;
|
|
984
|
+
}
|
|
985
|
+
${pt()}
|
|
986
|
+
</style>
|
|
987
|
+
</head>
|
|
988
|
+
<body>
|
|
989
|
+
${mt(se)}
|
|
990
|
+
${ut(K)}
|
|
991
|
+
|
|
992
|
+
${V}
|
|
993
|
+
|
|
994
|
+
<script>
|
|
995
|
+
${ft()}
|
|
996
|
+
</script>
|
|
997
|
+
</body>
|
|
998
|
+
</html>
|
|
999
|
+
`,pe=`/${ke.relative(p,S).replace(/\.md$/,"")}`;if(pe.endsWith("/index"))pe=pe.slice(0,-6)||"/";u[pe||"/"]={filePath:S,content:Y,fileType:"md"}}catch(V){console.error(`${e.red}Error processing Markdown file ${e.bright}${w}${e.reset}:`,V);continue}else{let V={name:"public-assets",setup(k){k.onResolve({filter:/^\/(images|fonts|assets|public)\//},(P)=>({path:P.path,external:!0}))}},se;try{let k=await Bun.build({entrypoints:[S],outdir:r,plugins:[V,rt],define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!k.success){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:`,De(k.logs,S));continue}let P=k.outputs.find((D)=>D.path.endsWith(".html"));if(!P){console.error(`${e.red}No HTML output found for ${e.bright}${w}${e.reset}`);continue}se=await Bun.file(P.path).text()}catch(k){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:
|
|
1000
|
+
${De(k,S)}`);continue}let j=`/${ke.relative(p,S).replace(/\.stx$/,"")}`;if(j.endsWith("/index"))j=j.slice(0,-6)||"/";if(j.includes("[")){let{regex:k,params:P}=Ds(j,{page:!0});m.push({pattern:k,paramNames:P,filePath:S,routeTemplate:j,fileType:"stx"}),u[j]={filePath:S,content:se,fileType:"stx"}}else u[j||"/"]={filePath:S,content:se,fileType:"stx"}}}if(Object.keys(u).length===0)return console.error(`${e.red}No files were successfully processed${e.reset}`),!1;return!0}catch(w){return console.error(`${e.red}Error processing files:${e.reset}`,De(w)),!1}};if(!await b())return!1;let v=o;try{if(v=await Ve(o),v!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${v} 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:${v}/${e.reset}...`);let C=Xn({port:v,async fetch(w){let S=new URL(w.url),A=ke.join(process.cwd(),"public",S.pathname);if(Ke.existsSync(A)&&Ke.statSync(A).isFile()){let B=Bun.file(A),j=ke.extname(A).toLowerCase(),k="application/octet-stream";if(j===".ts"||j===".tsx"){let P=new Bun.Transpiler({loader:j===".tsx"?"tsx":"ts"}),D=await B.text(),K=P.transformSync(D);return new Response(K,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(j){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(B,{headers:{"Content-Type":k}})}let V=u[S.pathname];if(!V&&!S.pathname.endsWith("/"))V=u[`${S.pathname}/`];if(!V)for(let B of m){let j=S.pathname.match(B.pattern);if(j){let k=u[B.routeTemplate];if(k){let P={};for(let Y=0;Y<B.paramNames.length;Y++)P[B.paramNames[Y]]=decodeURIComponent(j[Y+1]);let D=k.content,K=`<script>window.__routeParams = ${JSON.stringify(P)};</script>`;if(D.includes("</head>"))D=f(D,K);else D=K+D;V={...k,content:D}}break}}if(V)return x(V.content).then((B)=>{if(B.includes("</head>"))B=f(B,Kt);return new Response(B,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let se=ke.join(r,S.pathname);if(Ke.existsSync(se)&&Ke.statSync(se).isFile()){let B=Bun.file(se),j=ke.extname(se).toLowerCase(),k="text/plain";if(j===".ts"||j===".tsx"){let P=new Bun.Transpiler({loader:j===".tsx"?"tsx":"ts"}),D=await B.text(),K=P.transformSync(D);return new Response(K,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(j){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(B,{headers:{"Content-Type":k}})}if(S.pathname!=="/"&&u["/"]){let B=Ie(w);return x(u["/"].content).then((j)=>{if(B){let k=j.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(k){let P=j.match(/<title[^>]*>([\s\S]*?)<\/title>/i),D=P?P[1]:"",K=`<!DOCTYPE html><html><head><title>${Xt(D)}</title></head><body><main>${k[1]}</main></body></html>`;return new Response(K,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...H(),"Cache-Control":wt,Pragma:"no-cache",Expires:"0"}})}}return new Response(j,{headers:{"Content-Type":"text/html",...H(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(w){return new Response(`<pre>${w}
|
|
1001
|
+
${w.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
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:${v}/${e.reset}`),console.log(`
|
|
1004
|
+
${e.yellow}Routes:${e.reset}`);let R=new Set(m.map((w)=>w.routeTemplate)),O=Object.entries(u).filter(([w])=>!R.has(w)).sort(([w],[S])=>w.localeCompare(S)).map(([w,S])=>({route:w==="/"?"/":w,filePath:ke.relative(process.cwd(),S.filePath),fileType:S.fileType}));for(let w of m){let S=w.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");O.push({route:S,filePath:ke.relative(process.cwd(),w.filePath),fileType:"stx"})}if(O.sort((w,S)=>w.route.localeCompare(S.route)),O.forEach((w,S)=>{let V=S===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",se=w.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${V}${w.route}${e.reset} \u2192 ${e.bright}${w.filePath}${e.reset} ${se}`)}),console.log(`
|
|
1005
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Ke.watch(p,{recursive:!0},async(S,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}`),nt.clear(),xe(),await b()});process.on("SIGINT",()=>{w.close(),C.stop(),process.exit(0)})}return!0}function Xt(n){return String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Gn}=globalThis.Bun;import ge from"fs";import re from"path";async function Jt(n){try{return xn(await Bun.file(n).text())}catch{return}}function Lt(n){let t=Bun.file(n),o=re.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 Jr(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=re.resolve(n),{loadStxConfig:b}=await import("./chunk-eqfsw6x4.js"),y=await b(m),{createServerApi:v,isServerApiSource:C}=await import("./chunk-ydy0tfar.js"),R=t.stxOptions?.serverApi??y.serverApi,O=await v(m,R),w=y.root&&y.root!=="."?re.join(m,y.root):m,S=t.pagesDir||y.pagesDir||"pages",A=re.join(w,S);if(!ge.existsSync(A)&&!y._layerPageDirs?.some((T)=>ge.existsSync(T)))return console.error(`${e.red}Error: No '${S}' 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 ${S}/index.stx for the homepage.${e.reset}`),!1;let V=Q(w,{pagesDir:S,pagesDirs:y._layerPageDirs?[A,...y._layerPageDirs.slice(1)]:void 0});if(V.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}${V.length}${e.blue} routes${e.reset}`);let se=y?._pluginPageDirs||[],B=[];for(let{dir:T,prefix:_}of se)if(ge.existsSync(T)){let N=Q(re.dirname(T),{pagesDir:re.basename(T)});for(let ee of N){let X=_==="/"?ee.pattern:`${_}${ee.pattern==="/"?"":ee.pattern}`;B.push({route:{...ee,pattern:X},prefix:_})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${_}${e.reset}`)}let j=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Sa(m,t.stxOptions?.shell),P){if(k=await Eo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${re.relative(m,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Rt(),await Pt(m);let D=At();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let K={},Y=null;try{let{loadStxConfig:T}=await import("./chunk-eqfsw6x4.js"),_=await T(m);if(_?.apiRouter)Y=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){K=_.apiRoutes;let N=Object.keys(K).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:ee}=await import("./chunk-3te2y9qf.js"),X=_.broadcasting;await N(X);let $e=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${$e}/ws${e.reset}`);let we=re.join(process.cwd(),"channels.ts");if(ge.existsSync(we))try{let U=await ee(we);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let ve=l(m,"output");ge.mkdirSync(ve,{recursive:!0});let pe=new Map,Te=new Set,ie=async(T)=>{let _=Ms(A,T);if(!_)return null;try{let N=await Bun.build({entrypoints:[_],outdir:ve,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!N.success)return null;let ee=N.outputs.find((X)=>X.path.endsWith(".html"));if(!ee)return null;return await Bun.file(ee.path).text()}catch{return null}},z=new Map,E=async(T,_)=>{try{let{processDirectives:N,extractVariables:ee,defaultConfig:X,loadStxConfig:$e,injectRouterScript:we}=await import("./chunk-eqfsw6x4.js"),{checkCache:U,cacheTemplate:J,readFileCached:q,templateCache:ue}=await import("./chunk-6rqef7wp.js"),G=await $e(m),We=(le)=>{if(!le)return le;if(re.isAbsolute(le))return le;return re.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=We(de.partialsDir),de.componentsDir=We(de.componentsDir),de.layoutsDir=We(de.layoutsDir),de.storesDir=We(de.storesDir||"stores"),de.cachePath=We(de.cachePath)??l(m,"cache");let I=!_&&!t.profile,ae=de.cache!==!1;if(ae&&I){let le=ue.get(T.filePath);if(le)try{if((await ge.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Be=!0;for(let Se of le.dependencies){if(!ge.existsSync(Se)){Be=!1;break}if((await ge.promises.stat(Se)).mtime.getTime()>le.mtime){Be=!1;break}}if(Be){let Se=le.output;if(k)Se=Ye(Se,{preserveHead:!0});let st=z.get(T.filePath);return{route:T,content:Se,status:st?.status??await Jt(T.filePath),headers:st?.headers}}}}catch{}let je=await U(T.filePath,de);if(je){let He=je;if(k)He=Ye(He,{preserveHead:!0});let Be=z.get(T.filePath);return{route:T,content:He,status:Be?.status??await Jt(T.filePath),headers:Be?.headers}}}let te=ae?await q(T.filePath):await Bun.file(T.filePath).text(),ce=xn(te),{classifyAllScripts:fe}=await import("./chunk-eqfsw6x4.js"),F=fe(te),Le=F.server.map((le)=>le.content),Pe=te;for(let le of F.server)Pe=Pe.replace(le.fullTag,"");let ne={__filename:T.filePath,__dirname:re.dirname(T.filePath),__stx_options:de,params:_??{},__stx_runtime_head:{}};for(let le of Le)try{await ee(le,ne,T.filePath)}catch(je){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,je?.message||je)}let Re=new Set,ye;if(t.profile){let le=performance.now();ye=await N(Pe,ne,T.filePath,de,Re);let je=performance.now()-le,He=re.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${He} \u2192 ${je.toFixed(2)}ms`)}else ye=await N(Pe,ne,T.filePath,de,Re);if(!k)ye=await we(ye,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-9e3ggwk7.js");ye=ye.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(je,He,Be)=>{if(!/function\s+__stx_setup_/.test(Be))return je;return`<script${He}>${le(Be,ne)}</script>`})}if(k)ye=Ye(ye,{preserveHead:!0});if(ae&&I)await J(T.filePath,ye,Re,de);let{extractStreamBoundaries:dt}=await import("./chunk-24e4dapm.js"),Je=dt(ne),ot=ne.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let le=ne.streamBoundaries||{},je={...de,autoShell:!1},He=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof le[Se]==="function"?await le[Se]():void 0;return N(ot[Se],{...ne,$boundary:st},T.filePath,je,new Set)}})),Be=new Set(He.map((Se)=>Se.id));Je=[...(Je||[]).filter((Se)=>!Be.has(Se.id)),...He]}if(Je&&Je.length>0)Te.add(T.pattern);else Je=void 0;let zt=Bt(ne),Ut=Ft(ne);if(I)z.set(T.filePath,{status:zt,headers:Ut});return{route:T,content:ye,status:zt??ce,headers:Ut,boundaries:Je}}catch(N){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,N),null}},ze=8,Ne=async()=>{let T=new Set(pe.keys()),_=new Set(j.keys());pe.clear(),j.clear();let N=t.prebuild===!1?V.filter((X)=>T.has(X.pattern)):V,ee=t.prebuild===!1?B.filter(({route:X})=>_.has(X.pattern)):B;for(let X=0;X<N.length;X+=ze){let $e=N.slice(X,X+ze),we=await Promise.all($e.map((U)=>E(U)));for(let U of we)if(U)pe.set(U.route.pattern,U)}for(let X=0;X<ee.length;X+=ze){let $e=ee.slice(X,X+ze),we=await Promise.all($e.map(({route:U})=>E(U)));for(let U of we)if(U)j.set(U.route.pattern,U)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?V.length+B.length>0:await Ne()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await mn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let Tt=(T,_)=>{let ee=`<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,ee,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${ee}`);return ee+T};console.log(`${e.blue}Starting server...${e.reset}`);let Ct=Gn({port:Xe,hostname:t.hostname,async fetch(T){let _=new URL(T.url),N=t.stxOptions?.offline??y.offline;if(_.pathname===Wo&&N?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(T.method==="HEAD"?null:qo(N,gs()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let ee=y?.publicDir||"public",X=re.join(m,ee,_.pathname),$e=re.join(m,_.pathname),we=re.join(ve,_.pathname);if([X,$e,we].some((I)=>C(I,m,R)))return new Response("Not Found",{status:404});let[U,J,q]=await Promise.all([ge.promises.stat(X).catch(()=>null),ge.promises.stat($e).catch(()=>null),ge.promises.stat(we).catch(()=>null)]);if(U?.isFile()&&!C(X,m,R))return Lt(X);if(J?.isFile()&&!C($e,m,R))return Lt($e);if(q?.isFile()&&!C(we,m,R))return Lt(we);if(_.pathname.startsWith("/_stx/component/")){let I=decodeURIComponent(_.pathname.slice(16));if(I)try{let ae=`<${I} />`,te={...buildConfig,autoShell:!1},ce=await processDirectives(ae,{},re.join(m,"components",`${I}.stx`),te,new Set);return new Response(ce,{headers:{"Content-Type":"text/html"}})}catch(ae){return new Response(`<div class="stx-async-error">${ae.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(_.pathname==="/_stx/img"){let{handleImageRequest:I}=await import("./chunk-gn16yq49.js"),ae=await I(T,{publicDir:re.join(m,ee),cacheDir:l(m,"cache","img")});if(ae)return ae}if(Y)try{let I=await Y.handleRequest(T);if(I.status!==404)return I}catch{}if(K[_.pathname])try{return await K[_.pathname](T)}catch(I){return new Response(JSON.stringify({error:I.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=vr(_.pathname,V);if(G){let I=pe.get(G.route.pattern),ae=Te.has(G.route.pattern);if(!I||G.route.isDynamic&&Object.keys(G.params).length>0||ae){let te=await E(G.route,G.params);if(te){if(I=te,!G.route.isDynamic&&!ae)pe.set(G.route.pattern,te)}}if(I){let te=I.status??200,ce=I.headers??{},fe=(G.route.filePath?kt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await ie(404);if(Pe){let ne=Pe;if(ne=await x(ne,m),r)ne=Ue(ne,u);return new Response(ne,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Le=It(_.pathname,G.params,fe,_.search),Pe=Ot(Le,null,T,{isServer:!0}),ne=await Nt(fe.middleware,Pe);if(ne.redirect){let Re=ne.redirect.path,ye=ne.redirect.options.redirectCode||302,dt=new Headers(ne.responseHeaders);return dt.set("Location",Re),new Response(null,{status:ye,headers:dt})}if(ne.abort){let{statusCode:Re,message:ye}=ne.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Re}</title></head><body><h1>Error ${Re}</h1><p>${ye}</p></body></html>`,{status:Re,headers:{"Content-Type":"text/html"}})}if(Object.keys(ne.state).length>0){let Re=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ne.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;I.content=f(I.content,Re,"")}}let F=I.content;if(k&&ka(T)&&Ze(F,y?.router?.container||"main")){let Le=it(F),Pe=Ce(F),ne=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Re=ne?en(ne[1].trim()):"";if(Object.keys(G.params).length>0)F=Tt(F,G.params);F=await x(F,m);let ye=y?.router?.container||"main";return F=Oe(F,ye,!0),new Response(F,{status:te,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Pe?"true":"false",...Re&&{"X-STX-Title":encodeURIComponent(Re)},[wc]:gs(),...H(),"Cache-Control":wt}})}if(k)F=es(k,F);if(Object.keys(G.params).length>0)F=Tt(F,G.params);if(F=await x(F,m),r)F=Ue(F,u);if(t.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else 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 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}`;if(I.boundaries&&I.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Pe}=await import("./chunk-24e4dapm.js");return Pe(Le(F,I.boundaries,{timeoutMs:30000}),{status:te,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:te,headers:{"Content-Type":"text/html",...H(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ce}})}}if(B.length>0){let I=B.map((te)=>te.route),ae=vr(_.pathname,I);if(ae){let te=j.get(ae.route.pattern);if(!te||ae.route.isDynamic){let ce=await E(ae.route,ae.params);if(ce){if(te=ce,!ae.route.isDynamic)j.set(ae.route.pattern,ce)}}if(te){let ce=te.content;if(k)ce=es(k,ce);if(Object.keys(ae.params).length>0)ce=Tt(ce,ae.params);if(ce=await x(ce,m),r)ce=Ue(ce,u);return new Response(ce,{status:te.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:te}of se)if(te!=="/"&&_.pathname.startsWith(te)){let ce=j.get(te)||j.get(te+"/");if(!ce){let fe=B.find(({route:F})=>F.pattern===te||F.pattern===`${te}/`);if(fe){let F=await E(fe.route);if(F)ce=F,j.set(fe.route.pattern,F)}}if(ce){let fe=ce.content;if(k)fe=es(k,fe);if(fe=await x(fe,m),r)fe=Ue(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if($t(_.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let I=We.content;if(I=await x(I,m),r)I=Ue(I,u);if(t.native)if(I.includes("<head>"))I=I.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 I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;return new Response(I,{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 I=de;if(I=await x(I,m),r)I=Ue(I,u);return new Response(I,{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
|
+
${T.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
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
|
+
${e.bright}\u2192 ${e.cyan}http://localhost:${Xe}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1009
|
+
${e.yellow}Routes:${e.reset}`);let Et=[...Ls(V,m)];for(let{route:T}of B)Et.push(`${T.pattern}`);if(Et.forEach((T,_)=>{let ee=_===Et.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${ee}${e.reset}${T}`)}),console.log(`
|
|
1010
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(Ct.url.toString(),()=>{if(p)at();Ct.stop()}),t.native){let T,_=re.join(A,"index.stx");if(ge.existsSync(_)){let ee=await Bun.file(_).text();T=gt(ee)}let N=y?.app?.window??{};await Qe(Xe,{title:y?.app?.head?.title||re.basename(m)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(U)=>U.startsWith("public/")||U.startsWith("public\\"),_=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,ee=()=>{let U=new Set([m,...y._layerGraph?.layers.map((J)=>J.root)??[],...y._layerGraph?.configDependencies.map((J)=>re.dirname(J))??[]].filter((J)=>ge.existsSync(J)).map((J)=>ge.realpathSync(J)));for(let J of y._layerGraph?.layers??[])for(let q of Object.values(J.resources)){if(!ge.existsSync(q))continue;let ue=ge.realpathSync(q);if(![...U].some((G)=>ue===G||ue.startsWith(`${G}${re.sep}`)))U.add(ue)}for(let[J,q]of N)if(!U.has(J))q.close(),N.delete(J);for(let J of U)if(!N.has(J)&&ge.existsSync(J))N.set(J,ge.watch(J,{recursive:!0},(q,ue)=>{$e(J,q,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),$e=(U,J,q)=>(X=X.catch(()=>{}).then(()=>we(U,J,q)),X),we=async(U,J,q)=>{if(!q||xt(q))return;if(yt(q)){if(y._layerGraph){let ue=await b(m);Object.assign(y,ue),V.splice(0,V.length,...Q(w,{pagesDir:S,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),ee()}if(T(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),r&&p)p.reload(q)}else if(_(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),nt.clear(),xe();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-6rqef7wp.js");ue(re.resolve(U,q)),G.delete(re.resolve(U,q))}catch{}if(P&&q){if(re.resolve(U,q)===P||re.basename(P)===q){let G=await Eo(P,t.stxOptions||{});if(G)k=G}}if(await Ne(),await pr(m),r&&p)p.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),nt.clear(),xe();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-6rqef7wp.js");ue(re.resolve(U,q)),G.delete(re.resolve(U,q))}catch{}if(await Ne(),r&&p)p.reload(q)}}else if(ht(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),r&&p)p.updateCss(q)}};ee(),process.on("SIGINT",()=>{for(let U of N.values())U.close();if(p)at();Ct.stop(),process.exit(0)})}return!0}import jt from"fs";import ct from"path";async function Jn(n){try{let o=(await Bun.file(n).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],r=[],p=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=p.exec(d))!==null){let m=u[1],b=u[2]||u[3]||u[4];if(!b)continue;let y={name:b},v=m.match(/@type\s+\{([^}]+)\}/i);if(v)y.type=v[1].trim();if(m.match(/@required/i))y.required=!0;let R=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(R)y.default=R[1].trim();let O=m.split(`
|
|
1011
|
+
`).map((w)=>w.trim().replace(/^\*\s*/,"")).filter((w)=>!w.startsWith("@")&&w.length>0);y.description=O.join(" ").trim(),r.push(y)}if(r.length===0){let m=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(m){let y=m[1].split(",").map((v)=>v.trim()).filter(Boolean);for(let v of y){let[C]=v.split(":").map((R)=>R.trim());if(C)r.push({name:C})}}}return r}catch(t){return console.error(`Error extracting props from ${n}:`,t),[]}}async function Yn(n){try{let t=await Bun.file(n).text(),o=t.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||t.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
|
|
1012
|
+
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Qn(n,t=!1,o){let d=ct.basename(n,".stx"),r=await Jn(n),p=await Yn(n),u="";if(t&&o)u=`<${o}></${o}>`;else{let m=r.map((b)=>{if(b.type==="boolean")return`:${b.name}="true"`;return`${b.name}="value"`}).join(`
|
|
1013
|
+
`);u=`<${d}
|
|
1014
|
+
${m}
|
|
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 jt.promises.readdir(n,{withFileTypes:!0}),o=[];for(let d of t){let r=ct.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 Zn(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),m=!!u,b=u?.tag,y=await Qn(p,m,b);d.push(y)}return d}catch(o){return console.error("Error generating component docs:",o),[]}}async function er(n){try{if(!await s(n))return[];let t=await jt.promises.readdir(n,{withFileTypes:!0}),o=[];for(let d of t){if(!d.isFile()||!d.name.endsWith(".stx"))continue;let r=ct.join(n,d.name),p=await Bun.file(r).text(),u=ct.basename(r,".stx"),m=p.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||p.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),b=m?m[1].split(`
|
|
1016
|
+
`).map((S)=>S.trim().replace(/^\*\s*/,"")).join(" ").trim():"",y=/@component\(\s*['"]([^'"]+)['"]/g,v=/<([A-Z][a-zA-Z0-9]*|[a-z]+-[a-z0-9-]+)(?:\s[^>]*)?\/?>|\{\{\s*slot\s*\}\}/g,C=new Set,R;while((R=y.exec(p))!==null)C.add(R[1]);while((R=v.exec(p))!==null)if(R[1]&&R[1]!=="slot")C.add(R[1]);let O=/@([a-z]+)(?:\s*\(|\s+|$)/g,w=new Set;while((R=O.exec(p))!==null)w.add(R[1]);o.push({name:u,path:r,description:b,components:[...C],directives:[...w]})}return o}catch(t){return console.error("Error generating template docs:",t),[]}}async function tr(n=[]){try{let t=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
|
|
1017
|
+
<p>Welcome, {{ user.name }}!</p>
|
|
1018
|
+
@endif`},{name:"else",description:"Provides an alternative if a condition is not met",hasEndTag:!1,example:`@if(user.isLoggedIn)
|
|
1019
|
+
<p>Welcome back!</p>
|
|
1020
|
+
@else
|
|
1021
|
+
<p>Please log in</p>
|
|
1022
|
+
@endif`},{name:"elseif",description:"Provides an alternative condition",hasEndTag:!1,example:`@if(score > 90)
|
|
1023
|
+
<p>A</p>
|
|
1024
|
+
@elseif(score > 80)
|
|
1025
|
+
<p>B</p>
|
|
1026
|
+
@elseif(score > 70)
|
|
1027
|
+
<p>C</p>
|
|
1028
|
+
@endif`},{name:"unless",description:"Conditionally render content if a condition is false",hasEndTag:!0,example:`@unless(user.isLoggedIn)
|
|
1029
|
+
<p>Please log in</p>
|
|
1030
|
+
@endunless`},{name:"for",description:"Loop through an array or object",hasEndTag:!0,example:`@for(item of items)
|
|
1031
|
+
<li>{{ item.name }}</li>
|
|
1032
|
+
@endfor`},{name:"while",description:"Loop while a condition is true",hasEndTag:!0,example:`@while(page < totalPages)
|
|
1033
|
+
<p>Page {{ page }}</p>
|
|
1034
|
+
@endwhile`},{name:"component",description:"Include a component in the template",hasEndTag:!1,example:'@component("alert", { type: "warning", title: "Warning", message: "This is a warning" })'},{name:"include",description:"Include a partial template",hasEndTag:!1,example:'@include("partials/header")'},{name:"raw",description:"Display content without processing expressions",hasEndTag:!0,example:`@raw
|
|
1035
|
+
{{ This will be displayed as-is }}
|
|
1036
|
+
@endraw`},{name:"translate",description:"Translate a string using the i18n system",hasEndTag:!1,example:'@translate("welcome.message", { name: user.name })'},{name:"t",description:"Short alias for translate directive",hasEndTag:!1,example:'@t("welcome.message", { name: user.name })'}];for(let o of n)t.push({name:o.name,description:o.description||"",hasEndTag:o.hasEndTag||!1,example:""});return t}catch(t){return console.error("Error generating directive docs:",t),[]}}function nr(n=[],t=[],o=[],d){let r=`# stx Documentation
|
|
1037
|
+
|
|
1038
|
+
`;if(d)r+=`${d}
|
|
1039
|
+
|
|
1040
|
+
`;if(n.length>0){r+=`## Components
|
|
1041
|
+
|
|
1042
|
+
`;for(let p of n){if(r+=`### ${p.name}
|
|
1043
|
+
|
|
1044
|
+
`,p.description)r+=`${p.description}
|
|
1045
|
+
|
|
1046
|
+
`;if(p.isWebComponent)r+=`**Web Component Tag:** \`${p.tag}\`
|
|
1047
|
+
|
|
1048
|
+
`;if(p.props.length>0){r+=`#### Properties
|
|
1049
|
+
|
|
1050
|
+
`,r+=`| Name | Type | Required | Default | Description |
|
|
1051
|
+
`,r+=`| ---- | ---- | -------- | ------- | ----------- |
|
|
1052
|
+
`;for(let u of p.props)r+=`| ${u.name} | ${u.type||"any"} | ${u.required?"Yes":"No"} | ${u.default||"-"} | ${u.description||"-"} |
|
|
1053
|
+
`;r+=`
|
|
1054
|
+
`}if(p.example)r+=`#### Example
|
|
1055
|
+
|
|
1056
|
+
`,r+="```html\n",r+=p.example,r+="\n```\n\n"}}if(t.length>0){r+=`## Templates
|
|
1057
|
+
|
|
1058
|
+
`;for(let p of t){if(r+=`### ${p.name}
|
|
1059
|
+
|
|
1060
|
+
`,p.description)r+=`${p.description}
|
|
1061
|
+
|
|
1062
|
+
`;if(p.components&&p.components.length>0)r+=`**Components Used:** ${p.components.join(", ")}
|
|
1063
|
+
|
|
1064
|
+
`;if(p.directives&&p.directives.length>0)r+=`**Directives Used:** ${p.directives.join(", ")}
|
|
1065
|
+
|
|
1066
|
+
`}}if(o.length>0){r+=`## Directives
|
|
1067
|
+
|
|
1068
|
+
`,r+=`| Directive | Description | Has End Tag |
|
|
1069
|
+
`,r+=`| --------- | ----------- | ----------- |
|
|
1070
|
+
`;for(let p of o)r+=`| @${p.name} | ${p.description||"-"} | ${p.hasEndTag?"Yes":"No"} |
|
|
1071
|
+
`;r+=`
|
|
1072
|
+
`;for(let p of o)if(p.example)r+=`### @${p.name}
|
|
1073
|
+
|
|
1074
|
+
`,r+=`${p.description||""}
|
|
1075
|
+
|
|
1076
|
+
`,r+=`#### Example
|
|
1077
|
+
|
|
1078
|
+
`,r+="```html\n",r+=p.example,r+="\n```\n\n"}return r}function rr(n=[],t=[],o=[],d){let r=`<!DOCTYPE html>
|
|
1079
|
+
<html lang="en">
|
|
1080
|
+
<head>
|
|
1081
|
+
<meta charset="UTF-8">
|
|
1082
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1083
|
+
<title>stx Documentation</title>
|
|
1084
|
+
<style>
|
|
1085
|
+
body {
|
|
1086
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
1087
|
+
line-height: 1.6;
|
|
1088
|
+
color: #333;
|
|
1089
|
+
max-width: 1200px;
|
|
1090
|
+
margin: 0 auto;
|
|
1091
|
+
padding: 2rem;
|
|
1092
|
+
}
|
|
1093
|
+
h1, h2, h3, h4 { margin-top: 2rem; }
|
|
1094
|
+
table {
|
|
1095
|
+
border-collapse: collapse;
|
|
1096
|
+
width: 100%;
|
|
1097
|
+
margin: 1rem 0;
|
|
1098
|
+
}
|
|
1099
|
+
th, td {
|
|
1100
|
+
text-align: left;
|
|
1101
|
+
padding: 0.5rem;
|
|
1102
|
+
border-bottom: 1px solid #ddd;
|
|
1103
|
+
}
|
|
1104
|
+
th { border-bottom: 2px solid #ddd; }
|
|
1105
|
+
pre {
|
|
1106
|
+
background: #f5f5f5;
|
|
1107
|
+
padding: 1rem;
|
|
1108
|
+
border-radius: 4px;
|
|
1109
|
+
overflow-x: auto;
|
|
1110
|
+
}
|
|
1111
|
+
code {
|
|
1112
|
+
background: #f5f5f5;
|
|
1113
|
+
padding: 0.2rem 0.4rem;
|
|
1114
|
+
border-radius: 4px;
|
|
1115
|
+
font-size: 0.9em;
|
|
1116
|
+
}
|
|
1117
|
+
</style>
|
|
1118
|
+
</head>
|
|
1119
|
+
<body>
|
|
1120
|
+
<h1>stx Documentation</h1>
|
|
1121
|
+
`;if(d)r+=`<div>${d}</div>`;if(n.length>0){r+="<h2>Components</h2>";for(let p of n){if(r+=`<h3>${p.name}</h3>`,p.description)r+=`<p>${p.description}</p>`;if(p.isWebComponent)r+=`<p><strong>Web Component Tag:</strong> <code>${p.tag}</code></p>`;if(p.props.length>0){r+="<h4>Properties</h4>",r+=`<table>
|
|
1122
|
+
<thead>
|
|
1123
|
+
<tr>
|
|
1124
|
+
<th>Name</th>
|
|
1125
|
+
<th>Type</th>
|
|
1126
|
+
<th>Required</th>
|
|
1127
|
+
<th>Default</th>
|
|
1128
|
+
<th>Description</th>
|
|
1129
|
+
</tr>
|
|
1130
|
+
</thead>
|
|
1131
|
+
<tbody>`;for(let u of p.props)r+=`<tr>
|
|
1132
|
+
<td>${u.name}</td>
|
|
1133
|
+
<td>${u.type||"any"}</td>
|
|
1134
|
+
<td>${u.required?"Yes":"No"}</td>
|
|
1135
|
+
<td>${u.default||"-"}</td>
|
|
1136
|
+
<td>${u.description||"-"}</td>
|
|
1137
|
+
</tr>`;r+="</tbody></table>"}if(p.example)r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}}if(t.length>0){r+="<h2>Templates</h2>";for(let p of t){if(r+=`<h3>${p.name}</h3>`,p.description)r+=`<p>${p.description}</p>`;if(p.components&&p.components.length>0)r+=`<p><strong>Components Used:</strong> ${p.components.join(", ")}</p>`;if(p.directives&&p.directives.length>0)r+=`<p><strong>Directives Used:</strong> ${p.directives.join(", ")}</p>`}}if(o.length>0){r+="<h2>Directives</h2>",r+=`<table>
|
|
1138
|
+
<thead>
|
|
1139
|
+
<tr>
|
|
1140
|
+
<th>Directive</th>
|
|
1141
|
+
<th>Description</th>
|
|
1142
|
+
<th>Has End Tag</th>
|
|
1143
|
+
</tr>
|
|
1144
|
+
</thead>
|
|
1145
|
+
<tbody>`;for(let p of o)r+=`<tr>
|
|
1146
|
+
<td>@${p.name}</td>
|
|
1147
|
+
<td>${p.description||"-"}</td>
|
|
1148
|
+
<td>${p.hasEndTag?"Yes":"No"}</td>
|
|
1149
|
+
</tr>`;r+="</tbody></table>";for(let p of o)if(p.example)r+=`<h3>@${p.name}</h3>`,r+=`<p>${p.description||""}</p>`,r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return r+="</body></html>",r}function or(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function sr(n){try{let{componentsDir:t,templatesDir:o,webComponentsConfig:d,customDirectives:r,config:p}=n;if(!p.enabled)return!1;let u=p.outputDir||"docs";if(await jt.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),t)console.log(`Components directory: ${t}`);if(o)console.log(`Templates directory: ${o}`);console.log(`Output directory: ${u}`);let m=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),m=await Zn(t,d),console.log(`Found ${m.length} components`);let b=[];if(p.templates!==!1&&o)console.log("Generating template documentation..."),b=await er(o),console.log(`Found ${b.length} templates`);let y=[];if(p.directives!==!1)console.log("Generating directive documentation..."),y=await tr(r),console.log(`Found ${y.length} directives`);let v=p.format||"markdown",C=p.extraContent,R="",O="";switch(v){case"markdown":R=nr(m,b,y,C),O="md";break;case"html":R=rr(m,b,y,C),O="html";break;case"json":R=or(m,b,y,C),O="json";break;default:throw Error(`Unsupported documentation format: ${v}`)}let w=ct.join(u,`stx-docs.${O}`);return await Bun.write(w,R),console.log(`Documentation generated: ${w}`),!0}catch(t){return console.error("Error generating documentation:",t),!1}}async function pa(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||M.componentsDir,d=n.templatesDir||".";return sr({componentsDir:o,templatesDir:d,webComponentsConfig:M.webComponents,customDirectives:M.customDirectives,config:t})}var Zt={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function yo(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1150
|
+
`;let d=n;if(o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=cr(d,o),d=fr(d,o),d=lr(d,o),o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,""),d=d.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(d=d.replace(/\r\n/g,`
|
|
1151
|
+
`).replace(/\r/g,`
|
|
1152
|
+
`),!d.endsWith(`
|
|
1153
|
+
`))d+=`
|
|
1154
|
+
`;return d}function fa(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,m,b)=>{let y=m.split(`
|
|
1156
|
+
`),v=y.filter((S)=>S.trim().length>0);if(v.length===0)return r;let C=Math.min(...v.map((S)=>{let A=S.match(/^( *)/);return A?A[1].length:0})),R=y.map((S)=>{if(S.trim().length===0)return"";return S.substring(C)}).join(`
|
|
1157
|
+
`),w=yo(R,o).trimEnd().split(`
|
|
1158
|
+
`).map((S)=>{if(S.trim().length===0)return"";return p+S}).join(`
|
|
1159
|
+
`);return`${p}\`\`\`${u}
|
|
1160
|
+
${w}
|
|
1161
|
+
${p}\`\`\``}),o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=d.replace(/\r\n/g,`
|
|
1162
|
+
`).replace(/\r/g,`
|
|
1163
|
+
`),!d.endsWith(`
|
|
1164
|
+
`))d+=`
|
|
1165
|
+
`;return d}function ar(n){let t=n,o=[],d="__PROTECTED_BLOCK_";return t=t.replace(/(<(?:pre|code|textarea)[^>]*>)([\s\S]*?)(<\/(?:pre|code|textarea)>)/gi,(r)=>{let p=o.length;return o.push(r),`${d}${p}__`}),t=t.replace(/(@(?:if|foreach|for|while|unless|section|component|slot|push|prepend|error|auth|guest|can)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
|
|
1166
|
+
$1
|
|
1167
|
+
`),t=t.replace(/(@end\w+)/g,`
|
|
1168
|
+
$1
|
|
1169
|
+
`),t=t.replace(/(@(?:else|elseif|empty)(?:\((?:[^()'"]|'[^']*'|"[^"]*"|\((?:[^()'"]|'[^']*'|"[^"]*")*\))*\))?)/g,`
|
|
1170
|
+
$1
|
|
1171
|
+
`),t=t.replace(/(@(?:csrf|method|include|extends|yield|stack|vite|asset)(?:\([^)]*\))?)/g,`
|
|
1172
|
+
$1
|
|
1173
|
+
`),t=t.replace(/(?<=>)(<(?!\/)[^>]+>)/g,(r,p,u,m)=>{let b=m.substring(u+r.length,Math.min(m.length,u+r.length+20)),y=r.match(/<(\w+)/)?.[1];if(y&&b.match(new RegExp(`^</${y}>`)))return r;return`
|
|
1174
|
+
${r}`}),t=t.replace(/(>)(<\/)/g,(r,p,u,m,b)=>{let y=b.substring(Math.max(0,m-50),m),C=b.substring(m+r.length,Math.min(b.length,m+r.length+20)).match(/^(\w+)>/)?.[1],R=y.match(/<(\w+)[^>]*$/)?.[1];if(R&&C&&R===C)return r;return`${p}
|
|
1175
|
+
${u}`}),t=t.replace(/(<\/[^>]+>)(?=<|$)/g,(r,p,u,m)=>{let b=m.substring(Math.max(0,u-20),u),y=r.match(/<\/(\w+)>/)?.[1],v=new RegExp(`<${y}[^>]*>$`);if(y&&b.match(v))return r;return`${r}
|
|
1176
|
+
`}),t=t.replace(new RegExp(`${d}(\\d+)__`,"g"),(r,p)=>o[Number.parseInt(p,10)]),t=t.replace(/\n{2,}/g,`
|
|
1177
|
+
`),t=t.split(`
|
|
1178
|
+
`).map((r)=>r.trim()).join(`
|
|
1179
|
+
`),t=t.replace(/^\n+/,"").replace(/\n+$/,""),t}function cr(n,t){let d=ar(n).split(`
|
|
1180
|
+
`),r=[],p=0,u=!1,m=t.useTabs?"\t":" ".repeat(t.indentSize);for(let b=0;b<d.length;b++){let y=d[b],v=y.trim();if(v===""){r.push("");continue}let C=v.match(/<script\b/i),R=v.match(/<\/script>/i);if(u&&!R){r.push(y);continue}let O=v===">";if(Qt(v)&&!v.startsWith("<")&&!v.startsWith("@")){r.push(m.repeat(p)+v);continue}let w=v.startsWith("@end"),S=v.startsWith("@else")||v.startsWith("@elseif"),A=v.startsWith("@")&&ur(v),V=v.startsWith("<!DOCTYPE")||v.startsWith("<!doctype"),se=v.startsWith("<!--"),B=v.startsWith("</"),j=v.startsWith("<")&&!B&&!se&&!V,k=v.includes("/>")||dr(v),P=Qt(v);if(B||w)p=Math.max(0,p-1);let D=S?Math.max(0,p-1):p;if(O)r.push(y);else r.push(m.repeat(D)+v);if(j&&!k&&!P&&!O||A)p++;if(C)u=!0;if(R)u=!1}return r.join(`
|
|
1181
|
+
`)}function lr(n,t){if(n=n.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(o,d,r)=>{let p=r.trim().replace(/\s+/g," ");return`@${d}(${p})`}),n=n.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(o,d,r)=>{if(r.trim()==="")return`@${d}`;return`@${d}(${r.trim()})`}),t.normalizeWhitespace)n=n.replace(/\{\{\s*([^}]+)\s*\}\}/g,(o,d)=>`{{ ${d.trim()} }}`),n=n.replace(/\{!!\s*([^!]+)\s*!!\}/g,(o,d)=>`{!! ${d.trim()} !!}`);return n}function dr(n){let t=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if(n.includes("/>"))return!0;let o=n.match(/<(\w+)/);if(o){let d=o[1];return t.includes(d.toLowerCase())}return!1}function Qt(n){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test(n)}function 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=[],m;while((m=p.exec(r))!==null)u.push({name:m[1],value:m[2]});u.sort((y,v)=>{if(y.name==="id")return-1;if(v.name==="id")return 1;if(y.name==="class")return-1;if(v.name==="class")return 1;return y.name.localeCompare(v.name)});let b=u.map((y)=>y.value?`${y.name}=${y.value}`:y.name).join(" ");return`<${d}${b?` ${b}`:""}>`})}import tn from"fs";import Ht from"path";async function ga(n="index.stx",t={}){try{let o=t.force||!1,d=Ht.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=Ht.dirname(d);if(!tn.existsSync(r))tn.mkdirSync(r,{recursive:!0});let p;if(t.template){let u=Ht.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=nn(t.preset),console.warn(`Using '${t.preset}' preset template`);else p=nn("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 nn(n){switch(n){case"basic":return rn();case"component":return mr();case"layout":return gr();case"blog":return hr();case"api":return xr();case"app":return wr();default:return rn()}}function rn(){return`<script>
|
|
1183
|
+
const title = "My stx Page"
|
|
1184
|
+
const description = "A page built with stx"
|
|
1185
|
+
const features = [
|
|
1186
|
+
{ name: "Single File Components", desc: "Script, style, and template in one .stx file" },
|
|
1187
|
+
{ name: "Component System", desc: "Import components with @component('name', {})" },
|
|
1188
|
+
{ name: "Blade Directives", desc: "@if, @foreach, @switch, @layout and more" }
|
|
1189
|
+
]
|
|
1190
|
+
</script>
|
|
1191
|
+
|
|
1192
|
+
@section('content')
|
|
1193
|
+
<header>
|
|
1194
|
+
<h1>{{ title }}</h1>
|
|
1195
|
+
<p>{{ description }}</p>
|
|
1196
|
+
</header>
|
|
1197
|
+
|
|
1198
|
+
<main>
|
|
1199
|
+
<h2>Features</h2>
|
|
1200
|
+
@foreach(features as feature)
|
|
1201
|
+
<div class="card">
|
|
1202
|
+
<h3>{{ feature.name }}</h3>
|
|
1203
|
+
<p>{{ feature.desc }}</p>
|
|
1204
|
+
</div>
|
|
1205
|
+
@endforeach
|
|
1206
|
+
</main>
|
|
1207
|
+
@endsection`}function mr(){return`{{-- Component: Card --}}
|
|
1208
|
+
{{-- Props: title, variant, collapsible --}}
|
|
1209
|
+
{{-- Usage: @component('card', { title: "Hello", variant: "primary", collapsible: true }) Content @endcomponent --}}
|
|
1210
|
+
<script>
|
|
1211
|
+
// Props with defaults
|
|
1212
|
+
const title = props.title || 'Card Title'
|
|
1213
|
+
const variant = props.variant || 'default'
|
|
1214
|
+
const collapsible = props.collapsible || false
|
|
1215
|
+
</script>
|
|
1216
|
+
|
|
1217
|
+
<div class="card card--{{ variant }}">
|
|
1218
|
+
<div class="card__header" onclick="this.parentElement.classList.toggle('collapsed')">
|
|
1219
|
+
<h3 class="card__title">{{ title }}</h3>
|
|
1220
|
+
@if(collapsible)
|
|
1221
|
+
<span class="card__toggle">\u25BC</span>
|
|
1222
|
+
@endif
|
|
1223
|
+
</div>
|
|
1224
|
+
<div class="card__body">
|
|
1225
|
+
{{ slot }}
|
|
1226
|
+
</div>
|
|
1227
|
+
</div>
|
|
1228
|
+
|
|
1229
|
+
<style scoped>
|
|
1230
|
+
.card {
|
|
1231
|
+
border-radius: 8px;
|
|
1232
|
+
background: #fff;
|
|
1233
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
1234
|
+
overflow: hidden;
|
|
1235
|
+
}
|
|
1236
|
+
.card--primary { border-top: 3px solid #3498db; }
|
|
1237
|
+
.card--success { border-top: 3px solid #2ecc71; }
|
|
1238
|
+
.card--warning { border-top: 3px solid #f39c12; }
|
|
1239
|
+
.card--danger { border-top: 3px solid #e74c3c; }
|
|
1240
|
+
.card__header {
|
|
1241
|
+
padding: 1rem;
|
|
1242
|
+
background: #f8f9fa;
|
|
1243
|
+
display: flex;
|
|
1244
|
+
justify-content: space-between;
|
|
1245
|
+
align-items: center;
|
|
1246
|
+
}
|
|
1247
|
+
.card__title { margin: 0; font-size: 1.1rem; }
|
|
1248
|
+
.card__toggle { transition: transform 0.2s; }
|
|
1249
|
+
.card.collapsed .card__toggle { transform: rotate(-90deg); }
|
|
1250
|
+
.card__body { padding: 1rem; }
|
|
1251
|
+
.card.collapsed .card__body { display: none; }
|
|
1252
|
+
</style>`}function gr(){return`<!DOCTYPE html>
|
|
1253
|
+
<html lang="en">
|
|
1254
|
+
<head>
|
|
1255
|
+
<meta charset="UTF-8">
|
|
1256
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1257
|
+
<title>@yield('title', 'My App')</title>
|
|
1258
|
+
@yield('head')
|
|
1259
|
+
<style>
|
|
1260
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
1261
|
+
body {
|
|
1262
|
+
font-family: system-ui, sans-serif;
|
|
1263
|
+
min-height: 100vh;
|
|
1264
|
+
display: flex;
|
|
1265
|
+
flex-direction: column;
|
|
1266
|
+
}
|
|
1267
|
+
header, footer {
|
|
1268
|
+
background: #2c3e50;
|
|
1269
|
+
color: white;
|
|
1270
|
+
padding: 1rem 2rem;
|
|
1271
|
+
}
|
|
1272
|
+
main {
|
|
1273
|
+
flex: 1;
|
|
1274
|
+
padding: 2rem;
|
|
1275
|
+
max-width: 1200px;
|
|
1276
|
+
margin: 0 auto;
|
|
1277
|
+
width: 100%;
|
|
1278
|
+
}
|
|
1279
|
+
nav a { color: white; margin-right: 1rem; text-decoration: none; }
|
|
1280
|
+
nav a:hover { text-decoration: underline; }
|
|
1281
|
+
</style>
|
|
1282
|
+
@yield('styles')
|
|
1283
|
+
</head>
|
|
1284
|
+
<body>
|
|
1285
|
+
<header>
|
|
1286
|
+
<nav>
|
|
1287
|
+
<a href="/">Home</a>
|
|
1288
|
+
<a href="/about">About</a>
|
|
1289
|
+
<a href="/contact">Contact</a>
|
|
1290
|
+
</nav>
|
|
1291
|
+
</header>
|
|
1292
|
+
|
|
1293
|
+
<main>
|
|
1294
|
+
{{ slot }}
|
|
1295
|
+
</main>
|
|
1296
|
+
|
|
1297
|
+
<footer>
|
|
1298
|
+
<p>© {{ new Date().getFullYear() }} My App</p>
|
|
1299
|
+
</footer>
|
|
1300
|
+
|
|
1301
|
+
@yield('scripts')
|
|
1302
|
+
</body>
|
|
1303
|
+
</html>`}function hr(){return`<script>
|
|
1304
|
+
// Article metadata
|
|
1305
|
+
const title = "My Blog Post"
|
|
1306
|
+
const author = "Your Name"
|
|
1307
|
+
const date = new Date().toLocaleDateString('en-US', {
|
|
1308
|
+
year: 'numeric',
|
|
1309
|
+
month: 'long',
|
|
1310
|
+
day: 'numeric'
|
|
1311
|
+
})
|
|
1312
|
+
const tags = ["stx", "tutorial", "web development"]
|
|
1313
|
+
const readingTime = "5 min read"
|
|
1314
|
+
</script>
|
|
1315
|
+
|
|
1316
|
+
@layout('layouts/blog')
|
|
1317
|
+
|
|
1318
|
+
@section('title')
|
|
1319
|
+
{{ title }}
|
|
1320
|
+
@endsection
|
|
1321
|
+
|
|
1322
|
+
@section('content')
|
|
1323
|
+
<article class="blog-post">
|
|
1324
|
+
<header class="blog-post__header">
|
|
1325
|
+
<h1>{{ title }}</h1>
|
|
1326
|
+
<div class="blog-post__meta">
|
|
1327
|
+
<span class="author">By {{ author }}</span>
|
|
1328
|
+
<span class="date">{{ date }}</span>
|
|
1329
|
+
<span class="reading-time">{{ readingTime }}</span>
|
|
1330
|
+
</div>
|
|
1331
|
+
<div class="blog-post__tags">
|
|
1332
|
+
@foreach(tags as tag)
|
|
1333
|
+
<span class="tag">#{{ tag }}</span>
|
|
1334
|
+
@endforeach
|
|
1335
|
+
</div>
|
|
1336
|
+
</header>
|
|
1337
|
+
|
|
1338
|
+
<div class="blog-post__content">
|
|
1339
|
+
<p>Your content goes here...</p>
|
|
1340
|
+
|
|
1341
|
+
<h2>Introduction</h2>
|
|
1342
|
+
<p>Start writing your blog post content.</p>
|
|
1343
|
+
|
|
1344
|
+
<h2>Conclusion</h2>
|
|
1345
|
+
<p>Wrap up your thoughts here.</p>
|
|
1346
|
+
</div>
|
|
1347
|
+
</article>
|
|
1348
|
+
@endsection`}function xr(){return`<script>
|
|
1349
|
+
// API endpoint configuration
|
|
1350
|
+
const endpoint = "/api/data"
|
|
1351
|
+
const method = "GET"
|
|
1352
|
+
|
|
1353
|
+
// Mock data - replace with actual data fetching
|
|
1354
|
+
const data = {
|
|
1355
|
+
success: true,
|
|
1356
|
+
message: "Data retrieved successfully",
|
|
1357
|
+
items: [
|
|
1358
|
+
{ id: 1, name: "Item 1" },
|
|
1359
|
+
{ id: 2, name: "Item 2" },
|
|
1360
|
+
{ id: 3, name: "Item 3" }
|
|
1361
|
+
],
|
|
1362
|
+
meta: {
|
|
1363
|
+
total: 3,
|
|
1364
|
+
page: 1,
|
|
1365
|
+
perPage: 10
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// For error responses
|
|
1370
|
+
const error = null
|
|
1371
|
+
</script>
|
|
1372
|
+
|
|
1373
|
+
@if(error)
|
|
1374
|
+
{
|
|
1375
|
+
"success": false,
|
|
1376
|
+
"error": {
|
|
1377
|
+
"code": "{{ error.code || 'UNKNOWN_ERROR' }}",
|
|
1378
|
+
"message": "{{ error.message || 'An error occurred' }}"
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
@else
|
|
1382
|
+
{{ JSON.stringify(data, null, 2) }}
|
|
1383
|
+
@endif`}function wr(){return`<!DOCTYPE html>
|
|
1384
|
+
<html lang="en">
|
|
1385
|
+
<head>
|
|
1386
|
+
<meta charset="UTF-8">
|
|
1387
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1388
|
+
<title>{{ title }} - stx App</title>
|
|
1389
|
+
<script>
|
|
1390
|
+
const title = "My App"
|
|
1391
|
+
</script>
|
|
1392
|
+
<style>
|
|
1393
|
+
:root {
|
|
1394
|
+
--bg: #1a1a2e;
|
|
1395
|
+
--bg-dark: #16213e;
|
|
1396
|
+
--fg: #eaeaea;
|
|
1397
|
+
--primary: #e94560;
|
|
1398
|
+
--secondary: #0f3460;
|
|
1399
|
+
--success: #00d9ff;
|
|
1400
|
+
--border: #2a2a4a;
|
|
1401
|
+
}
|
|
1402
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
1403
|
+
body {
|
|
1404
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
1405
|
+
background: var(--bg);
|
|
1406
|
+
color: var(--fg);
|
|
1407
|
+
min-height: 100vh;
|
|
1408
|
+
}
|
|
1409
|
+
.container { max-width: 800px; margin: 0 auto; padding: 2rem; }
|
|
1410
|
+
.header { text-align: center; margin-bottom: 2rem; }
|
|
1411
|
+
.header h1 { color: var(--primary); margin-bottom: 0.5rem; }
|
|
1412
|
+
.card {
|
|
1413
|
+
background: var(--bg-dark);
|
|
1414
|
+
border: 1px solid var(--border);
|
|
1415
|
+
border-radius: 12px;
|
|
1416
|
+
padding: 1.5rem;
|
|
1417
|
+
margin-bottom: 1rem;
|
|
1418
|
+
}
|
|
1419
|
+
.btn {
|
|
1420
|
+
background: var(--primary);
|
|
1421
|
+
color: white;
|
|
1422
|
+
border: none;
|
|
1423
|
+
padding: 0.75rem 1.5rem;
|
|
1424
|
+
border-radius: 8px;
|
|
1425
|
+
cursor: pointer;
|
|
1426
|
+
font-size: 1rem;
|
|
1427
|
+
transition: opacity 0.2s;
|
|
1428
|
+
}
|
|
1429
|
+
.btn:hover { opacity: 0.9; }
|
|
1430
|
+
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
1431
|
+
.btn--secondary { background: var(--secondary); }
|
|
1432
|
+
.btn--success { background: var(--success); color: var(--bg); }
|
|
1433
|
+
.input {
|
|
1434
|
+
width: 100%;
|
|
1435
|
+
background: var(--bg);
|
|
1436
|
+
border: 1px solid var(--border);
|
|
1437
|
+
color: var(--fg);
|
|
1438
|
+
padding: 0.75rem 1rem;
|
|
1439
|
+
border-radius: 8px;
|
|
1440
|
+
font-size: 1rem;
|
|
1441
|
+
margin-bottom: 1rem;
|
|
1442
|
+
}
|
|
1443
|
+
.input:focus { outline: none; border-color: var(--primary); }
|
|
1444
|
+
.flex { display: flex; gap: 1rem; align-items: center; }
|
|
1445
|
+
.flex-between { justify-content: space-between; }
|
|
1446
|
+
.text-muted { color: #888; }
|
|
1447
|
+
.text-success { color: var(--success); }
|
|
1448
|
+
.mb-1 { margin-bottom: 1rem; }
|
|
1449
|
+
.hidden { display: none; }
|
|
1450
|
+
</style>
|
|
1451
|
+
</head>
|
|
1452
|
+
<body>
|
|
1453
|
+
<div class="container">
|
|
1454
|
+
<header class="header">
|
|
1455
|
+
<h1>{{ title }}</h1>
|
|
1456
|
+
<p class="text-muted">Built with stx</p>
|
|
1457
|
+
</header>
|
|
1458
|
+
|
|
1459
|
+
<!-- Counter Example -->
|
|
1460
|
+
<div class="card">
|
|
1461
|
+
<h2 class="mb-1">Counter Example</h2>
|
|
1462
|
+
<div class="flex flex-between">
|
|
1463
|
+
<span id="counterDisplay">Count: 0</span>
|
|
1464
|
+
<div class="flex">
|
|
1465
|
+
<button class="btn btn--secondary" onclick="window.app?.decrement()">-</button>
|
|
1466
|
+
<button class="btn" onclick="window.app?.increment()">+</button>
|
|
1467
|
+
<button class="btn btn--success" onclick="window.app?.reset()">Reset</button>
|
|
1468
|
+
</div>
|
|
1469
|
+
</div>
|
|
1470
|
+
</div>
|
|
1471
|
+
|
|
1472
|
+
<!-- Todo List Example -->
|
|
1473
|
+
<div class="card">
|
|
1474
|
+
<h2 class="mb-1">Todo List</h2>
|
|
1475
|
+
<div class="flex mb-1">
|
|
1476
|
+
<input
|
|
1477
|
+
type="text"
|
|
1478
|
+
id="todoInput"
|
|
1479
|
+
class="input"
|
|
1480
|
+
placeholder="Add a new todo..."
|
|
1481
|
+
onkeypress="if(event.key==='Enter') window.app?.addTodo()"
|
|
1482
|
+
style="margin-bottom:0"
|
|
1483
|
+
/>
|
|
1484
|
+
<button class="btn" onclick="window.app?.addTodo()">Add</button>
|
|
1485
|
+
</div>
|
|
1486
|
+
<div id="todoList"></div>
|
|
1487
|
+
<p id="todoCount" class="text-muted">0 items</p>
|
|
1488
|
+
</div>
|
|
1489
|
+
|
|
1490
|
+
<!-- Toggle Example -->
|
|
1491
|
+
<div class="card">
|
|
1492
|
+
<h2 class="mb-1">Toggle Example</h2>
|
|
1493
|
+
<button
|
|
1494
|
+
id="toggleBtn"
|
|
1495
|
+
class="btn btn--secondary"
|
|
1496
|
+
onclick="window.app?.toggle()"
|
|
1497
|
+
>Inactive</button>
|
|
1498
|
+
<div id="toggleContent" class="mt-1" style="margin-top:1rem;display:none">
|
|
1499
|
+
<p class="text-success">This content is visible when active!</p>
|
|
1500
|
+
</div>
|
|
1501
|
+
</div>
|
|
1502
|
+
</div>
|
|
1503
|
+
|
|
1504
|
+
<!-- Simple Store Implementation -->
|
|
1505
|
+
<script>
|
|
1506
|
+
(function() {
|
|
1507
|
+
// Create a simple reactive store
|
|
1508
|
+
function createStore(initialState) {
|
|
1509
|
+
let state = { ...initialState };
|
|
1510
|
+
const listeners = [];
|
|
1511
|
+
return {
|
|
1512
|
+
get() { return state; },
|
|
1513
|
+
set(newState) {
|
|
1514
|
+
state = { ...state, ...newState };
|
|
1515
|
+
listeners.forEach(fn => fn(state));
|
|
1516
|
+
},
|
|
1517
|
+
subscribe(fn) {
|
|
1518
|
+
listeners.push(fn);
|
|
1519
|
+
fn(state); // Call immediately
|
|
1520
|
+
return () => listeners.splice(listeners.indexOf(fn), 1);
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
// Initialize app store
|
|
1526
|
+
const appStore = createStore({
|
|
1527
|
+
count: 0,
|
|
1528
|
+
todos: [],
|
|
1529
|
+
isActive: false
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
// App methods
|
|
1533
|
+
window.app = {
|
|
1534
|
+
increment() {
|
|
1535
|
+
const { count } = appStore.get();
|
|
1536
|
+
appStore.set({ count: count + 1 });
|
|
1537
|
+
},
|
|
1538
|
+
decrement() {
|
|
1539
|
+
const { count } = appStore.get();
|
|
1540
|
+
appStore.set({ count: Math.max(0, count - 1) });
|
|
1541
|
+
},
|
|
1542
|
+
reset() {
|
|
1543
|
+
appStore.set({ count: 0 });
|
|
1544
|
+
},
|
|
1545
|
+
toggle() {
|
|
1546
|
+
const { isActive } = appStore.get();
|
|
1547
|
+
appStore.set({ isActive: !isActive });
|
|
1548
|
+
},
|
|
1549
|
+
addTodo() {
|
|
1550
|
+
const input = document.getElementById('todoInput');
|
|
1551
|
+
const text = input.value.trim();
|
|
1552
|
+
if (!text) return;
|
|
1553
|
+
const { todos } = appStore.get();
|
|
1554
|
+
appStore.set({ todos: [...todos, { id: Date.now(), text, done: false }] });
|
|
1555
|
+
input.value = '';
|
|
1556
|
+
},
|
|
1557
|
+
toggleTodo(id) {
|
|
1558
|
+
const { todos } = appStore.get();
|
|
1559
|
+
appStore.set({
|
|
1560
|
+
todos: todos.map(t => t.id === id ? { ...t, done: !t.done } : t)
|
|
1561
|
+
});
|
|
1562
|
+
},
|
|
1563
|
+
deleteTodo(id) {
|
|
1564
|
+
const { todos } = appStore.get();
|
|
1565
|
+
appStore.set({ todos: todos.filter(t => t.id !== id) });
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
// Update UI based on state
|
|
1570
|
+
function updateUI(state) {
|
|
1571
|
+
// Update counter
|
|
1572
|
+
const counterDisplay = document.getElementById('counterDisplay');
|
|
1573
|
+
if (counterDisplay) counterDisplay.textContent = 'Count: ' + state.count;
|
|
1574
|
+
|
|
1575
|
+
// Update todo count
|
|
1576
|
+
const todoCount = document.getElementById('todoCount');
|
|
1577
|
+
if (todoCount) todoCount.textContent = state.todos.length + ' items';
|
|
1578
|
+
|
|
1579
|
+
// Update toggle button
|
|
1580
|
+
const toggleBtn = document.getElementById('toggleBtn');
|
|
1581
|
+
if (toggleBtn) {
|
|
1582
|
+
toggleBtn.textContent = state.isActive ? 'Active' : 'Inactive';
|
|
1583
|
+
toggleBtn.className = 'btn ' + (state.isActive ? 'btn--success' : 'btn--secondary');
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// Show/hide toggle content
|
|
1587
|
+
const toggleContent = document.getElementById('toggleContent');
|
|
1588
|
+
if (toggleContent) toggleContent.style.display = state.isActive ? 'block' : 'none';
|
|
1589
|
+
|
|
1590
|
+
// Render todo list
|
|
1591
|
+
const list = document.getElementById('todoList');
|
|
1592
|
+
if (list) {
|
|
1593
|
+
list.innerHTML = state.todos.map(todo => \`
|
|
1594
|
+
<div style="display:flex;align-items:center;gap:0.5rem;padding:0.5rem 0;border-bottom:1px solid var(--border)">
|
|
1595
|
+
<input type="checkbox" \${todo.done ? 'checked' : ''} onchange="window.app?.toggleTodo(\${todo.id})" />
|
|
1596
|
+
<span style="\${todo.done ? 'text-decoration:line-through;opacity:0.5' : ''}">\${todo.text}</span>
|
|
1597
|
+
<button onclick="window.app?.deleteTodo(\${todo.id})" style="margin-left:auto;background:none;border:none;color:var(--primary);cursor:pointer">\xD7</button>
|
|
1598
|
+
</div>
|
|
1599
|
+
\`).join('');
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// Subscribe to store changes
|
|
1604
|
+
appStore.subscribe(updateUI);
|
|
1605
|
+
})();
|
|
1606
|
+
</script>
|
|
1607
|
+
</body>
|
|
1608
|
+
</html>`}var ma="f9c3713";function Vl(n){return n}function Ul(n){return n}function ua(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 _e from"fs";import be from"path";function un(n){try{return _e.statSync(n).mtimeMs}catch{return null}}function St(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 Hs(n,t){try{return globalThis.Bun?.resolveSync(n,t)??null}catch{return null}}function fn(n,t="stx"){let o=be.resolve(n);for(let d=0;d<10;d++){let r=be.join(o,"pantry","@stacksjs",t);if(_e.existsSync(r))return r;let p=be.dirname(o);if(p===o)break;o=p}return null}var gn=["@stacksjs/stx","bun-plugin-stx"];function Bs(n){try{let t=_e.readFileSync(be.join(n,"package.json"),"utf8"),o=JSON.parse(t)?.version;return typeof o==="string"?o:null}catch{return null}}function Fs(n,t=6){let o=be.resolve(n),d=[],r=new Set;function p(m,b){if(b>t)return;let y;try{y=_e.realpathSync(m)}catch{return}if(r.has(y))return;r.add(y);for(let C of gn){let R=be.join(m,C),O=Bs(R);if(O!==null)d.push({name:C,version:O,dir:be.relative(o,R)||R,nested:b>0})}let v;try{v=_e.readdirSync(m,{withFileTypes:!0})}catch{return}for(let C of v){if(!C.isDirectory()&&!C.isSymbolicLink())continue;if(C.name===".bin"||C.name===".cache")continue;let R=be.join(m,C.name);if(C.name.startsWith("@")){let w;try{w=_e.readdirSync(R,{withFileTypes:!0})}catch{continue}for(let S of w){let A=be.join(R,S.name,"node_modules");if(_e.existsSync(A))p(A,b+1)}continue}let O=be.join(R,"node_modules");if(_e.existsSync(O))p(O,b+1)}}let u=be.join(o,"node_modules");if(_e.existsSync(u))p(u,0);return d}function zs(n){let t=[];for(let o of gn){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 bo(n={}){let t=n.cwd?be.resolve(n.cwd):process.cwd(),o=n.resolve??Hs,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 b of zs(Fs(t)))r.push(b);let m=fn(t,"stx");if(!m)r.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let b=be.join(m,"src/signals.ts"),y=[be.join(m,"dist/index.js"),be.join(m,"dist/signals.js")].find((w)=>_e.existsSync(w))||null,v=un(b),C=y?un(y):null;if(v==null)r.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${m} but no src/signals.ts to compare`});else if(C==null)r.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${m} && bun build.ts`});else if(C<v){let w=Math.round((v-C)/1000);r.push({name:"pantry dist freshness",status:"error",detail:`dist (${St(C,d)}) is OLDER than src/signals.ts (${St(v,d)}) by ${w}s \u2014 your edit isn't built`,fix:`cd ${m} && bun build.ts`})}else r.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${St(v,d)}, dist ${St(C,d)})`});let R=be.join(t,"node_modules/@stacksjs/stx"),O=null;try{O=_e.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 w=null;try{w=_e.realpathSync(R)}catch{}let S=(()=>{try{return _e.realpathSync(m)}catch{return m}})();r.push(w===S?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${w||"(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 y=n.generateRuntime().length;r.push(y>1000?{name:"signals runtime",status:"ok",detail:`generated ${y.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${y} chars \u2014 suspiciously short`})}catch(b){r.push({name:"signals runtime",status:"error",detail:`failed to generate: ${b.message}`})}return{checks:r,ok:!r.some((b)=>b.status==="error")}}function wo(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{ua,da,pa,yo,fa,ga,ma,Vl,Ul,bo,wo,Gr,Xr,Jr};
|