@stacksjs/stx 0.2.887 → 0.2.888
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-000mwmfq.js +1203 -0
- package/dist/chunk-043d0en0.js +2 -0
- package/dist/{chunk-3cq4a4x7.js → chunk-0d7ypcjb.js} +2 -2
- package/dist/{chunk-02qmvcmv.js → chunk-0dq9svfb.js} +2 -2
- package/dist/{chunk-cb0c6959.js → chunk-0hj5apb9.js} +1 -1
- package/dist/chunk-0w66z6eq.js +2 -0
- package/dist/{chunk-n22xtagg.js → chunk-11fxbd71.js} +2 -2
- package/dist/chunk-13wd9gf0.js +3 -0
- package/dist/{chunk-zch65qrd.js → chunk-1kc0jyhj.js} +1 -1
- package/dist/{chunk-ram5944w.js → chunk-1wkp3pks.js} +2 -2
- package/dist/{chunk-69ezjc8k.js → chunk-1xpq83mc.js} +4 -4
- package/dist/chunk-1znqedae.js +2 -0
- package/dist/{chunk-gvd8nb8z.js → chunk-2assyczz.js} +1 -1
- package/dist/{chunk-cev5z6gj.js → chunk-2drzzjcm.js} +1 -1
- package/dist/{chunk-y6eaqs8v.js → chunk-2rmqmajd.js} +3 -3
- package/dist/{chunk-59er0fc7.js → chunk-303vzq80.js} +3 -3
- package/dist/{chunk-zj5eq4b6.js → chunk-372xh1g1.js} +4 -4
- package/dist/chunk-3c7nt5qp.js +2 -0
- package/dist/{chunk-zpj6ggee.js → chunk-3ed2erm6.js} +3 -3
- package/dist/{chunk-gbncp2gp.js → chunk-3fbgpv1d.js} +2 -2
- package/dist/chunk-3zyzhcd9.js +2 -0
- package/dist/chunk-44rb9fk0.js +2 -0
- package/dist/chunk-472j3bhp.js +2 -0
- package/dist/chunk-4acce1m8.js +2 -0
- package/dist/{chunk-2r0nrvqe.js → chunk-4c9p434g.js} +2 -2
- package/dist/chunk-4kasmp98.js +2 -0
- package/dist/{chunk-e41pgmgk.js → chunk-4nnmrp7w.js} +2 -2
- package/dist/{chunk-c47stwqj.js → chunk-52mhrbps.js} +1 -1
- package/dist/chunk-53kkjn23.js +2 -0
- package/dist/{chunk-7wqz32ay.js → chunk-55kwxxm5.js} +2 -2
- package/dist/chunk-5gwvy612.js +2 -0
- package/dist/{chunk-0rdh8bw3.js → chunk-5ymf5c8m.js} +6 -6
- package/dist/{chunk-xcsgpf83.js → chunk-5ysv0499.js} +1 -1
- package/dist/{chunk-4n45qa0b.js → chunk-605g9qhp.js} +4 -4
- package/dist/chunk-61vbqrde.js +2 -0
- package/dist/chunk-6fpzwryt.js +2 -0
- package/dist/{chunk-rv0a3stz.js → chunk-6fsnnj5v.js} +5 -5
- package/dist/{chunk-q74affc4.js → chunk-6qq3wy3m.js} +2 -2
- package/dist/{chunk-h63ma36g.js → chunk-6zq3eh7d.js} +2 -2
- package/dist/chunk-7195598h.js +2 -0
- package/dist/{chunk-czcx3nbx.js → chunk-7hm1tpw0.js} +4 -4
- package/dist/{chunk-a7ryj8z8.js → chunk-7nhgpjjw.js} +6 -6
- package/dist/{chunk-0mx7rg07.js → chunk-7s3j8pqq.js} +3 -3
- package/dist/chunk-7zvf79vb.js +2 -0
- package/dist/chunk-88a735jw.js +2 -0
- package/dist/chunk-8v7yjq3b.js +2 -0
- package/dist/{chunk-463weehv.js → chunk-98mj0es1.js} +1 -1
- package/dist/{chunk-ef9m5fjb.js → chunk-9qrgdekg.js} +11 -11
- package/dist/{chunk-fg67643b.js → chunk-9tecekzq.js} +4 -4
- package/dist/chunk-a8c9j9cj.js +2 -0
- package/dist/chunk-acw851e8.js +2 -0
- package/dist/{chunk-d2pexm3z.js → chunk-ah6nc29h.js} +1 -1
- package/dist/chunk-andfvr3g.js +2 -0
- package/dist/chunk-ay5zkfdg.js +2 -0
- package/dist/{chunk-xpbakn6t.js → chunk-b0jekg4c.js} +2 -2
- package/dist/chunk-b4gptdtc.js +2 -0
- package/dist/{chunk-agd2b928.js → chunk-b8528fra.js} +2 -2
- package/dist/chunk-baaw9w7y.js +2 -0
- package/dist/{chunk-sc1gmts0.js → chunk-btsgt6w3.js} +2 -2
- package/dist/chunk-bw2p9h2g.js +2 -0
- package/dist/{chunk-6mfpns00.js → chunk-c1b0fy70.js} +4 -4
- package/dist/{chunk-qt39mb2a.js → chunk-c3ca056p.js} +1 -1
- package/dist/chunk-ce0vv7kz.js +2 -0
- package/dist/chunk-d1yj29g2.js +2 -0
- package/dist/{chunk-4j50hrgq.js → chunk-dbhmbef1.js} +4 -4
- package/dist/chunk-dfsykk1r.js +2 -0
- package/dist/{chunk-satrf398.js → chunk-dj9ztcth.js} +1 -1
- package/dist/{chunk-pgrm1vet.js → chunk-e1qcfesw.js} +5 -5
- package/dist/{chunk-cv4bfhn1.js → chunk-e2ws79vt.js} +4 -4
- package/dist/chunk-e9p596bp.js +2 -0
- package/dist/{chunk-q3epnfp4.js → chunk-e9tjxnhn.js} +4 -4
- package/dist/{chunk-dz7amds0.js → chunk-edysherg.js} +3 -3
- package/dist/{chunk-g2xy0z0e.js → chunk-em6fqvjy.js} +2 -2
- package/dist/{chunk-kaem8q20.js → chunk-fce8wj3t.js} +1 -1
- package/dist/{chunk-f2twg7ze.js → chunk-fepezvdq.js} +5 -5
- package/dist/chunk-ftecsa8e.js +2 -0
- package/dist/{chunk-50cnypys.js → chunk-gdtj5rfa.js} +5 -5
- package/dist/chunk-ge2h5v46.js +2 -0
- package/dist/chunk-gqvnz8a7.js +2 -0
- package/dist/chunk-j41gp8p3.js +2 -0
- package/dist/{chunk-nzpzyz22.js → chunk-j51wss7s.js} +1 -1
- package/dist/chunk-jxvccj30.js +2 -0
- package/dist/chunk-k5bbre7d.js +2 -0
- package/dist/chunk-kd47vgs8.js +2 -0
- package/dist/chunk-keqjafdz.js +2 -0
- package/dist/{chunk-kwf3kfr0.js → chunk-kvxdyg7e.js} +2 -2
- package/dist/chunk-kz3mejc4.js +2 -0
- package/dist/{chunk-ezna4dhj.js → chunk-mbm3ma63.js} +2 -2
- package/dist/{chunk-qx1nbryq.js → chunk-mk6thhwf.js} +2 -2
- package/dist/{chunk-twmkz0xs.js → chunk-mm1eg2pg.js} +7 -7
- package/dist/chunk-ngkh0t5b.js +2 -0
- package/dist/chunk-nx9895m6.js +2 -0
- package/dist/chunk-nxgtt1t1.js +2 -0
- package/dist/chunk-nyw2ztar.js +2 -0
- package/dist/{chunk-km14pdrt.js → chunk-p33npqjt.js} +11 -11
- package/dist/chunk-p5q27adr.js +2 -0
- package/dist/chunk-pczb7xav.js +2 -0
- package/dist/{chunk-sfyyn0mg.js → chunk-pm4kn9h2.js} +6 -6
- package/dist/chunk-ps37r6hj.js +2 -0
- package/dist/chunk-pvbhk17r.js +2 -0
- package/dist/chunk-q252qvsy.js +2 -0
- package/dist/{chunk-6qpe4f8e.js → chunk-q3bkxg2n.js} +4 -4
- package/dist/chunk-q5b0vpmm.js +2 -0
- package/dist/{chunk-4251fy7d.js → chunk-qjy5yq25.js} +9 -9
- package/dist/{chunk-pdprhg5k.js → chunk-qsnpqa8q.js} +1 -1
- package/dist/{chunk-2v7v6jcs.js → chunk-r561zt9v.js} +3 -3
- package/dist/{chunk-ybjgnnyf.js → chunk-r57jz09p.js} +5 -5
- package/dist/{chunk-dwyhpbpx.js → chunk-r8xper92.js} +2 -2
- package/dist/{chunk-sv7fdqmc.js → chunk-ry6w43p6.js} +6 -6
- package/dist/{chunk-e362e615.js → chunk-s7wp7a2x.js} +30 -30
- package/dist/chunk-sbr85vda.js +2 -0
- package/dist/{chunk-57q4nvs9.js → chunk-sbwvvjkc.js} +3 -3
- package/dist/chunk-tkab24xr.js +2 -0
- package/dist/{chunk-16aqrwmk.js → chunk-v47xc2fr.js} +5 -5
- package/dist/{chunk-q1mb0fbt.js → chunk-v8e2c2r1.js} +2 -2
- package/dist/{chunk-aaea157p.js → chunk-vazk5qbh.js} +2 -2
- package/dist/{chunk-6df3j3qq.js → chunk-vgr7gd8k.js} +1 -1
- package/dist/{chunk-kee5a3ce.js → chunk-vgsasnwm.js} +2 -2
- package/dist/{chunk-32twt3wx.js → chunk-vjfp8n6p.js} +3 -3
- package/dist/chunk-vn59yrjh.js +2 -0
- package/dist/{chunk-shcnt6aa.js → chunk-w1q86c89.js} +3 -3
- package/dist/{chunk-ws2h92mm.js → chunk-w50yggy3.js} +2 -2
- package/dist/{chunk-8e1cv1hh.js → chunk-w624s5jf.js} +3 -3
- package/dist/chunk-wa9q1gyv.js +2 -0
- package/dist/{chunk-a0q0kb0s.js → chunk-wbxmn5gk.js} +5 -5
- package/dist/{chunk-pc8dt8xs.js → chunk-wf8pdjq5.js} +1 -1
- package/dist/{chunk-88tshy2f.js → chunk-whsdyf4t.js} +6 -6
- package/dist/{chunk-3bfheqe3.js → chunk-wm287dz2.js} +2 -2
- package/dist/{chunk-rsxxajv6.js → chunk-wpa3r3b9.js} +2 -2
- package/dist/chunk-wpgxhrd7.js +2 -0
- package/dist/{chunk-yasdj4ve.js → chunk-wscry63p.js} +2 -2
- package/dist/chunk-x3azrbpr.js +2 -0
- package/dist/chunk-x50hk1hq.js +2 -0
- package/dist/{chunk-8va3fs07.js → chunk-xavx271y.js} +5 -5
- package/dist/chunk-xbkbvfcg.js +2 -0
- package/dist/{chunk-295bykzd.js → chunk-xw291tn7.js} +13 -11
- package/dist/{chunk-94ctmp0j.js → chunk-xy4j8t7w.js} +2 -2
- package/dist/{chunk-azf6tdq6.js → chunk-y76znqmh.js} +17 -17
- package/dist/{chunk-yp4tn4zn.js → chunk-y8p59h6c.js} +4 -4
- package/dist/{chunk-s7xywsqd.js → chunk-z55rpt3s.js} +2 -2
- package/dist/{chunk-ssg6ne5b.js → chunk-zf29ahhd.js} +4 -4
- package/dist/{chunk-mxvgft6p.js → chunk-zje94z0k.js} +9 -9
- package/dist/{chunk-gtv9jd68.js → chunk-znnvq1jp.js} +26 -26
- package/dist/{chunk-08cb7cyw.js → chunk-zwde52kw.js} +1 -1
- package/dist/chunk-zxff7kq9.js +2 -0
- package/dist/cli.js +19 -19
- package/dist/component-library.js +118 -21
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +6 -6
- package/package.json +5 -5
- package/dist/chunk-0gkxqcpj.js +0 -2
- package/dist/chunk-0h1dyd38.js +0 -2
- package/dist/chunk-0sew66hf.js +0 -2
- package/dist/chunk-13dgqekj.js +0 -2
- package/dist/chunk-15n20xwe.js +0 -2
- package/dist/chunk-1ta1pj1t.js +0 -2
- package/dist/chunk-1z3r2jjp.js +0 -2
- package/dist/chunk-1z6rrqvm.js +0 -2
- package/dist/chunk-41353gyc.js +0 -2
- package/dist/chunk-4pjqj54a.js +0 -2
- package/dist/chunk-53cc06w7.js +0 -2
- package/dist/chunk-5m02cbxg.js +0 -2
- package/dist/chunk-5rd0an89.js +0 -2
- package/dist/chunk-5s0w910j.js +0 -2
- package/dist/chunk-6fy11vfb.js +0 -2
- package/dist/chunk-6mjk28s3.js +0 -2
- package/dist/chunk-8h5nje66.js +0 -2
- package/dist/chunk-9h3qq2d2.js +0 -2
- package/dist/chunk-9kza7gxd.js +0 -2
- package/dist/chunk-a02gt4tz.js +0 -1199
- package/dist/chunk-a30zpnqp.js +0 -2
- package/dist/chunk-aq0fz4mr.js +0 -2
- package/dist/chunk-axra1yas.js +0 -2
- package/dist/chunk-b2vhsyf9.js +0 -2
- package/dist/chunk-c42b1y7z.js +0 -2
- package/dist/chunk-c89wryyz.js +0 -2
- package/dist/chunk-ch57kgb6.js +0 -2
- package/dist/chunk-cv1vm1w0.js +0 -2
- package/dist/chunk-d7b30bg6.js +0 -2
- package/dist/chunk-f3j1h3ch.js +0 -2
- package/dist/chunk-fz4c5e9m.js +0 -2
- package/dist/chunk-gd04nvj3.js +0 -2
- package/dist/chunk-gmp10259.js +0 -2
- package/dist/chunk-gr956aar.js +0 -2
- package/dist/chunk-h3fv0q25.js +0 -2
- package/dist/chunk-jghpzx5m.js +0 -2
- package/dist/chunk-kcqfrw10.js +0 -2
- package/dist/chunk-kfzvtzsz.js +0 -2
- package/dist/chunk-kqgspa3s.js +0 -2
- package/dist/chunk-mast9wb2.js +0 -2
- package/dist/chunk-mqy1wz09.js +0 -3
- package/dist/chunk-mv21mc9p.js +0 -2
- package/dist/chunk-n9bw9bsn.js +0 -2
- package/dist/chunk-ngzyzcrp.js +0 -2
- package/dist/chunk-nnqyn7db.js +0 -2
- package/dist/chunk-p5qac909.js +0 -2
- package/dist/chunk-pa6kgbmw.js +0 -2
- package/dist/chunk-pd089tq0.js +0 -2
- package/dist/chunk-pjjrx9pk.js +0 -2
- package/dist/chunk-pt3rp3zg.js +0 -2
- package/dist/chunk-t8r40wgf.js +0 -2
- package/dist/chunk-wjafpvjv.js +0 -2
- package/dist/chunk-x44f0eq1.js +0 -2
- package/dist/chunk-xhr35ctb.js +0 -2
- package/dist/chunk-xk15vzb6.js +0 -2
- package/dist/chunk-xmmr0916.js +0 -2
- package/dist/chunk-ywnqjqns.js +0 -2
- package/dist/chunk-z7k1xn6k.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{j,Tn,Wt,qt,h,s,
|
|
2
|
+
import{j,Tn,Wt,qt,h,s,_e,g}from"./chunk-000mwmfq.js";import{Rt,ze,$c,vs,Zo,Qo,i}from"./chunk-znnvq1jp.js";import{ye}from"./chunk-s29hp1qw.js";import{ae,Br,Ne,K,Mn}from"./chunk-xw291tn7.js";import{Nt,Cr,zs,Hs,Vs,Mt,Dt,Lt,jt,Bt,Ft,dt}from"./chunk-b8528fra.js";import{Ms,a,L}from"./chunk-zje94z0k.js";import{Ct,an,Le,V,Pa,Oo,is,nt,Ia,rt,je}from"./chunk-v47xc2fr.js";import{Sr,kr}from"./chunk-55kwxxm5.js";import{e,xn,yr,x}from"./chunk-pm4kn9h2.js";import{at}from"./chunk-qjy5yq25.js";import{Fe}from"./chunk-9f31gs4m.js";import{zn}from"./chunk-wscry63p.js";import{ne,$e,Re}from"./chunk-fepezvdq.js";import{l}from"./chunk-z55rpt3s.js";import{te}from"./chunk-w50yggy3.js";import{c,f}from"./chunk-b0jekg4c.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=An(t,o),p=Dn(t,o);return{file:n,metrics:o,issues:d,suggestions:r,performance:p}}catch(t){throw Error(`Failed to analyze template ${n}: ${t instanceof Error?t.message:String(t)}`)}}function En(n){let t=n.split(`
|
|
3
3
|
`),o=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=(o?o[1]:"").split(`
|
|
4
4
|
`).length,p={conditionals:(n.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(n.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(n.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};p.total=p.conditionals+p.loops+p.includes+p.custom;let u=(n.match(/\{\{[\s\S]*?\}\}/g)||[]).length,m=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length,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=Ut(n,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let r=Ut(n,"foreach","endforeach");if(r>0)o.push({type:"error",category:"syntax",message:`Found ${r} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let p=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=n.match(/<img[^>]*>/g);if(m){let 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 An(n,t){let o=[];if(t.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(t.complexity>5&&t.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(t.lines>100&&t.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(t.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(t.directives.total===0&&t.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(t.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Dn(n,t){let o=1;if(o+=t.directives.conditionals*0.1,o+=t.directives.loops*0.5,o+=t.directives.includes*2,o+=t.expressions*0.05,o+=t.components*1,t.scriptLines>10)o+=t.scriptLines*0.1;let d;if(t.expressions===0&&t.directives.total===0)d="high";else if(t.expressions<5&&t.directives.total<3)d="medium";else d="low";let r=[];if(o>10)r.push("Consider optimizing template complexity");if(d==="low"&&t.directives.total>5)r.push("Reduce dynamic content for better caching");if(t.components===0&&t.lines>40)r.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:t.complexity,cacheability:d,recommendations:r}}function Ut(n,t,o){let d=n.replace(/<!--[\s\S]*?-->/g,""),r=(d.match(new RegExp(`@${t}\\b`,"g"))||[]).length,p=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(r-p)}async function
|
|
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 An(n,t){let o=[];if(t.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(t.complexity>5&&t.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(t.lines>100&&t.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(t.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(t.directives.total===0&&t.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(t.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Dn(n,t){let o=1;if(o+=t.directives.conditionals*0.1,o+=t.directives.loops*0.5,o+=t.directives.includes*2,o+=t.expressions*0.05,o+=t.components*1,t.scriptLines>10)o+=t.scriptLines*0.1;let d;if(t.expressions===0&&t.directives.total===0)d="high";else if(t.expressions<5&&t.directives.total<3)d="medium";else d="low";let r=[];if(o>10)r.push("Consider optimizing template complexity");if(d==="low"&&t.directives.total>5)r.push("Reduce dynamic content for better caching");if(t.components===0&&t.lines>40)r.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:t.complexity,cacheability:d,recommendations:r}}function Ut(n,t,o){let d=n.replace(/<!--[\s\S]*?-->/g,""),r=(d.match(new RegExp(`@${t}\\b`,"g"))||[]).length,p=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(r-p)}async function va(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=_n(o);return{results:o,summary:r}}function _n(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 Pt from"fs";import Qe from"path";function pt(){return`
|
|
6
6
|
/* Theme selector for code blocks */
|
|
7
7
|
.theme-selector {
|
|
8
8
|
margin: 1rem 0;
|
|
@@ -82,7 +82,7 @@ else {
|
|
|
82
82
|
<span class="frontmatter-label">${t}:</span>
|
|
83
83
|
<span>${Array.isArray(o)?o.join(", "):String(o)}</span>
|
|
84
84
|
</div>`).join("")}
|
|
85
|
-
</div>`}async function Ln(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"0.0.0.0")})}async function In(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"::")})}async function jn(n){if(!await Ln(n))return!1;return await In(n)}async function Ve(n,t=20){n=Number(n);for(let o=0;o<t;o++){let d=n+o;if(await jn(d))return d}throw Error(`Could not find an available port between ${n} and ${n+t-1}`)}var Hn={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Bn(){try{let n=await import("./chunk-
|
|
85
|
+
</div>`}async function Ln(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"0.0.0.0")})}async function In(n){let{default:t}=await import("net");return new Promise((o)=>{let d=t.createServer();d.once("error",()=>o(!1)),d.once("listening",()=>{d.close(()=>o(!0))}),d.listen(n,"::")})}async function jn(n){if(!await Ln(n))return!1;return await In(n)}async function Ve(n,t=20){n=Number(n);for(let o=0;o<t;o++){let d=n+o;if(await jn(d))return d}throw Error(`Could not find an available port between ${n} and ${n+t-1}`)}var Hn={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Bn(){try{let n=await import("./chunk-nx9895m6.js");if(typeof n.openDevWindow!=="function")return null;return n}catch{return null}}async function Ye(n,t={}){let o={...Hn,...t},d=await Bn();if(!d)return console.log(`${e.yellow}\u26A0${e.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let r=await d.openDevWindow(n,{title:o.title,width:o.width,height:o.height,darkMode:o.darkMode,hotReload:o.hotReload,titlebarHidden:o.titlebarHidden,nativeSidebar:o.nativeSidebar,sidebarWidth:o.sidebarWidth,sidebarConfig:o.sidebarConfig});if(r&&o.nativeSidebar)console.log(`${e.green}\u2713${e.reset} Native sidebar enabled (macOS Tahoe style)`);return r}catch(r){return console.log(`${e.red}\u2717${e.reset} Could not open native window:`,r),!1}}function gt(n){if(n.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let r=n.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(r){let p=r[1];try{let u=`
|
|
86
86
|
${p}
|
|
87
87
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
88
88
|
`,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 $t(){console.log(`
|
|
@@ -454,10 +454,10 @@ else {
|
|
|
454
454
|
};
|
|
455
455
|
})();
|
|
456
456
|
</script>
|
|
457
|
-
`}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Vt(n);return Ze}function st(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await Ms(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 Sr(u,o);if(S){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:S,loader:"html"}}}let b=await Ne(()=>Bun.file(u).text(),"",(S)=>{throw new Br(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${S.message}`)});if(!b)throw new Br(`stx file is empty: ${u}`,u);let{scriptContent:y,templateContent:v,allScripts:C}=ye.time("script-extraction",()=>{let S=b,A=j(b);if(A)S=A.content.trim();let U=b.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],oe="",H=[];for(let k of U){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),
|
|
457
|
+
`}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Vt(n);return Ze}function st(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await Ms(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 Sr(u,o);if(S){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:S,loader:"html"}}}let b=await Ne(()=>Bun.file(u).text(),"",(S)=>{throw new Br(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${S.message}`)});if(!b)throw new Br(`stx file is empty: ${u}`,u);let{scriptContent:y,templateContent:v,allScripts:C}=ye.time("script-extraction",()=>{let S=b,A=j(b);if(A)S=A.content.trim();let U=b.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],oe="",H=[];for(let k of U){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),q=D?D[1]:"";if(/\bserver\b/i.test(q))oe=P;else H.push(k)}let I=S.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:oe,templateContent:I,allScripts:H}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Ne(()=>h(y,R,u),void 0,(S)=>{let A=new ae(`Script execution failed in ${u}: ${S.message}`,u,void 0,void 0,y.substring(0,100));if(K.log(A,{filePath:u,scriptContent:y}),o.debug)throw A});let w=await ye.timeAsync("directive-processing",async()=>await i(v,R,u,o,m));if(C.length>0){let{interpolateScriptsInTemplate:S}=await import("./chunk-dfsykk1r.js"),A=S(C.join(`
|
|
458
458
|
`),R),U=w.search(/<\/body>/i);if(U!==-1)w=w.slice(0,U)+A+`
|
|
459
459
|
`+w.slice(U);else w+=`
|
|
460
|
-
${A}`}if(w=await
|
|
460
|
+
${A}`}if(w=await Re(w),m.forEach((S)=>d.add(S)),o.cache&&o.cachePath){if(await kr(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 ae(`Plugin processing failed: ${String(m)}`,u);if(K.log(b,{filePath:u,buildConfig:n.config}),Mn.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||te()?`<!DOCTYPE html>
|
|
461
461
|
<html lang="en">
|
|
462
462
|
<head>
|
|
463
463
|
<meta charset="UTF-8">
|
|
@@ -517,12 +517,12 @@ ${A}`}if(w=await $e(w),m.forEach((S)=>d.add(S)),o.cache&&o.cachePath){if(await k
|
|
|
517
517
|
<h1>Something went wrong</h1>
|
|
518
518
|
<p>An internal error occurred. Please try again later.</p>
|
|
519
519
|
</body>
|
|
520
|
-
</html>`,loader:"html"}}})}};async function es(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=ge.resolve(n);if(!Ie.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Et(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let b=l(process.cwd(),"output");Ie.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(be){be.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:b,plugins:[P,et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!D.success)return console.error(`${e.red}Build failed:${e.reset}`,D.logs),!1;let
|
|
520
|
+
</html>`,loader:"html"}}})}};async function es(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=ge.resolve(n);if(!Ie.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Et(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let b=l(process.cwd(),"output");Ie.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(be){be.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:b,plugins:[P,et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!D.success)return console.error(`${e.red}Build failed:${e.reset}`,D.logs),!1;let q=D.outputs.find((be)=>be.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return y=await Bun.file(q.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=ge.dirname(m);await xn(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-j41gp8p3.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 q=Object.keys(w).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:Y}=await import("./chunk-6fpzwryt.js"),be=D.broadcasting;await q(be);let pe=be.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let ke=ge.join(process.cwd(),"channels.ts");if(Ie.existsSync(ke))try{let se=await Y(ke);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:U,isServerApiSource:oe}=await import("./chunk-ngkh0t5b.js"),H=await U(process.cwd(),A);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${O}/${e.reset}...`),r)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let I=Kn({port:O,async fetch(P){return zn(P,await(async()=>{let D=new URL(P.url);if([b,ge.dirname(m),ge.join(process.cwd(),"public")].some((se)=>oe(ge.join(se,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(S)try{let se=await S.handleRequest(P);if(se.status!==404)return se}catch{}if(w[D.pathname])try{return await w[D.pathname](P)}catch(se){return new Response(JSON.stringify({error:se.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await H(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await x(y||"");if(r)F=Ue(F,u);if(t.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(t.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(b,D.pathname);if(Ie.existsSync(Y)&&Ie.statSync(Y).isFile()){let se=Bun.file(Y),F=ge.extname(Y).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let He=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Be=await se.text(),Ge=He.transformSync(Be);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}let be=ge.dirname(m),pe=ge.join(be,D.pathname);if(Ie.existsSync(pe)&&Ie.statSync(pe).isFile()){let se=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let He=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Be=await se.text(),Ge=He.transformSync(Be);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}let ke=ge.join(process.cwd(),"public",D.pathname);if(Ie.existsSync(ke)&&Ie.statSync(ke).isFile()){let se=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let He=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Be=await se.text(),Ge=He.transformSync(Be);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(P){return new Response(`<pre>${P}
|
|
521
521
|
${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
522
522
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
523
523
|
${e.bright}\u2192 ${e.cyan}http://localhost:${O}/${e.reset}`),console.log(`
|
|
524
524
|
${e.yellow}Routes:${e.reset}`);let k=ge.relative(process.cwd(),m);if(console.log(` ${e.green}\u2514\u2500 /${e.reset} \u2192 ${e.bright}${k}${e.reset}`),console.log(`
|
|
525
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(I.url.toString(),()=>{if(d)Ie.watch(ge.dirname(m),{recursive:!0}).close();I.stop()}),t.native){let P=await Bun.file(m).text(),D=gt(P);await Ye(O,{title:ge.basename(m,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=ge.dirname(m);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=Ie.watch(P,{recursive:!0},async(
|
|
525
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(I.url.toString(),()=>{if(d)Ie.watch(ge.dirname(m),{recursive:!0}).close();I.stop()}),t.native){let P=await Bun.file(m).text(),D=gt(P);await Ye(O,{title:ge.basename(m,".stx"),titlebarHidden:t.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(d){let P=ge.dirname(m);console.log(`${e.blue}Watching ${e.bright}${P}${e.reset} for changes...`);let D=Ie.watch(P,{recursive:!0},async(q,Y)=>{if(!Y||xt(Y))return;if(yt(Y)){console.log(`${e.yellow}File ${e.bright}${Y}${e.yellow} changed, rebuilding...${e.reset}`),at.clear(),_e();let be=await v();if(await yr(R),r&&p)if(be)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)st();I.stop(),process.exit(0)})}return!0}var{serve:Xn}=globalThis.Bun;import Ke from"fs";import Se from"path";var Kt=`
|
|
526
526
|
<script data-stx-helpers>
|
|
527
527
|
(function() {
|
|
528
528
|
'use strict'
|
|
@@ -833,7 +833,7 @@ else {
|
|
|
833
833
|
|
|
834
834
|
})()
|
|
835
835
|
</script>
|
|
836
|
-
`;function Gt(n){if(n.length===0)return"";if(n.length===1)return n[0];let t=n.map((d)=>d.split(Se.sep)),o=[];for(let d=0;d<t[0].length;d++){let r=t[0][d];if(t.every((p)=>p[d]===r))o.push(r);else break}return o.join(Se.sep)}async function ts(n,t={}){let o=t.port||3000,d=t.watch!==!1;for(let w of n){let S=Se.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)=>Se.dirname(Se.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=Se.resolve(w);if(S.endsWith(".md"))try{let{content:U,data:oe}=await ze(S,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:L.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),H=t.markdown?.syntaxHighlighting||L.markdown?.syntaxHighlighting,I=H?.defaultTheme||"github-dark",k=["github-dark"],P=H?.additionalThemes||[],
|
|
836
|
+
`;function Gt(n){if(n.length===0)return"";if(n.length===1)return n[0];let t=n.map((d)=>d.split(Se.sep)),o=[];for(let d=0;d<t[0].length;d++){let r=t[0][d];if(t.every((p)=>p[d]===r))o.push(r);else break}return o.join(Se.sep)}async function ts(n,t={}){let o=t.port||3000,d=t.watch!==!1;for(let w of n){let S=Se.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)=>Se.dirname(Se.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=Se.resolve(w);if(S.endsWith(".md"))try{let{content:U,data:oe}=await ze(S,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:L.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),H=t.markdown?.syntaxHighlighting||L.markdown?.syntaxHighlighting,I=H?.defaultTheme||"github-dark",k=["github-dark"],P=H?.additionalThemes||[],q=[...new Set([...k,...P])].map((ke)=>`<option value="${ke}"${ke===I?" selected":""}>${ke}</option>`).join(`
|
|
837
837
|
`),Y=`
|
|
838
838
|
<!DOCTYPE html>
|
|
839
839
|
<html lang="en">
|
|
@@ -987,7 +987,7 @@ else {
|
|
|
987
987
|
</head>
|
|
988
988
|
<body>
|
|
989
989
|
${mt(oe)}
|
|
990
|
-
${ut(
|
|
990
|
+
${ut(q)}
|
|
991
991
|
|
|
992
992
|
${U}
|
|
993
993
|
|
|
@@ -997,17 +997,17 @@ else {
|
|
|
997
997
|
</body>
|
|
998
998
|
</html>
|
|
999
999
|
`,pe=`/${Se.relative(p,S).replace(/\.md$/,"")}`;if(pe.endsWith("/index"))pe=pe.slice(0,-6)||"/";u[pe||"/"]={filePath:S,content:Y,fileType:"md"}}catch(U){console.error(`${e.red}Error processing Markdown file ${e.bright}${w}${e.reset}:`,U);continue}else{let U={name:"public-assets",setup(k){k.onResolve({filter:/^\/(images|fonts|assets|public)\//},(P)=>({path:P.path,external:!0}))}},oe;try{let k=await Bun.build({entrypoints:[S],outdir:r,plugins:[U,et],define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!k.success){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:`,Fe(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}oe=await Bun.file(P.path).text()}catch(k){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:
|
|
1000
|
-
${Fe(k,S)}`);continue}let I=`/${Se.relative(p,S).replace(/\.stx$/,"")}`;if(I.endsWith("/index"))I=I.slice(0,-6)||"/";if(I.includes("[")){let{regex:k,params:P}=zs(I,{page:!0});m.push({pattern:k,paramNames:P,filePath:S,routeTemplate:I,fileType:"stx"}),u[I]={filePath:S,content:oe,fileType:"stx"}}else u[I||"/"]={filePath:S,content:oe,fileType:"stx"}}}if(Object.keys(u).length===0)return console.error(`${e.red}No files were successfully processed${e.reset}`),!1;return!0}catch(w){return console.error(`${e.red}Error processing files:${e.reset}`,Fe(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=Se.join(process.cwd(),"public",S.pathname);if(Ke.existsSync(A)&&Ke.statSync(A).isFile()){let H=Bun.file(A),I=Se.extname(A).toLowerCase(),k="application/octet-stream";if(I===".ts"||I===".tsx"){let P=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),D=await H.text(),
|
|
1000
|
+
${Fe(k,S)}`);continue}let I=`/${Se.relative(p,S).replace(/\.stx$/,"")}`;if(I.endsWith("/index"))I=I.slice(0,-6)||"/";if(I.includes("[")){let{regex:k,params:P}=zs(I,{page:!0});m.push({pattern:k,paramNames:P,filePath:S,routeTemplate:I,fileType:"stx"}),u[I]={filePath:S,content:oe,fileType:"stx"}}else u[I||"/"]={filePath:S,content:oe,fileType:"stx"}}}if(Object.keys(u).length===0)return console.error(`${e.red}No files were successfully processed${e.reset}`),!1;return!0}catch(w){return console.error(`${e.red}Error processing files:${e.reset}`,Fe(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=Se.join(process.cwd(),"public",S.pathname);if(Ke.existsSync(A)&&Ke.statSync(A).isFile()){let H=Bun.file(A),I=Se.extname(A).toLowerCase(),k="application/octet-stream";if(I===".ts"||I===".tsx"){let P=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),D=await H.text(),q=P.transformSync(D);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(H,{headers:{"Content-Type":k}})}let U=u[S.pathname];if(!U&&!S.pathname.endsWith("/"))U=u[`${S.pathname}/`];if(!U)for(let H of m){let I=S.pathname.match(H.pattern);if(I){let k=u[H.routeTemplate];if(k){let P={};for(let Y=0;Y<H.paramNames.length;Y++)P[H.paramNames[Y]]=decodeURIComponent(I[Y+1]);let D=k.content,q=`<script>window.__routeParams = ${JSON.stringify(P)};</script>`;if(D.includes("</head>"))D=f(D,q);else D=q+D;U={...k,content:D}}break}}if(U)return x(U.content).then((H)=>{if(H.includes("</head>"))H=f(H,Kt);return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let oe=Se.join(r,S.pathname);if(Ke.existsSync(oe)&&Ke.statSync(oe).isFile()){let H=Bun.file(oe),I=Se.extname(oe).toLowerCase(),k="text/plain";if(I===".ts"||I===".tsx"){let P=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),D=await H.text(),q=P.transformSync(D);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(H,{headers:{"Content-Type":k}})}if(S.pathname!=="/"&&u["/"]){let H=Le(w);return x(u["/"].content).then((I)=>{if(H){let k=I.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(k){let P=I.match(/<title[^>]*>([\s\S]*?)<\/title>/i),D=P?P[1]:"",q=`<!DOCTYPE html><html><head><title>${Xt(D)}</title></head><body><main>${k[1]}</main></body></html>`;return new Response(q,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...V(),"Cache-Control":Ct,Pragma:"no-cache",Expires:"0"}})}}return new Response(I,{headers:{"Content-Type":"text/html",...V(),"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
1001
|
${w.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1002
1002
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1003
1003
|
${e.bright}\u2192 ${e.cyan}http://localhost:${v}/${e.reset}`),console.log(`
|
|
1004
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:Se.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:Se.relative(process.cwd(),w.filePath),fileType:"stx"})}if(O.sort((w,S)=>w.route.localeCompare(S.route)),O.forEach((w,S)=>{let U=S===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",oe=w.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${U}${w.route}${e.reset} \u2192 ${e.bright}${w.filePath}${e.reset} ${oe}`)}),console.log(`
|
|
1005
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let 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}`),at.clear(),ke(),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 me from"fs";import re from"path";async function Jt(n){try{return Tn(await Bun.file(n).text())}catch{return}}function Ot(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 ns(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-5m02cbxg.js"),y=await b(m),{createServerApi:v,isServerApiSource:C}=await import("./chunk-aq0fz4mr.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(!me.existsSync(A)&&!y._layerPageDirs?.some((T)=>me.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 U=ne(w,{pagesDir:S,pagesDirs:y._layerPageDirs?[A,...y._layerPageDirs.slice(1)]:void 0});if(U.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${U.length}${e.blue} routes${e.reset}`);let oe=y?._pluginPageDirs||[],H=[];for(let{dir:T,prefix:M}of oe)if(me.existsSync(T)){let z=ne(re.dirname(T),{pagesDir:re.basename(T)});for(let Q of z){let X=M==="/"?Q.pattern:`${M}${Q.pattern==="/"?"":Q.pattern}`;H.push({route:{...Q,pattern:X},prefix:M})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${M}${e.reset}`)}let I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Aa(m,t.stxOptions?.shell),P){if(k=await Oo(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}`)}}Mt(),await Lt(m);let D=Dt();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-5m02cbxg.js"),M=await T(m);if(M?.apiRouter)Y=M?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(M?.apiRoutes){K=M.apiRoutes;let z=Object.keys(K).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-5rd0an89.js"),X=M.broadcasting;await z(X);let Re=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Re}/ws${e.reset}`);let ve=re.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let N=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let be=l(m,"output");me.mkdirSync(be,{recursive:!0});let pe=new Map,Ce=new Set,se=async(T)=>{let M=Hs(A,T);if(!M)return null;try{let z=await Bun.build({entrypoints:[M],outdir:be,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,E=async(T,M)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Re,injectRouterScript:ve}=await import("./chunk-5m02cbxg.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:ue}=await import("./chunk-1ta1pj1t.js"),G=await Re(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 _=!M&&!t.profile,ie=de.cache!==!1;if(ie&&_){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let _e=!0;for(let we of le.dependencies){if(!me.existsSync(we)){_e=!1;break}if((await me.promises.stat(we)).mtime.getTime()>le.mtime){_e=!1;break}}if(_e){let we=le.output;if(k)we=nt(we,{preserveHead:!0});let ot=F.get(T.filePath);return{route:T,content:we,status:ot?.status??await Jt(T.filePath),headers:ot?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let Me=De;if(k)Me=nt(Me,{preserveHead:!0});let _e=F.get(T.filePath);return{route:T,content:Me,status:_e?.status??await Jt(T.filePath),headers:_e?.headers}}}let Z=ie?await W(T.filePath):await Bun.file(T.filePath).text(),ce=Tn(Z),{classifyAllScripts:fe}=await import("./chunk-5m02cbxg.js"),B=fe(Z),Ae=B.server.map((le)=>le.content),Ee=Z;for(let le of B.server)Ee=Ee.replace(le.fullTag,"");let ee={__filename:T.filePath,__dirname:re.dirname(T.filePath),__stx_options:de,params:M??{},__stx_runtime_head:{}};for(let le of Ae)try{await Q(le,ee,T.filePath)}catch(De){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,De?.message||De)}let Pe=new Set,he;if(t.profile){let le=performance.now();he=await z(Ee,ee,T.filePath,de,Pe);let De=performance.now()-le,Me=re.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${Me} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Ee,ee,T.filePath,de,Pe);if(!k)he=await ve(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-mv21mc9p.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,Me,_e)=>{if(!/function\s+__stx_setup_/.test(_e))return De;return`<script${Me}>${le(_e,ee)}</script>`})}if(k)he=nt(he,{preserveHead:!0});if(ie&&_)await J(T.filePath,he,Pe,de);let{extractStreamBoundaries:lt}=await import("./chunk-kcqfrw10.js"),Je=lt(ee),tt=ee.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=ee.streamBoundaries||{},De={...de,autoShell:!1},Me=Object.keys(tt).map((we)=>({id:we,render:async()=>{let ot=typeof le[we]==="function"?await le[we]():void 0;return z(tt[we],{...ee,$boundary:ot},T.filePath,De,new Set)}})),_e=new Set(Me.map((we)=>we.id));Je=[...(Je||[]).filter((we)=>!_e.has(we.id)),...Me]}if(Je&&Je.length>0)Ce.add(T.pattern);else Je=void 0;let It=Wt(ee),Ht=qt(ee);if(_)F.set(T.filePath,{status:It,headers:Ht});return{route:T,content:he,status:It??ce,headers:Ht,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},He=8,Be=async()=>{let T=new Set(pe.keys()),M=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((X)=>T.has(X.pattern)):U,Q=t.prebuild===!1?H.filter(({route:X})=>M.has(X.pattern)):H;for(let X=0;X<z.length;X+=He){let Re=z.slice(X,X+He),ve=await Promise.all(Re.map((N)=>E(N)));for(let N of ve)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=He){let Re=Q.slice(X,X+He),ve=await Promise.all(Re.map(({route:N})=>E(N)));for(let N of ve)if(N)I.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?U.length+H.length>0:await Be()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await xn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,M)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(M).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Q,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let M=new URL(T.url),z=t.stxOptions?.offline??y.offline;if(M.pathname===Zo&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(T.method==="HEAD"?null:Qo(z,vs()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=y?.publicDir||"public",X=re.join(m,Q,M.pathname),Re=re.join(m,M.pathname),ve=re.join(be,M.pathname);if([X,Re,ve].some((_)=>C(_,m,R)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Re).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(J?.isFile()&&!C(Re,m,R))return Ot(Re);if(W?.isFile()&&!C(ve,m,R))return Ot(ve);if(M.pathname.startsWith("/_stx/component/")){let _=decodeURIComponent(M.pathname.slice(16));if(_)try{let ie=`<${_} />`,Z={...buildConfig,autoShell:!1},ce=await processDirectives(ie,{},re.join(m,"components",`${_}.stx`),Z,new Set);return new Response(ce,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(M.pathname==="/_stx/img"){let{handleImageRequest:_}=await import("./chunk-53cc06w7.js"),ie=await _(T,{publicDir:re.join(m,Q),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Y)try{let _=await Y.handleRequest(T);if(_.status!==404)return _}catch{}if(K[M.pathname])try{return await K[M.pathname](T)}catch(_){return new Response(JSON.stringify({error:_.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=Cr(M.pathname,U);if(G){let _=pe.get(G.route.pattern),ie=Ce.has(G.route.pattern);if(!_||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let Z=await E(G.route,G.params);if(Z){if(_=Z,!G.route.isDynamic&&!ie)pe.set(G.route.pattern,Z)}}if(_){let Z=_.status??200,ce=_.headers??{},fe=(G.route.filePath?Rt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Ee=await se(404);if(Ee){let ee=Ee;if(ee=await x(ee,m),r)ee=Ue(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Ae=jt(M.pathname,G.params,fe,M.search),Ee=Bt(Ae,null,T,{isServer:!0}),ee=await Ft(fe.middleware,Ee);if(ee.redirect){let Pe=ee.redirect.path,he=ee.redirect.options.redirectCode||302,lt=new Headers(ee.responseHeaders);return lt.set("Location",Pe),new Response(null,{status:he,headers:lt})}if(ee.abort){let{statusCode:Pe,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Pe}</title></head><body><h1>Error ${Pe}</h1><p>${he}</p></body></html>`,{status:Pe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Pe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;_.content=f(_.content,Pe,"")}}let B=_.content;if(k&&Pa(T)&&rt(B,y?.router?.container||"main")){let Ae=dt(B),Ee=Te(B),ee=B.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Pe=ee?an(ee[1].trim()):"";if(Object.keys(G.params).length>0)B=St(B,G.params);B=await x(B,m);let he=y?.router?.container||"main";return B=je(B,he,!0),new Response(B,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ae.layout,"X-STX-Layout-Group":Ae.group,"X-STX-Runtime":Ee?"true":"false",...Pe&&{"X-STX-Title":encodeURIComponent(Pe)},[Tc]:vs(),...V(),"Cache-Control":Ct}})}if(k)B=is(k,B);if(Object.keys(G.params).length>0)B=St(B,G.params);if(B=await x(B,m),r)B=Ue(B,u);if(t.native)if(B.includes("<head>"))B=B.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 B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;if(t.titlebarHidden)if(B.includes("<head>"))B=B.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 B=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${B}`;if(_.boundaries&&_.boundaries.length>0){let{renderStreamingPage:Ae,streamToResponse:Ee}=await import("./chunk-kcqfrw10.js");return Ee(Ae(B,_.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(B,{status:Z,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ce}})}}if(H.length>0){let _=H.map((Z)=>Z.route),ie=Cr(M.pathname,_);if(ie){let Z=I.get(ie.route.pattern);if(!Z||ie.route.isDynamic){let ce=await E(ie.route,ie.params);if(ce){if(Z=ce,!ie.route.isDynamic)I.set(ie.route.pattern,ce)}}if(Z){let ce=Z.content;if(k)ce=is(k,ce);if(Object.keys(ie.params).length>0)ce=St(ce,ie.params);if(ce=await x(ce,m),r)ce=Ue(ce,u);return new Response(ce,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of oe)if(Z!=="/"&&M.pathname.startsWith(Z)){let ce=I.get(Z)||I.get(Z+"/");if(!ce){let fe=H.find(({route:B})=>B.pattern===Z||B.pattern===`${Z}/`);if(fe){let B=await E(fe.route);if(B)ce=B,I.set(fe.route.pattern,B)}}if(ce){let fe=ce.content;if(k)fe=is(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(Nt(M.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let _=We.content;if(_=await x(_,m),r)_=Ue(_,u);if(t.native)if(_.includes("<head>"))_=_.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else _="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+_;return new Response(_,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await se(404);if(de){let _=de;if(_=await x(_,m),r)_=Ue(_,u);return new Response(_,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let M=await se(500);if(M)return new Response(M,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
|
|
1005
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let 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}`),at.clear(),_e(),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 me from"fs";import re from"path";async function Jt(n){try{return Tn(await Bun.file(n).text())}catch{return}}function Ot(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 ns(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-j41gp8p3.js"),y=await b(m),{createServerApi:v,isServerApiSource:C}=await import("./chunk-ngkh0t5b.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(!me.existsSync(A)&&!y._layerPageDirs?.some((T)=>me.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 U=ne(w,{pagesDir:S,pagesDirs:y._layerPageDirs?[A,...y._layerPageDirs.slice(1)]:void 0});if(U.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${U.length}${e.blue} routes${e.reset}`);let oe=y?._pluginPageDirs||[],H=[];for(let{dir:T,prefix:M}of oe)if(me.existsSync(T)){let z=ne(re.dirname(T),{pagesDir:re.basename(T)});for(let Q of z){let X=M==="/"?Q.pattern:`${M}${Q.pattern==="/"?"":Q.pattern}`;H.push({route:{...Q,pattern:X},prefix:M})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${M}${e.reset}`)}let I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Pa(m,t.stxOptions?.shell),P){if(k=await Oo(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}`)}}Mt(),await Lt(m);let D=Dt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let q={},Y=null;try{let{loadStxConfig:T}=await import("./chunk-j41gp8p3.js"),M=await T(m);if(M?.apiRouter)Y=M?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(M?.apiRoutes){q=M.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-6fpzwryt.js"),X=M.broadcasting;await z(X);let Te=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let ve=re.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let N=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let be=l(m,"output");me.mkdirSync(be,{recursive:!0});let pe=new Map,ke=new Set,se=async(T)=>{let M=Hs(A,T);if(!M)return null;try{let z=await Bun.build({entrypoints:[M],outdir:be,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Q=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,E=async(T,M)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:X,loadStxConfig:Te,injectRouterScript:ve}=await import("./chunk-j41gp8p3.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:ue}=await import("./chunk-kz3mejc4.js"),G=await Te(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 _=!M&&!t.profile,ie=de.cache!==!1;if(ie&&_){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Me=!0;for(let we of le.dependencies){if(!me.existsSync(we)){Me=!1;break}if((await me.promises.stat(we)).mtime.getTime()>le.mtime){Me=!1;break}}if(Me){let we=le.output;if(k)we=nt(we,{preserveHead:!0});let ot=F.get(T.filePath);return{route:T,content:we,status:ot?.status??await Jt(T.filePath),headers:ot?.headers}}}}catch{}let Ae=await N(T.filePath,de);if(Ae){let De=Ae;if(k)De=nt(De,{preserveHead:!0});let Me=F.get(T.filePath);return{route:T,content:De,status:Me?.status??await Jt(T.filePath),headers:Me?.headers}}}let Z=ie?await W(T.filePath):await Bun.file(T.filePath).text(),ce=Tn(Z),{classifyAllScripts:fe}=await import("./chunk-j41gp8p3.js"),B=fe(Z),Oe=B.server.map((le)=>le.content),Pe=Z;for(let le of B.server)Pe=Pe.replace(le.fullTag,"");let ee={__filename:T.filePath,__dirname:re.dirname(T.filePath),__stx_options:de,params:M??{},__stx_runtime_head:{}};for(let le of Oe)try{await Q(le,ee,T.filePath)}catch(Ae){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,Ae?.message||Ae)}let Ce=new Set,he;if(t.profile){let le=performance.now();he=await z(Pe,ee,T.filePath,de,Ce);let Ae=performance.now()-le,De=re.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${De} \u2192 ${Ae.toFixed(2)}ms`)}else he=await z(Pe,ee,T.filePath,de,Ce);if(!k)he=await ve(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-dfsykk1r.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ae,De,Me)=>{if(!/function\s+__stx_setup_/.test(Me))return Ae;return`<script${De}>${le(Me,ee)}</script>`})}if(k)he=nt(he,{preserveHead:!0});if(ie&&_)await J(T.filePath,he,Ce,de);let{extractStreamBoundaries:lt}=await import("./chunk-a8c9j9cj.js"),Je=lt(ee),tt=ee.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=ee.streamBoundaries||{},Ae={...de,autoShell:!1},De=Object.keys(tt).map((we)=>({id:we,render:async()=>{let ot=typeof le[we]==="function"?await le[we]():void 0;return z(tt[we],{...ee,$boundary:ot},T.filePath,Ae,new Set)}})),Me=new Set(De.map((we)=>we.id));Je=[...(Je||[]).filter((we)=>!Me.has(we.id)),...De]}if(Je&&Je.length>0)ke.add(T.pattern);else Je=void 0;let It=Wt(ee),Ht=qt(ee);if(_)F.set(T.filePath,{status:It,headers:Ht});return{route:T,content:he,status:It??ce,headers:Ht,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},He=8,Be=async()=>{let T=new Set(pe.keys()),M=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((X)=>T.has(X.pattern)):U,Q=t.prebuild===!1?H.filter(({route:X})=>M.has(X.pattern)):H;for(let X=0;X<z.length;X+=He){let Te=z.slice(X,X+He),ve=await Promise.all(Te.map((N)=>E(N)));for(let N of ve)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Q.length;X+=He){let Te=Q.slice(X,X+He),ve=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of ve)if(N)I.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?U.length+H.length>0:await Be()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await xn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,M)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(M).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Q,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let M=new URL(T.url),z=t.stxOptions?.offline??y.offline;if(M.pathname===Zo&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(T.method==="HEAD"?null:Qo(z,vs()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=y?.publicDir||"public",X=re.join(m,Q,M.pathname),Te=re.join(m,M.pathname),ve=re.join(be,M.pathname);if([X,Te,ve].some((_)=>C(_,m,R)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(J?.isFile()&&!C(Te,m,R))return Ot(Te);if(W?.isFile()&&!C(ve,m,R))return Ot(ve);if(M.pathname.startsWith("/_stx/component/")){let _=decodeURIComponent(M.pathname.slice(16));if(_)try{let ie=`<${_} />`,Z={...buildConfig,autoShell:!1},ce=await processDirectives(ie,{},re.join(m,"components",`${_}.stx`),Z,new Set);return new Response(ce,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(M.pathname==="/_stx/img"){let{handleImageRequest:_}=await import("./chunk-q252qvsy.js"),ie=await _(T,{publicDir:re.join(m,Q),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Y)try{let _=await Y.handleRequest(T);if(_.status!==404)return _}catch{}if(q[M.pathname])try{return await q[M.pathname](T)}catch(_){return new Response(JSON.stringify({error:_.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=Cr(M.pathname,U);if(G){let _=pe.get(G.route.pattern),ie=ke.has(G.route.pattern);if(!_||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let Z=await E(G.route,G.params);if(Z){if(_=Z,!G.route.isDynamic&&!ie)pe.set(G.route.pattern,Z)}}if(_){let Z=_.status??200,ce=_.headers??{},fe=(G.route.filePath?Rt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await se(404);if(Pe){let ee=Pe;if(ee=await x(ee,m),r)ee=Ue(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=jt(M.pathname,G.params,fe,M.search),Pe=Bt(Oe,null,T,{isServer:!0}),ee=await Ft(fe.middleware,Pe);if(ee.redirect){let Ce=ee.redirect.path,he=ee.redirect.options.redirectCode||302,lt=new Headers(ee.responseHeaders);return lt.set("Location",Ce),new Response(null,{status:he,headers:lt})}if(ee.abort){let{statusCode:Ce,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Ce}</title></head><body><h1>Error ${Ce}</h1><p>${he}</p></body></html>`,{status:Ce,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Ce=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;_.content=f(_.content,Ce,"")}}let B=_.content;if(k&&Ia(T)&&rt(B,y?.router?.container||"main")){let Oe=dt(B),Pe=$e(B),ee=B.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Ce=ee?an(ee[1].trim()):"";if(Object.keys(G.params).length>0)B=St(B,G.params);B=await x(B,m);let he=y?.router?.container||"main";return B=je(B,he,!0),new Response(B,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Pe?"true":"false",...Ce&&{"X-STX-Title":encodeURIComponent(Ce)},[$c]:vs(),...V(),"Cache-Control":Ct}})}if(k)B=is(k,B);if(Object.keys(G.params).length>0)B=St(B,G.params);if(B=await x(B,m),r)B=Ue(B,u);if(t.native)if(B.includes("<head>"))B=B.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 B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;if(t.titlebarHidden)if(B.includes("<head>"))B=B.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 B=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${B}`;if(_.boundaries&&_.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Pe}=await import("./chunk-a8c9j9cj.js");return Pe(Oe(B,_.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(B,{status:Z,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ce}})}}if(H.length>0){let _=H.map((Z)=>Z.route),ie=Cr(M.pathname,_);if(ie){let Z=I.get(ie.route.pattern);if(!Z||ie.route.isDynamic){let ce=await E(ie.route,ie.params);if(ce){if(Z=ce,!ie.route.isDynamic)I.set(ie.route.pattern,ce)}}if(Z){let ce=Z.content;if(k)ce=is(k,ce);if(Object.keys(ie.params).length>0)ce=St(ce,ie.params);if(ce=await x(ce,m),r)ce=Ue(ce,u);return new Response(ce,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of oe)if(Z!=="/"&&M.pathname.startsWith(Z)){let ce=I.get(Z)||I.get(Z+"/");if(!ce){let fe=H.find(({route:B})=>B.pattern===Z||B.pattern===`${Z}/`);if(fe){let B=await E(fe.route);if(B)ce=B,I.set(fe.route.pattern,B)}}if(ce){let fe=ce.content;if(k)fe=is(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(Nt(M.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let _=We.content;if(_=await x(_,m),r)_=Ue(_,u);if(t.native)if(_.includes("<head>"))_=_.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else _="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+_;return new Response(_,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await se(404);if(de){let _=de;if(_=await x(_,m),r)_=Ue(_,u);return new Response(_,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let M=await se(500);if(M)return new Response(M,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
|
|
1006
1006
|
${T.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1007
1007
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1008
1008
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Xe}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1009
1009
|
${e.yellow}Routes:${e.reset}`);let Tt=[...Vs(U,m)];for(let{route:T}of H)Tt.push(`${T.pattern}`);if(Tt.forEach((T,M)=>{let Q=M===Tt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${T}`)}),console.log(`
|
|
1010
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)st();kt.stop()}),t.native){let T,M=re.join(A,"index.stx");if(me.existsSync(M)){let Q=await Bun.file(M).text();T=gt(Q)}let z=y?.app?.window??{};await Ye(Xe,{title:y?.app?.head?.title||re.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),M=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([m,...y._layerGraph?.layers.map((J)=>J.root)??[],...y._layerGraph?.configDependencies.map((J)=>re.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of y._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let ue=me.realpathSync(W);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${re.sep}`)))N.add(ue)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,ue)=>{
|
|
1010
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)st();kt.stop()}),t.native){let T,M=re.join(A,"index.stx");if(me.existsSync(M)){let Q=await Bun.file(M).text();T=gt(Q)}let z=y?.app?.window??{};await Ye(Xe,{title:y?.app?.head?.title||re.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),M=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([m,...y._layerGraph?.layers.map((J)=>J.root)??[],...y._layerGraph?.configDependencies.map((J)=>re.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of y._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let ue=me.realpathSync(W);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${re.sep}`)))N.add(ue)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,ue)=>{Te(J,W,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,J,W)=>(X=X.catch(()=>{}).then(()=>ve(N,J,W)),X),ve=async(N,J,W)=>{if(!W||xt(W))return;if(yt(W)){if(y._layerGraph){let ue=await b(m);Object.assign(y,ue),U.splice(0,U.length,...ne(w,{pagesDir:S,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Q()}if(T(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),r&&p)p.reload(W)}else if(M(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),at.clear(),_e();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-kz3mejc4.js");ue(re.resolve(N,W)),G.delete(re.resolve(N,W))}catch{}if(P&&W){if(re.resolve(N,W)===P||re.basename(P)===W){let G=await Oo(P,t.stxOptions||{});if(G)k=G}}if(await Be(),await yr(m),r&&p)p.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),at.clear(),_e();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-kz3mejc4.js");ue(re.resolve(N,W)),G.delete(re.resolve(N,W))}catch{}if(await Be(),r&&p)p.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),r&&p)p.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)st();kt.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Jn(n){try{let o=(await Bun.file(n).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],r=[],p=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=p.exec(d))!==null){let m=u[1],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
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
1012
|
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Qn(n,t=!1,o){let d=it.basename(n,".stx"),r=await Jn(n),p=await Yn(n),u="";if(t&&o)u=`<${o}></${o}>`;else{let m=r.map((b)=>{if(b.type==="boolean")return`:${b.name}="true"`;return`${b.name}="value"`}).join(`
|
|
1013
1013
|
`);u=`<${d}
|
|
@@ -1146,12 +1146,12 @@ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.
|
|
|
1146
1146
|
<td>@${p.name}</td>
|
|
1147
1147
|
<td>${p.description||"-"}</td>
|
|
1148
1148
|
<td>${p.hasEndTag?"Yes":"No"}</td>
|
|
1149
|
-
</tr>`;r+="</tbody></table>";for(let p of o)if(p.example)r+=`<h3>@${p.name}</h3>`,r+=`<p>${p.description||""}</p>`,r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return r+="</body></html>",r}function or(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function sr(n){try{let{componentsDir:t,templatesDir:o,webComponentsConfig:d,customDirectives:r,config:p}=n;if(!p.enabled)return!1;let u=p.outputDir||"docs";if(await At.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),t)console.log(`Components directory: ${t}`);if(o)console.log(`Templates directory: ${o}`);console.log(`Output directory: ${u}`);let m=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),m=await Zn(t,d),console.log(`Found ${m.length} components`);let 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=it.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
|
|
1149
|
+
</tr>`;r+="</tbody></table>";for(let p of o)if(p.example)r+=`<h3>@${p.name}</h3>`,r+=`<p>${p.description||""}</p>`,r+="<h4>Example</h4>",r+=`<pre><code>${p.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return r+="</body></html>",r}function or(n=[],t=[],o=[],d){return JSON.stringify({components:n,templates:t,directives:o,extraContent:d||""},null,2)}async function sr(n){try{let{componentsDir:t,templatesDir:o,webComponentsConfig:d,customDirectives:r,config:p}=n;if(!p.enabled)return!1;let u=p.outputDir||"docs";if(await At.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),t)console.log(`Components directory: ${t}`);if(o)console.log(`Templates directory: ${o}`);console.log(`Output directory: ${u}`);let m=[];if(p.components!==!1&&t)console.log("Generating component documentation..."),m=await Zn(t,d),console.log(`Found ${m.length} components`);let 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=it.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 xa(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||L.componentsDir,d=n.templatesDir||".";return sr({componentsDir:o,templatesDir:d,webComponentsConfig:L.webComponents,customDirectives:L.customDirectives,config:t})}var Zt={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function _o(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1150
1150
|
`;let d=n;if(o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=cr(d,o),d=ur(d,o),d=lr(d,o),o.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,""),d=d.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(d=d.replace(/\r\n/g,`
|
|
1151
1151
|
`).replace(/\r/g,`
|
|
1152
1152
|
`),!d.endsWith(`
|
|
1153
1153
|
`))d+=`
|
|
1154
|
-
`;return d}function
|
|
1154
|
+
`;return d}function Sa(n,t={}){let o={...Zt,...t};if(n.trim()==="")return`
|
|
1155
1155
|
`;let d=n;if(d=d.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(r,p,u,m,b)=>{let y=m.split(`
|
|
1156
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
1157
|
`),w=_o(R,o).trimEnd().split(`
|
|
@@ -1179,7 +1179,7 @@ ${u}`}),t=t.replace(/(<\/[^>]+>)(?=<|$)/g,(r,p,u,m)=>{let b=m.substring(Math.max
|
|
|
1179
1179
|
`),t=t.replace(/^\n+/,"").replace(/\n+$/,""),t}function cr(n,t){let d=ar(n).split(`
|
|
1180
1180
|
`),r=[],p=0,u=!1,m=t.useTabs?"\t":" ".repeat(t.indentSize);for(let 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("@")&&pr(v),U=v.startsWith("<!DOCTYPE")||v.startsWith("<!doctype"),oe=v.startsWith("<!--"),H=v.startsWith("</"),I=v.startsWith("<")&&!H&&!oe&&!U,k=v.includes("/>")||dr(v),P=Qt(v);if(H||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(I&&!k&&!P&&!O||A)p++;if(C)u=!0;if(R)u=!1}return r.join(`
|
|
1181
1181
|
`)}function lr(n,t){if(n=n.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(o,d,r)=>{let p=r.trim().replace(/\s+/g," ");return`@${d}(${p})`}),n=n.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(o,d,r)=>{if(r.trim()==="")return`@${d}`;return`@${d}(${r.trim()})`}),t.normalizeWhitespace)n=n.replace(/\{\{\s*([^}]+)\s*\}\}/g,(o,d)=>`{{ ${d.trim()} }}`),n=n.replace(/\{!!\s*([^!]+)\s*!!\}/g,(o,d)=>`{!! ${d.trim()} !!}`);return n}function dr(n){let t=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if(n.includes("/>"))return!0;let o=n.match(/<(\w+)/);if(o){let d=o[1];return t.includes(d.toLowerCase())}return!1}function Qt(n){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test(n)}function pr(n){let t=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let o of t)if(n.startsWith(`@${o}`))return!n.includes(`@end${o}`);return!1}function ur(n,t){if(!t.sortAttributes)return n;return n.replace(/<(\w+)([^>]*)>/g,(o,d,r)=>{if(!r.trim())return o;if(r.includes("<")||r.includes(`
|
|
1182
|
-
`)||r.includes("@"))return o;let p=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],m;while((m=p.exec(r))!==null)u.push({name:m[1],value:m[2]});u.sort((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 en from"fs";import _t from"path";async function
|
|
1182
|
+
`)||r.includes("@"))return o;let p=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],m;while((m=p.exec(r))!==null)u.push({name:m[1],value:m[2]});u.sort((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 en from"fs";import _t from"path";async function ka(n="index.stx",t={}){try{let o=t.force||!1,d=_t.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=_t.dirname(d);if(!en.existsSync(r))en.mkdirSync(r,{recursive:!0});let p;if(t.template){let u=_t.resolve(process.cwd(),t.template);if(!await Bun.file(u).exists())throw Error(`Template file ${t.template} does not exist.`);if(!u.endsWith(".stx"))console.warn(`Warning: Template file ${t.template} does not have a .stx extension. Using it anyway.`);p=await Bun.file(u).text(),console.warn(`Using template from ${t.template}`)}else if(t.preset)p=tn(t.preset),console.warn(`Using '${t.preset}' preset template`);else p=tn("basic");return await Bun.write(d,p),console.warn(`Created new stx file: ${n}`),!0}catch(o){return console.error(`Error creating file: ${o instanceof Error?o.message:String(o)}`),!1}}function tn(n){switch(n){case"basic":return nn();case"component":return fr();case"layout":return mr();case"blog":return gr();case"api":return hr();case"app":return xr();default:return nn()}}function nn(){return`<script>
|
|
1183
1183
|
const title = "My stx Page"
|
|
1184
1184
|
const description = "A page built with stx"
|
|
1185
1185
|
const features = [
|
|
@@ -1605,5 +1605,5 @@ const features = [
|
|
|
1605
1605
|
})();
|
|
1606
1606
|
</script>
|
|
1607
1607
|
</body>
|
|
1608
|
-
</html>`}var
|
|
1609
|
-
`)}export{
|
|
1608
|
+
</html>`}var _a="f9c3713";function eu(n){return n}function tu(n){return n}function wa(n,t){let o=[],d=`${t}=`;for(let r=0;r<n.length;r++){let p=n[r];if(p.startsWith(d)){let u=p.slice(d.length);if(u)o.push(u);continue}if(p===t){let u=n[r+1];if(u!==void 0&&!u.startsWith("-"))o.push(u),r++}}return o}import Ee from"fs";import xe from"path";function un(n){try{return Ee.statSync(n).mtimeMs}catch{return null}}function wt(n,t){let o=Math.max(0,Math.round((t-n)/1000));if(o<60)return`${o}s ago`;if(o<3600)return`${Math.round(o/60)}m ago`;return`${Math.round(o/3600)}h ago`}function Ls(n,t){try{return globalThis.Bun?.resolveSync(n,t)??null}catch{return null}}function fn(n,t="stx"){let o=xe.resolve(n);for(let d=0;d<10;d++){let r=xe.join(o,"pantry","@stacksjs",t);if(Ee.existsSync(r))return r;let p=xe.dirname(o);if(p===o)break;o=p}return null}var mn=["@stacksjs/stx","bun-plugin-stx"];function Is(n){try{let t=Ee.readFileSync(xe.join(n,"package.json"),"utf8"),o=JSON.parse(t)?.version;return typeof o==="string"?o:null}catch{return null}}function js(n,t=6){let o=xe.resolve(n),d=[],r=new Set;function p(m,b){if(b>t)return;let y;try{y=Ee.realpathSync(m)}catch{return}if(r.has(y))return;r.add(y);for(let C of mn){let R=xe.join(m,C),O=Is(R);if(O!==null)d.push({name:C,version:O,dir:xe.relative(o,R)||R,nested:b>0})}let v;try{v=Ee.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=xe.join(m,C.name);if(C.name.startsWith("@")){let w;try{w=Ee.readdirSync(R,{withFileTypes:!0})}catch{continue}for(let S of w){let A=xe.join(R,S.name,"node_modules");if(Ee.existsSync(A))p(A,b+1)}continue}let O=xe.join(R,"node_modules");if(Ee.existsSync(O))p(O,b+1)}}let u=xe.join(o,"node_modules");if(Ee.existsSync(u))p(u,0);return d}function Bs(n){let t=[];for(let o of mn){let d=n.filter((u)=>u.name===o);if(d.length<=1)continue;let r=[...new Set(d.map((u)=>u.version))],p=d.map((u)=>`${u.version} at ${u.dir}`).join("; ");if(r.length===1){t.push({name:`${o} copies`,status:"info",detail:`${d.length} copies, all ${r[0]} \u2014 duplicated but in agreement`});continue}t.push({name:`${o} copies disagree`,status:"error",detail:`${r.length} versions installed, so which one runs depends on who imports it: ${p}`,fix:`remove the nested copies, or add an overrides entry pinning ${o}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${o}/package.json' -exec grep -H '"version"' {} +`})}return t}async function Co(n={}){let t=n.cwd?xe.resolve(n.cwd):process.cwd(),o=n.resolve??Ls,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 Bs(js(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=xe.join(m,"src/signals.ts"),y=[xe.join(m,"dist/index.js"),xe.join(m,"dist/signals.js")].find((w)=>Ee.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 (${wt(C,d)}) is OLDER than src/signals.ts (${wt(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 ${wt(v,d)}, dist ${wt(C,d)})`});let R=xe.join(t,"node_modules/@stacksjs/stx"),O=null;try{O=Ee.lstatSync(R)}catch{O=null}if(!O)r.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(O.isSymbolicLink()){let w=null;try{w=Ee.realpathSync(R)}catch{}let S=(()=>{try{return Ee.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 Eo(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{wa,va,xa,_o,Sa,ka,_a,eu,tu,Co,Eo,es,ts,ns};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function
|
|
2
|
+
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function Gm(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,i=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,a,d)=>{let l=p(),y=u(s);return m(l,y,a.trim(),d.trim())}),n=n.replace(i,(r,s,a)=>{let d=p(),l=u(s);return m(d,l,a.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let i=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(i){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:i,timeout:n,delay:r,suspensible:s,retries:a}=t;return`
|
|
3
3
|
<div class="stx-async-component" data-async-id="${e}" data-component="${i}" data-status="pending">
|
|
4
4
|
<div class="stx-async-loading" data-async-loading="${e}">
|
|
5
5
|
${c}
|
|
@@ -226,7 +226,7 @@ catch (error) {
|
|
|
226
226
|
loadComponent();
|
|
227
227
|
})();
|
|
228
228
|
</script>
|
|
229
|
-
`}function
|
|
229
|
+
`}function Xm(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function Jm(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function Ym(){return`
|
|
230
230
|
/* STX Async Component Styles */
|
|
231
231
|
.stx-async-component {
|
|
232
232
|
position: relative;
|
|
@@ -300,7 +300,7 @@ catch (error) {
|
|
|
300
300
|
background-size: 200% 100%;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
`}function
|
|
303
|
+
`}function Zm(){return`
|
|
304
304
|
// STX Async Component Runtime
|
|
305
305
|
(function() {
|
|
306
306
|
if (typeof window === 'undefined') return;
|
|
@@ -355,4 +355,4 @@ catch (error) {
|
|
|
355
355
|
console.log('[stx] Async component runtime initialized');
|
|
356
356
|
})();
|
|
357
357
|
`}
|
|
358
|
-
export{
|
|
358
|
+
export{Gm,Xm,Jm,Ym,Zm};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import i from"path";var kn=".stx",o="STX_DIR",e=null;function
|
|
3
|
-
export{kn,
|
|
2
|
+
import i from"path";var kn=".stx",o="STX_DIR",e=null;function Qc(t){e=t?.trim()||null}function $r(){return process.env[o]?.trim()||e||kn}function l(t=process.cwd(),...n){let r=$r();return i.isAbsolute(r)?i.join(r,...n):i.join(t,r,...n)}function Rr(t){if(!t||i.isAbsolute(t))return t;let n=t.replace(/\\/g,"/");if(n!==kn&&!n.startsWith(`${kn}/`))return t;let r=n.slice(kn.length+1);return r?i.join($r(),r):$r()}
|
|
3
|
+
export{kn,Qc,$r,l,Rr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function
|
|
3
|
-
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function
|
|
4
|
-
`)}function
|
|
5
|
-
export{
|
|
2
|
+
import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function qc(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
|
|
3
|
+
`)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function Kc(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await hi(m,e),{config:f,graph:m}}async function hi(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function Ds(e){return O(A(e))}function Ls(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
|
|
4
|
+
`)}function Gc(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
|
|
5
|
+
export{qc,Kc,hi,Ds,Ls,Gc};
|