@stacksjs/stx 0.2.795 → 0.2.798
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-y64f5t74.js → chunk-0beyn8ak.js} +5 -5
- package/dist/{chunk-jmbh26gv.js → chunk-0gsq8gps.js} +1 -1
- package/dist/chunk-0xnvjw7s.js +2 -0
- package/dist/chunk-1wyccmsr.js +2 -0
- package/dist/{chunk-4s0ye933.js → chunk-20yz8bjp.js} +2 -2
- package/dist/{chunk-bzhzp4f4.js → chunk-2ws2qe1k.js} +2 -2
- package/dist/{chunk-2bvaakcv.js → chunk-2z2bq2at.js} +3 -3
- package/dist/chunk-31qjy9xr.js +2 -0
- package/dist/chunk-33devn0s.js +2 -0
- package/dist/{chunk-baj6w8ja.js → chunk-33vr7x2t.js} +3 -3
- package/dist/chunk-33wpv2n1.js +2 -0
- package/dist/{chunk-aksrh8je.js → chunk-3mby4nes.js} +3 -3
- package/dist/chunk-3p5gxc6t.js +2 -0
- package/dist/{chunk-88acqv2r.js → chunk-3x598qjt.js} +4 -4
- package/dist/chunk-4hgz9dkv.js +2 -0
- package/dist/{chunk-7k6hd10j.js → chunk-4sesw88b.js} +5 -5
- package/dist/{chunk-624xpap6.js → chunk-4v50nafp.js} +13 -13
- package/dist/chunk-5kc9kjaa.js +2 -0
- package/dist/{chunk-2e5tvryz.js → chunk-5wwcgze3.js} +2 -2
- package/dist/chunk-5xd53dwe.js +2 -0
- package/dist/chunk-5y6518h8.js +2 -0
- package/dist/chunk-5y77pe7b.js +2 -0
- package/dist/chunk-6a97a9wk.js +2 -0
- package/dist/{chunk-xqjat573.js → chunk-6b5zhtb3.js} +2 -2
- package/dist/chunk-6hre8cg4.js +2 -0
- package/dist/{chunk-vpzdqbw7.js → chunk-6m4y5dh5.js} +6 -6
- package/dist/chunk-6pyweb05.js +2 -0
- package/dist/chunk-6tp7ys77.js +2 -0
- package/dist/chunk-6zxzr20d.js +2 -0
- package/dist/chunk-75ctpxr3.js +2 -0
- package/dist/{chunk-tmfrq4nq.js → chunk-7bxnjr3b.js} +7 -7
- package/dist/chunk-7gw96jpj.js +2 -0
- package/dist/chunk-7m4eesp0.js +2 -0
- package/dist/chunk-7na8bets.js +2 -0
- package/dist/{chunk-6s9bk98p.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-dstzvtvk.js → chunk-810r5dk3.js} +3 -3
- package/dist/{chunk-njk5db1q.js → chunk-89jn2jmf.js} +4 -4
- package/dist/{chunk-nyer6v3y.js → chunk-8bzq2z0m.js} +5 -5
- package/dist/chunk-8k2n6abg.js +2 -0
- package/dist/chunk-8vqs94f3.js +2 -0
- package/dist/{chunk-3em44jbm.js → chunk-91htcq62.js} +2 -2
- package/dist/chunk-9736003n.js +2 -0
- package/dist/{chunk-p3ej3954.js → chunk-9b6896tb.js} +2 -2
- package/dist/{chunk-pnddmgjf.js → chunk-9k6tza24.js} +7 -7
- package/dist/chunk-9w33k6f7.js +2 -0
- package/dist/{chunk-g4n0bjfb.js → chunk-9x62j5f0.js} +10 -10
- package/dist/{chunk-1q16p7t2.js → chunk-a1ba9d2r.js} +5 -5
- package/dist/{chunk-8t8e75xm.js → chunk-a20wq8wf.js} +4 -4
- package/dist/{chunk-7y73txmp.js → chunk-a3xqfyb6.js} +2 -2
- package/dist/chunk-ag8j9ec2.js +2 -0
- package/dist/chunk-ak15dt1a.js +2 -0
- package/dist/{chunk-qnxctfdf.js → chunk-akcyaxwv.js} +2 -2
- package/dist/{chunk-f4j7nsj1.js → chunk-aw6369cx.js} +1 -1
- package/dist/{chunk-ennzzth4.js → chunk-b5ck6epd.js} +17 -17
- package/dist/chunk-b98743ja.js +2 -0
- package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
- package/dist/chunk-bskxswmn.js +2 -0
- package/dist/chunk-bv5h4etd.js +2 -0
- package/dist/chunk-c7x3bmvs.js +2 -0
- package/dist/{chunk-12jjf2me.js → chunk-c84pxd2k.js} +2 -2
- package/dist/chunk-camm2hcx.js +2 -0
- package/dist/chunk-cd2wda5c.js +2 -0
- package/dist/chunk-cv6pqg85.js +2 -0
- package/dist/chunk-cy0mab8y.js +2 -0
- package/dist/chunk-d554f2fj.js +2 -0
- package/dist/chunk-dd1vqndp.js +2 -0
- package/dist/{chunk-cfbpvm5e.js → chunk-ddhkhhc7.js} +2 -2
- package/dist/{chunk-thpwk6ya.js → chunk-dsnggn3g.js} +2 -2
- package/dist/chunk-e14v1q9c.js +2 -0
- package/dist/{chunk-hp10khyy.js → chunk-e37g6ezw.js} +20 -20
- package/dist/chunk-e3xw2bzh.js +2 -0
- package/dist/{chunk-pm8a4kdf.js → chunk-eegb7f3t.js} +5 -5
- package/dist/chunk-eeztqt6f.js +2 -0
- package/dist/{chunk-7s1kerhs.js → chunk-ef3w5thv.js} +2 -2
- package/dist/chunk-eh528njb.js +2 -0
- package/dist/{chunk-wzwfbehm.js → chunk-en0wry1c.js} +11 -11
- package/dist/chunk-eszpqrxy.js +2 -0
- package/dist/{chunk-dxe94pwy.js → chunk-fp0ew9n4.js} +4 -4
- package/dist/chunk-fyxkzs9c.js +2 -0
- package/dist/{chunk-hwcfgs3e.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-8zf87cc5.js → chunk-gvnfb6s2.js} +2 -2
- package/dist/{chunk-fcqxa38q.js → chunk-gzfvj15b.js} +1 -1
- package/dist/chunk-hb4jkdfr.js +2 -0
- package/dist/{chunk-r3a15pax.js → chunk-hg9mwgnr.js} +1 -1
- package/dist/{chunk-reb7rddz.js → chunk-hmt0vqhb.js} +1 -1
- package/dist/{chunk-r1vkk7qp.js → chunk-hp9e8nz6.js} +2 -2
- package/dist/chunk-hzps1xya.js +2 -0
- package/dist/{chunk-4p5g7v9g.js → chunk-j3st59hv.js} +2 -2
- package/dist/{chunk-zva4a7xq.js → chunk-jde0shn4.js} +2 -2
- package/dist/{chunk-2xprqx2v.js → chunk-jeprxn45.js} +6 -6
- package/dist/{chunk-d50vw81s.js → chunk-jt0yn7ab.js} +4 -4
- package/dist/chunk-k8gpvg0w.js +2 -0
- package/dist/chunk-kgn911k7.js +2 -0
- package/dist/{chunk-1hq3y7ss.js → chunk-kj8dvzpc.js} +2 -2
- package/dist/chunk-km8c0j9g.js +2 -0
- package/dist/{chunk-ayd635jf.js → chunk-mj3hzy1e.js} +5 -5
- package/dist/{chunk-9jcqbgq9.js → chunk-nw0v655w.js} +6 -6
- package/dist/{chunk-ata5wp2m.js → chunk-p1mghe1h.js} +6 -6
- package/dist/{chunk-rdymnn2t.js → chunk-p2a6dwj6.js} +6 -6
- package/dist/chunk-pw89m3re.js +2 -0
- package/dist/chunk-q38vjqv2.js +2 -0
- package/dist/{chunk-9b9tvhmh.js → chunk-q3ma4khe.js} +5 -5
- package/dist/{chunk-3f8w1x6w.js → chunk-q7q9e0gj.js} +7 -7
- package/dist/{chunk-7y29q1ng.js → chunk-qef2vv0m.js} +2 -2
- package/dist/{chunk-6wpwpk3c.js → chunk-qjbpa1n4.js} +4 -4
- package/dist/{chunk-y2jqx5k4.js → chunk-qm2wmqre.js} +1 -1
- package/dist/{chunk-53v4cby3.js → chunk-qpvwxppw.js} +4 -4
- package/dist/{chunk-427mhgje.js → chunk-qxt6hdat.js} +1 -1
- package/dist/{chunk-w6e30qkz.js → chunk-r6d6jphq.js} +20 -20
- package/dist/{chunk-538d185r.js → chunk-rbv6fxtx.js} +2 -2
- package/dist/chunk-rrketemm.js +2 -0
- package/dist/chunk-rwys552r.js +3 -0
- package/dist/chunk-s0bx4gjh.js +2 -0
- package/dist/{chunk-90zswh9v.js → chunk-s14jcqdf.js} +4 -4
- package/dist/{chunk-bwf8b4e4.js → chunk-s3fmmm98.js} +3 -3
- package/dist/chunk-s8s7b7rv.js +2 -0
- package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
- package/dist/{chunk-w76cve9j.js → chunk-sprgkk9j.js} +31 -31
- package/dist/chunk-sywqa4da.js +2 -0
- package/dist/{chunk-b58n1kfe.js → chunk-t65tn8ee.js} +2 -2
- package/dist/{chunk-ka8sk5qa.js → chunk-trjhz9d9.js} +1 -1
- package/dist/chunk-txrbz95y.js +2 -0
- package/dist/{chunk-yjnaqahd.js → chunk-v9hm1xv6.js} +5 -5
- package/dist/{chunk-c5vzr1va.js → chunk-w0zayhmg.js} +2 -2
- package/dist/{chunk-h656zg6k.js → chunk-w58bnt44.js} +3 -3
- package/dist/chunk-w7681v48.js +2 -0
- package/dist/chunk-w7wz670a.js +2 -0
- package/dist/{chunk-zmr0pvcd.js → chunk-wp6bdac7.js} +59 -59
- package/dist/{chunk-cepctq7e.js → chunk-x8ckxemg.js} +23 -23
- package/dist/{chunk-mcj5qtpp.js → chunk-xa36escd.js} +3 -3
- package/dist/{chunk-wa7fzgw7.js → chunk-xskswvef.js} +4 -4
- package/dist/chunk-xzgtdcbg.js +2 -0
- package/dist/{chunk-7xs45trj.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-yfdb3x3p.js +2 -0
- package/dist/{chunk-azqf0ps0.js → chunk-yv4dwdhc.js} +2 -2
- package/dist/{chunk-m081078c.js → chunk-z1aq59qj.js} +3 -3
- package/dist/{chunk-axjfaere.js → chunk-z1fb5k3h.js} +127 -40
- package/dist/{chunk-tqvw1673.js → chunk-z8wfvqbk.js} +5 -5
- package/dist/chunk-z9a80qqg.js +2 -0
- package/dist/chunk-za5kx15m.js +2 -0
- package/dist/{chunk-hnbx1t3t.js → chunk-zbv8e4rq.js} +2 -2
- package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
- package/dist/{chunk-zv3zpmv1.js → chunk-zqsacq3r.js} +1 -1
- package/dist/{chunk-ectx5ar9.js → chunk-zsy145ac.js} +3 -3
- package/dist/{chunk-x8ghjw9b.js → chunk-zx8tnhfr.js} +3 -3
- package/dist/cli.js +18 -18
- package/dist/client/signals-authoring-runtime.js +4 -1
- package/dist/client/signals-handler-runtime.js +25 -4
- package/dist/client/signals-helpers-runtime.js +12 -0
- package/dist/client/signals-native-row-runtime.js +58 -23
- package/dist/client/signals-pipe-runtime.js +16 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/inline-style.js +91 -39
- package/dist/native/runtime/native-host.js +138 -17
- package/dist/native-build.js +2 -23
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +5 -5
- package/package.json +6 -6
- package/dist/chunk-027hdpgv.js +0 -2
- package/dist/chunk-054h7ktz.js +0 -2
- package/dist/chunk-09nyt9c5.js +0 -2
- package/dist/chunk-0d3ncyqh.js +0 -2
- package/dist/chunk-1yew6rw9.js +0 -2
- package/dist/chunk-211kxm18.js +0 -2
- package/dist/chunk-26y92p8r.js +0 -2
- package/dist/chunk-3ep9h16p.js +0 -2
- package/dist/chunk-49tn6yst.js +0 -2
- package/dist/chunk-4b7dwwn6.js +0 -2
- package/dist/chunk-4ncbq4bx.js +0 -2
- package/dist/chunk-4srnxp3b.js +0 -2
- package/dist/chunk-6z4bza9z.js +0 -2
- package/dist/chunk-75y9heas.js +0 -2
- package/dist/chunk-7ckdvsmj.js +0 -3
- package/dist/chunk-8w1wxr96.js +0 -2
- package/dist/chunk-98kjk52z.js +0 -2
- package/dist/chunk-9sea317f.js +0 -2
- package/dist/chunk-9tpv4cg7.js +0 -2
- package/dist/chunk-9wmjmas8.js +0 -2
- package/dist/chunk-ak10vygz.js +0 -2
- package/dist/chunk-axq3c7cb.js +0 -2
- package/dist/chunk-c5trhqpg.js +0 -2
- package/dist/chunk-c692kj5v.js +0 -2
- package/dist/chunk-cfr7cd88.js +0 -2
- package/dist/chunk-dsh5q9bg.js +0 -2
- package/dist/chunk-emnphnz7.js +0 -2
- package/dist/chunk-epcdgn78.js +0 -2
- package/dist/chunk-etegf4zj.js +0 -2
- package/dist/chunk-ewzdsksb.js +0 -2
- package/dist/chunk-ey8bgg6x.js +0 -2
- package/dist/chunk-f03sg8b0.js +0 -2
- package/dist/chunk-gf04pgaa.js +0 -2
- package/dist/chunk-ghn8vhet.js +0 -2
- package/dist/chunk-gywp6kd8.js +0 -2
- package/dist/chunk-k6sjqb7g.js +0 -2
- package/dist/chunk-me71d5w5.js +0 -2
- package/dist/chunk-nvytej81.js +0 -2
- package/dist/chunk-p1txw41y.js +0 -2
- package/dist/chunk-p8gekf4b.js +0 -2
- package/dist/chunk-px0qsd38.js +0 -2
- package/dist/chunk-qr23snrp.js +0 -2
- package/dist/chunk-s151a2dj.js +0 -2
- package/dist/chunk-sqettc34.js +0 -2
- package/dist/chunk-srgbv05n.js +0 -2
- package/dist/chunk-t0d4rsfx.js +0 -2
- package/dist/chunk-t0k0yk24.js +0 -2
- package/dist/chunk-tdcgskyy.js +0 -2
- package/dist/chunk-te3hr6d7.js +0 -2
- package/dist/chunk-tes8fdv6.js +0 -2
- package/dist/chunk-v6j5vkce.js +0 -2
- package/dist/chunk-vmp876q6.js +0 -2
- package/dist/chunk-vwp5fchy.js +0 -2
- package/dist/chunk-wes5fdpe.js +0 -2
- package/dist/chunk-wfnfb4fr.js +0 -2
- package/dist/chunk-wfrqwtar.js +0 -2
- package/dist/chunk-xbhb8102.js +0 -2
- package/dist/chunk-xv4paxmt.js +0 -2
- package/dist/chunk-yeaqebnd.js +0 -2
- package/dist/chunk-yj20tq3s.js +0 -2
- package/dist/chunk-yjm7c78z.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oe,de,gn,Ot,Nt,m,s,fe,p}from"./chunk-
|
|
2
|
+
import{oe,de,gn,Ot,Nt,m,s,fe,p}from"./chunk-wp6bdac7.js";import{yt,Re,sc,is,No,Mo,i}from"./chunk-e37g6ezw.js";import{ae,Tr,ke,B,Sn}from"./chunk-4v50nafp.js";import{St,pr,$s,Rs,As,kt,_t,Ct,Et,Tt,$t,et}from"./chunk-qjbpa1n4.js";import{Ss,a,P}from"./chunk-9x62j5f0.js";import{ft,An,Ce,D,ca,mo,Xr,We,la,qe,Ee}from"./chunk-mj3hzy1e.js";import{lr,ur}from"./chunk-rbv6fxtx.js";import{$n}from"./chunk-5wwcgze3.js";import{e,cn,sr,y}from"./chunk-nw0v655w.js";import{Je}from"./chunk-q7q9e0gj.js";import{$e}from"./chunk-7sh9fa3q.js";import{K,be,we}from"./chunk-eegb7f3t.js";import{l}from"./chunk-kj8dvzpc.js";import{X}from"./chunk-w0zayhmg.js";async function Nn(t){try{let n=await Bun.file(t).text(),r=Un(n),d=Wn(n,t),o=Vn(n,r),c=qn(n,r);return{file:t,metrics:r,issues:d,suggestions:o,performance:c}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Un(t){let n=t.split(`
|
|
3
3
|
`),r=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),o=(r?r[1]:"").split(`
|
|
4
4
|
`).length,c={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};c.total=c.conditionals+c.loops+c.includes+c.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,f=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,g=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+f+g,x=(t.match(/<[A-Z][^>]*>/g)||[]).length,v=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,T=0;for(let k of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(k)&&!/@end/.test(k)&&!/@else/.test(k))T++,S=Math.max(S,T);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(k))T--;let w=S>=4?3:0,b=Math.min(10,Math.ceil(c.total*0.5+h*0.1+x*0.3+(o>10?o*0.05:0)+w));return{lines:n.length,characters:t.length,directives:c,expressions:h,components:x,layouts:v,scriptLines:o,complexity:b}}function Wn(t,n){let r=[],d=Xt(t,"if","endif");if(d>0)r.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let o=Xt(t,"foreach","endforeach");if(o>0)r.push({type:"error",category:"syntax",message:`Found ${o} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let c=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(c&&c.length>0)r.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=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)r.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let f=t.match(/<img[^>]*>/g);if(f){let x=f.filter((v)=>!v.includes("alt="));if(x.length>0)r.push({type:"warning",category:"accessibility",message:`Found ${x.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let g=t.split(`
|
|
5
|
-
`).filter((x)=>x.length>120);if(g.length>0)r.push({type:"info",category:"maintainability",message:`Found ${g.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)r.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return r}function Vn(t,n){let r=[];if(n.complexity>7)r.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)r.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)r.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)r.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)r.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)r.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)r.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return r}function qn(t,n){let r=1;if(r+=n.directives.conditionals*0.1,r+=n.directives.loops*0.5,r+=n.directives.includes*2,r+=n.expressions*0.05,r+=n.components*1,n.scriptLines>10)r+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let o=[];if(r>10)o.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)o.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)o.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(r*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:o}}function Xt(t,n,r){let d=t.replace(/<!--[\s\S]*?-->/g,""),o=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,c=(d.match(new RegExp(`@${r}\\b`,"g"))||[]).length;return Math.abs(o-c)}async function
|
|
5
|
+
`).filter((x)=>x.length>120);if(g.length>0)r.push({type:"info",category:"maintainability",message:`Found ${g.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)r.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return r}function Vn(t,n){let r=[];if(n.complexity>7)r.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)r.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)r.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)r.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)r.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)r.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)r.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return r}function qn(t,n){let r=1;if(r+=n.directives.conditionals*0.1,r+=n.directives.loops*0.5,r+=n.directives.includes*2,r+=n.expressions*0.05,r+=n.components*1,n.scriptLines>10)r+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let o=[];if(r>10)o.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)o.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)o.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(r*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:o}}function Xt(t,n,r){let d=t.replace(/<!--[\s\S]*?-->/g,""),o=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,c=(d.match(new RegExp(`@${r}\\b`,"g"))||[]).length;return Math.abs(o-c)}async function Gi(t=["**/*.stx"],n){let r=[],d=[];for(let c of t){let u=await Array.fromAsync(new Bun.Glob(c).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((f)=>f.endsWith(".stx")))}for(let c of d)try{let u=await Nn(c);r.push(u)}catch(u){console.warn(`Failed to analyze ${c}:`,u)}let o=Kn(r);return{results:r,summary:o}}function Kn(t){let n=t.length,r=t.reduce((h,x)=>h+x.metrics.lines,0),d=n>0?t.reduce((h,x)=>h+x.metrics.complexity,0)/n:0,o=t.reduce((h,x)=>h+x.issues.length,0),c={};t.forEach((h)=>{h.issues.forEach((x)=>{c[x.category]=(c[x.category]||0)+1})});let u=n>0?t.reduce((h,x)=>h+x.performance.estimatedRenderTime,0)/n:0,f=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),g=[];if(d>6)g.push("Project has high average complexity. Consider refactoring complex templates.");if(o>n*2)g.push("High number of issues detected. Run detailed analysis on individual files.");if(c.security>0)g.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:r,avgComplexity:Math.round(d*100)/100,totalIssues:o,issuesByCategory:c,performanceScore:f,recommendations:g}}import{mkdir as Xn,readFile as Gn,readdir as Jn,stat as Gt,writeFile as Yn}from"fs/promises";import Te from"path";function tn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var nn=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function Qn(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function It(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Zn(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function er(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function tr(t){let n=[];async function r(d){let o=await Jn(d,{withFileTypes:!0});o.sort((c,u)=>c.name.localeCompare(u.name));for(let c of o){let u=Te.join(d,c.name);if(c.isDirectory()){if(!c.name.startsWith(".")&&c.name!=="node_modules")await r(u)}else if(c.isFile()&&c.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(c.name))n.push(u)}}return await r(t),n}function nr(t,n){let r=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!r)return{};let d=r[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(o){throw Error(`${n}: <script component> must contain JSON metadata (${o.message})`)}}function rr(t,n){let r={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let o of d){if(!/\bclient\b/i.test(o[1])||/\bcomponent\b|\bstx:component\b/i.test(o[1]))continue;let c;try{c=new Bun.Transpiler({loader:"ts"}).transformSync(o[2])}catch(g){throw Error(`${n}: failed to transpile <script client> (${g.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,f;while(f=u.exec(c)){let g=f[1];if(nn.has(g))throw Error(`${n}: client ${tn(g)}`);let h=u.lastIndex,x=1,v="",S=!1,T=h;for(;T<c.length&&x>0;T++){let b=c[T];if(S){S=!1;continue}if(v){if(b==="\\")S=!0;else if(b===v)v="";continue}if(b==='"'||b==="'"||b==="`")v=b;else if(b==="{")x++;else if(b==="}")x--}if(x!==0)throw Error(`${n}: unterminated client function "${g}"`);let w=f[0].includes("async")?"async ":"";r[g]=`${w}${g}(${f[2]}) {${c.slice(h,T-1)}}`,u.lastIndex=T}}return r}function or(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Jt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
|
|
6
6
|
|
|
7
7
|
`)}function ir(t){if(!t)return null;let n=t.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function ar(t){if(t===void 0)return"object";if(t==="true"||t==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(t))return"number";if(/^['"`]/.test(t))return"string";return"object"}function cr(t){if(t==="true")return!0;if(t==="false")return!1;if(/^-?\d+(?:\.\d+)?$/.test(t))return Number(t);if(/^['"`]/.test(t))return t.slice(1,-1);try{return JSON.parse(t)}catch{return}}function dr(t){let n=[],r=0,d=t.replace(/\{\{--[\s\S]*?--\}\}/g,""),o=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,c,u=(g)=>{if(d[g]!=="(")return null;let h=0,x="";for(let v=g;v<d.length;v++){let S=d[v];if(x!==""){if(S==="\\")v++;else if(S===x)x="";continue}if(S==="'"||S==='"'||S==="`"){x=S;continue}if(S==="(")h++;else if(S===")"){if(h--,h===0)return{expression:d.slice(g+1,v),end:v+1}}}return null},f=(g)=>{if(g==="")return;let h=0,x=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,v;while(v=x.exec(g)){if(v.index>h)n.push(`out += ${JSON.stringify(g.slice(h,v.index))};`);n.push(v[1]!==void 0?`out += __raw(${v[1]});`:`out += __escape(${v[2]});`),h=v.index+v[0].length}if(h<g.length)n.push(`out += ${JSON.stringify(g.slice(h))};`)};while(c=o.exec(d)){f(d.slice(r,c.index)),r=c.index+c[0].length;let h=c[1]==="if"||c[1]==="elseif"||c[1]==="foreach"?u(r):null;if(h)r=h.end,o.lastIndex=h.end;let x=h?.expression;switch(c[1]){case"if":n.push(`if (${x}) {`);break;case"elseif":n.push(`} else if (${x}) {`);break;case"else":n.push("} else {");break;case"endif":case"endforeach":n.push("}");break;case"foreach":{let v=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((x||"").trim());if(!v){n.push(`out += ${JSON.stringify(c[0]+(h?`(${x})`:""))};`);break}let[,S,T,w]=v;n.push(T?`for (const [${T}, ${w}] of __entries(${S})) {`:`for (const ${w} of __values(${S})) {`);break}}}return f(d.slice(r)),n.join(`
|
|
8
8
|
`)}function lt(t,n,r,d){if(t[n]!==r)return-1;let o=0,c=null;for(let u=n;u<t.length;u++){let f=t[u];if(c){if(f==="\\"){u++;continue}if(f===c)c=null;continue}if(f==="'"||f==='"'||f==="`"){c=f;continue}if(f===r)o++;else if(f===d){if(d===">"&&t[u-1]==="=")continue;if(o--,o===0)return u+1}}return-1}function Mt(t,n,r){let d=r?"([{<":"([{",o=r?")]}>":")]}",c=[],u=0,f=null,g="";for(let h=0;h<t.length;h++){let x=t[h];if(f){if(g+=x,x==="\\"){g+=t[++h]??"";continue}if(x===f)f=null;continue}if(x==="'"||x==='"'||x==="`"){f=x,g+=x;continue}if(d.includes(x))u++;else if(o.includes(x))u--;if(u===0&&n.includes(x)){c.push(g),g="";continue}g+=x}return c.push(g),c.map((h)=>h.trim()).filter(Boolean)}function fr(t){let n=0,r=null;for(let d=0;d<t.length;d++){let o=t[d];if(r){if(o==="\\"){d++;continue}if(o===r)r=null;continue}if(o==="'"||o==='"'||o==="`"){r=o;continue}if("([{".includes(o))n++;else if(")]}".includes(o))n--;if(n!==0||o!=="=")continue;let c=t[d-1];if(t[d+1]==="="||c==="="||c==="!"||c==="<"||c===">")continue;return d}return-1}function Yt(t){switch(t.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function mr(t){let n=/\bdefineProps\b/.exec(t);if(!n)return null;let r=/(?:^|[\s;{}()])(const|let|var)\s+/g,d=-1;for(let E=r.exec(t);E&&E.index<n.index;E=r.exec(t))d=E.index+E[0].indexOf(E[1]);if(d===-1)return null;let o={},c={},u=[],f={},g=d+(/^(?:const|let|var)\s+/.exec(t.slice(d))?.[0].length??0),h=()=>{while(g<t.length&&/\s/.test(t[g]))g++},x;if(t[g]==="{"){let E=lt(t,g,"{","}");if(E===-1)return null;x=t.slice(g,E),g=E}else{let E=/^[A-Za-z_$][\w$]*/.exec(t.slice(g));if(!E)return null;x=E[0],g+=E[0].length}if(h(),t[g]!=="=")return null;g++,h();let v=/^withDefaults\s*\(\s*/.exec(t.slice(g)),S=Boolean(v);if(v)g+=v[0].length;let T=/^defineProps\b/.exec(t.slice(g));if(!T)return null;g+=T[0].length;let w="";if(h(),t[g]==="<"){let E=lt(t,g,"<",">");if(E===-1)return null;w=t.slice(g+1,E-1).trim(),g=E}if(h(),t[g]!=="(")return null;let b=lt(t,g,"(",")");if(b===-1)return null;let k=t.slice(g+1,b-1).trim();if(g=b,S){if(h(),t[g]===",")g++,h();if(t[g]==="{"){let E=lt(t,g,"{","}");if(E===-1)return null;for(let[R,A]of Lt(t.slice(g,E)))c[R]=A;g=E}if(h(),t[g]===",")g++,h();if(t[g]===")")g++}if(t[g]===";")g++;let _=/^[A-Za-z_$][\w$]*$/.test(w)?w:void 0;if(w.startsWith("{"))for(let E of Mt(w.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let R=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(E);if(R)o[R[1]]=R[2].trim()}if(k.startsWith("{"))for(let[E,R]of Lt(k)){if(u.push(E),!R.startsWith("{")){let A=Yt(R);if(A)o[E]=A;continue}for(let[A,C]of Lt(R))if(A==="default")c[E]=C;else if(A==="type"){let M=Yt(C);if(M)o[E]=M}}else if(k.startsWith("["))for(let E of Mt(k.slice(1,-1),",",!1))u.push(E.replace(/^['"`]/,"").replace(/['"`]$/,""));if(x.startsWith("{")){u.length=0;for(let E of Mt(x.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let R=fr(E),A=R===-1?E:E.slice(0,R),C=A.split(":")[0].trim().replace(/^\.\.\./,"");if(!C)continue;if(u.push(C),f[C]=A.trim(),R!==-1)c[C]=E.slice(R+1).trim()}}else if(u.length===0)u.push(...Object.keys(o));return{text:t.slice(d,g),propNames:u,propBindings:f,defaults:c,declared:o,typeName:_}}function Lt(t){let n=t.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],d=0;while(d<n.length){let o=/\s*([A-Za-z_$][\w$]*)\s*:/y;o.lastIndex=d;let c=o.exec(n);if(!c)break;d=o.lastIndex;let u=0,f="",g=d;while(d<n.length){let x=n[d];if(f){if(x==="\\")d++;else if(x===f)f=""}else if(x==="'"||x==='"'||x==="`")f=x;else if(x==="{"||x==="["||x==="(")u++;else if(x==="}"||x==="]"||x===")")u--;else if(x===","&&u===0)break;d++}let h=n.slice(g,d).trim();if(h)r.push([c[1],h]);d++}return r}function gr(t,n,r){let o=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((T)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(T[1]));if(!o)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{}};let c=o[2],u=[],f=[],g={},h={},x={};c=c.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(T)=>{if(/from\s*['"]stx['"]/.test(T))return"";return u.push(T.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(w,b,k,_)=>{let E=Te.resolve(Te.dirname(n),k),R=Te.relative(r,E);return`${b}${R.startsWith(".")?R:`./${R}`}${_}`})),""});let v=mr(c);if(v)f.push(...v.propNames),Object.assign(g,v.propBindings),Object.assign(h,v.defaults),Object.assign(x,v.declared),c=c.replace(v.text,"");let S={};for(let T of c.matchAll(/(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\s*\{([\s\S]*?)\n\}/g)){let w=[];for(let b of T[2].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))x[b[1]]=b[2].trim(),w.push(b[1]);S[T[1]]=w}if(v&&v.propNames.length===0&&v.typeName){for(let T of S[v.typeName]??[])if(!f.includes(T))f.push(T)}return c=c.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:u,body:c.trim(),propNames:f,propBindings:g,defaults:h,declared:x}}function hr(t){let n=new Set;return{template:t.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(d,o,c,u,f)=>{let g=o.toLowerCase();n.add(g);let h=(c||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${g}="${f}"${h?` data-stx-mod-${g}="${h}"`:""}`}),eventTypes:[...n].sort()}}function yr(t){let n=[];return{template:t.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(d,o,c,u)=>{let f=n.length;return n.push({id:f,name:o,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function br(t){let n=new Set;for(let r of t.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function xr(t){return[...new Set([...t.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function Qt(t,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${t}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function vr(t,n,r){let d=Te.isAbsolute(n.file)?n.file:Te.resolve(t,n.file),o=await Gn(d,"utf8"),c=nr(o,d),u=Te.basename(d,".stx"),f=n.name||c.name||Qn(u),g=`${It(r.prefix||"stx")}-${It(u)}`,h=n.tag||c.tag||g;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${d}: invalid component class name "${f}"`);if(!Zn(h))throw Error(`${d}: invalid custom-element tag "${h}"; tags must be lowercase and contain a hyphen`);let x=n.properties||c.properties||c.props||{},v=Object.fromEntries(Object.entries(x).map(([R,A])=>[R,Qt(R,A)])),S=hr(or(o)),T=yr(S.template),w=gr(o,d,Te.resolve(r.outputDir)),b=dr(T.template);for(let R of w.propNames){if(v[R])continue;let A=w.defaults[R];v[R]=Qt(R,{type:ir(w.declared[R])??ar(A),...A===void 0?{}:{default:cr(A)}})}let k=c.methods||{},_=n.methods||{},E=rr(o,d);return{file:Te.relative(t,d),sourcePath:d,name:f,tag:h,description:n.description||c.description||"",template:T.template,styles:Jt(o),shadowMode:er(n.shadowDOM??c.shadowDOM??r.shadowDOM),progressive:n.progressive??c.progressive??r.progressive??!0,properties:v,events:n.events||c.events||{},methods:{...k,..._,...E},eventTypes:S.eventTypes,bindings:T.bindings,slots:br(T.template),cssProperties:xr(Jt(o)),scope:w,render:b}}function wr(){let t=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),n=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
@@ -421,7 +421,7 @@ export function renderComponent(tag, props = {}, slots = {}) {
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
${c}
|
|
424
|
-
`}async function
|
|
424
|
+
`}async function Ji(t){let n=Te.resolve(t.inputDir),r=Te.resolve(t.outputDir);if(!(await Gt(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let o=t.components?.length?t.components:(await tr(n)).map((b)=>({file:b}));if(!o.length)throw Error(`No .stx components found in ${n}`);let c=await Promise.all(o.map((b)=>vr(n,b,t)));c.sort((b,k)=>b.tag.localeCompare(k.tag));let u=c.filter((b,k)=>c.findIndex((_)=>_.tag===b.tag)!==k);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=c.filter((b,k)=>c.findIndex((_)=>_.name===b.name)!==k);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Xn(r,{recursive:!0});let g=[],h=async(b,k)=>{let _=Te.join(r,b);return await Yn(_,k.endsWith(`
|
|
425
425
|
`)?k:`${k}
|
|
426
426
|
`,"utf8"),g.push(_),_};await h("runtime.js",wr());for(let b of c){if(await h(`${b.tag}.js`,Sr(b)),t.declarations!==!1)await h(`${b.tag}.d.ts`,kr(b));if(t.css!==!1&&b.styles){let k=b.shadowMode?b.styles:Zt(b);await h(`${b.tag}.css`,t.minify?en(k):k)}}let x=c.map((b)=>`export { ${b.name}, default as ${b.name}Element } from './${b.tag}.js';`).join(`
|
|
427
427
|
`);if(await h("index.js",x),await h("ssr.js",Rr(c)),t.declarations!==!1)await h("index.d.ts",c.map((b)=>`export * from './${b.tag}.js'`).join(`
|
|
@@ -515,7 +515,7 @@ else {
|
|
|
515
515
|
<span class="frontmatter-label">${n}:</span>
|
|
516
516
|
<span>${Array.isArray(r)?r.join(", "):String(r)}</span>
|
|
517
517
|
</div>`).join("")}
|
|
518
|
-
</div>`}import rn from"net";async function Er(t){return new Promise((n)=>{let r=rn.createServer();r.once("error",()=>n(!1)),r.once("listening",()=>{r.close(()=>n(!0))}),r.listen(t,"0.0.0.0")})}async function Pr(t){return new Promise((n)=>{let r=rn.createServer();r.once("error",()=>n(!1)),r.once("listening",()=>{r.close(()=>n(!0))}),r.listen(t,"::")})}async function Or(t){if(!await Er(t))return!1;return await Pr(t)}async function Ve(t,n=20){t=Number(t);for(let r=0;r<n;r++){let d=t+r;if(await Or(d))return d}throw Error(`Could not find an available port between ${t} and ${t+n-1}`)}var Ar={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Dr(){try{let t=await import("./chunk-
|
|
518
|
+
</div>`}import rn from"net";async function Er(t){return new Promise((n)=>{let r=rn.createServer();r.once("error",()=>n(!1)),r.once("listening",()=>{r.close(()=>n(!0))}),r.listen(t,"0.0.0.0")})}async function Pr(t){return new Promise((n)=>{let r=rn.createServer();r.once("error",()=>n(!1)),r.once("listening",()=>{r.close(()=>n(!0))}),r.listen(t,"::")})}async function Or(t){if(!await Er(t))return!1;return await Pr(t)}async function Ve(t,n=20){t=Number(t);for(let r=0;r<n;r++){let d=t+r;if(await Or(d))return d}throw Error(`Could not find an available port between ${t} and ${t+n-1}`)}var Ar={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function Dr(){try{let t=await import("./chunk-dd1vqndp.js");if(typeof t.openDevWindow!=="function")return null;return t}catch{return null}}async function Ze(t,n={}){let r={...Ar,...n},d=await Dr();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 o=await d.openDevWindow(t,{title:r.title,width:r.width,height:r.height,darkMode:r.darkMode,hotReload:r.hotReload,titlebarHidden:r.titlebarHidden,nativeSidebar:r.nativeSidebar,sidebarWidth:r.sidebarWidth,sidebarConfig:r.sidebarConfig});if(o&&r.nativeSidebar)console.log(`${e.green}\u2713${e.reset} Native sidebar enabled (macOS Tahoe style)`);return o}catch(o){return console.log(`${e.red}\u2717${e.reset} Could not open native window:`,o),!1}}function gt(t){if(t.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let o=t.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(o){let c=o[1];try{let u=`
|
|
519
519
|
${c}
|
|
520
520
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
521
521
|
`,g=Function(u)();if(g)return g}catch(u){console.warn("Invalid sidebarConfig:",u)}}return{sections:[]}}let r=t.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(r)try{return JSON.parse(r[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let d=t.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(d)try{let o=d[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(o)return Function(`return ${o[1]}`)()}catch(o){console.warn("Invalid native-sidebar script configuration:",o)}return}function Ht(){console.log(`
|
|
@@ -887,10 +887,10 @@ else {
|
|
|
887
887
|
};
|
|
888
888
|
})();
|
|
889
889
|
</script>
|
|
890
|
-
`}function Ne(t,n,r={}){let d=Br(n,r),o=t.lastIndexOf("</body>");if(o!==-1)return t.slice(0,o)+d+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},d=new Set,o=r.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(r.webComponents?.enabled)try{let u=await
|
|
890
|
+
`}function Ne(t,n,r={}){let d=Br(n,r),o=t.lastIndexOf("</body>");if(o!==-1)return t.slice(0,o)+d+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},d=new Set,o=r.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(r.webComponents?.enabled)try{let u=await Ss(r,d);if(c.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let f=new Set;if(r.cache&&r.cachePath){let b=await lr(u,r);if(b){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:b,loader:"html"}}}let g=await ke(()=>Bun.file(u).text(),"",(b)=>{throw new Tr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${b.message}`)});if(!g)throw new Tr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:v}=oe.time("script-extraction",()=>{let b=g,k=de(g);if(k)b=k.content.trim();let _=g.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],E="",R=[];for(let C of _){let M=C.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=C.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))E=M;else R.push(C)}let A=b.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:E,templateContent:A,allScripts:R}}),S={__filename:u,__dirname:wt.dirname(u),__stx:{webComponentsPath:o,builtComponents:c}};await ke(()=>m(h,S,u),void 0,(b)=>{let k=new ae(`Script execution failed in ${u}: ${b.message}`,u,void 0,void 0,h.substring(0,100));if(B.log(k,{filePath:u,scriptContent:h}),r.debug)throw k});let w=await oe.timeAsync("directive-processing",async()=>await i(x,S,u,r,f));if(v.length>0){let{interpolateScriptsInTemplate:b}=await import("./chunk-eh528njb.js"),k=b(v.join(`
|
|
891
891
|
`),S),_=w.search(/<\/body>/i);if(_!==-1)w=w.slice(0,_)+k+`
|
|
892
892
|
`+w.slice(_);else w+=`
|
|
893
|
-
${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),r.cache&&r.cachePath){if(await ur(u,w,f,r),r.debug)console.log(`Cached template ${u} with ${f.size} dependencies`)}return{contents:w,loader:"html"}}catch(f){let g=f instanceof Error?f:new ae(`Plugin processing failed: ${String(f)}`,u);if(B.log(g,{filePath:u,buildConfig:t.config}),Sn.logDetailedError(g,{filePath:u,plugin:"bun-plugin-stx"}),r.debug)console.error("stx Plugin Error:",g);let h=g,x=h.line||null,v=h.context||null;return{contents:r.debug||
|
|
893
|
+
${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),r.cache&&r.cachePath){if(await ur(u,w,f,r),r.debug)console.log(`Cached template ${u} with ${f.size} dependencies`)}return{contents:w,loader:"html"}}catch(f){let g=f instanceof Error?f:new ae(`Plugin processing failed: ${String(f)}`,u);if(B.log(g,{filePath:u,buildConfig:t.config}),Sn.logDetailedError(g,{filePath:u,plugin:"bun-plugin-stx"}),r.debug)console.error("stx Plugin Error:",g);let h=g,x=h.line||null,v=h.context||null;return{contents:r.debug||X()?`<!DOCTYPE html>
|
|
894
894
|
<html lang="en">
|
|
895
895
|
<head>
|
|
896
896
|
<meta charset="UTF-8">
|
|
@@ -950,7 +950,7 @@ ${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),r.cache&&r.cachePath){if(await u
|
|
|
950
950
|
<h1>Something went wrong</h1>
|
|
951
951
|
<p>An internal error occurred. Please try again later.</p>
|
|
952
952
|
</body>
|
|
953
|
-
</html>`,loader:"html"}}})}};async function zr(t,n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,c=null,u=n.hmrPort||r+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return Ft(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=l(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let M={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[f],outdir:g,plugins:[M,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(M){return console.error(`${e.red}Error building stx file:${e.reset}`,M),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=r;try{if(T=await Ve(r),T!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let M=n.hmrPort||T+1;c=vt({wsPort:M,verbose:!1}),u=c.start(M)}let w={},b=null,k;try{let{loadStxConfig:M}=await import("./chunk-
|
|
953
|
+
</html>`,loader:"html"}}})}};async function zr(t,n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,c=null,u=n.hmrPort||r+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return Ft(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=l(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let M={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[f],outdir:g,plugins:[M,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(M){return console.error(`${e.red}Error building stx file:${e.reset}`,M),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=r;try{if(T=await Ve(r),T!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let M=n.hmrPort||T+1;c=vt({wsPort:M,verbose:!1}),u=c.start(M)}let w={},b=null,k;try{let{loadStxConfig:M}=await import("./chunk-6hre8cg4.js"),I=await M();if(k=n.stxOptions?.serverApi??I.serverApi,I?.apiRouter)b=I?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(I?.apiRoutes){w=I.apiRoutes;let V=Object.keys(w).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(I?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-6pyweb05.js"),xe=I.broadcasting;await V(xe);let le=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Oe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Oe))try{let ne=await Y(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:_,isServerApiSource:E}=await import("./chunk-75ctpxr3.js"),R=await _(process.cwd(),k);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${T}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let A=Fr({port:T,async fetch(M){return $n(M,await(async()=>{let I=new URL(M.url);if([g,ge.dirname(f),ge.join(process.cwd(),"public")].some((ne)=>E(ge.join(ne,I.pathname),process.cwd(),k)))return new Response("Not Found",{status:404});if(b)try{let ne=await b.handleRequest(M);if(ne.status!==404)return ne}catch{}if(w[I.pathname])try{return await w[I.pathname](M)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(M);if(V)return V;if(I.pathname==="/")return(async()=>{let z=await y(h||"");if(o)z=Ne(z,u);if(n.native)if(z.includes("<head>"))z=z.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;if(n.titlebarHidden)if(z.includes("<head>"))z=z.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else z=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${z}`;return z})().then((z)=>new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(g,I.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),z=ge.extname(Y).toLowerCase(),L="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}let xe=ge.dirname(f),le=ge.join(xe,I.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),z=ge.extname(le).toLowerCase(),L="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".svg":L="image/svg+xml";break;case".ico":L="image/x-icon";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}let Oe=ge.join(process.cwd(),"public",I.pathname);if(Be.existsSync(Oe)&&Be.statSync(Oe).isFile()){let ne=Bun.file(Oe),z=ge.extname(Oe).toLowerCase(),L="application/octet-stream";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".svg":L="image/svg+xml";break;case".ico":L="image/x-icon";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}return new Response("Not Found",{status:404})})())},error(M){return new Response(`<pre>${M}
|
|
954
954
|
${M.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
955
955
|
${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(`
|
|
956
956
|
${e.bright}\u2192 ${e.cyan}http://localhost:${T}/${e.reset}`),console.log(`
|
|
@@ -1430,24 +1430,24 @@ else {
|
|
|
1430
1430
|
</body>
|
|
1431
1431
|
</html>
|
|
1432
1432
|
`,le=`/${Pe.relative(c,b).replace(/\.md$/,"")}`;if(le.endsWith("/index"))le=le.slice(0,-6)||"/";u[le||"/"]={filePath:b,content:Y,fileType:"md"}}catch(_){console.error(`${e.red}Error processing Markdown file ${e.bright}${w}${e.reset}:`,_);continue}else{let _={name:"public-assets",setup(C){C.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>({path:M.path,external:!0}))}},E;try{let C=await Bun.build({entrypoints:[b],outdir:o,plugins:[_,rt],define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!C.success){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:`,$e(C.logs,b));continue}let M=C.outputs.find((I)=>I.path.endsWith(".html"));if(!M){console.error(`${e.red}No HTML output found for ${e.bright}${w}${e.reset}`);continue}E=await Bun.file(M.path).text()}catch(C){console.error(`${e.red}Build failed for ${e.bright}${w}${e.reset}:
|
|
1433
|
-
${$e(C,b)}`);continue}let A=`/${Pe.relative(c,b).replace(/\.stx$/,"")}`;if(A.endsWith("/index"))A=A.slice(0,-6)||"/";if(A.includes("[")){let{regex:C,params:M}
|
|
1433
|
+
${$e(C,b)}`);continue}let A=`/${Pe.relative(c,b).replace(/\.stx$/,"")}`;if(A.endsWith("/index"))A=A.slice(0,-6)||"/";if(A.includes("[")){let{regex:C,params:M}=$s(A,{page:!0});f.push({pattern:C,paramNames:M,filePath:b,routeTemplate:A,fileType:"stx"}),u[A]={filePath:b,content:E,fileType:"stx"}}else u[A||"/"]={filePath:b,content:E,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}`,$e(w)),!1}};if(!await g())return!1;let x=r;try{if(x=await Ve(r),x!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${x} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${x}/${e.reset}...`);let v=Nr({port:x,async fetch(w){let b=new URL(w.url),k=Pe.join(process.cwd(),"public",b.pathname);if(Xe.existsSync(k)&&Xe.statSync(k).isFile()){let R=Bun.file(k),A=Pe.extname(k).toLowerCase(),C="application/octet-stream";if(A===".ts"||A===".tsx"){let M=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),I=await R.text(),V=M.transformSync(I);return new Response(V,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":C="text/html";break;case".css":C="text/css";break;case".js":C="text/javascript";break;case".json":C="application/json";break;case".png":C="image/png";break;case".jpg":case".jpeg":C="image/jpeg";break;case".gif":C="image/gif";break;case".svg":C="image/svg+xml";break;case".ico":C="image/x-icon";break;case".woff":C="font/woff";break;case".woff2":C="font/woff2";break;case".ttf":C="font/ttf";break;case".otf":C="font/otf";break;case".eot":C="application/vnd.ms-fontobject";break}return new Response(R,{headers:{"Content-Type":C}})}let _=u[b.pathname];if(!_&&!b.pathname.endsWith("/"))_=u[`${b.pathname}/`];if(!_)for(let R of f){let A=b.pathname.match(R.pattern);if(A){let C=u[R.routeTemplate];if(C){let M={};for(let Y=0;Y<R.paramNames.length;Y++)M[R.paramNames[Y]]=decodeURIComponent(A[Y+1]);let I=C.content,V=`<script>window.__routeParams = ${JSON.stringify(M)};</script>`;if(I.includes("</head>"))I=I.replace("</head>",`${V}
|
|
1434
1434
|
</head>`);else I=V+I;_={...C,content:I}}break}}if(_)return y(_.content).then((R)=>{if(R.includes("</head>"))R=R.replace("</head>",`${sn}
|
|
1435
1435
|
</head>`);return new Response(R,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let E=Pe.join(o,b.pathname);if(Xe.existsSync(E)&&Xe.statSync(E).isFile()){let R=Bun.file(E),A=Pe.extname(E).toLowerCase(),C="text/plain";if(A===".ts"||A===".tsx"){let M=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),I=await R.text(),V=M.transformSync(I);return new Response(V,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":C="text/html";break;case".css":C="text/css";break;case".js":C="text/javascript";break;case".json":C="application/json";break;case".png":C="image/png";break;case".jpg":case".jpeg":C="image/jpeg";break;case".gif":C="image/gif";break;case".svg":C="image/svg+xml";break;case".ico":C="image/x-icon";break;case".woff":C="font/woff";break;case".woff2":C="font/woff2";break;case".ttf":C="font/ttf";break;case".otf":C="font/otf";break;case".eot":C="application/vnd.ms-fontobject";break}return new Response(R,{headers:{"Content-Type":C}})}if(b.pathname!=="/"&&u["/"]){let R=Ce(w);return y(u["/"].content).then((A)=>{if(R){let C=A.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(C){let M=A.match(/<title[^>]*>([\s\S]*?)<\/title>/i),I=M?M[1]:"",V=`<!DOCTYPE html><html><head><title>${an(I)}</title></head><body><main>${C[1]}</main></body></html>`;return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...D(),"Cache-Control":ft,Pragma:"no-cache",Expires:"0"}})}}return new Response(A,{headers:{"Content-Type":"text/html",...D(),"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}
|
|
1436
1436
|
${w.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1437
1437
|
${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(`
|
|
1438
1438
|
${e.bright}\u2192 ${e.cyan}http://localhost:${x}/${e.reset}`),console.log(`
|
|
1439
1439
|
${e.yellow}Routes:${e.reset}`);let S=new Set(f.map((w)=>w.routeTemplate)),T=Object.entries(u).filter(([w])=>!S.has(w)).sort(([w],[b])=>w.localeCompare(b)).map(([w,b])=>({route:w==="/"?"/":w,filePath:Pe.relative(process.cwd(),b.filePath),fileType:b.fileType}));for(let w of f){let b=w.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");T.push({route:b,filePath:Pe.relative(process.cwd(),w.filePath),fileType:"stx"})}if(T.sort((w,b)=>w.route.localeCompare(b.route)),T.forEach((w,b)=>{let _=b===T.length-1?"\u2514\u2500 ":"\u251C\u2500 ",E=w.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${_}${w.route}${e.reset} \u2192 ${e.bright}${w.filePath}${e.reset} ${E}`)}),console.log(`
|
|
1440
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(c,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(c,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),r=te.extname(t).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"},c=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[r]||"application/octet-stream",...c}})}async function Vr(t=".",n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,c=null,u=n.hmrPort||r+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-t0d4rsfx.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-75y9heas.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((O)=>me.existsSync(O)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${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 ${b}/index.stx for the homepage.${e.reset}`),!1;let _=X(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(_.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${_.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:O,prefix:j}of E)if(me.existsSync(O)){let N=X(te.dirname(O),{pagesDir:te.basename(O)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,C=null,M=null;if(n.stxOptions?.shell!==!1){if(M=await aa(f,n.stxOptions?.shell),M){if(C=await go(M,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,M)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let I=_t();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:O}=await import("./chunk-t0d4rsfx.js"),j=await O(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-c692kj5v.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=l(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(O)=>{let j=$s(k,O);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,L=async(O,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-t0d4rsfx.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-9tpv4cg7.js"),G=await Ae(f),Ue=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(f,ie)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??l(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(O.filePath);if(ie)try{if((await me.promises.stat(O.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let Se of ie.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let Se=ie.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(O.filePath);return{route:O,content:Se,status:st?.status??await dn(O.filePath),headers:st?.headers}}}}catch{}let Ie=await U(O.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(O.filePath);return{route:O,content:je,status:He?.status??await dn(O.filePath),headers:He?.headers}}}let Z=re?await W(O.filePath):await Bun.file(O.filePath).text(),se=gn(Z),{classifyAllScripts:ue}=await import("./chunk-t0d4rsfx.js"),F=ue(Z),Le=F.server.map((ie)=>ie.content),Me=Z;for(let ie of F.server)Me=Me.replace(ie.fullTag,"");let ee={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,O.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let ie=performance.now();he=await N(Me,ee,O.filePath,ce,De);let Ie=performance.now()-ie,je=te.relative(f,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,O.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-s151a2dj.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(O.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-ghn8vhet.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof ie[Se]==="function"?await ie[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},O.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(O.pattern);else Qe=void 0;let Vt=Ot(ee),qt=Nt(ee);if(H)z.set(O.filePath,{status:Vt,headers:qt});return{route:O,content:he,status:Vt??se,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let O=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let N=n.prebuild===!1?_.filter((q)=>O.has(q.pattern)):_,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>L(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>L(U)));for(let U of ve)if(U)A.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?_.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=r;try{if(Ge=await Ve(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let O=n.hmrPort||Ge+1;c=vt({wsPort:O,verbose:!1}),u=c.start(O)}let Pt=(O,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).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(O.includes("</head>"))return O.replace("</head>",`${Q}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+O};console.log(`${e.blue}Starting server...${e.reset}`);let At=Ur({port:Ge,hostname:n.hostname,async fetch(O){let j=new URL(O.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===Oo&&N?.enabled){if(!["GET","HEAD"].includes(O.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(O.method==="HEAD"?null:No(N,os()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return zt(q);if(J?.isFile()&&!v(Ae,f,S))return zt(Ae);if(W?.isFile()&&!v(ve,f,S))return zt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-ewzdsksb.js"),re=await H(O,{publicDir:te.join(f,Q),cacheDir:l(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(O);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](O)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(O);if(pe)return pe;let G=pr(j.pathname,_);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await L(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),o)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,O,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let F=H.content;if(C&&ca(O)&&qe(F,h?.router?.container||"main")){let Le=et(F),Me=be(F),ee=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)F=Pt(F,G.params);F=await y(F,f);let he=h?.router?.container||"main";return F=Ee(F,he,!0),new Response(F,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[rc]:os(),...D(),"Cache-Control":ft}})}if(C)F=Kr(C,F);if(Object.keys(G.params).length>0)F=Pt(F,G.params);if(F=await y(F,f),o)F=Ne(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-ghn8vhet.js");return Me(Le(F,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:Z,headers:{"Content-Type":"text/html",...D(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await L(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(C)se=Kr(C,se);if(Object.keys(re.params).length>0)se=Pt(se,re.params);if(se=await y(se,f),o)se=Ne(se,u);return new Response(se,{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 E)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=R.find(({route:F})=>F.pattern===Z||F.pattern===`${Z}/`);if(ue){let F=await L(ue.route);if(F)se=F,A.set(ue.route.pattern,F)}}if(se){let ue=se.content;if(C)ue=Kr(C,ue);if(ue=await y(ue,f),o)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),o)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),o)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1440
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(c,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(c,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),r=te.extname(t).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"},c=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[r]||"application/octet-stream",...c}})}async function Vr(t=".",n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,c=null,u=n.hmrPort||r+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-6hre8cg4.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-75ctpxr3.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((O)=>me.existsSync(O)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${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 ${b}/index.stx for the homepage.${e.reset}`),!1;let _=K(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(_.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${_.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:O,prefix:j}of E)if(me.existsSync(O)){let N=K(te.dirname(O),{pagesDir:te.basename(O)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,C=null,M=null;if(n.stxOptions?.shell!==!1){if(M=await ca(f,n.stxOptions?.shell),M){if(C=await mo(M,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,M)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let I=_t();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:O}=await import("./chunk-6hre8cg4.js"),j=await O(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-6pyweb05.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=l(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(O)=>{let j=Rs(k,O);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,L=async(O,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-6hre8cg4.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-km8c0j9g.js"),G=await Ae(f),Ue=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(f,ie)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??l(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(O.filePath);if(ie)try{if((await me.promises.stat(O.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let Se of ie.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let Se=ie.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(O.filePath);return{route:O,content:Se,status:st?.status??await dn(O.filePath),headers:st?.headers}}}}catch{}let Ie=await U(O.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(O.filePath);return{route:O,content:je,status:He?.status??await dn(O.filePath),headers:He?.headers}}}let Z=re?await W(O.filePath):await Bun.file(O.filePath).text(),se=gn(Z),{classifyAllScripts:ue}=await import("./chunk-6hre8cg4.js"),F=ue(Z),Le=F.server.map((ie)=>ie.content),Me=Z;for(let ie of F.server)Me=Me.replace(ie.fullTag,"");let ee={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,O.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let ie=performance.now();he=await N(Me,ee,O.filePath,ce,De);let Ie=performance.now()-ie,je=te.relative(f,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,O.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-eh528njb.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(O.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-c7x3bmvs.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof ie[Se]==="function"?await ie[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},O.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(O.pattern);else Qe=void 0;let Vt=Ot(ee),qt=Nt(ee);if(H)z.set(O.filePath,{status:Vt,headers:qt});return{route:O,content:he,status:Vt??se,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let O=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let N=n.prebuild===!1?_.filter((q)=>O.has(q.pattern)):_,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>L(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>L(U)));for(let U of ve)if(U)A.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?_.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=r;try{if(Ge=await Ve(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let O=n.hmrPort||Ge+1;c=vt({wsPort:O,verbose:!1}),u=c.start(O)}let Pt=(O,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).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(O.includes("</head>"))return O.replace("</head>",`${Q}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+O};console.log(`${e.blue}Starting server...${e.reset}`);let At=Ur({port:Ge,hostname:n.hostname,async fetch(O){let j=new URL(O.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===No&&N?.enabled){if(!["GET","HEAD"].includes(O.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(O.method==="HEAD"?null:Mo(N,is()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return zt(q);if(J?.isFile()&&!v(Ae,f,S))return zt(Ae);if(W?.isFile()&&!v(ve,f,S))return zt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-7m4eesp0.js"),re=await H(O,{publicDir:te.join(f,Q),cacheDir:l(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(O);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](O)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(O);if(pe)return pe;let G=pr(j.pathname,_);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await L(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),o)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,O,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let F=H.content;if(C&&la(O)&&qe(F,h?.router?.container||"main")){let Le=et(F),Me=be(F),ee=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)F=Pt(F,G.params);F=await y(F,f);let he=h?.router?.container||"main";return F=Ee(F,he,!0),new Response(F,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[sc]:is(),...D(),"Cache-Control":ft}})}if(C)F=Xr(C,F);if(Object.keys(G.params).length>0)F=Pt(F,G.params);if(F=await y(F,f),o)F=Ne(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-c7x3bmvs.js");return Me(Le(F,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:Z,headers:{"Content-Type":"text/html",...D(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await L(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(C)se=Xr(C,se);if(Object.keys(re.params).length>0)se=Pt(se,re.params);if(se=await y(se,f),o)se=Ne(se,u);return new Response(se,{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 E)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=R.find(({route:F})=>F.pattern===Z||F.pattern===`${Z}/`);if(ue){let F=await L(ue.route);if(F)se=F,A.set(ue.route.pattern,F)}}if(se){let ue=se.content;if(C)ue=Xr(C,ue);if(ue=await y(ue,f),o)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),o)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),o)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1441
1441
|
${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1442
1442
|
${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(`
|
|
1443
1443
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Ge}/${e.reset}`),o)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1444
|
-
${e.yellow}Routes:${e.reset}`);let Dt=[...
|
|
1445
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(c)it();At.stop()}),n.native){let O,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();O=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),_.splice(0,_.length,...
|
|
1444
|
+
${e.yellow}Routes:${e.reset}`);let Dt=[...As(_,f)];for(let{route:O}of R)Dt.push(`${O.pattern}`);if(Dt.forEach((O,j)=>{let Q=j===Dt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${O}`)}),console.log(`
|
|
1445
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(c)it();At.stop()}),n.native){let O,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();O=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),_.splice(0,_.length,...K(w,{pagesDir:b,pagesDirs:pe._layerPageDirs?[k,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(O(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),o&&c)c.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-km8c0j9g.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(M&&W){if(te.resolve(U,W)===M||te.basename(M)===W){let G=await mo(M,n.stxOptions||{});if(G)C=G}}if(await ze(),await sr(f),o&&c)c.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-km8c0j9g.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(await ze(),o&&c)c.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),o&&c)c.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let U of N.values())U.close();if(c)it();At.stop(),process.exit(0)})}return!0}import Ut from"fs";import at from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let d=r[1],o=[],c=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=c.exec(d))!==null){let f=u[1],g=u[2]||u[3]||u[4];if(!g)continue;let h={name:g},x=f.match(/@type\s+\{([^}]+)\}/i);if(x)h.type=x[1].trim();if(f.match(/@required/i))h.required=!0;let S=f.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)h.default=S[1].trim();let T=f.split(`
|
|
1446
1446
|
`).map((w)=>w.trim().replace(/^\*\s*/,"")).filter((w)=>!w.startsWith("@")&&w.length>0);h.description=T.join(" ").trim(),o.push(h)}if(o.length===0){let f=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(f){let h=f[1].split(",").map((x)=>x.trim()).filter(Boolean);for(let x of h){let[v]=x.split(":").map((S)=>S.trim());if(v)o.push({name:v})}}}return o}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function qr(t){try{let n=await Bun.file(t).text(),r=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(r)return r[1].split(`
|
|
1447
|
-
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function
|
|
1447
|
+
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Kr(t,n=!1,r){let d=at.basename(t,".stx"),o=await Wr(t),c=await qr(t),u="";if(n&&r)u=`<${r}></${r}>`;else{let f=o.map((g)=>{if(g.type==="boolean")return`:${g.name}="true"`;return`${g.name}="value"`}).join(`
|
|
1448
1448
|
`);u=`<${d}
|
|
1449
1449
|
${f}
|
|
1450
|
-
/>`}return{name:d,path:t,description:c,props:o,example:u,isWebComponent:n,tag:r}}async function pn(t){try{if(!await s(t))return console.warn(`Components directory does not exist: ${t}`),[];let n=await Ut.promises.readdir(t,{withFileTypes:!0}),r=[];for(let d of n){let o=at.join(t,d.name);if(d.isDirectory()){let c=await pn(o);r.push(...c)}else if(d.isFile()&&d.name.endsWith(".stx"))r.push(o)}return r}catch(n){return console.error(`Error finding component files in ${t}:`,n),[]}}async function Gr(t,n){try{if(!await s(t))return[];let r=await pn(t),d=[],o=new Map;if(n?.components?.length)for(let c of n.components)o.set(c.file,c);for(let c of r){let u=o.get(c),f=!!u,g=u?.tag,h=await
|
|
1450
|
+
/>`}return{name:d,path:t,description:c,props:o,example:u,isWebComponent:n,tag:r}}async function pn(t){try{if(!await s(t))return console.warn(`Components directory does not exist: ${t}`),[];let n=await Ut.promises.readdir(t,{withFileTypes:!0}),r=[];for(let d of n){let o=at.join(t,d.name);if(d.isDirectory()){let c=await pn(o);r.push(...c)}else if(d.isFile()&&d.name.endsWith(".stx"))r.push(o)}return r}catch(n){return console.error(`Error finding component files in ${t}:`,n),[]}}async function Gr(t,n){try{if(!await s(t))return[];let r=await pn(t),d=[],o=new Map;if(n?.components?.length)for(let c of n.components)o.set(c.file,c);for(let c of r){let u=o.get(c),f=!!u,g=u?.tag,h=await Kr(c,f,g);d.push(h)}return d}catch(r){return console.error("Error generating component docs:",r),[]}}async function Jr(t){try{if(!await s(t))return[];let n=await Ut.promises.readdir(t,{withFileTypes:!0}),r=[];for(let d of n){if(!d.isFile()||!d.name.endsWith(".stx"))continue;let o=at.join(t,d.name),c=await Bun.file(o).text(),u=at.basename(o,".stx"),f=c.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||c.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//),g=f?f[1].split(`
|
|
1451
1451
|
`).map((b)=>b.trim().replace(/^\*\s*/,"")).join(" ").trim():"",h=/@component\(\s*['"]([^'"]+)['"]/g,x=/<([A-Z][a-zA-Z0-9]*|[a-z]+-[a-z0-9-]+)(?:\s[^>]*)?\/?>|\{\{\s*slot\s*\}\}/g,v=new Set,S;while((S=h.exec(c))!==null)v.add(S[1]);while((S=x.exec(c))!==null)if(S[1]&&S[1]!=="slot")v.add(S[1]);let T=/@([a-z]+)(?:\s*\(|\s+|$)/g,w=new Set;while((S=T.exec(c))!==null)w.add(S[1]);r.push({name:u,path:o,description:g,components:[...v],directives:[...w]})}return r}catch(n){return console.error("Error generating template docs:",n),[]}}async function Yr(t=[]){try{let n=[{name:"if",description:"Conditionally render content based on a condition",hasEndTag:!0,example:`@if(user.isLoggedIn)
|
|
1452
1452
|
<p>Welcome, {{ user.name }}!</p>
|
|
1453
1453
|
@endif`},{name:"else",description:"Provides an alternative if a condition is not met",hasEndTag:!1,example:`@if(user.isLoggedIn)
|
|
@@ -1581,15 +1581,15 @@ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.
|
|
|
1581
1581
|
<td>@${c.name}</td>
|
|
1582
1582
|
<td>${c.description||"-"}</td>
|
|
1583
1583
|
<td>${c.hasEndTag?"Yes":"No"}</td>
|
|
1584
|
-
</tr>`;o+="</tbody></table>";for(let c of r)if(c.example)o+=`<h3>@${c.name}</h3>`,o+=`<p>${c.description||""}</p>`,o+="<h4>Example</h4>",o+=`<pre><code>${c.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return o+="</body></html>",o}function eo(t=[],n=[],r=[],d){return JSON.stringify({components:t,templates:n,directives:r,extraContent:d||""},null,2)}async function to(t){try{let{componentsDir:n,templatesDir:r,webComponentsConfig:d,customDirectives:o,config:c}=t;if(!c.enabled)return!1;let u=c.outputDir||"docs";if(await Ut.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),n)console.log(`Components directory: ${n}`);if(r)console.log(`Templates directory: ${r}`);console.log(`Output directory: ${u}`);let f=[];if(c.components!==!1&&n)console.log("Generating component documentation..."),f=await Gr(n,d),console.log(`Found ${f.length} components`);let g=[];if(c.templates!==!1&&r)console.log("Generating template documentation..."),g=await Jr(r),console.log(`Found ${g.length} templates`);let h=[];if(c.directives!==!1)console.log("Generating directive documentation..."),h=await Yr(o),console.log(`Found ${h.length} directives`);let x=c.format||"markdown",v=c.extraContent,S="",T="";switch(x){case"markdown":S=Qr(f,g,h,v),T="md";break;case"html":S=Zr(f,g,h,v),T="html";break;case"json":S=eo(f,g,h,v),T="json";break;default:throw Error(`Unsupported documentation format: ${x}`)}let w=at.join(u,`stx-docs.${T}`);return await Bun.write(w,S),console.log(`Documentation generated: ${w}`),!0}catch(n){return console.error("Error generating documentation:",n),!1}}async function
|
|
1585
|
-
`;let d=t;if(r.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=
|
|
1584
|
+
</tr>`;o+="</tbody></table>";for(let c of r)if(c.example)o+=`<h3>@${c.name}</h3>`,o+=`<p>${c.description||""}</p>`,o+="<h4>Example</h4>",o+=`<pre><code>${c.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return o+="</body></html>",o}function eo(t=[],n=[],r=[],d){return JSON.stringify({components:t,templates:n,directives:r,extraContent:d||""},null,2)}async function to(t){try{let{componentsDir:n,templatesDir:r,webComponentsConfig:d,customDirectives:o,config:c}=t;if(!c.enabled)return!1;let u=c.outputDir||"docs";if(await Ut.promises.mkdir(u,{recursive:!0}),console.log("Generating documentation..."),n)console.log(`Components directory: ${n}`);if(r)console.log(`Templates directory: ${r}`);console.log(`Output directory: ${u}`);let f=[];if(c.components!==!1&&n)console.log("Generating component documentation..."),f=await Gr(n,d),console.log(`Found ${f.length} components`);let g=[];if(c.templates!==!1&&r)console.log("Generating template documentation..."),g=await Jr(r),console.log(`Found ${g.length} templates`);let h=[];if(c.directives!==!1)console.log("Generating directive documentation..."),h=await Yr(o),console.log(`Found ${h.length} directives`);let x=c.format||"markdown",v=c.extraContent,S="",T="";switch(x){case"markdown":S=Qr(f,g,h,v),T="md";break;case"html":S=Zr(f,g,h,v),T="html";break;case"json":S=eo(f,g,h,v),T="json";break;default:throw Error(`Unsupported documentation format: ${x}`)}let w=at.join(u,`stx-docs.${T}`);return await Bun.write(w,S),console.log(`Documentation generated: ${w}`),!0}catch(n){return console.error("Error generating documentation:",n),!1}}async function Yi(t){let n={enabled:!0,outputDir:t.output||"docs",format:t.format||"markdown",components:t.components!==!1,templates:t.templates!==!1,directives:t.directives!==!1,extraContent:t.extraContent},r=t.componentsDir||P.componentsDir,d=t.templatesDir||".";return to({componentsDir:r,templatesDir:d,webComponentsConfig:P.webComponents,customDirectives:P.customDirectives,config:n})}var fn={indentSize:2,useTabs:!1,maxLineLength:120,normalizeWhitespace:!0,sortAttributes:!1,trimTrailingWhitespace:!0};function io(t,n={}){let r={...fn,...n};if(t.trim()==="")return`
|
|
1585
|
+
`;let d=t;if(r.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,"");if(d=oo(d,r),d=uo(d,r),d=so(d,r),r.trimTrailingWhitespace)d=d.replace(/[ \t]+$/gm,""),d=d.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(d=d.replace(/\r\n/g,`
|
|
1586
1586
|
`).replace(/\r/g,`
|
|
1587
1587
|
`),!d.endsWith(`
|
|
1588
1588
|
`))d+=`
|
|
1589
|
-
`;return d}function
|
|
1589
|
+
`;return d}function Zi(t,n={}){let r={...fn,...n};if(t.trim()==="")return`
|
|
1590
1590
|
`;let d=t;if(d=d.replace(/^( *)```(html|stx)\n([\s\S]*?)^( *)```/gm,(o,c,u,f,g)=>{let h=f.split(`
|
|
1591
1591
|
`),x=h.filter((b)=>b.trim().length>0);if(x.length===0)return o;let v=Math.min(...x.map((b)=>{let k=b.match(/^( *)/);return k?k[1].length:0})),S=h.map((b)=>{if(b.trim().length===0)return"";return b.substring(v)}).join(`
|
|
1592
|
-
`),w=
|
|
1592
|
+
`),w=io(S,r).trimEnd().split(`
|
|
1593
1593
|
`).map((b)=>{if(b.trim().length===0)return"";return c+b}).join(`
|
|
1594
1594
|
`);return`${c}\`\`\`${u}
|
|
1595
1595
|
${w}
|
|
@@ -1611,10 +1611,10 @@ ${u}`}),n=n.replace(/(<\/[^>]+>)(?=<|$)/g,(o,c,u,f)=>{let g=f.substring(Math.max
|
|
|
1611
1611
|
`}),n=n.replace(new RegExp(`${d}(\\d+)__`,"g"),(o,c)=>r[Number.parseInt(c,10)]),n=n.replace(/\n{2,}/g,`
|
|
1612
1612
|
`),n=n.split(`
|
|
1613
1613
|
`).map((o)=>o.trim()).join(`
|
|
1614
|
-
`),n=n.replace(/^\n+/,"").replace(/\n+$/,""),n}function
|
|
1614
|
+
`),n=n.replace(/^\n+/,"").replace(/\n+$/,""),n}function oo(t,n){let d=ro(t).split(`
|
|
1615
1615
|
`),o=[],c=0,u=!1,f=n.useTabs?"\t":" ".repeat(n.indentSize);for(let g=0;g<d.length;g++){let h=d[g],x=h.trim();if(x===""){o.push("");continue}let v=x.match(/<script\b/i),S=x.match(/<\/script>/i);if(u&&!S){o.push(h);continue}let T=x===">";if(un(x)&&!x.startsWith("<")&&!x.startsWith("@")){o.push(f.repeat(c)+x);continue}let w=x.startsWith("@end"),b=x.startsWith("@else")||x.startsWith("@elseif"),k=x.startsWith("@")&&po(x),_=x.startsWith("<!DOCTYPE")||x.startsWith("<!doctype"),E=x.startsWith("<!--"),R=x.startsWith("</"),A=x.startsWith("<")&&!R&&!E&&!_,C=x.includes("/>")||lo(x),M=un(x);if(R||w)c=Math.max(0,c-1);let I=b?Math.max(0,c-1):c;if(T)o.push(h);else o.push(f.repeat(I)+x);if(A&&!C&&!M&&!T||k)c++;if(v)u=!0;if(S)u=!1}return o.join(`
|
|
1616
|
-
`)}function
|
|
1617
|
-
`)||o.includes("@"))return r;let c=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],f;while((f=c.exec(o))!==null)u.push({name:f[1],value:f[2]});u.sort((h,x)=>{if(h.name==="id")return-1;if(x.name==="id")return 1;if(h.name==="class")return-1;if(x.name==="class")return 1;return h.name.localeCompare(x.name)});let g=u.map((h)=>h.value?`${h.name}=${h.value}`:h.name).join(" ");return`<${d}${g?` ${g}`:""}>`})}import mn from"fs";import Wt from"path";async function
|
|
1616
|
+
`)}function so(t,n){if(t=t.replace(/@(if|elseif|foreach|for|while)\s*\(\s*([^)]+)\s*\)/g,(r,d,o)=>{let c=o.trim().replace(/\s+/g," ");return`@${d}(${c})`}),t=t.replace(/@(csrf|method)\s*\(\s*([^)]*)\s*\)/g,(r,d,o)=>{if(o.trim()==="")return`@${d}`;return`@${d}(${o.trim()})`}),n.normalizeWhitespace)t=t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(r,d)=>`{{ ${d.trim()} }}`),t=t.replace(/\{!!\s*([^!]+)\s*!!\}/g,(r,d)=>`{!! ${d.trim()} !!}`);return t}function lo(t){let n=["br","hr","img","input","meta","link","area","base","col","embed","source","track","wbr"];if(t.includes("/>"))return!0;let r=t.match(/<(\w+)/);if(r){let d=r[1];return n.includes(d.toLowerCase())}return!1}function un(t){return/<(\w+)(?:\s[^>]*)?>[\s\S]*?<\/\1>/.test(t)}function po(t){let n=["if","unless","foreach","for","while","section","push","component","slot","markdown","wrap","error"];for(let r of n)if(t.startsWith(`@${r}`))return!t.includes(`@end${r}`);return!1}function uo(t,n){if(!n.sortAttributes)return t;return t.replace(/<(\w+)([^>]*)>/g,(r,d,o)=>{if(!o.trim())return r;if(o.includes("<")||o.includes(`
|
|
1617
|
+
`)||o.includes("@"))return r;let c=/(\w+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,u=[],f;while((f=c.exec(o))!==null)u.push({name:f[1],value:f[2]});u.sort((h,x)=>{if(h.name==="id")return-1;if(x.name==="id")return 1;if(h.name==="class")return-1;if(x.name==="class")return 1;return h.name.localeCompare(x.name)});let g=u.map((h)=>h.value?`${h.name}=${h.value}`:h.name).join(" ");return`<${d}${g?` ${g}`:""}>`})}import mn from"fs";import Wt from"path";async function Qi(t="index.stx",n={}){try{let r=n.force||!1,d=Wt.resolve(process.cwd(),t);if(await Bun.file(d).exists()){if(!r)throw Error(`File ${t} already exists. Use --force to overwrite.`);console.warn(`File ${t} already exists. Overwriting...`)}let o=Wt.dirname(d);if(!mn.existsSync(o))mn.mkdirSync(o,{recursive:!0});let c;if(n.template){let u=Wt.resolve(process.cwd(),n.template);if(!await Bun.file(u).exists())throw Error(`Template file ${n.template} does not exist.`);if(!u.endsWith(".stx"))console.warn(`Warning: Template file ${n.template} does not have a .stx extension. Using it anyway.`);c=await Bun.file(u).text(),console.warn(`Using template from ${n.template}`)}else if(n.preset)c=hn(n.preset),console.warn(`Using '${n.preset}' preset template`);else c=hn("basic");return await Bun.write(d,c),console.warn(`Created new stx file: ${t}`),!0}catch(r){return console.error(`Error creating file: ${r instanceof Error?r.message:String(r)}`),!1}}function hn(t){switch(t){case"basic":return yn();case"component":return fo();case"layout":return go();case"blog":return ho();case"api":return yo();case"app":return bo();default:return yn()}}function yn(){return`<script>
|
|
1618
1618
|
const title = "My stx Page"
|
|
1619
1619
|
const description = "A page built with stx"
|
|
1620
1620
|
const features = [
|
|
@@ -1684,7 +1684,7 @@ const features = [
|
|
|
1684
1684
|
.card.collapsed .card__toggle { transform: rotate(-90deg); }
|
|
1685
1685
|
.card__body { padding: 1rem; }
|
|
1686
1686
|
.card.collapsed .card__body { display: none; }
|
|
1687
|
-
</style>`}function
|
|
1687
|
+
</style>`}function go(){return`<!DOCTYPE html>
|
|
1688
1688
|
<html lang="en">
|
|
1689
1689
|
<head>
|
|
1690
1690
|
<meta charset="UTF-8">
|
|
@@ -2040,5 +2040,5 @@ const features = [
|
|
|
2040
2040
|
})();
|
|
2041
2041
|
</script>
|
|
2042
2042
|
</body>
|
|
2043
|
-
</html>`}var
|
|
2044
|
-
`)}export{Ki,
|
|
2043
|
+
</html>`}var ea="f9c3713";function El(t){return t}function Tl(t){return t}function Ki(t,n){let r=[],d=`${n}=`;for(let o=0;o<t.length;o++){let c=t[o];if(c.startsWith(d)){let u=c.slice(d.length);if(u)r.push(u);continue}if(c===n){let u=t[o+1];if(u!==void 0&&!u.startsWith("-"))r.push(u),o++}}return r}import _e from"fs";import ye from"path";function Rn(t){try{return _e.statSync(t).mtimeMs}catch{return null}}function Rt(t,n){let r=Math.max(0,Math.round((n-t)/1000));if(r<60)return`${r}s ago`;if(r<3600)return`${Math.round(r/60)}m ago`;return`${Math.round(r/3600)}h ago`}function $i(t,n){try{return globalThis.Bun?.resolveSync(t,n)??null}catch{return null}}function En(t,n="stx"){let r=ye.resolve(t);for(let d=0;d<10;d++){let o=ye.join(r,"pantry","@stacksjs",n);if(_e.existsSync(o))return o;let c=ye.dirname(r);if(c===r)break;r=c}return null}var Pn=["@stacksjs/stx","bun-plugin-stx"];function Ci(t){try{let n=_e.readFileSync(ye.join(t,"package.json"),"utf8"),r=JSON.parse(n)?.version;return typeof r==="string"?r:null}catch{return null}}function Ri(t,n=6){let r=ye.resolve(t),d=[],o=new Set;function c(f,g){if(g>n)return;let h;try{h=_e.realpathSync(f)}catch{return}if(o.has(h))return;o.add(h);for(let v of Pn){let S=ye.join(f,v),T=Ci(S);if(T!==null)d.push({name:v,version:T,dir:ye.relative(r,S)||S,nested:g>0})}let x;try{x=_e.readdirSync(f,{withFileTypes:!0})}catch{return}for(let v of x){if(!v.isDirectory()&&!v.isSymbolicLink())continue;if(v.name===".bin"||v.name===".cache")continue;let S=ye.join(f,v.name);if(v.name.startsWith("@")){let w;try{w=_e.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let b of w){let k=ye.join(S,b.name,"node_modules");if(_e.existsSync(k))c(k,g+1)}continue}let T=ye.join(S,"node_modules");if(_e.existsSync(T))c(T,g+1)}}let u=ye.join(r,"node_modules");if(_e.existsSync(u))c(u,0);return d}function Ei(t){let n=[];for(let r of Pn){let d=t.filter((u)=>u.name===r);if(d.length<=1)continue;let o=[...new Set(d.map((u)=>u.version))],c=d.map((u)=>`${u.version} at ${u.dir}`).join("; ");if(o.length===1){n.push({name:`${r} copies`,status:"info",detail:`${d.length} copies, all ${o[0]} \u2014 duplicated but in agreement`});continue}n.push({name:`${r} copies disagree`,status:"error",detail:`${o.length} versions installed, so which one runs depends on who imports it: ${c}`,fix:`remove the nested copies, or add an overrides entry pinning ${r}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${r}/package.json' -exec grep -H '"version"' {} +`})}return n}async function ao(t={}){let n=t.cwd?ye.resolve(t.cwd):process.cwd(),r=t.resolve??$i,d=Date.now(),o=[],c=r("@stacksjs/stx",n);o.push(c?{name:"@stacksjs/stx resolves to",status:"ok",detail:c}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let u=r("bun-plugin-stx",n);if(u)o.push({name:"bun-plugin-stx resolves to",status:"ok",detail:u});for(let g of Ei(Ri(n)))o.push(g);let f=En(n,"stx");if(!f)o.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let g=ye.join(f,"src/signals.ts"),h=[ye.join(f,"dist/index.js"),ye.join(f,"dist/signals.js")].find((w)=>_e.existsSync(w))||null,x=Rn(g),v=h?Rn(h):null;if(x==null)o.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${f} but no src/signals.ts to compare`});else if(v==null)o.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 ${f} && bun build.ts`});else if(v<x){let w=Math.round((x-v)/1000);o.push({name:"pantry dist freshness",status:"error",detail:`dist (${Rt(v,d)}) is OLDER than src/signals.ts (${Rt(x,d)}) by ${w}s \u2014 your edit isn't built`,fix:`cd ${f} && bun build.ts`})}else o.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${Rt(x,d)}, dist ${Rt(v,d)})`});let S=ye.join(n,"node_modules/@stacksjs/stx"),T=null;try{T=_e.lstatSync(S)}catch{T=null}if(!T)o.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(T.isSymbolicLink()){let w=null;try{w=_e.realpathSync(S)}catch{}let b=(()=>{try{return _e.realpathSync(f)}catch{return f}})();o.push(w===b?{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 o.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(o.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let h=t.generateRuntime().length;o.push(h>1000?{name:"signals runtime",status:"ok",detail:`generated ${h.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${h} chars \u2014 suspiciously short`})}catch(g){o.push({name:"signals runtime",status:"error",detail:`failed to generate: ${g.message}`})}return{checks:o,ok:!o.some((g)=>g.status==="error")}}function co(t){let n={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},r=["stx runtime resolution:"];for(let d of t.checks)if(r.push(` ${n[d.status]} ${d.name}: ${d.detail}`),d.fix)r.push(` \u2192 ${d.fix}`);return r.push(""),r.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),r.join(`
|
|
2044
|
+
`)}export{Ki,Gi,Ji,Yi,io,Zi,Qi,ea,El,Tl,ao,co,zr,Hr,Vr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_}from"./chunk-
|
|
2
|
+
import{_}from"./chunk-wp6bdac7.js";import{i}from"./chunk-e37g6ezw.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -16,9 +16,9 @@ ${e.bold}Markdown:${e.reset}`),a.forEach((c)=>console.log(` ${e.blue}${c}${e.re
|
|
|
16
16
|
${e.bold}Other:${e.reset}`),d.forEach((c)=>console.log(` ${e.dim}${c}${e.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}let s=(await Bun.file(n).text()).split(`
|
|
17
17
|
`);console.log(),s.forEach((l,a)=>{let d=String(a+1).padStart(3," ");console.log(`${e.dim}${d}${e.reset} ${l}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a JSON file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}try{let r=await Bun.file(n).text(),s=JSON.parse(r);o.context={...o.context,...s},console.log(`${e.green}\u2713${e.reset} Loaded ${Object.keys(s).length} variables from ${t[0]}`)}catch(r){console.log(`${e.red}Error parsing JSON:${e.reset}`,r)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file name${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);try{await Bun.write(n,JSON.stringify(o.context,null,2)),console.log(`${e.green}\u2713${e.reset} Context saved to ${t[0]}`)}catch(r){console.log(`${e.red}Error saving file:${e.reset}`,r)}}},history:{description:"Show command history",usage:"history [count]",handler:async(t,o)=>{let n=t[0]?Number.parseInt(t[0],10):20,r=o.history.slice(-n);if(r.length===0){console.log(`${e.dim}No history${e.reset}`);return}console.log(),r.forEach((s,l)=>{let a=String(o.history.length-r.length+l+1).padStart(3," ");console.log(`${e.dim}${a}${e.reset} ${s}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async(t,o)=>{o.running=!1,console.log(`
|
|
18
18
|
${e.dim}Goodbye!${e.reset}
|
|
19
|
-
`)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async(t,o)=>u.exit.handler(t,o)}};function h(t,o){let n=t.split(" "),r=n[0];if(n.length===1)return Object.keys(u).filter((s)=>s.startsWith(r));if(["render","cat","load","cd"].includes(r)){let s=n.slice(1).join(" "),l=g.dirname(s)||".",a=g.basename(s),d=g.resolve(o.cwd,l);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${l==="."?"":`${l}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let s=n[1]||"";return Object.keys(o.context).filter((l)=>l.startsWith(s)).map((l)=>`${r} ${l}`)}return[]}async function
|
|
19
|
+
`)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async(t,o)=>u.exit.handler(t,o)}};function h(t,o){let n=t.split(" "),r=n[0];if(n.length===1)return Object.keys(u).filter((s)=>s.startsWith(r));if(["render","cat","load","cd"].includes(r)){let s=n.slice(1).join(" "),l=g.dirname(s)||".",a=g.basename(s),d=g.resolve(o.cwd,l);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${l==="."?"":`${l}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let s=n[1]||"";return Object.keys(o.context).filter((l)=>l.startsWith(s)).map((l)=>`${r} ${l}`)}return[]}async function Ug(t={}){let o={context:t.context||{},cwd:t.cwd||process.cwd(),history:[],running:!0,lastResult:null},n=y.createInterface({input:process.stdin,output:process.stdout,completer:(s)=>[h(s,o),s],historySize:t.maxHistory||100});console.log(`
|
|
20
20
|
${e.bold}${e.blue}stx Interactive Mode${e.reset}
|
|
21
21
|
${e.dim}Type 'help' for available commands, 'exit' to quit${e.reset}
|
|
22
22
|
`);let r=()=>{let s=o.cwd.replace(process.env.HOME||"","~");n.question(`${e.cyan}stx${e.reset} ${e.dim}${s}${e.reset} ${e.green}>${e.reset} `,async(l)=>{let a=l.trim();if(!a){if(o.running)r();return}o.history.push(a);let d=a.match(/(?:[^\s"]|"[^"]*")+/g)||[],c=d[0]?.toLowerCase(),f=d.slice(1).map((m)=>m.replace(/^"|"$/g,""));if(c&&u[c])try{await u[c].handler(f,o)}catch(m){console.log(`${e.red}Error:${e.reset}`,m)}else if(c)if(a.includes("{{")||a.includes("}}"))try{let m=await _(a,o.context,"eval");console.log(`${e.green}\u2192${e.reset} ${m}`)}catch{console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`)}else console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`);if(o.running)r();else n.close()})};n.on("SIGINT",()=>{console.log(`
|
|
23
23
|
${e.dim}(Use 'exit' to quit)${e.reset}`),r()}),r()}
|
|
24
|
-
export{
|
|
24
|
+
export{Ug};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-t65tn8ee.js";import{A,En}from"./chunk-2yxva96k.js";import{Ie,C,Y}from"./chunk-wp6bdac7.js";import{a}from"./chunk-9x62j5f0.js";import{he,nn,rn,sn}from"./chunk-3x598qjt.js";import{wt}from"./chunk-9k6tza24.js";import{mt,zn,Gt,ce}from"./chunk-tsvnhc0c.js";import{E,Cn}from"./chunk-w0zayhmg.js";import M from"fs";import b from"path";import x from"process";function B(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function R(s,o=E()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${rn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ce(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>he(l))])],f=mt(i()),u=Gt(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ce(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=Y({loader:"ts",target:"browser",define:C()});for(let l of p)try{let c=await Bun.file(l).text(),_=b.basename(l,".ts"),y=new Set;B(c,y);let v=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((U)=>U[2]),N=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(nn(c))c=await sn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=wt(c),c=A(c),c=En(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:_,ids:v.length===N?v:[],declared:y,code:`// Store: ${_}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return ce(h,t,f,{chunks:[]}),null;f=mt(i());let S={chunks:g};return ce(h,t,f,S),S}function j(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -12,7 +12,7 @@ var __stx = window.stx || {};
|
|
|
12
12
|
${k.filter((i)=>!n.has(i)&&new RegExp(`\\b${i}\\b`).test(e.code)).map((i)=>`var ${i} = __stx[${JSON.stringify(i)}];`).join(`
|
|
13
13
|
`)}
|
|
14
14
|
${e.code}
|
|
15
|
-
}`})}var z=new WeakMap;async function
|
|
15
|
+
}`})}var z=new WeakMap;async function nh(s){let o=await R(s);if(!o)return null;let e=z.get(o);if(e===void 0)e=j(o.chunks),z.set(o,e);return e}function W(s){if(!/\buseStore\b/.test(s))return!1;if(/\buseStore\s+as\s+[A-Za-z_$]/.test(s))return!0;if(/\{[^{}]*\buseStore\s*:\s*[A-Za-z_$[{][^{}]*\}\s*=(?!=)/.test(s))return!0;if(/\[\s*(['"`])useStore\1\s*\]/.test(s.replace(/\b(?:var|let|const)\s+useStore\s*=\s*[\w$.]*\[\s*(['"`])useStore\1\s*\]/g," ")))return!0;let o=s.replace(/\/\*[\s\S]*?\*\//g," ").replace(/(^|[^:\\'"`])\/\/[^\n]*/g,"$1 ").replace(/\b(?:var|let|const)\s+useStore\s*=\s*[\w$.]*\[\s*(['"`])useStore\1\s*\]/g," ").replace(/\b(?:const|let|var)\s*\{[^{}]*\}\s*=/g," ").replace(/\bimport\s*(?:type\s+)?\{[^{}]*\}\s*from\b/g," ").replace(/\bexport\s*(?:type\s+)?\{[^{}]*\}/g," ").replace(/\btypeof\s+useStore\b/g," ").replace(/(['"`])useStore\1/g," ");for(let e of o.matchAll(/\buseStore\b/g)){let t=o.slice(Math.max(0,e.index-9),e.index);if(/\bfunction\s*$/.test(t))continue;let n=o.slice(e.index+8).trimStart();if(n.startsWith("(")||n.startsWith("<")||n.startsWith("?.("))continue;if(/^=(?![=>])/.test(n))continue;return!0}return!1}function bo(...s){let o=new Set,e=!1;for(let t of s){if(!t)continue;if(/__STX_STORES__|\b_stores\b/.test(t))e=!0;if(W(t))e=!0;let n=t.match(/\buseStore\s*(?:<[^>()]*>)?\s*(?:\?\.\s*)?\(/g)?.length??0;if(n===0)continue;let r=0;for(let i of t.matchAll(/\buseStore\s*(?:<[^>()]*>)?\s*(?:\?\.\s*)?\(\s*(['"`])([^'"`$\\]+)\1\s*[,)]/g))o.add(i[2]),r++;if(r!==n)e=!0}return{names:o,all:e}}var F=new Map;function rh(s){let o=new Set,e=!1;for(let t of s){if(/\.(?:css|json|svg|wasm|png|jpe?g|gif|webp|avif|woff2?|ttf|txt|md)$/i.test(t))continue;let n;try{let r=M.statSync(t),i=F.get(t);if(i&&i.mtimeMs===r.mtimeMs&&i.size===r.size)n=i.read;else n=bo(M.readFileSync(t,"utf8")),F.set(t,{mtimeMs:r.mtimeMs,size:r.size,read:n})}catch{n={names:new Set,all:!0}}if(n.all)e=!0;for(let r of n.names)o.add(r)}return{names:o,all:e}}function sh(s=x.env){return s.STX_PAGE_STORES==="all"}async function oh(s,o,e={}){let t=await R(s,e.sharedModules);if(!t)return null;let{chunks:n}=t,r=bo(...o);if(e.reads){if(e.reads.all)r.all=!0;for(let u of e.reads.names)r.names.add(u)}let i=e.runOnce?Z(t):void 0,f;if(e.all||r.all||n.some((u)=>u.ids.length===0)||i===null)f=n;else{let u=new Map;for(let d of n)for(let S of d.ids)u.set(S,d);let m=new Set,p=[...r.names],g=!1;while(p.length>0&&!g){let d=u.get(p.pop());if(!d||m.has(d))continue;m.add(d);let S=bo(d.code);if(S.all)g=!0;else p.push(...S.names)}f=g?n:n.filter((d)=>m.has(d))}if(f.length===0)return null;if(i){let u=f.map((d)=>i.get(d)),m=f.map((d)=>d.name),p=O.get(t);if(!p)O.set(t,p=new Map);let g=p.get(m.join("\x00"));if(g===void 0)p.set(m.join("\x00"),g=P(m,u));return{code:g,stores:m,functions:u}}return{code:j(f),stores:f.map((u)=>u.name),functions:I(f)}}var O=new WeakMap,w=new WeakMap;function Z(s){if(w.has(s))return w.get(s);let o=I(s.chunks),e=o?new Map(s.chunks.map((t,n)=>[t,o[n]])):null;return w.set(s,e),e}function P(s,o){let t=`;(function(){
|
|
16
16
|
var ran = window.__stxStoreFiles || (window.__stxStoreFiles = {});
|
|
17
17
|
function run(name, define) {
|
|
18
18
|
if (ran[name]) return;
|
|
@@ -22,5 +22,5 @@ function run(name, define) {
|
|
|
22
22
|
}
|
|
23
23
|
${s.map((n,r)=>`run(${JSON.stringify(n)}, ${o[r]})`).join(`;
|
|
24
24
|
`)};
|
|
25
|
-
})();`;return E()?Cn(t):t}function
|
|
26
|
-
export{
|
|
25
|
+
})();`;return E()?Cn(t):t}function ih(){h.clear(),zn()}
|
|
26
|
+
export{nh,bo,rh,sh,oh,ih};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{nh,bo,rh,sh,oh,ih}from"./chunk-xskswvef.js";import"./chunk-3x598qjt.js";import"./chunk-0beyn8ak.js";import"./chunk-7sh9fa3q.js";import"./chunk-9k6tza24.js";import"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-9x62j5f0.js";import"./chunk-3mby4nes.js";import"./chunk-2ws2qe1k.js";import"./chunk-qpvwxppw.js";import"./chunk-7bxnjr3b.js";import"./chunk-qjbpa1n4.js";import"./chunk-wp6bdac7.js";import"./chunk-zbv8e4rq.js";import"./chunk-akcyaxwv.js";import"./chunk-4v50nafp.js";import"./chunk-2yxva96k.js";import"./chunk-t65tn8ee.js";export{ih as clearStoreCache,nh as getStoreScript,oh as getStoreScriptFor,sh as pageStoresAll,bo as storesRead,rh as storesReadInFiles};
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function Ue(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function Tn(e){if(e.entries.length===0)return"[]";return`[
|
|
3
3
|
${e.entries.map((t)=>` { url: '${t.url}', revision: '${t.revision}' }`).join(`,
|
|
4
4
|
`)}
|
|
5
|
-
]`}function
|
|
6
|
-
export{Ue,Tn,
|
|
5
|
+
]`}function Oi(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(2)} MB`}
|
|
6
|
+
export{Ue,Tn,Oi};
|