@stacksjs/stx 0.2.648 → 0.2.654
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-17srvghf.js +2 -0
- package/dist/{chunk-nt0n0vjm.js → chunk-1zb7ar32.js} +2 -2
- package/dist/{chunk-e87xa4r3.js → chunk-26whq1rg.js} +2 -2
- package/dist/{chunk-k79x96ra.js → chunk-28jtt8hn.js} +42 -42
- package/dist/{chunk-zsgcsqat.js → chunk-2yg9y1na.js} +99 -99
- package/dist/{chunk-481d4kr9.js → chunk-2zqg980j.js} +1 -1
- package/dist/{chunk-x5tjb4y4.js → chunk-35zjpdcb.js} +1 -1
- package/dist/chunk-3634ds4n.js +2 -0
- package/dist/{chunk-nj1t4g3a.js → chunk-36649w15.js} +6 -6
- package/dist/chunk-3msbc4zj.js +2 -0
- package/dist/chunk-3q3gsr7m.js +2 -0
- package/dist/{chunk-3q163st5.js → chunk-3v8yejzc.js} +3 -3
- package/dist/chunk-42v0vegr.js +2 -0
- package/dist/{chunk-2jh21f1n.js → chunk-46w53nj5.js} +1 -1
- package/dist/{chunk-0jhdrgpr.js → chunk-48acjmeg.js} +2 -2
- package/dist/{chunk-55zaxb4s.js → chunk-4e0z858k.js} +10 -10
- package/dist/{chunk-yq021b3r.js → chunk-4nbq7mnp.js} +4 -4
- package/dist/{chunk-7rta163c.js → chunk-4qwvqbzf.js} +2 -2
- package/dist/{chunk-hjm69qnj.js → chunk-50pkybyn.js} +1 -1
- package/dist/{chunk-88z4wkrj.js → chunk-5yxd4ryz.js} +2 -2
- package/dist/{chunk-vqc4h16r.js → chunk-6598d3m6.js} +2 -2
- package/dist/{chunk-ab7zqtax.js → chunk-6raq8r7w.js} +1 -1
- package/dist/{chunk-zmh9p9aa.js → chunk-6rparhvs.js} +1 -1
- package/dist/{chunk-t1k9160w.js → chunk-71mthavp.js} +32 -32
- package/dist/chunk-73swyb5p.js +2 -0
- package/dist/{chunk-b0hpshvk.js → chunk-7wnd2psp.js} +1 -1
- package/dist/{chunk-ymymwzt5.js → chunk-8gewq710.js} +1 -1
- package/dist/{chunk-3zyjqvsq.js → chunk-929zbzh7.js} +9 -9
- package/dist/{chunk-v2x9vzgw.js → chunk-9y2ncrnq.js} +2 -2
- package/dist/{chunk-c9k40352.js → chunk-a2a74f6c.js} +1 -1
- package/dist/{chunk-67xhsacd.js → chunk-bgt1dx8c.js} +1 -1
- package/dist/chunk-c9b0cme2.js +2 -0
- package/dist/{chunk-89yj6tcd.js → chunk-cq40n7ak.js} +1 -1
- package/dist/{chunk-f46ht5kq.js → chunk-cvw7gknw.js} +3 -3
- package/dist/chunk-d0xcykw6.js +2 -0
- package/dist/{chunk-vdxjy7j2.js → chunk-d3bsfd10.js} +2 -2
- package/dist/{chunk-rjh2jwxx.js → chunk-d4tf0tfn.js} +4 -4
- package/dist/chunk-dxjc11hx.js +2 -0
- package/dist/{chunk-zhf01af3.js → chunk-dxk5sqtv.js} +2 -2
- package/dist/chunk-edz1h5f9.js +2 -0
- package/dist/{chunk-fg3jw17w.js → chunk-en8jgavy.js} +6 -5
- package/dist/chunk-etw04j02.js +2 -0
- package/dist/chunk-ewng6v6g.js +49 -0
- package/dist/{chunk-9121nkpj.js → chunk-ex1kd5gs.js} +3 -3
- package/dist/chunk-fbd9w4ys.js +2 -0
- package/dist/{chunk-qfe7ps3v.js → chunk-ff1cb7k4.js} +2 -2
- package/dist/chunk-fnj3gja0.js +2 -0
- package/dist/chunk-fsnby15p.js +2 -0
- package/dist/{chunk-pbtkbe48.js → chunk-g7j3mwzd.js} +18 -18
- package/dist/{chunk-3p7mk3mw.js → chunk-gmrc24cb.js} +1 -1
- package/dist/{chunk-p44kmbdg.js → chunk-h09a03ay.js} +4 -4
- package/dist/chunk-h0bg2h0j.js +2 -0
- package/dist/{chunk-wjt0kej9.js → chunk-h4vg78mw.js} +1 -1
- package/dist/{chunk-4q2dtxdk.js → chunk-hjmnsa6a.js} +1 -1
- package/dist/{chunk-er60h3j3.js → chunk-ht3dxx5m.js} +1 -1
- package/dist/{chunk-h5nmf98w.js → chunk-hw7sv4ac.js} +1 -1
- package/dist/{chunk-pg0xzsss.js → chunk-j2bkjtp3.js} +4 -4
- package/dist/chunk-j3472s37.js +3 -0
- package/dist/chunk-jmx4q1yr.js +2 -0
- package/dist/{chunk-j393gsfd.js → chunk-k49fg322.js} +2 -2
- package/dist/{chunk-0vkawews.js → chunk-k7nan28e.js} +5 -5
- package/dist/{chunk-06w0z1cm.js → chunk-kcrtqyek.js} +4 -4
- package/dist/{chunk-t2pzy3x1.js → chunk-khvc43pq.js} +2 -2
- package/dist/{chunk-qm4672dj.js → chunk-ktvr9ta8.js} +2 -2
- package/dist/{chunk-wq6j2h32.js → chunk-m47spkxr.js} +7 -7
- package/dist/chunk-m947aq9a.js +2 -0
- package/dist/{chunk-jkaszw24.js → chunk-mgj34bbg.js} +1 -1
- package/dist/{chunk-r1r6311d.js → chunk-n7xbhzzt.js} +4 -4
- package/dist/chunk-ndtxkps4.js +2 -0
- package/dist/{chunk-np4zm2ph.js → chunk-nttspz8c.js} +4 -4
- package/dist/chunk-pge3bzqx.js +2 -0
- package/dist/{chunk-9txn4rvb.js → chunk-phws2c9s.js} +1 -1
- package/dist/{chunk-j5gd0e53.js → chunk-q1x7ckfw.js} +1 -1
- package/dist/chunk-q79ksfcd.js +2 -0
- package/dist/chunk-qjf1c8fa.js +2 -0
- package/dist/{chunk-gv793yqq.js → chunk-qrt8b179.js} +2 -2
- package/dist/{chunk-w2zceynt.js → chunk-qygynhzc.js} +1 -1
- package/dist/{chunk-6ea6az61.js → chunk-ra56jh7e.js} +1 -1
- package/dist/chunk-rmdw6s65.js +2 -0
- package/dist/chunk-s0crnpyx.js +2 -0
- package/dist/{chunk-8p9kpfk8.js → chunk-s4cs2n2c.js} +1 -1
- package/dist/{chunk-t82be9yf.js → chunk-sd4jwn3y.js} +1 -1
- package/dist/chunk-t7j4h3nf.js +128 -0
- package/dist/{chunk-sgptbhrc.js → chunk-v9bmw06j.js} +1 -1
- package/dist/{chunk-gz90fqn8.js → chunk-vmn2b6p6.js} +1 -1
- package/dist/{chunk-aprhqxky.js → chunk-vngnface.js} +3 -3
- package/dist/{chunk-0h8tg21j.js → chunk-vs8kg85h.js} +1 -1
- package/dist/{chunk-84djpte6.js → chunk-wbzmr6a4.js} +2 -2
- package/dist/{chunk-ye8tgmd3.js → chunk-wh838rdh.js} +1 -1
- package/dist/{chunk-xm2mee4a.js → chunk-x9d4bpmh.js} +21 -21
- package/dist/{chunk-mnp8ecj9.js → chunk-xdgvb5a5.js} +1 -1
- package/dist/{chunk-pxs7sgnp.js → chunk-xhmpfq9d.js} +1 -1
- package/dist/{chunk-hfpv56cp.js → chunk-xq410rsc.js} +1 -1
- package/dist/{chunk-xvs04cnp.js → chunk-y8881za3.js} +1 -1
- package/dist/chunk-z75bp57x.js +2 -0
- package/dist/{chunk-8d2f2e42.js → chunk-znnfjxph.js} +1 -1
- package/dist/chunk-zrqremja.js +2 -0
- package/dist/cli.js +11 -11
- package/dist/client/signals-head-runtime.js +2 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/expressions.js +9 -0
- package/dist/interpolation-context.d.ts +2 -0
- package/dist/interpolation-context.js +8 -0
- package/dist/native/bridge/protocol.d.ts +2 -0
- package/dist/native/compiler/bundle.d.ts +6 -0
- package/dist/native/compiler/bundle.js +16 -9
- package/dist/native/compiler/headwind-to-style.d.ts +5 -1
- package/dist/native/compiler/headwind-to-style.js +188 -3
- package/dist/native/compiler/html-to-ir.d.ts +2 -1
- package/dist/native/compiler/html-to-ir.js +9 -4
- package/dist/native/compiler/ir.d.ts +15 -0
- package/dist/native/compiler/layout-chrome.d.ts +6 -0
- package/dist/native/compiler/layout-chrome.js +72 -0
- package/dist/native/compiler/render-screen.js +19 -3
- package/dist/native/compiler/style-config.d.ts +32 -0
- package/dist/native/compiler/style-config.js +71 -0
- package/dist/native/compiler/stylesheet-rules.d.ts +17 -0
- package/dist/native/compiler/stylesheet-rules.js +107 -0
- package/dist/native/runtime/browser-screen.js +11 -0
- package/dist/native/runtime/craft-bridge.d.ts +3 -0
- package/dist/native/runtime/craft-bridge.js +41 -4
- package/dist/native/runtime/jsc-globals.d.ts +2 -0
- package/dist/native/runtime/jsc-globals.js +8 -1
- package/dist/native/runtime/native-host.d.ts +5 -0
- package/dist/native/runtime/native-host.js +48 -5
- package/dist/native/runtime/shared-screen.js +18 -2
- package/dist/native/runtime/web-navigation.d.ts +33 -0
- package/dist/native/runtime/web-navigation.js +107 -0
- package/dist/native/runtime/web-storage.d.ts +56 -0
- package/dist/native/runtime/web-storage.js +89 -0
- package/dist/native/testing.d.ts +3 -0
- package/dist/native/testing.js +3 -0
- package/dist/native-signing.d.ts +2 -0
- package/dist/native-signing.js +13 -4
- package/dist/process.js +2 -0
- package/dist/pwa.js +3 -3
- package/dist/reactive-bindings.js +3 -1
- package/dist/ssg.js +12 -12
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-0en5jwjy.js +0 -2
- package/dist/chunk-2n3pa5gm.js +0 -2
- package/dist/chunk-354jmw2k.js +0 -3
- package/dist/chunk-3b5bphcn.js +0 -2
- package/dist/chunk-57md41g9.js +0 -2
- package/dist/chunk-6vh8s0pg.js +0 -2
- package/dist/chunk-8fsq2ynj.js +0 -2
- package/dist/chunk-8tpmz4as.js +0 -2
- package/dist/chunk-9x0zt65f.js +0 -2
- package/dist/chunk-a2bw46t9.js +0 -2
- package/dist/chunk-a4sggwcz.js +0 -2
- package/dist/chunk-b4fd2dtk.js +0 -2
- package/dist/chunk-c1479y92.js +0 -2
- package/dist/chunk-embejqx4.js +0 -2
- package/dist/chunk-eyfxw7ds.js +0 -2
- package/dist/chunk-f3y4fnaa.js +0 -2
- package/dist/chunk-f7930sce.js +0 -2
- package/dist/chunk-fsbjat59.js +0 -2
- package/dist/chunk-h15xb2vd.js +0 -2
- package/dist/chunk-m6qfqkbh.js +0 -2
- package/dist/chunk-ncqh5qe5.js +0 -2
- package/dist/chunk-radggg3p.js +0 -49
- package/dist/chunk-sszhz1zh.js +0 -2
- package/dist/chunk-weqc0ssb.js +0 -2
- package/dist/chunk-xfzcv0jc.js +0 -2
- package/dist/chunk-y9x4pyp2.js +0 -2
- package/dist/chunk-zdnc7a4t.js +0 -127
- package/dist/chunk-zyqs6a3p.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{w}from"./chunk-
|
|
2
|
+
import{w}from"./chunk-4e0z858k.js";function Ge(e,r){let n=v(e,r);return n.ok?{expression:n.expression,endPos:n.endPos}:null}function v(e,r){let n=r;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]!=="(")return{ok:!1,reason:"missing-open-paren",pos:n};let c=w(e,"(",")",n);if(c===-1)return{ok:!1,reason:"unclosed-paren",pos:n};return{ok:!0,expression:e.slice(n+1,c),endPos:c+1}}function y(e,r){let n=e.lastIndexOf("<",r);if(n===-1)return!1;return n>e.lastIndexOf(">",r)}function ht(e,r,n,c){let o=1,i=c,u=new RegExp(`@${r}\\s*\\(`,"g"),a=new RegExp(`@${n}(?![a-z])`,"g");while(i<e.length&&o>0){u.lastIndex=i,a.lastIndex=i;let p=u.exec(e),t=a.exec(e),s=p?p.index:1/0,f=t?t.index:1/0;if(s<f)o++,i=s+p[0].length;else if(f<1/0){if(o--,o===0)return f;i=f+t[0].length}else break}return-1}function P(e,r){let n=e.slice(r).match(/^@if\s*/);if(!n)return null;let c=r+n[0].length,o=Ge(e,c);if(!o)return null;let i=o.endPos,u=ht(e,"if","endif",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s="if",f=o.expression,l=0,x=0;while(t<a.length){let h=a.indexOf("@",t);if(h===-1)break;t=h;let d=a.substring(h);if(y(a,h)){t++;continue}if(/^@if\s*\(/.test(d)){x++,t++;continue}if(/^@endif(?![a-z])/.test(d)){x--,t+=6;continue}if(x===0){let g=d.match(/^@elseif\s*/);if(g){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t});let m=t+g[0].length,b=Ge(a,m);if(!b){t++;continue}s="elseif",f=b.expression,t=b.endPos,l=t;continue}else if(/^@else(?![a-z])/.test(d)){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t}),s="else",f=void 0,t+=5,l=t;continue}}t++}return p.push({type:s,condition:f,content:a.slice(l),start:i+l,end:i+a.length}),{fullMatch:e.slice(r,u+6),branches:p,start:r,end:u+6}}function tn(e){let r=[],n=/@if\s*\(/g,c=n.exec(e);while(c!==null){if(r.some((u)=>c.index>u.start&&c.index<u.end)){c=n.exec(e);continue}let i=P(e,c.index);if(i)r.push(i),n.lastIndex=i.end;c=n.exec(e)}return r}function Ur(e,r,n){let c=[],o=new RegExp(`@${r}\\s*\\(`,"g"),i=o.exec(e);while(i!==null){if(c.some((d)=>i.index>d.start&&i.index<d.end)){i=o.exec(e);continue}let a=i.index,p=a+i[0].length-1,t=w(e,"(",")",p);if(t===-1){i=o.exec(e);continue}let s=e.slice(p+1,t),f=t+1,l=ht(e,r,n,f);if(l===-1){i=o.exec(e);continue}let x=e.slice(f,l),h=l+`@${n}`.length;c.push({fullMatch:e.slice(a,h),name:r,params:s,content:x,start:a,end:h}),o.lastIndex=h,i=o.exec(e)}return c}function lo(e,r){let n=e.slice(r).match(/^@switch\s*/);if(!n)return null;let c=r+n[0].length,o=Ge(e,c);if(!o)return null;let i=o.endPos,u=ht(e,"switch","endswitch",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s=null,f=0;while(t<a.length){let l=a.slice(t),x=l.match(/^@switch\s*\(/),h=l.match(/^@endswitch(?![a-z])/);if(x){if(f++,s)s.content+=x[0];t+=x[0].length;continue}if(h){if(f--,s)s.content+=h[0];t+=h[0].length;continue}if(f>0){if(s)s.content+=a[t];t++;continue}let d=l.match(/^@case\s*/),g=l.match(/^@default(?![a-z])/),m=l.match(/^@break(?![a-z])/);if(d&&l.startsWith("@case")){if(s)p.push(s);let b=t+d[0].length,E=Ge(a,b);if(!E){t++;continue}s={type:"case",value:E.expression,content:""},t=E.endPos}else if(g&&l.startsWith("@default")){if(s)p.push(s);s={type:"default",content:""},t+=g[0].length}else if(m&&l.startsWith("@break"))t+=m[0].length;else{if(s)s.content+=a[t];t++}}if(s)p.push(s);return{fullMatch:e.slice(r,u+10),expression:o.expression,cases:p,start:r,end:u+10}}export{Ge,ht,tn,Ur,lo};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{te,
|
|
2
|
+
import{te,ae,cn,Rt,At,f,n,de,m}from"./chunk-2yg9y1na.js";import{ft,Ee,ta,Ys,s}from"./chunk-g7j3mwzd.js";import{re,ur,ve,D,hn}from"./chunk-4e0z858k.js";import{bt,Zn,Zr,Qr,es,vt,wt,xt,St,kt,Ct,Xe}from"./chunk-qrt8b179.js";import{qr,i,R}from"./chunk-3v8yejzc.js";import{lt,_i,xe,O,Ei,js,$r,ze,Ti,Se}from"./chunk-kcrtqyek.js";import{Xn,Jn}from"./chunk-xhmpfq9d.js";import{xn}from"./chunk-h4vg78mw.js";import{e,en,Wn,h}from"./chunk-ff1cb7k4.js";import{We}from"./chunk-ewng6v6g.js";import{_e}from"./chunk-9y2ncrnq.js";import{V,ge,me}from"./chunk-n7xbhzzt.js";import{c}from"./chunk-dxk5sqtv.js";import{H}from"./chunk-j3472s37.js";async function Fn(t){try{let r=await Bun.file(t).text(),o=zn(r),d=Nn(r,t),a=Un(r,o),l=Vn(r,o);return{file:t,metrics:o,issues:d,suggestions:a,performance:l}}catch(r){throw Error(`Failed to analyze template ${t}: ${r instanceof Error?r.message:String(r)}`)}}function zn(t){let r=t.split(`
|
|
3
3
|
`),o=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),a=(o?o[1]:"").split(`
|
|
4
4
|
`).length,l={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};l.total=l.conditionals+l.loops+l.includes+l.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,p=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,y=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,g=u+p+y,b=(t.match(/<[A-Z][^>]*>/g)||[]).length,w=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,C=0;for(let T of r)if(/@(?:if|unless|foreach|for|while|section)\b/.test(T)&&!/@end/.test(T)&&!/@else/.test(T))C++,S=Math.max(S,C);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(T))C--;let v=S>=4?3:0,x=Math.min(10,Math.ceil(l.total*0.5+g*0.1+b*0.3+(a>10?a*0.05:0)+v));return{lines:r.length,characters:t.length,directives:l,expressions:g,components:b,layouts:w,scriptLines:a,complexity:x}}function Nn(t,r){let o=[],d=qt(t,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let a=qt(t,"foreach","endforeach");if(a>0)o.push({type:"error",category:"syntax",message:`Found ${a} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let l=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(l&&l.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let p=t.match(/<img[^>]*>/g);if(p){let b=p.filter((w)=>!w.includes("alt="));if(b.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${b.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let y=t.split(`
|
|
5
5
|
`).filter((b)=>b.length>120);if(y.length>0)o.push({type:"info",category:"maintainability",message:`Found ${y.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let g=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(g>3)o.push({type:"info",category:"maintainability",message:`Found ${g} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function Un(t,r){let o=[];if(r.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(r.complexity>5&&r.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(r.lines>100&&r.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(r.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(r.directives.total===0&&r.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(r.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Vn(t,r){let o=1;if(o+=r.directives.conditionals*0.1,o+=r.directives.loops*0.5,o+=r.directives.includes*2,o+=r.expressions*0.05,o+=r.components*1,r.scriptLines>10)o+=r.scriptLines*0.1;let d;if(r.expressions===0&&r.directives.total===0)d="high";else if(r.expressions<5&&r.directives.total<3)d="medium";else d="low";let a=[];if(o>10)a.push("Consider optimizing template complexity");if(d==="low"&&r.directives.total>5)a.push("Reduce dynamic content for better caching");if(r.components===0&&r.lines>40)a.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:r.complexity,cacheability:d,recommendations:a}}function qt(t,r,o){let d=t.replace(/<!--[\s\S]*?-->/g,""),a=(d.match(new RegExp(`@${r}\\b`,"g"))||[]).length,l=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(a-l)}async function pi(t=["**/*.stx"],r){let o=[],d=[];for(let l of t){let u=await Array.fromAsync(new Bun.Glob(l).scan({cwd:r||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((p)=>p.endsWith(".stx")))}for(let l of d)try{let u=await Fn(l);o.push(u)}catch(u){console.warn(`Failed to analyze ${l}:`,u)}let a=qn(o);return{results:o,summary:a}}function qn(t){let r=t.length,o=t.reduce((g,b)=>g+b.metrics.lines,0),d=r>0?t.reduce((g,b)=>g+b.metrics.complexity,0)/r:0,a=t.reduce((g,b)=>g+b.issues.length,0),l={};t.forEach((g)=>{g.issues.forEach((b)=>{l[b.category]=(l[b.category]||0)+1})});let u=r>0?t.reduce((g,b)=>g+b.performance.estimatedRenderTime,0)/r:0,p=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),y=[];if(d>6)y.push("Project has high average complexity. Consider refactoring complex templates.");if(a>r*2)y.push("High number of issues detected. Run detailed analysis on individual files.");if(l.security>0)y.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:r,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:a,issuesByCategory:l,performanceScore:p,recommendations:y}}import{mkdir as Kn,readFile as Gn,readdir as Yn,stat as Kt,writeFile as Qn}from"fs/promises";import Te from"path";function Zt(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 tn=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function er(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((r)=>r.charAt(0).toUpperCase()+r.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 tr(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function nr(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function rr(t){let r=[];async function o(d){let a=await Yn(d,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=Te.join(d,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await o(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))r.push(u)}}return await o(t),r}function or(t,r){let o=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!o)return{};let d=o[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(a){throw Error(`${r}: <script component> must contain JSON metadata (${a.message})`)}}function sr(t,r){let o={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let a of d){if(!/\bclient\b/i.test(a[1])||/\bcomponent\b|\bstx:component\b/i.test(a[1]))continue;let l;try{l=new Bun.Transpiler({loader:"ts"}).transformSync(a[2])}catch(y){throw Error(`${r}: failed to transpile <script client> (${y.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,p;while(p=u.exec(l)){let y=p[1];if(tn.has(y))throw Error(`${r}: client ${Zt(y)}`);let g=u.lastIndex,b=1,w="",S=!1,C=g;for(;C<l.length&&b>0;C++){let x=l[C];if(S){S=!1;continue}if(w){if(x==="\\")S=!0;else if(x===w)w="";continue}if(x==='"'||x==="'"||x==="`")w=x;else if(x==="{")b++;else if(x==="}")b--}if(b!==0)throw Error(`${r}: unterminated client function "${y}"`);let v=p[0].includes("async")?"async ":"";o[y]=`${v}${y}(${p[2]}) {${l.slice(g,C-1)}}`,u.lastIndex=C}}return o}function ir(t){let r=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(r?r[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Xt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((r)=>r[1].trim()).filter(Boolean).join(`
|
|
6
6
|
|
|
7
7
|
`)}function ar(t){if(!t)return null;let r=t.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(r))return"string";if(/^number$/.test(r))return"number";if(/^boolean$/.test(r))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(r))return"string";return"object"}function cr(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 lr(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 r=[],o=0,d=t.replace(/\{\{--[\s\S]*?--\}\}/g,""),a=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,l,u=(y)=>{if(d[y]!=="(")return null;let g=0,b="";for(let w=y;w<d.length;w++){let S=d[w];if(b!==""){if(S==="\\")w++;else if(S===b)b="";continue}if(S==="'"||S==='"'||S==="`"){b=S;continue}if(S==="(")g++;else if(S===")"){if(g--,g===0)return{expression:d.slice(y+1,w),end:w+1}}}return null},p=(y)=>{if(y==="")return;let g=0,b=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,w;while(w=b.exec(y)){if(w.index>g)r.push(`out += ${JSON.stringify(y.slice(g,w.index))};`);r.push(w[1]!==void 0?`out += __raw(${w[1]});`:`out += __escape(${w[2]});`),g=w.index+w[0].length}if(g<y.length)r.push(`out += ${JSON.stringify(y.slice(g))};`)};while(l=a.exec(d)){p(d.slice(o,l.index)),o=l.index+l[0].length;let g=l[1]==="if"||l[1]==="elseif"||l[1]==="foreach"?u(o):null;if(g)o=g.end,a.lastIndex=g.end;let b=g?.expression;switch(l[1]){case"if":r.push(`if (${b}) {`);break;case"elseif":r.push(`} else if (${b}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let w=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec((b||"").trim());if(!w){r.push(`out += ${JSON.stringify(l[0]+(g?`(${b})`:""))};`);break}let[,S,C,v]=w;r.push(C?`for (const [${C}, ${v}] of __entries(${S})) {`:`for (const ${v} of __values(${S})) {`);break}}}return p(d.slice(o)),r.join(`
|
|
8
|
-
`)}function at(t,r,o,d){if(t[r]!==o)return-1;let a=0,l=null;for(let u=r;u<t.length;u++){let p=t[u];if(l){if(p==="\\"){u++;continue}if(p===l)l=null;continue}if(p==="'"||p==='"'||p==="`"){l=p;continue}if(p===o)a++;else if(p===d){if(d===">"&&t[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function
|
|
8
|
+
`)}function at(t,r,o,d){if(t[r]!==o)return-1;let a=0,l=null;for(let u=r;u<t.length;u++){let p=t[u];if(l){if(p==="\\"){u++;continue}if(p===l)l=null;continue}if(p==="'"||p==='"'||p==="`"){l=p;continue}if(p===o)a++;else if(p===d){if(d===">"&&t[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function _t(t,r,o){let d=o?"([{<":"([{",a=o?")]}>":")]}",l=[],u=0,p=null,y="";for(let g=0;g<t.length;g++){let b=t[g];if(p){if(y+=b,b==="\\"){y+=t[++g]??"";continue}if(b===p)p=null;continue}if(b==="'"||b==='"'||b==="`"){p=b,y+=b;continue}if(d.includes(b))u++;else if(a.includes(b))u--;if(u===0&&r.includes(b)){l.push(y),y="";continue}y+=b}return l.push(y),l.map((g)=>g.trim()).filter(Boolean)}function pr(t){let r=0,o=null;for(let d=0;d<t.length;d++){let a=t[d];if(o){if(a==="\\"){d++;continue}if(a===o)o=null;continue}if(a==="'"||a==='"'||a==="`"){o=a;continue}if("([{".includes(a))r++;else if(")]}".includes(a))r--;if(r!==0||a!=="=")continue;let l=t[d-1];if(t[d+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return d}return-1}function Gt(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 fr(t){let r=/\bdefineProps\b/.exec(t);if(!r)return null;let o=/(?:^|[\s;{}()])(const|let|var)\s+/g,d=-1;for(let k=o.exec(t);k&&k.index<r.index;k=o.exec(t))d=k.index+k[0].indexOf(k[1]);if(d===-1)return null;let a={},l={},u=[],p=d+(/^(?:const|let|var)\s+/.exec(t.slice(d))?.[0].length??0),y=()=>{while(p<t.length&&/\s/.test(t[p]))p++},g;if(t[p]==="{"){let k=at(t,p,"{","}");if(k===-1)return null;g=t.slice(p,k),p=k}else{let k=/^[A-Za-z_$][\w$]*/.exec(t.slice(p));if(!k)return null;g=k[0],p+=k[0].length}if(y(),t[p]!=="=")return null;p++,y();let b=/^withDefaults\s*\(\s*/.exec(t.slice(p)),w=Boolean(b);if(b)p+=b[0].length;let S=/^defineProps\b/.exec(t.slice(p));if(!S)return null;p+=S[0].length;let C="";if(y(),t[p]==="<"){let k=at(t,p,"<",">");if(k===-1)return null;C=t.slice(p+1,k-1).trim(),p=k}if(y(),t[p]!=="(")return null;let v=at(t,p,"(",")");if(v===-1)return null;let x=t.slice(p+1,v-1).trim();if(p=v,w){if(y(),t[p]===",")p++,y();if(t[p]==="{"){let k=at(t,p,"{","}");if(k===-1)return null;for(let[j,M]of Lt(t.slice(p,k)))l[j]=M;p=k}if(y(),t[p]===",")p++,y();if(t[p]===")")p++}if(t[p]===";")p++;let T=/^[A-Za-z_$][\w$]*$/.test(C)?C:void 0;if(C.startsWith("{"))for(let k of _t(C.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let j=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(k);if(j)a[j[1]]=j[2].trim()}if(x.startsWith("{"))for(let[k,j]of Lt(x)){if(u.push(k),!j.startsWith("{")){let M=Gt(j);if(M)a[k]=M;continue}for(let[M,L]of Lt(j))if(M==="default")l[k]=L;else if(M==="type"){let E=Gt(L);if(E)a[k]=E}}else if(x.startsWith("["))for(let k of _t(x.slice(1,-1),",",!1))u.push(k.replace(/^['"`]/,"").replace(/['"`]$/,""));if(g.startsWith("{")){u.length=0;for(let k of _t(g.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let j=pr(k),L=(j===-1?k:k.slice(0,j)).split(":")[0].trim().replace(/^\.\.\./,"");if(!L)continue;if(u.push(L),j!==-1)l[L]=k.slice(j+1).trim()}}else if(u.length===0)u.push(...Object.keys(a));return{text:t.slice(d,p),propNames:u,defaults:l,declared:a,typeName:T}}function Lt(t){let r=t.trim().replace(/^\{/,"").replace(/\}$/,""),o=[],d=0;while(d<r.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=d;let l=a.exec(r);if(!l)break;d=a.lastIndex;let u=0,p="",y=d;while(d<r.length){let b=r[d];if(p){if(b==="\\")d++;else if(b===p)p=""}else if(b==="'"||b==='"'||b==="`")p=b;else if(b==="{"||b==="["||b==="(")u++;else if(b==="}"||b==="]"||b===")")u--;else if(b===","&&u===0)break;d++}let g=r.slice(y,d).trim();if(g)o.push([l[1],g]);d++}return o}function mr(t,r,o){let a=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].find((S)=>!/\bcomponent\b|\bstx:component\b|\bclient\b/i.test(S[1]));if(!a)return{imports:[],body:"",propNames:[],defaults:{},declared:{}};let l=a[2],u=[],p=[],y={},g={};l=l.replace(/^\s*import\s+[\s\S]*?from\s*['"][^'"]+['"];?\s*$/gm,(S)=>{if(/from\s*['"]stx['"]/.test(S))return"";return u.push(S.trim().replace(/(from\s*['"])(\.[^'"]*)(['"])/,(C,v,x,T)=>{let k=Te.resolve(Te.dirname(r),x),j=Te.relative(o,k);return`${v}${j.startsWith(".")?j:`./${j}`}${T}`})),""});let b=fr(l);if(b)p.push(...b.propNames),Object.assign(y,b.defaults),Object.assign(g,b.declared),l=l.replace(b.text,"");let w={};for(let S of l.matchAll(/(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\s*\{([\s\S]*?)\n\}/g)){let C=[];for(let v of S[2].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))g[v[1]]=v[2].trim(),C.push(v[1]);w[S[1]]=C}if(b&&b.propNames.length===0&&b.typeName){for(let S of w[b.typeName]??[])if(!p.includes(S))p.push(S)}return l=l.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:u,body:l.trim(),propNames:p,defaults:y,declared:g}}function gr(t){let r=new Set;return{template:t.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(d,a,l,u,p)=>{let y=a.toLowerCase();r.add(y);let g=(l||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${y}="${p}"${g?` data-stx-mod-${y}="${g}"`:""}`}),eventTypes:[...r].sort()}}function hr(t){let r=[];return{template:t.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(d,a,l,u)=>{let p=r.length;return r.push({id:p,name:a,expression:u}),` data-stx-bind-${p}=""`}),bindings:r}}function yr(t){let r=new Set;for(let o of t.matchAll(/<slot\b([^>]*)>/gi))r.add(o[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...r].map((o)=>({name:o}))}function br(t){return[...new Set([...t.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((r)=>r[1]))].sort().map((r)=>({name:r}))}function Jt(t,r){if(!r||!new Set(["string","number","boolean","object","array"]).has(r.type))throw Error(`Property "${t}" must declare one of: string, number, boolean, object, array`);return{...r,reflect:r.reflect??r.attribute!==!1}}async function xr(t,r,o){let d=Te.isAbsolute(r.file)?r.file:Te.resolve(t,r.file),a=await Gn(d,"utf8"),l=or(a,d),u=Te.basename(d,".stx"),p=r.name||l.name||er(u),y=`${It(o.prefix||"stx")}-${It(u)}`,g=r.tag||l.tag||y;if(!p||!/^[A-Za-z_$][\w$]*$/.test(p))throw Error(`${d}: invalid component class name "${p}"`);if(!tr(g))throw Error(`${d}: invalid custom-element tag "${g}"; tags must be lowercase and contain a hyphen`);let b=r.properties||l.properties||l.props||{},w=Object.fromEntries(Object.entries(b).map(([M,L])=>[M,Jt(M,L)])),S=gr(ir(a)),C=hr(S.template),v=mr(a,d,Te.resolve(o.outputDir)),x=dr(C.template);for(let M of v.propNames){if(w[M])continue;let L=v.defaults[M];w[M]=Jt(M,{type:ar(v.declared[M])??cr(L),...L===void 0?{}:{default:lr(L)}})}let T=l.methods||{},k=r.methods||{},j=sr(a,d);return{file:Te.relative(t,d),sourcePath:d,name:p,tag:g,description:r.description||l.description||"",template:C.template,styles:Xt(a),shadowMode:nr(r.shadowDOM??l.shadowDOM??o.shadowDOM),progressive:r.progressive??l.progressive??o.progressive??!0,properties:w,events:r.events||l.events||{},methods:{...T,...k,...j},eventTypes:S.eventTypes,bindings:C.bindings,slots:yr(C.template),cssProperties:br(Xt(a)),scope:v,render:x}}function vr(){let t=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
9
9
|
|
|
10
10
|
const escapeHTML = (value) => String(value ?? '')
|
|
11
11
|
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
@@ -355,7 +355,7 @@ declare global {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
export default ${t.name}
|
|
358
|
-
`}function
|
|
358
|
+
`}function Rr(t){return`declare global {
|
|
359
359
|
namespace JSX {
|
|
360
360
|
interface IntrinsicElements {
|
|
361
361
|
${t.map((o)=>{let d=Object.entries(o.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${ct(u)}`).join(`
|
|
@@ -374,9 +374,9 @@ ${a}
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export {}
|
|
377
|
-
`}function
|
|
377
|
+
`}function Er(t){return{schemaVersion:"1.0.0",modules:t.map((r)=>({kind:"javascript-module",path:`./${r.tag}.js`,declarations:[{kind:"class",name:r.name,description:r.description||void 0,customElement:!0,tagName:r.tag,members:Object.entries(r.properties).map(([o,d])=>({kind:"field",name:o,description:d.description,type:{text:ct(d)},default:d.default===void 0?void 0:JSON.stringify(d.default),attribute:d.attribute===!1?void 0:d.attribute||It(o),reflects:d.reflect})),events:Object.entries(r.events).map(([o,d])=>({name:o,description:d.description,type:{text:`CustomEvent<${d.detailType||"unknown"}>`}})),slots:r.slots,cssProperties:r.cssProperties}],exports:[{kind:"js",name:r.name,declaration:{name:r.name,module:`./${r.tag}.js`}}]}))}}function Yt(t){if(!t.styles)return"";let r=t.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(r))return r;return`@scope (${t.tag}) {
|
|
378
378
|
${r}
|
|
379
|
-
}`}function Qt(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function
|
|
379
|
+
}`}function Qt(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Pr(t){let r=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),o=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),d=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(t.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=t.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
|
|
380
380
|
`);return`const definitions = ${JSON.stringify(a,null,2)};
|
|
381
381
|
const escapeHTML = (value) => String(value ?? '')
|
|
382
382
|
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
@@ -413,12 +413,12 @@ ${l}
|
|
|
413
413
|
`}async function fi(t){let r=Te.resolve(t.inputDir),o=Te.resolve(t.outputDir);if(!(await Kt(r).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${r}`);let a=t.components?.length?t.components:(await rr(r)).map((x)=>({file:x}));if(!a.length)throw Error(`No .stx components found in ${r}`);let l=await Promise.all(a.map((x)=>xr(r,x,t)));l.sort((x,T)=>x.tag.localeCompare(T.tag));let u=l.filter((x,T)=>l.findIndex((k)=>k.tag===x.tag)!==T);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let p=l.filter((x,T)=>l.findIndex((k)=>k.name===x.name)!==T);if(p.length)throw Error(`Duplicate component class name: ${p[0].name}`);await Kn(o,{recursive:!0});let y=[],g=async(x,T)=>{let k=Te.join(o,x);return await Qn(k,T.endsWith(`
|
|
414
414
|
`)?T:`${T}
|
|
415
415
|
`,"utf8"),y.push(k),k};await g("runtime.js",vr());for(let x of l){if(await g(`${x.tag}.js`,wr(x)),t.declarations!==!1)await g(`${x.tag}.d.ts`,Tr(x));if(t.css!==!1&&x.styles){let T=x.shadowMode?x.styles:Yt(x);await g(`${x.tag}.css`,t.minify?Qt(T):T)}}let b=l.map((x)=>`export { ${x.name}, default as ${x.name}Element } from './${x.tag}.js';`).join(`
|
|
416
|
-
`);if(await g("index.js",b),await g("ssr.js",
|
|
417
|
-
`)),await g("custom-elements.d.ts",
|
|
416
|
+
`);if(await g("index.js",b),await g("ssr.js",Pr(l)),t.declarations!==!1)await g("index.d.ts",l.map((x)=>`export * from './${x.tag}.js'`).join(`
|
|
417
|
+
`)),await g("custom-elements.d.ts",Rr(l)),await g("ssr.d.ts",`${l.map((x)=>`export declare const render${x.name}: (props?: ${x.name}Props, slots?: Record<string, string>) => string`).join(`
|
|
418
418
|
`)}
|
|
419
419
|
export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
|
|
420
420
|
${l.map((x)=>`import type { ${x.name}Props } from './${x.tag}.js'`).join(`
|
|
421
|
-
`)}`);let w;if(t.manifest!==!1)w=await g("custom-elements.json",JSON.stringify(
|
|
421
|
+
`)}`);let w;if(t.manifest!==!1)w=await g("custom-elements.json",JSON.stringify(Er(l),null,2));let S;if(t.css!==!1){let x=l.filter((T)=>!T.shadowMode&&T.styles).map(Yt).join(`
|
|
422
422
|
|
|
423
423
|
`);if(x)S=await g("bundle.css",t.minify?Qt(x):x)}let C;if(t.bundle!==!1){C=Te.join(o,"bundle.js");let x;try{x=await Bun.build({entrypoints:[Te.join(o,"index.js")],outdir:o,naming:"bundle.js",target:"browser",format:"esm",minify:t.minify??!0,sourcemap:t.sourcemap||"none"})}catch(T){let k=T instanceof AggregateError?T.errors:[T],j=k.map((M)=>String(M).trim()).filter(Boolean).join(`
|
|
424
424
|
`);throw AggregateError(k,`Failed to bundle component library${j?`
|
|
@@ -504,7 +504,7 @@ else {
|
|
|
504
504
|
<span class="frontmatter-label">${r}:</span>
|
|
505
505
|
<span>${Array.isArray(o)?o.join(", "):String(o)}</span>
|
|
506
506
|
</div>`).join("")}
|
|
507
|
-
</div>`}import nn from"net";async function
|
|
507
|
+
</div>`}import nn from"net";async function Or(t){return new Promise((r)=>{let o=nn.createServer();o.once("error",()=>r(!1)),o.once("listening",()=>{o.close(()=>r(!0))}),o.listen(t,"0.0.0.0")})}async function Ar(t){return new Promise((r)=>{let o=nn.createServer();o.once("error",()=>r(!1)),o.once("listening",()=>{o.close(()=>r(!0))}),o.listen(t,"::")})}async function Dr(t){if(!await Or(t))return!1;return await Ar(t)}async function qe(t,r=20){t=Number(t);for(let o=0;o<r;o++){let d=t+o;if(await Dr(d))return d}throw Error(`Could not find an available port between ${t} and ${t+r-1}`)}var Mr={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function _r(){try{let t=await import("./chunk-28jtt8hn.js");if(typeof t.openDevWindow!=="function")return null;return t}catch{return null}}async function Ze(t,r={}){let o={...Mr,...r},d=await _r();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 a=await d.openDevWindow(t,{title:o.title,width:o.width,height:o.height,darkMode:o.darkMode,hotReload:o.hotReload,titlebarHidden:o.titlebarHidden,nativeSidebar:o.nativeSidebar,sidebarWidth:o.sidebarWidth,sidebarConfig:o.sidebarConfig});if(a&&o.nativeSidebar)console.log(`${e.green}\u2713${e.reset} Native sidebar enabled (macOS Tahoe style)`);return a}catch(a){return console.log(`${e.red}\u2717${e.reset} Could not open native window:`,a),!1}}function gt(t){if(t.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let a=t.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(a){let l=a[1];try{let u=`
|
|
508
508
|
${l}
|
|
509
509
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
510
510
|
`,y=Function(u)();if(y)return y}catch(u){console.warn("Invalid sidebarConfig:",u)}}return{sections:[]}}let o=t.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(o)try{return JSON.parse(o[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let d=t.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(d)try{let a=d[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(a)return Function(`return ${a[1]}`)()}catch(a){console.warn("Invalid native-sidebar script configuration:",a)}return}function jt(){console.log(`
|
|
@@ -876,10 +876,10 @@ else {
|
|
|
876
876
|
};
|
|
877
877
|
})();
|
|
878
878
|
</script>
|
|
879
|
-
`}function Ne(t,r,o={}){let d=Fr(r,o),a=t.lastIndexOf("</body>");if(a!==-1)return t.slice(0,a)+d+t.slice(a);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let r=t.toLowerCase();return r.endsWith(".css")||r.endsWith(".scss")||r.endsWith(".sass")||r.endsWith(".less")}function yt(t){let r=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>r.endsWith(d))}function Tt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function $t(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import
|
|
879
|
+
`}function Ne(t,r,o={}){let d=Fr(r,o),a=t.lastIndexOf("</body>");if(a!==-1)return t.slice(0,a)+d+t.slice(a);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let r=t.toLowerCase();return r.endsWith(".css")||r.endsWith(".scss")||r.endsWith(".sass")||r.endsWith(".less")}function yt(t){let r=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>r.endsWith(d))}function Tt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function $t(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import Et from"path";var nt={name:"bun-plugin-stx",async setup(t){let o={...await i(),...t.config?.stx},d=new Set,a=o.webComponents?.enabled?`./${Et.relative(Et.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(o.webComponents?.enabled)try{let u=await qr(o,d);if(l.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let p=new Set;if(o.cache&&o.cachePath){let x=await Xn(u,o);if(x){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:x,loader:"html"}}}let y=await ve(()=>Bun.file(u).text(),"",(x)=>{throw new ur(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${x.message}`)});if(!y)throw new ur(`stx file is empty: ${u}`,u);let{scriptContent:g,templateContent:b,allScripts:w}=te.time("script-extraction",()=>{let x=y,T=ae(y);if(T)x=T.content.trim();let k=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],j="",M=[];for(let E of k){let _=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),q=B?B[1]:"";if(/\bserver\b/i.test(q))j=_;else M.push(E)}let L=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:j,templateContent:L,allScripts:M}}),S={__filename:u,__dirname:Et.dirname(u),__stx:{webComponentsPath:a,builtComponents:l}};await ve(()=>f(g,S,u),void 0,(x)=>{let T=new re(`Script execution failed in ${u}: ${x.message}`,u,void 0,void 0,g.substring(0,100));if(D.log(T,{filePath:u,scriptContent:g}),o.debug)throw T});let v=await te.timeAsync("directive-processing",async()=>await s(b,S,u,o,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-q1x7ckfw.js"),T=x(w.join(`
|
|
880
880
|
`),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
|
|
881
881
|
`+v.slice(k);else v+=`
|
|
882
|
-
${T}`}if(v=await me(v),p.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await Jn(u,v,p,o),o.debug)console.log(`Cached template ${u} with ${p.size} dependencies`)}return{contents:v,loader:"html"}}catch(p){let y=p instanceof Error?p:new
|
|
882
|
+
${T}`}if(v=await me(v),p.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await Jn(u,v,p,o),o.debug)console.log(`Cached template ${u} with ${p.size} dependencies`)}return{contents:v,loader:"html"}}catch(p){let y=p instanceof Error?p:new re(`Plugin processing failed: ${String(p)}`,u);if(D.log(y,{filePath:u,buildConfig:t.config}),hn.logDetailedError(y,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",y);let g=y,b=g.line||null,w=g.context||null;return{contents:o.debug||H()?`<!DOCTYPE html>
|
|
883
883
|
<html lang="en">
|
|
884
884
|
<head>
|
|
885
885
|
<meta charset="UTF-8">
|
|
@@ -920,7 +920,7 @@ ${T}`}if(v=await me(v),p.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await J
|
|
|
920
920
|
<li>Check the syntax of your stx directives (e.g., @if, @foreach)</li>
|
|
921
921
|
<li>Verify that all variables used in the template are properly defined</li>
|
|
922
922
|
<li>Ensure script tags have valid JavaScript/TypeScript syntax</li>
|
|
923
|
-
<li>Run <code>stx debug ${m(
|
|
923
|
+
<li>Run <code>stx debug ${m(Et.basename(u))}</code> for detailed analysis</li>
|
|
924
924
|
<li>Enable debug mode in your stx config for more detailed error messages</li>
|
|
925
925
|
</ul>
|
|
926
926
|
</div>
|
|
@@ -939,7 +939,7 @@ ${T}`}if(v=await me(v),p.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await J
|
|
|
939
939
|
<h1>Something went wrong</h1>
|
|
940
940
|
<p>An internal error occurred. Please try again later.</p>
|
|
941
941
|
</body>
|
|
942
|
-
</html>`,loader:"html"}}})}};async function Sr(t,r={}){let o=r.port||3000,d=r.watch!==!1,a=r.hotReload!==!1&&d,l=null,u=r.hmrPort||o+1,p=fe.resolve(t);if(!Le.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return Bt(p,r);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let y=c(process.cwd(),"output");Le.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let _={name:"public-assets",setup(be){be.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ce)=>({path:ce.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:y,plugins:[_,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let q=B.outputs.find((be)=>be.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(q.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await b())return!1;let S=fe.dirname(p);await en(S);let C=o;try{if(C=await qe(o),C!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(a){let _=r.hmrPort||C+1;l=$t({wsPort:_,verbose:!1}),u=l.start(_)}let v={},x=null,T;try{let{loadStxConfig:_}=await import("./chunk-
|
|
942
|
+
</html>`,loader:"html"}}})}};async function Sr(t,r={}){let o=r.port||3000,d=r.watch!==!1,a=r.hotReload!==!1&&d,l=null,u=r.hmrPort||o+1,p=fe.resolve(t);if(!Le.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return Bt(p,r);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let y=c(process.cwd(),"output");Le.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let _={name:"public-assets",setup(be){be.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ce)=>({path:ce.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:y,plugins:[_,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let q=B.outputs.find((be)=>be.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(q.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await b())return!1;let S=fe.dirname(p);await en(S);let C=o;try{if(C=await qe(o),C!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(a){let _=r.hmrPort||C+1;l=$t({wsPort:_,verbose:!1}),u=l.start(_)}let v={},x=null,T;try{let{loadStxConfig:_}=await import("./chunk-jmx4q1yr.js"),B=await _();if(T=r.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let q=Object.keys(v).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:J}=await import("./chunk-j0v970k3.js"),be=B.broadcasting;await q(be);let ce=be.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ce}/ws${e.reset}`);let Ce=fe.join(process.cwd(),"channels.ts");if(Le.existsSync(Ce))try{let Z=await J(Ce);console.log(`${e.blue}Loaded ${e.bright}${Z} broadcast channel${Z!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(Z){console.warn(`${e.yellow}Failed to load channels.ts: ${Z.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:j}=await import("./chunk-7wnd2psp.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),a)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let L=zr({port:C,async fetch(_){return xn(_,await(async()=>{let B=new URL(_.url);if([y,fe.dirname(p),fe.join(process.cwd(),"public")].some((Z)=>j(fe.join(Z,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let Z=await x.handleRequest(_);if(Z.status!==404)return Z}catch{}if(v[B.pathname])try{return await v[B.pathname](_)}catch(Z){return new Response(JSON.stringify({error:Z.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await M(_);if(q)return q;if(B.pathname==="/")return(async()=>{let N=await h(g||"");if(a)N=Ne(N,u);if(r.native)if(N.includes("<head>"))N=N.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(N.includes("<html"))N=N.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 N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(r.titlebarHidden)if(N.includes("<head>"))N=N.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(N.includes("<html"))N=N.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 N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;return N})().then((N)=>new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let J=fe.join(y,B.pathname);if(Le.existsSync(J)&&Le.statSync(J).isFile()){let Z=Bun.file(J),N=fe.extname(J).toLowerCase(),I="text/plain";if(N===".ts"||N===".tsx"){let Ie=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Be=await Z.text(),Ye=Ie.transformSync(Be);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(Z,{headers:{"Content-Type":I}})}let be=fe.dirname(p),ce=fe.join(be,B.pathname);if(Le.existsSync(ce)&&Le.statSync(ce).isFile()){let Z=Bun.file(ce),N=fe.extname(ce).toLowerCase(),I="text/plain";if(N===".ts"||N===".tsx"){let Ie=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Be=await Z.text(),Ye=Ie.transformSync(Be);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(Z,{headers:{"Content-Type":I}})}let Ce=fe.join(process.cwd(),"public",B.pathname);if(Le.existsSync(Ce)&&Le.statSync(Ce).isFile()){let Z=Bun.file(Ce),N=fe.extname(Ce).toLowerCase(),I="application/octet-stream";if(N===".ts"||N===".tsx"){let Ie=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Be=await Z.text(),Ye=Ie.transformSync(Be);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(Z,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})})())},error(_){return new Response(`<pre>${_}
|
|
943
943
|
${_.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
944
944
|
${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(`
|
|
945
945
|
${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
|
|
@@ -1255,7 +1255,7 @@ else {
|
|
|
1255
1255
|
|
|
1256
1256
|
})()
|
|
1257
1257
|
</script>
|
|
1258
|
-
`;function an(t){if(t.length===0)return"";if(t.length===1)return t[0];let r=t.map((d)=>d.split($e.sep)),o=[];for(let d=0;d<r[0].length;d++){let a=r[0][d];if(r.every((l)=>l[d]===a))o.push(a);else break}return o.join($e.sep)}async function kr(t,r={}){let o=r.port||3000,d=r.watch!==!1;for(let v of t){let x=$e.resolve(v);if(!Ge.existsSync(x))return console.error(`${e.red}Error: File not found: ${e.bright}${x}${e.reset}`),!1;if(!x.endsWith(".stx")&&!x.endsWith(".md"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${x}${e.reset}. Only .stx and .md files are supported.`),!1}let a=c(process.cwd(),"output");Ge.mkdirSync(a,{recursive:!0});let l=an(t.map((v)=>$e.dirname($e.resolve(v))));console.log(`${e.blue}Processing ${e.bright}${t.length}${e.reset} files...`);let u={},p=[],y=async()=>{try{for(let v of t){let x=$e.resolve(v);if(x.endsWith(".md"))try{let{content:k,data:j}=await Ee(x,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:R.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=r.markdown?.syntaxHighlighting||R.markdown?.syntaxHighlighting,L=M?.defaultTheme||"github-dark",E=["github-dark"],_=M?.additionalThemes||[],q=[...new Set([...E,..._])].map((
|
|
1258
|
+
`;function an(t){if(t.length===0)return"";if(t.length===1)return t[0];let r=t.map((d)=>d.split($e.sep)),o=[];for(let d=0;d<r[0].length;d++){let a=r[0][d];if(r.every((l)=>l[d]===a))o.push(a);else break}return o.join($e.sep)}async function kr(t,r={}){let o=r.port||3000,d=r.watch!==!1;for(let v of t){let x=$e.resolve(v);if(!Ge.existsSync(x))return console.error(`${e.red}Error: File not found: ${e.bright}${x}${e.reset}`),!1;if(!x.endsWith(".stx")&&!x.endsWith(".md"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${x}${e.reset}. Only .stx and .md files are supported.`),!1}let a=c(process.cwd(),"output");Ge.mkdirSync(a,{recursive:!0});let l=an(t.map((v)=>$e.dirname($e.resolve(v))));console.log(`${e.blue}Processing ${e.bright}${t.length}${e.reset} files...`);let u={},p=[],y=async()=>{try{for(let v of t){let x=$e.resolve(v);if(x.endsWith(".md"))try{let{content:k,data:j}=await Ee(x,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:R.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),M=r.markdown?.syntaxHighlighting||R.markdown?.syntaxHighlighting,L=M?.defaultTheme||"github-dark",E=["github-dark"],_=M?.additionalThemes||[],q=[...new Set([...E,..._])].map((Ce)=>`<option value="${Ce}"${Ce===L?" selected":""}>${Ce}</option>`).join(`
|
|
1259
1259
|
`),J=`
|
|
1260
1260
|
<!DOCTYPE html>
|
|
1261
1261
|
<html lang="en">
|
|
@@ -1418,20 +1418,20 @@ else {
|
|
|
1418
1418
|
</script>
|
|
1419
1419
|
</body>
|
|
1420
1420
|
</html>
|
|
1421
|
-
`,ce=`/${$e.relative(l,x).replace(/\.md$/,"")}`;if(ce.endsWith("/index"))ce=ce.slice(0,-6)||"/";u[ce||"/"]={filePath:x,content:J,fileType:"md"}}catch(k){console.error(`${e.red}Error processing Markdown file ${e.bright}${v}${e.reset}:`,k);continue}else{let k={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(_)=>({path:_.path,external:!0}))}},j;try{let E=await Bun.build({entrypoints:[x],outdir:a,plugins:[k,nt],define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!E.success){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:`,
|
|
1422
|
-
${
|
|
1421
|
+
`,ce=`/${$e.relative(l,x).replace(/\.md$/,"")}`;if(ce.endsWith("/index"))ce=ce.slice(0,-6)||"/";u[ce||"/"]={filePath:x,content:J,fileType:"md"}}catch(k){console.error(`${e.red}Error processing Markdown file ${e.bright}${v}${e.reset}:`,k);continue}else{let k={name:"public-assets",setup(E){E.onResolve({filter:/^\/(images|fonts|assets|public)\//},(_)=>({path:_.path,external:!0}))}},j;try{let E=await Bun.build({entrypoints:[x],outdir:a,plugins:[k,nt],define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!E.success){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:`,_e(E.logs,x));continue}let _=E.outputs.find((B)=>B.path.endsWith(".html"));if(!_){console.error(`${e.red}No HTML output found for ${e.bright}${v}${e.reset}`);continue}j=await Bun.file(_.path).text()}catch(E){console.error(`${e.red}Build failed for ${e.bright}${v}${e.reset}:
|
|
1422
|
+
${_e(E,x)}`);continue}let L=`/${$e.relative(l,x).replace(/\.stx$/,"")}`;if(L.endsWith("/index"))L=L.slice(0,-6)||"/";if(L.includes("[")){let{regex:E,params:_}=Zr(L,{page:!0});p.push({pattern:E,paramNames:_,filePath:x,routeTemplate:L,fileType:"stx"}),u[L]={filePath:x,content:j,fileType:"stx"}}else u[L||"/"]={filePath:x,content:j,fileType:"stx"}}}if(Object.keys(u).length===0)return console.error(`${e.red}No files were successfully processed${e.reset}`),!1;return!0}catch(v){return console.error(`${e.red}Error processing files:${e.reset}`,_e(v)),!1}};if(!await y())return!1;let b=o;try{if(b=await qe(o),b!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${b} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${b}/${e.reset}...`);let w=Nr({port:b,async fetch(v){let x=new URL(v.url),T=$e.join(process.cwd(),"public",x.pathname);if(Ge.existsSync(T)&&Ge.statSync(T).isFile()){let M=Bun.file(T),L=$e.extname(T).toLowerCase(),E="application/octet-stream";if(L===".ts"||L===".tsx"){let _=new Bun.Transpiler({loader:L===".tsx"?"tsx":"ts"}),B=await M.text(),q=_.transformSync(B);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(L){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":E}})}let k=u[x.pathname];if(!k&&!x.pathname.endsWith("/"))k=u[`${x.pathname}/`];if(!k)for(let M of p){let L=x.pathname.match(M.pattern);if(L){let E=u[M.routeTemplate];if(E){let _={};for(let J=0;J<M.paramNames.length;J++)_[M.paramNames[J]]=decodeURIComponent(L[J+1]);let B=E.content,q=`<script>window.__routeParams = ${JSON.stringify(_)};</script>`;if(B.includes("</head>"))B=B.replace("</head>",`${q}
|
|
1423
1423
|
</head>`);else B=q+B;k={...E,content:B}}break}}if(k)return h(k.content).then((M)=>{if(M.includes("</head>"))M=M.replace("</head>",`${on}
|
|
1424
1424
|
</head>`);return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let j=$e.join(a,x.pathname);if(Ge.existsSync(j)&&Ge.statSync(j).isFile()){let M=Bun.file(j),L=$e.extname(j).toLowerCase(),E="text/plain";if(L===".ts"||L===".tsx"){let _=new Bun.Transpiler({loader:L===".tsx"?"tsx":"ts"}),B=await M.text(),q=_.transformSync(B);return new Response(q,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(L){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(M,{headers:{"Content-Type":E}})}if(x.pathname!=="/"&&u["/"]){let M=xe(v);return h(u["/"].content).then((L)=>{if(M){let E=L.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(E){let _=L.match(/<title[^>]*>([\s\S]*?)<\/title>/i),B=_?_[1]:"",q=`<!DOCTYPE html><html><head><title>${sn(B)}</title></head><body><main>${E[1]}</main></body></html>`;return new Response(q,{headers:{"Content-Type":"text/html","X-STX-Partial":"true",...O(),"Cache-Control":lt,Pragma:"no-cache",Expires:"0"}})}}return new Response(L,{headers:{"Content-Type":"text/html",...O(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(v){return new Response(`<pre>${v}
|
|
1425
1425
|
${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1426
1426
|
${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(`
|
|
1427
1427
|
${e.bright}\u2192 ${e.cyan}http://localhost:${b}/${e.reset}`),console.log(`
|
|
1428
1428
|
${e.yellow}Routes:${e.reset}`);let S=new Set(p.map((v)=>v.routeTemplate)),C=Object.entries(u).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:$e.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of p){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");C.push({route:x,filePath:$e.relative(process.cwd(),v.filePath),fileType:"stx"})}if(C.sort((v,x)=>v.route.localeCompare(x.route)),C.forEach((v,x)=>{let k=x===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ",j=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${j}`)}),console.log(`
|
|
1429
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(w.url.toString(),()=>{if(d)Ge.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ge.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),We.clear(),de(),await y()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function sn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import pe from"fs";import Q from"path";async function ln(t){try{return cn(await Bun.file(t).text())}catch{return}}function Ft(t){let r=Bun.file(t),o=Q.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"},l=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(r,{headers:{"Content-Type":d[o]||"application/octet-stream",...l}})}async function _r(t=".",r={}){let o=r.port||3000,d=r.watch!==!1,a=r.hotReload!==!1&&d,l=null,u=r.hmrPort||o+1,p=Q.resolve(t),{loadStxConfig:y}=await import("./chunk-ncqh5qe5.js"),g=await y(p),{createServerApi:b,isServerApiSource:w}=await import("./chunk-b0hpshvk.js"),S=r.stxOptions?.serverApi??g.serverApi,C=await b(p,S),v=g.root&&g.root!=="."?Q.join(p,g.root):p,x=r.pagesDir||g.pagesDir||"pages",T=Q.join(v,x);if(!pe.existsSync(T)&&!g._layerPageDirs?.some((P)=>pe.existsSync(P)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${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 ${x}/index.stx for the homepage.${e.reset}`),!1;let k=V(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let j=g?._pluginPageDirs||[],M=[];for(let{dir:P,prefix:F}of j)if(pe.existsSync(P)){let z=V(Q.dirname(P),{pagesDir:Q.basename(P)});for(let U of z){let ue=F==="/"?U.pattern:`${F}${U.pattern==="/"?"":U.pattern}`;M.push({route:{...U,pattern:ue},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let L=new Map,E=null,_=null;if(r.stxOptions?.shell!==!1){if(_=await Ei(p,r.stxOptions?.shell),_){if(E=await js(_,r.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${Q.relative(p,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}vt(),await xt(p);let B=wt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let q={},J=null;try{let{loadStxConfig:P}=await import("./chunk-ncqh5qe5.js"),F=await P(p);if(F?.apiRouter)J=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){q=F.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:U}=await import("./chunk-j0v970k3.js"),ue=F.broadcasting;await z(ue);let je=ue.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${je}/ws${e.reset}`);let Ue=Q.join(process.cwd(),"channels.ts");if(pe.existsSync(Ue))try{let Y=await U(Ue);console.log(`${e.blue}Loaded ${e.bright}${Y} broadcast channel${Y!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(Y){console.warn(`${e.yellow}Failed to load channels.ts: ${Y.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let be=c(p,"output");pe.mkdirSync(be,{recursive:!0});let ce=new Map,Re=new Set,Z=async(P)=>{let F=Qr(T,P);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:be,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!z.success)return null;let U=z.outputs.find((ue)=>ue.path.endsWith(".html"));if(!U)return null;return await Bun.file(U.path).text()}catch{return null}},N=new Map,I=async(P,F)=>{try{let{processDirectives:z,extractVariables:U,defaultConfig:ue,loadStxConfig:je,injectRouterScript:Ue}=await import("./chunk-ncqh5qe5.js"),{checkCache:Y,cacheTemplate:G,readFileCached:W,templateCache:K}=await import("./chunk-h5nmf98w.js"),he=await je(p),Ve=(ee)=>{if(!ee)return ee;if(Q.isAbsolute(ee))return ee;return Q.resolve(p,ee)},A={...ue,...he,...r.stxOptions,autoShell:!0};if(r.debugDirectives)A.debug=!0;A.partialsDir=Ve(A.partialsDir),A.componentsDir=Ve(A.componentsDir),A.layoutsDir=Ve(A.layoutsDir),A.storesDir=Ve(A.storesDir||"stores"),A.cachePath=Ve(A.cachePath)??c(p,"cache");let le=!F&&!r.profile,re=A.cache!==!1;if(re&&le){let ee=K.get(P.filePath);if(ee)try{if((await pe.promises.stat(P.filePath)).mtime.getTime()<=ee.mtime){let _e=!0;for(let ke of ee.dependencies){if(!pe.existsSync(ke)){_e=!1;break}if((await pe.promises.stat(ke)).mtime.getTime()>ee.mtime){_e=!1;break}}if(_e){let ke=ee.output;if(E)ke=ze(ke,{preserveHead:!0});let ot=N.get(P.filePath);return{route:P,content:ke,status:ot?.status??await ln(P.filePath),headers:ot?.headers}}}}catch{}let De=await Y(P.filePath,A);if(De){let Me=De;if(E)Me=ze(Me,{preserveHead:!0});let _e=N.get(P.filePath);return{route:P,content:Me,status:_e?.status??await ln(P.filePath),headers:_e?.headers}}}let ae=re?await W(P.filePath):await Bun.file(P.filePath).text(),we=cn(ae),{classifyAllScripts:X}=await import("./chunk-ncqh5qe5.js"),Ae=X(ae),He=Ae.server.map((ee)=>ee.content),oe=ae;for(let ee of Ae.server)oe=oe.replace(ee.fullTag,"");let se={__filename:P.filePath,__dirname:Q.dirname(P.filePath),__stx_options:A,params:F??{},__stx_runtime_head:{}};for(let ee of He)try{await U(ee,se,P.filePath)}catch(De){if(r.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,De?.message||De)}let Fe=new Set,Pe;if(r.profile){let ee=performance.now();Pe=await z(oe,se,P.filePath,A,Fe);let De=performance.now()-ee,Me=Q.relative(p,P.filePath)||P.filePath;console.log(`[stx:profile] ${Me} \u2192 ${De.toFixed(2)}ms`)}else Pe=await z(oe,se,P.filePath,A,Fe);if(!E)Pe=await Ue(Pe,{router:A.router});{let{interpolateScriptExpressions:ee}=await import("./chunk-j5gd0e53.js");Pe=Pe.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,Me,_e)=>{if(!/function\s+__stx_setup_/.test(_e))return De;return`<script${Me}>${ee(_e,se)}</script>`})}if(E)Pe=ze(Pe,{preserveHead:!0});if(re&&le)await G(P.filePath,Pe,Fe,A);let{extractStreamBoundaries:Hn}=await import("./chunk-8fsq2ynj.js"),Qe=Hn(se),rt=se.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ee=se.streamBoundaries||{},De={...A,autoShell:!1},Me=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ee[ke]==="function"?await ee[ke]():void 0;return z(rt[ke],{...se,$boundary:ot},P.filePath,De,new Set)}})),_e=new Set(Me.map((ke)=>ke.id));Qe=[...(Qe||[]).filter((ke)=>!_e.has(ke.id)),...Me]}if(Qe&&Qe.length>0)Re.add(P.pattern);else Qe=void 0;let Ut=Rt(se),Wt=At(se);if(le)N.set(P.filePath,{status:Ut,headers:Wt});return{route:P,content:Pe,status:Ut??we,headers:Wt,boundaries:Qe}}catch(z){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,z),null}},Ie=8,Be=async()=>{ce.clear(),L.clear();for(let P=0;P<k.length;P+=Ie){let F=k.slice(P,P+Ie),z=await Promise.all(F.map((U)=>I(U)));for(let U of z)if(U)ce.set(U.route.pattern,U)}for(let P=0;P<M.length;P+=Ie){let F=M.slice(P,P+Ie),z=await Promise.all(F.map(({route:U})=>I(U)));for(let U of z)if(U)L.set(U.route.pattern,U)}return ce.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Be())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await en(p);let Je=o;try{if(Je=await qe(o),Je!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Je} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(a){let P=r.hmrPort||Je+1;l=$t({wsPort:P,verbose:!1}),u=l.start(P)}let Pt=(P,F)=>{let U=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).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(P.includes("</head>"))return P.replace("</head>",`${U}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${U}`);return U+P};console.log(`${e.blue}Starting server...${e.reset}`);let Ot=Ur({port:Je,async fetch(P){let F=new URL(P.url),z=g?.publicDir||"public",U=Q.join(p,z,F.pathname),ue=Q.join(p,F.pathname),je=Q.join(be,F.pathname);if([U,ue,je].some((A)=>w(A,p,S)))return new Response("Not Found",{status:404});let[Ue,Y,G]=await Promise.all([pe.promises.stat(U).catch(()=>null),pe.promises.stat(ue).catch(()=>null),pe.promises.stat(je).catch(()=>null)]);if(Ue?.isFile()&&!w(U,p,S))return Ft(U);if(Y?.isFile()&&!w(ue,p,S))return Ft(ue);if(G?.isFile()&&!w(je,p,S))return Ft(je);if(F.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(F.pathname.slice(16));if(A)try{let le=`<${A} />`,re={...buildConfig,autoShell:!1},ae=await processDirectives(le,{},Q.join(p,"components",`${A}.stx`),re,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(le){return new Response(`<div class="stx-async-error">${le.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-gz90fqn8.js"),le=await A(P,{publicDir:Q.join(p,z),cacheDir:c(p,"cache","img")});if(le)return le}if(J)try{let A=await J.handleRequest(P);if(A.status!==404)return A}catch{}if(q[F.pathname])try{return await q[F.pathname](P)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let W=await C(P);if(W)return W;let K=Zn(F.pathname,k);if(K){let A=ce.get(K.route.pattern),le=Re.has(K.route.pattern);if(K.route.isDynamic&&Object.keys(K.params).length>0||le){let re=await I(K.route,K.params);if(re)A=re}if(A){let re=A.status??200,ae=A.headers??{},we=(K.route.filePath?ft(await Bun.file(K.route.filePath).text().catch(()=>"")):null)??{};if(we.validate){if(!await we.validate({params:K.params})){let He=await Z(404);if(He){let oe=He;if(oe=await h(oe,p),a)oe=Ne(oe,u);return new Response(oe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(we.middleware){let Ae=St(F.pathname,K.params,we,F.search),He=kt(Ae,null,P,{isServer:!0}),oe=await _t(we.middleware,He);if(oe.redirect){let se=oe.redirect.path,Fe=oe.redirect.options.redirectCode||302,Pe=new Headers(oe.responseHeaders);return Pe.set("Location",se),new Response(null,{status:Fe,headers:Pe})}if(oe.abort){let{statusCode:se,message:Fe}=oe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${se}</title></head><body><h1>Error ${se}</h1><p>${Fe}</p></body></html>`,{status:se,headers:{"Content-Type":"text/html"}})}if(Object.keys(oe.state).length>0){let se=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(oe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${se}</head>`)}}let X=A.content;if(E&&Ti(P)){let Ae=Xe(X),He=ge(X),oe=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i),se=oe?Ci(oe[1].trim()):"";if(Object.keys(K.params).length>0)X=Pt(X,K.params);X=await h(X,p);let Fe=g?.router?.container||"main";return X=Se(X,Fe),new Response(X,{status:re,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ae.layout,"X-STX-Layout-Group":Ae.group,"X-STX-Runtime":He?"true":"false",...se&&{"X-STX-Title":encodeURIComponent(se)},[ta]:Ys(),...O(),"Cache-Control":lt}})}if(E)X=$r(E,X);if(Object.keys(K.params).length>0)X=Pt(X,K.params);if(X=await h(X,p),a)X=Ne(X,u);if(r.native)if(X.includes("<head>"))X=X.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 X="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+X;if(r.titlebarHidden)if(X.includes("<head>"))X=X.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 X=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${X}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Ae,streamToResponse:He}=await import("./chunk-8fsq2ynj.js");return He(Ae(X,A.boundaries,{timeoutMs:30000}),{status:re,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(X,{status:re,headers:{"Content-Type":"text/html",...O(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(M.length>0){let A=M.map((re)=>re.route),le=Zn(F.pathname,A);if(le){let re=L.get(le.route.pattern);if(re){let ae=re.content;if(E)ae=$r(E,ae);if(Object.keys(le.params).length>0)ae=Pt(ae,le.params);if(ae=await h(ae,p),a)ae=Ne(ae,u);return new Response(ae,{status:re.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:re}of j)if(re!=="/"&&F.pathname.startsWith(re)){let ae=L.get(re)||L.get(re+"/");if(ae){let we=ae.content;if(E)we=$r(E,we);if(we=await h(we,p),a)we=Ne(we,u);return new Response(we,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(bt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let he=ce.get("/");if(he){let A=he.content;if(A=await h(A,p),a)A=Ne(A,u);if(r.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Ve=await Z(404);if(Ve){let A=Ve;if(A=await h(A,p),a)A=Ne(A,u);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let F=await Z(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
|
|
1429
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(w.url.toString(),()=>{if(d)Ge.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ge.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),We.clear(),de(),await y()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function sn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import pe from"fs";import Q from"path";async function ln(t){try{return cn(await Bun.file(t).text())}catch{return}}function Ft(t){let r=Bun.file(t),o=Q.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"},l=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(r,{headers:{"Content-Type":d[o]||"application/octet-stream",...l}})}async function Cr(t=".",r={}){let o=r.port||3000,d=r.watch!==!1,a=r.hotReload!==!1&&d,l=null,u=r.hmrPort||o+1,p=Q.resolve(t),{loadStxConfig:y}=await import("./chunk-jmx4q1yr.js"),g=await y(p),{createServerApi:b,isServerApiSource:w}=await import("./chunk-7wnd2psp.js"),S=r.stxOptions?.serverApi??g.serverApi,C=await b(p,S),v=g.root&&g.root!=="."?Q.join(p,g.root):p,x=r.pagesDir||g.pagesDir||"pages",T=Q.join(v,x);if(!pe.existsSync(T)&&!g._layerPageDirs?.some((P)=>pe.existsSync(P)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${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 ${x}/index.stx for the homepage.${e.reset}`),!1;let k=V(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let j=g?._pluginPageDirs||[],M=[];for(let{dir:P,prefix:F}of j)if(pe.existsSync(P)){let z=V(Q.dirname(P),{pagesDir:Q.basename(P)});for(let U of z){let ue=F==="/"?U.pattern:`${F}${U.pattern==="/"?"":U.pattern}`;M.push({route:{...U,pattern:ue},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let L=new Map,E=null,_=null;if(r.stxOptions?.shell!==!1){if(_=await Ei(p,r.stxOptions?.shell),_){if(E=await js(_,r.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${Q.relative(p,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}vt(),await xt(p);let B=wt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let q={},J=null;try{let{loadStxConfig:P}=await import("./chunk-jmx4q1yr.js"),F=await P(p);if(F?.apiRouter)J=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){q=F.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:U}=await import("./chunk-j0v970k3.js"),ue=F.broadcasting;await z(ue);let je=ue.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${je}/ws${e.reset}`);let Ue=Q.join(process.cwd(),"channels.ts");if(pe.existsSync(Ue))try{let Y=await U(Ue);console.log(`${e.blue}Loaded ${e.bright}${Y} broadcast channel${Y!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(Y){console.warn(`${e.yellow}Failed to load channels.ts: ${Y.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let be=c(p,"output");pe.mkdirSync(be,{recursive:!0});let ce=new Map,Ce=new Set,Z=async(P)=>{let F=Qr(T,P);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:be,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...r.stxOptions});if(!z.success)return null;let U=z.outputs.find((ue)=>ue.path.endsWith(".html"));if(!U)return null;return await Bun.file(U.path).text()}catch{return null}},N=new Map,I=async(P,F)=>{try{let{processDirectives:z,extractVariables:U,defaultConfig:ue,loadStxConfig:je,injectRouterScript:Ue}=await import("./chunk-jmx4q1yr.js"),{checkCache:Y,cacheTemplate:G,readFileCached:W,templateCache:K}=await import("./chunk-hw7sv4ac.js"),he=await je(p),Ve=(ee)=>{if(!ee)return ee;if(Q.isAbsolute(ee))return ee;return Q.resolve(p,ee)},A={...ue,...he,...r.stxOptions,autoShell:!0};if(r.debugDirectives)A.debug=!0;A.partialsDir=Ve(A.partialsDir),A.componentsDir=Ve(A.componentsDir),A.layoutsDir=Ve(A.layoutsDir),A.storesDir=Ve(A.storesDir||"stores"),A.cachePath=Ve(A.cachePath)??c(p,"cache");let le=!F&&!r.profile,ne=A.cache!==!1;if(ne&&le){let ee=K.get(P.filePath);if(ee)try{if((await pe.promises.stat(P.filePath)).mtime.getTime()<=ee.mtime){let Me=!0;for(let ke of ee.dependencies){if(!pe.existsSync(ke)){Me=!1;break}if((await pe.promises.stat(ke)).mtime.getTime()>ee.mtime){Me=!1;break}}if(Me){let ke=ee.output;if(E)ke=ze(ke,{preserveHead:!0});let ot=N.get(P.filePath);return{route:P,content:ke,status:ot?.status??await ln(P.filePath),headers:ot?.headers}}}}catch{}let Ae=await Y(P.filePath,A);if(Ae){let De=Ae;if(E)De=ze(De,{preserveHead:!0});let Me=N.get(P.filePath);return{route:P,content:De,status:Me?.status??await ln(P.filePath),headers:Me?.headers}}}let ie=ne?await W(P.filePath):await Bun.file(P.filePath).text(),we=cn(ie),{classifyAllScripts:X}=await import("./chunk-jmx4q1yr.js"),Oe=X(ie),He=Oe.server.map((ee)=>ee.content),oe=ie;for(let ee of Oe.server)oe=oe.replace(ee.fullTag,"");let se={__filename:P.filePath,__dirname:Q.dirname(P.filePath),__stx_options:A,params:F??{},__stx_runtime_head:{}};for(let ee of He)try{await U(ee,se,P.filePath)}catch(Ae){if(r.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,Ae?.message||Ae)}let Fe=new Set,Re;if(r.profile){let ee=performance.now();Re=await z(oe,se,P.filePath,A,Fe);let Ae=performance.now()-ee,De=Q.relative(p,P.filePath)||P.filePath;console.log(`[stx:profile] ${De} \u2192 ${Ae.toFixed(2)}ms`)}else Re=await z(oe,se,P.filePath,A,Fe);if(!E)Re=await Ue(Re,{router:A.router});{let{interpolateScriptExpressions:ee}=await import("./chunk-q1x7ckfw.js");Re=Re.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ae,De,Me)=>{if(!/function\s+__stx_setup_/.test(Me))return Ae;return`<script${De}>${ee(Me,se)}</script>`})}if(E)Re=ze(Re,{preserveHead:!0});if(ne&&le)await G(P.filePath,Re,Fe,A);let{extractStreamBoundaries:Hn}=await import("./chunk-ndtxkps4.js"),Qe=Hn(se),rt=se.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ee=se.streamBoundaries||{},Ae={...A,autoShell:!1},De=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ee[ke]==="function"?await ee[ke]():void 0;return z(rt[ke],{...se,$boundary:ot},P.filePath,Ae,new Set)}})),Me=new Set(De.map((ke)=>ke.id));Qe=[...(Qe||[]).filter((ke)=>!Me.has(ke.id)),...De]}if(Qe&&Qe.length>0)Ce.add(P.pattern);else Qe=void 0;let Ut=Rt(se),Wt=At(se);if(le)N.set(P.filePath,{status:Ut,headers:Wt});return{route:P,content:Re,status:Ut??we,headers:Wt,boundaries:Qe}}catch(z){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,z),null}},Ie=8,Be=async()=>{ce.clear(),L.clear();for(let P=0;P<k.length;P+=Ie){let F=k.slice(P,P+Ie),z=await Promise.all(F.map((U)=>I(U)));for(let U of z)if(U)ce.set(U.route.pattern,U)}for(let P=0;P<M.length;P+=Ie){let F=M.slice(P,P+Ie),z=await Promise.all(F.map(({route:U})=>I(U)));for(let U of z)if(U)L.set(U.route.pattern,U)}return ce.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Be())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await en(p);let Je=o;try{if(Je=await qe(o),Je!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Je} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(a){let P=r.hmrPort||Je+1;l=$t({wsPort:P,verbose:!1}),u=l.start(P)}let Ot=(P,F)=>{let U=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).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(P.includes("</head>"))return P.replace("</head>",`${U}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${U}`);return U+P};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Ur({port:Je,async fetch(P){let F=new URL(P.url),z=g?.publicDir||"public",U=Q.join(p,z,F.pathname),ue=Q.join(p,F.pathname),je=Q.join(be,F.pathname);if([U,ue,je].some((A)=>w(A,p,S)))return new Response("Not Found",{status:404});let[Ue,Y,G]=await Promise.all([pe.promises.stat(U).catch(()=>null),pe.promises.stat(ue).catch(()=>null),pe.promises.stat(je).catch(()=>null)]);if(Ue?.isFile()&&!w(U,p,S))return Ft(U);if(Y?.isFile()&&!w(ue,p,S))return Ft(ue);if(G?.isFile()&&!w(je,p,S))return Ft(je);if(F.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(F.pathname.slice(16));if(A)try{let le=`<${A} />`,ne={...buildConfig,autoShell:!1},ie=await processDirectives(le,{},Q.join(p,"components",`${A}.stx`),ne,new Set);return new Response(ie,{headers:{"Content-Type":"text/html"}})}catch(le){return new Response(`<div class="stx-async-error">${le.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-vmn2b6p6.js"),le=await A(P,{publicDir:Q.join(p,z),cacheDir:c(p,"cache","img")});if(le)return le}if(J)try{let A=await J.handleRequest(P);if(A.status!==404)return A}catch{}if(q[F.pathname])try{return await q[F.pathname](P)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let W=await C(P);if(W)return W;let K=Zn(F.pathname,k);if(K){let A=ce.get(K.route.pattern),le=Ce.has(K.route.pattern);if(K.route.isDynamic&&Object.keys(K.params).length>0||le){let ne=await I(K.route,K.params);if(ne)A=ne}if(A){let ne=A.status??200,ie=A.headers??{},we=(K.route.filePath?ft(await Bun.file(K.route.filePath).text().catch(()=>"")):null)??{};if(we.validate){if(!await we.validate({params:K.params})){let He=await Z(404);if(He){let oe=He;if(oe=await h(oe,p),a)oe=Ne(oe,u);return new Response(oe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(we.middleware){let Oe=St(F.pathname,K.params,we,F.search),He=kt(Oe,null,P,{isServer:!0}),oe=await Ct(we.middleware,He);if(oe.redirect){let se=oe.redirect.path,Fe=oe.redirect.options.redirectCode||302,Re=new Headers(oe.responseHeaders);return Re.set("Location",se),new Response(null,{status:Fe,headers:Re})}if(oe.abort){let{statusCode:se,message:Fe}=oe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${se}</title></head><body><h1>Error ${se}</h1><p>${Fe}</p></body></html>`,{status:se,headers:{"Content-Type":"text/html"}})}if(Object.keys(oe.state).length>0){let se=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(oe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${se}</head>`)}}let X=A.content;if(E&&Ti(P)){let Oe=Xe(X),He=ge(X),oe=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i),se=oe?_i(oe[1].trim()):"";if(Object.keys(K.params).length>0)X=Ot(X,K.params);X=await h(X,p);let Fe=g?.router?.container||"main";return X=Se(X,Fe),new Response(X,{status:ne,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":He?"true":"false",...se&&{"X-STX-Title":encodeURIComponent(se)},[ta]:Ys(),...O(),"Cache-Control":lt}})}if(E)X=$r(E,X);if(Object.keys(K.params).length>0)X=Ot(X,K.params);if(X=await h(X,p),a)X=Ne(X,u);if(r.native)if(X.includes("<head>"))X=X.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 X="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+X;if(r.titlebarHidden)if(X.includes("<head>"))X=X.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 X=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${X}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:He}=await import("./chunk-ndtxkps4.js");return He(Oe(X,A.boundaries,{timeoutMs:30000}),{status:ne,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(X,{status:ne,headers:{"Content-Type":"text/html",...O(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ie}})}}if(M.length>0){let A=M.map((ne)=>ne.route),le=Zn(F.pathname,A);if(le){let ne=L.get(le.route.pattern);if(ne){let ie=ne.content;if(E)ie=$r(E,ie);if(Object.keys(le.params).length>0)ie=Ot(ie,le.params);if(ie=await h(ie,p),a)ie=Ne(ie,u);return new Response(ie,{status:ne.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ne}of j)if(ne!=="/"&&F.pathname.startsWith(ne)){let ie=L.get(ne)||L.get(ne+"/");if(ie){let we=ie.content;if(E)we=$r(E,we);if(we=await h(we,p),a)we=Ne(we,u);return new Response(we,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(bt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let he=ce.get("/");if(he){let A=he.content;if(A=await h(A,p),a)A=Ne(A,u);if(r.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Ve=await Z(404);if(Ve){let A=Ve;if(A=await h(A,p),a)A=Ne(A,u);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let F=await Z(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
|
|
1430
1430
|
${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1431
1431
|
${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(`
|
|
1432
1432
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Je}/${e.reset}`),a)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1433
|
-
${e.yellow}Routes:${e.reset}`);let
|
|
1434
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(
|
|
1433
|
+
${e.yellow}Routes:${e.reset}`);let Mt=[...es(k,p)];for(let{route:P}of M)Mt.push(`${P.pattern}`);if(Mt.forEach((P,F)=>{let U=F===Mt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${U}${e.reset}${P}`)}),console.log(`
|
|
1434
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(Dt.url.toString(),()=>{if(l)st();Dt.stop()}),r.native){let P,F=Q.join(T,"index.stx");if(pe.existsSync(F)){let U=await Bun.file(F).text();P=gt(U)}let z=g?.app?.window??{};await Ze(Je,{title:g?.app?.head?.title||Q.basename(p)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??r.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let P=(Y)=>Y.startsWith("public/")||Y.startsWith("public\\"),F=(Y)=>{let G=Y.toLowerCase();return G.endsWith(".stx")||G.endsWith(".html")||G.endsWith(".md")},z=new Map,U=()=>{let Y=new Set([p,...g._layerGraph?.layers.map((G)=>G.root)??[],...g._layerGraph?.configDependencies.map((G)=>Q.dirname(G))??[]].filter((G)=>pe.existsSync(G)).map((G)=>pe.realpathSync(G)));for(let G of g._layerGraph?.layers??[])for(let W of Object.values(G.resources)){if(!pe.existsSync(W))continue;let K=pe.realpathSync(W);if(![...Y].some((he)=>K===he||K.startsWith(`${he}${Q.sep}`)))Y.add(K)}for(let[G,W]of z)if(!Y.has(G))W.close(),z.delete(G);for(let G of Y)if(!z.has(G)&&pe.existsSync(G))z.set(G,pe.watch(G,{recursive:!0},(W,K)=>{je(G,W,K).catch((he)=>console.error("[stx] Layer rebuild failed:",he))}))},ue=Promise.resolve(),je=(Y,G,W)=>(ue=ue.catch(()=>{}).then(()=>Ue(Y,G,W)),ue),Ue=async(Y,G,W)=>{if(!W||Tt(W))return;if(yt(W)){if(g._layerGraph){let K=await y(p);Object.assign(g,K),k.splice(0,k.length,...V(v,{pagesDir:x,pagesDirs:K._layerPageDirs?[T,...K._layerPageDirs.slice(1)]:void 0})),U()}if(P(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),a&&l)l.reload(W)}else if(F(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),We.clear(),de();try{let{invalidateFileCache:K,templateCache:he}=await import("./chunk-hw7sv4ac.js");K(Q.resolve(Y,W)),he.delete(Q.resolve(Y,W))}catch{}if(_&&W){if(Q.resolve(Y,W)===_||Q.basename(_)===W){let he=await js(_,r.stxOptions||{});if(he)E=he}}if(await Be(),await Wn(p),a&&l)l.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),We.clear(),de();try{let{invalidateFileCache:K,templateCache:he}=await import("./chunk-hw7sv4ac.js");K(Q.resolve(Y,W)),he.delete(Q.resolve(Y,W))}catch{}if(await Be(),a&&l)l.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),a&&l)l.updateCss(W)}};U(),process.on("SIGINT",()=>{for(let Y of z.values())Y.close();if(l)st();Dt.stop(),process.exit(0)})}return!0}import zt from"fs";import it from"path";async function Wr(t){try{let o=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],a=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=l.exec(d))!==null){let p=u[1],y=u[2]||u[3]||u[4];if(!y)continue;let g={name:y},b=p.match(/@type\s+\{([^}]+)\}/i);if(b)g.type=b[1].trim();if(p.match(/@required/i))g.required=!0;let S=p.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let C=p.split(`
|
|
1435
1435
|
`).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);g.description=C.join(" ").trim(),a.push(g)}if(a.length===0){let p=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(p){let g=p[1].split(",").map((b)=>b.trim()).filter(Boolean);for(let b of g){let[w]=b.split(":").map((S)=>S.trim());if(w)a.push({name:w})}}}return a}catch(r){return console.error(`Error extracting props from ${t}:`,r),[]}}async function Vr(t){try{let r=await Bun.file(t).text(),o=r.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||r.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
|
|
1436
1436
|
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Kr(t,r=!1,o){let d=it.basename(t,".stx"),a=await Wr(t),l=await Vr(t),u="";if(r&&o)u=`<${o}></${o}>`;else{let p=a.map((y)=>{if(y.type==="boolean")return`:${y.name}="true"`;return`${y.name}="value"`}).join(`
|
|
1437
1437
|
`);u=`<${d}
|
|
@@ -2029,5 +2029,5 @@ const features = [
|
|
|
2029
2029
|
})();
|
|
2030
2030
|
</script>
|
|
2031
2031
|
</body>
|
|
2032
|
-
</html>`}var yi="f9c3713";function xc(t){return t}function Sc(t){return t}function di(t,r){let o=[],d=`${r}=`;for(let a=0;a<t.length;a++){let l=t[a];if(l.startsWith(d)){let u=l.slice(d.length);if(u)o.push(u);continue}if(l===r){let u=t[a+1];if(u!==void 0&&!u.startsWith("-"))o.push(u),a++}}return o}import
|
|
2033
|
-
`)}export{di,pi,fi,gi,As,mi,hi,yi,xc,Sc,Ps,Is,Sr,kr,
|
|
2032
|
+
</html>`}var yi="f9c3713";function xc(t){return t}function Sc(t){return t}function di(t,r){let o=[],d=`${r}=`;for(let a=0;a<t.length;a++){let l=t[a];if(l.startsWith(d)){let u=l.slice(d.length);if(u)o.push(u);continue}if(l===r){let u=t[a+1];if(u!==void 0&&!u.startsWith("-"))o.push(u),a++}}return o}import Pe from"fs";import ye from"path";function $n(t){try{return Pe.statSync(t).mtimeMs}catch{return null}}function Pt(t,r){let o=Math.max(0,Math.round((r-t)/1000));if(o<60)return`${o}s ago`;if(o<3600)return`${Math.round(o/60)}m ago`;return`${Math.round(o/3600)}h ago`}function Oi(t,r){try{return globalThis.Bun?.resolveSync(t,r)??null}catch{return null}}function Cn(t,r="stx"){let o=ye.resolve(t);for(let d=0;d<10;d++){let a=ye.join(o,"pantry","@stacksjs",r);if(Pe.existsSync(a))return a;let l=ye.dirname(o);if(l===o)break;o=l}return null}var Rn=["@stacksjs/stx","bun-plugin-stx"];function Ai(t){try{let r=Pe.readFileSync(ye.join(t,"package.json"),"utf8"),o=JSON.parse(r)?.version;return typeof o==="string"?o:null}catch{return null}}function Di(t,r=6){let o=ye.resolve(t),d=[],a=new Set;function l(p,y){if(y>r)return;let g;try{g=Pe.realpathSync(p)}catch{return}if(a.has(g))return;a.add(g);for(let w of Rn){let S=ye.join(p,w),C=Ai(S);if(C!==null)d.push({name:w,version:C,dir:ye.relative(o,S)||S,nested:y>0})}let b;try{b=Pe.readdirSync(p,{withFileTypes:!0})}catch{return}for(let w of b){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=ye.join(p,w.name);if(w.name.startsWith("@")){let v;try{v=Pe.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let T=ye.join(S,x.name,"node_modules");if(Pe.existsSync(T))l(T,y+1)}continue}let C=ye.join(S,"node_modules");if(Pe.existsSync(C))l(C,y+1)}}let u=ye.join(o,"node_modules");if(Pe.existsSync(u))l(u,0);return d}function Mi(t){let r=[];for(let o of Rn){let d=t.filter((u)=>u.name===o);if(d.length<=1)continue;let a=[...new Set(d.map((u)=>u.version))],l=d.map((u)=>`${u.version} at ${u.dir}`).join("; ");if(a.length===1){r.push({name:`${o} copies`,status:"info",detail:`${d.length} copies, all ${a[0]} \u2014 duplicated but in agreement`});continue}r.push({name:`${o} copies disagree`,status:"error",detail:`${a.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${o}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${o}/package.json' -exec grep -H '"version"' {} +`})}return r}async function Ps(t={}){let r=t.cwd?ye.resolve(t.cwd):process.cwd(),o=t.resolve??Oi,d=Date.now(),a=[],l=o("@stacksjs/stx",r);a.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let u=o("bun-plugin-stx",r);if(u)a.push({name:"bun-plugin-stx resolves to",status:"ok",detail:u});for(let y of Mi(Di(r)))a.push(y);let p=Cn(r,"stx");if(!p)a.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let y=ye.join(p,"src/signals.ts"),g=[ye.join(p,"dist/index.js"),ye.join(p,"dist/signals.js")].find((v)=>Pe.existsSync(v))||null,b=$n(y),w=g?$n(g):null;if(b==null)a.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${p} but no src/signals.ts to compare`});else if(w==null)a.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 ${p} && bun build.ts`});else if(w<b){let v=Math.round((b-w)/1000);a.push({name:"pantry dist freshness",status:"error",detail:`dist (${Pt(w,d)}) is OLDER than src/signals.ts (${Pt(b,d)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${p} && bun build.ts`})}else a.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${Pt(b,d)}, dist ${Pt(w,d)})`});let S=ye.join(r,"node_modules/@stacksjs/stx"),C=null;try{C=Pe.lstatSync(S)}catch{C=null}if(!C)a.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(C.isSymbolicLink()){let v=null;try{v=Pe.realpathSync(S)}catch{}let x=(()=>{try{return Pe.realpathSync(p)}catch{return p}})();a.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else a.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(a.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 g=t.generateRuntime().length;a.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(y){a.push({name:"signals runtime",status:"error",detail:`failed to generate: ${y.message}`})}return{checks:a,ok:!a.some((y)=>y.status==="error")}}function Is(t){let r={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},o=["stx runtime resolution:"];for(let d of t.checks)if(o.push(` ${r[d.status]} ${d.name}: ${d.detail}`),d.fix)o.push(` \u2192 ${d.fix}`);return o.push(""),o.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),o.join(`
|
|
2033
|
+
`)}export{di,pi,fi,gi,As,mi,hi,yi,xc,Sc,Ps,Is,Sr,kr,Cr};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Es,jt,bc,gu}from"./chunk-
|
|
2
|
+
import{Es,jt,bc,gu}from"./chunk-mgj34bbg.js";export{Es as generateServiceWorker,gu as generateServiceWorkerAuto,jt as getServiceWorkerFileName,bc as isWorkboxEnabled};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ta,n,de}from"./chunk-
|
|
2
|
+
import{Ta,n,de}from"./chunk-2yg9y1na.js";import{Ye}from"./chunk-x34scshq.js";import{c}from"./chunk-dxk5sqtv.js";import o from"fs";import l from"path";var El=new Map,m=new Map;async function gp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function mp(e){m.delete(e)}function hp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yp(e){x=e}async function Tl(e=!1){let t=x??await import("./chunk-c9b0cme2.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function $l(){if(S===null){let{getRouterScript:e}=await import("./chunk-50pkybyn.js");S=e()}return S}var y={};async function bp(e,t=!1){let r=e==="runtime"?await Tl(t):await $l(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function vp(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function uo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function wp(){m.clear(),de(),Ta(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Xn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Wr(e)}.html`),s=l.join(r,`${Wr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Ye())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Jn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Wr(e)}.html`),a=l.join(s,`${Wr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Ye(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),El.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Wr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-z75bp57x.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-edz1h5f9.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-ht3dxx5m.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-hvtzw1jh.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
|
|
4
4
|
`)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{gn,jo}from"./chunk-
|
|
2
|
+
import{gn,jo}from"./chunk-35zjpdcb.js";import"./chunk-2h8ea0we.js";export{jo as generateRuntimeConfigTypes,gn as prepareRuntimeConfig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-cvw7gknw.js";import"./chunk-5yxd4ryz.js";import"./chunk-9y2ncrnq.js";import"./chunk-3v8yejzc.js";import"./chunk-26whq1rg.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-h09a03ay.js";import"./chunk-qrt8b179.js";import"./chunk-2yg9y1na.js";import"./chunk-35zjpdcb.js";import"./chunk-2h8ea0we.js";import"./chunk-4e0z858k.js";import"./chunk-ce6zddpf.js";import"./chunk-4qwvqbzf.js";export{Fn as MODULE_SPECIFIER_PREFIX,ll as bundleCacheDir,ul as bundleCacheEntryLimit,Yt as bundleClientScript,Kt as clearBundleFailures,Ce as clientBundleDependencies,Gt as getBundleFailures,Xt as hasUserImports,Jt as moduleSubstitutionKey,fl as normalizeRegistrySpecifiers,ml as queueClientBundleBuild,Qi as recordBundleFailure,pl as registryIdForPath,ea as resolveBundlerFallback,gl as rewriteRegistryImports,rp as setBundlerFallbackMode,dl as shouldLogBundlerDiagnostics,hl as tempBuildName,qs as withModuleSubstitutes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{X,J,Y,
|
|
2
|
+
import{X,J,Y,_n,pe,ke,Rr,Fc,ut,Ut,En,Tn,$n,Z,Rn,An,Ar}from"./chunk-48acjmeg.js";import"./chunk-c1dkh0es.js";export{J as DEFAULT_FORMATS,Y as DEFAULT_QUALITY,X as DEFAULT_WIDTHS,Ar as ImageProcessingError,An as formatSize,Ut as generateSizes,ut as generateSrcSet,En as getFallbackVariant,Rr as getImageMetadata,Z as getMimeType,Rn as getTotalSize,Tn as groupVariantsByFormat,pe as isImageBackendAvailable,$n as isImageFile,_n as isSharpAvailable,ke as processImage,Fc as resizeAndConvert};
|