@stacksjs/stx 0.2.719 → 0.2.720
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-e1aanync.js → chunk-009y9zkg.js} +1 -1
- package/dist/{chunk-mzpwx4wc.js → chunk-04xtzbf6.js} +1 -1
- package/dist/{chunk-73q5nsnn.js → chunk-0azq3w1a.js} +70 -70
- package/dist/{chunk-dt6brr7c.js → chunk-0ktg5dw9.js} +1 -1
- package/dist/{chunk-g3abhp6t.js → chunk-0wfbhs15.js} +1 -1
- package/dist/{chunk-mt0ygagj.js → chunk-11k6atcw.js} +1 -1
- package/dist/{chunk-vmw58vmd.js → chunk-1xt84h16.js} +1 -1
- package/dist/{chunk-de57r7mv.js → chunk-2f3zw2wy.js} +1 -1
- package/dist/{chunk-4ck9gn1p.js → chunk-2gg3apz0.js} +1 -1
- package/dist/{chunk-cn8f5xrk.js → chunk-2rj4t9wz.js} +1 -1
- package/dist/chunk-2sjvj2gb.js +2 -0
- package/dist/{chunk-78q2vtj6.js → chunk-43anje0a.js} +1 -1
- package/dist/chunk-4m1zv168.js +2 -0
- package/dist/{chunk-kz45byxr.js → chunk-57ecpsqy.js} +1 -1
- package/dist/chunk-5awvckb2.js +2 -0
- package/dist/{chunk-jj6603q4.js → chunk-5bm0nh5f.js} +2 -2
- package/dist/chunk-5dvb2e8f.js +2 -0
- package/dist/{chunk-2bd58z9j.js → chunk-5rjfaj0b.js} +2 -2
- package/dist/{chunk-xse41ysy.js → chunk-6h0n7h97.js} +2 -2
- package/dist/chunk-6r1wzzt3.js +2 -0
- package/dist/{chunk-wx7mnsn3.js → chunk-8csv4s4f.js} +3 -3
- package/dist/{chunk-420c80ek.js → chunk-8deed4r2.js} +1 -1
- package/dist/{chunk-ywbzzwan.js → chunk-9v16zd8h.js} +1 -1
- package/dist/{chunk-n4syb1xp.js → chunk-9vx6et01.js} +1 -1
- package/dist/{chunk-m5j9mmdg.js → chunk-a82dg51h.js} +1 -1
- package/dist/{chunk-p71pn6y7.js → chunk-b8a8900p.js} +1 -1
- package/dist/{chunk-3nnrr8gj.js → chunk-bpds7e9v.js} +1 -1
- package/dist/chunk-ddxrb5zk.js +2 -0
- package/dist/{chunk-7s330jzg.js → chunk-dffe3vx2.js} +1 -1
- package/dist/{chunk-tagjv0jv.js → chunk-e13vngat.js} +1 -1
- package/dist/{chunk-fv5ve865.js → chunk-ejp4d8cq.js} +1 -1
- package/dist/chunk-g9vag1n2.js +2 -0
- package/dist/{chunk-d7ke92fw.js → chunk-gwq82dpy.js} +4 -4
- package/dist/chunk-hgrtnyp3.js +2 -0
- package/dist/{chunk-ffwcxkwc.js → chunk-hp957nrn.js} +2 -2
- package/dist/{chunk-pjxhwadp.js → chunk-hpg5bjzb.js} +1 -1
- package/dist/{chunk-017qzxk2.js → chunk-hsqqhjhr.js} +1 -1
- package/dist/{chunk-qn70kptb.js → chunk-jh8b3f9w.js} +1 -1
- package/dist/{chunk-p0f8tk1y.js → chunk-jtf6sxgd.js} +1 -1
- package/dist/chunk-jy8m3dah.js +3 -0
- package/dist/{chunk-7gwzs2r4.js → chunk-kbw75yd7.js} +1 -1
- package/dist/{chunk-jezde5e7.js → chunk-kn92y5yd.js} +2 -2
- package/dist/{chunk-333m1t0q.js → chunk-kxp881ch.js} +1 -1
- package/dist/{chunk-znem9gkn.js → chunk-m7hbk341.js} +1 -1
- package/dist/{chunk-xer0b0fq.js → chunk-mhpek1hj.js} +1 -1
- package/dist/{chunk-k9b03fs7.js → chunk-n0bw2kzs.js} +1 -1
- package/dist/{chunk-f4psctmd.js → chunk-nb65s3b5.js} +4 -4
- package/dist/{chunk-bhjxhn4f.js → chunk-pcsgj3a5.js} +1 -1
- package/dist/{chunk-51dchxrg.js → chunk-pqrgaahp.js} +1 -1
- package/dist/{chunk-k22vwba4.js → chunk-pz837t6v.js} +1 -1
- package/dist/{chunk-qmkyg3ms.js → chunk-qvwwpnyk.js} +3 -3
- package/dist/{chunk-75gpcwjh.js → chunk-r1t5dcsn.js} +1 -1
- package/dist/{chunk-3q7k14g4.js → chunk-rfb00eqz.js} +5 -5
- package/dist/{chunk-hdp7ahdh.js → chunk-rm9rmyh2.js} +1 -1
- package/dist/chunk-sey2x612.js +2 -0
- package/dist/{chunk-66japy4e.js → chunk-ty5rncss.js} +1 -1
- package/dist/{chunk-kqn9hdcv.js → chunk-ve78svbr.js} +1 -1
- package/dist/{chunk-840g5rgt.js → chunk-xhpf68p4.js} +1 -1
- package/dist/{chunk-tgfjt525.js → chunk-xvkqa756.js} +1 -1
- package/dist/{chunk-k121aqt5.js → chunk-y0bepgyh.js} +1 -1
- package/dist/chunk-y7b9kqz8.js +2 -0
- package/dist/{chunk-rpwnawz7.js → chunk-zc116ep8.js} +1 -1
- package/dist/{chunk-8r9e5jwh.js → chunk-znknf1jt.js} +5 -5
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-6z4m16w5.js +0 -2
- package/dist/chunk-8992v121.js +0 -2
- package/dist/chunk-9fzv6jq3.js +0 -2
- package/dist/chunk-dn45g6kf.js +0 -2
- package/dist/chunk-dveg90mc.js +0 -2
- package/dist/chunk-fckcrfwh.js +0 -2
- package/dist/chunk-fg0gvfg5.js +0 -2
- package/dist/chunk-m70n1h42.js +0 -2
- package/dist/chunk-qp5t4yy0.js +0 -2
- package/dist/chunk-qs440jfy.js +0 -2
- package/dist/chunk-sn9e37wg.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ko,pc,o,$t,oe,C,Ie,un,Oe,pe,X,hr,dn,$s,kc,fn,vr,As,Ps,_c,Qo,Cc,Ec,Tc,$c,De,Me,Is,Be,r,hn,h,p,V,Z,xe,k,E}from"./chunk-
|
|
2
|
+
import{Ko,pc,o,$t,oe,C,Ie,un,Oe,pe,X,hr,dn,$s,kc,fn,vr,As,Ps,_c,Qo,Cc,Ec,Tc,$c,De,Me,Is,Be,r,hn,h,p,V,Z,xe,k,E}from"./chunk-0azq3w1a.js";import{u,f,R,t,ae,q,c,Se,ui,B,wn,di,jt,pi,zc,kr,Hc,st,Vc,_r,Uc,xn,fi,Wc,Cr,Tr,ke,gi}from"./chunk-zkx2m308.js";import{Dt}from"./chunk-rbmt5w9v.js";import{bn}from"./chunk-xhpf68p4.js";import{y}from"./chunk-6h0n7h97.js";import{dr,vs}from"./chunk-2mqzpzy7.js";import{Ja,Ya,cr,Ye,Za,P}from"./chunk-5rjfaj0b.js";import{jo,Bo,Fo,zo}from"./chunk-q7fh1xka.js";import{Wa,ns}from"./chunk-kbw75yd7.js";import{Zr,Qr,es}from"./chunk-nb65s3b5.js";import{rs,Ao,Po,ss,os,Io}from"./chunk-5bm0nh5f.js";import{Yr,nr}from"./chunk-jtf6sxgd.js";import{So}from"./chunk-x9wwd2ee.js";import{se,Eo,To,$o}from"./chunk-r3j4m04w.js";import{sr,ye,Ka,or,Ga}from"./chunk-gwq82dpy.js";import{L,Xe}from"./chunk-f4gqzg1y.js";import{Qa,ec}from"./chunk-b8a8900p.js";import{T,Sn,mi}from"./chunk-xaddgvkx.js";import fs from"fs";import ce from"path";function lt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -1558,13 +1558,13 @@ ${M}
|
|
|
1558
1558
|
</style>`;a=a.replace(x,I),v.lastIndex=0}catch(M){}}}return a}import it from"path";var us=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ds=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ps(s,e){if(!e||!s.includes("/"))return s;let l=it.dirname(e);return s.replace(us,(a,g,n,d)=>{let v=it.resolve(l,d);return`${g}${n}${v.split(it.sep).join("/")}${n}`})}function cn(s,e){if(!e||!s.includes("<script"))return s;return s.replace(ds,(l,a,g,n)=>`${a}${ps(g,e)}${n}`)}var _e="<!--PARENT_CONTENT_PLACEHOLDER-->";function ln(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function kn(s,e){let l=s.length,a=e,g=!0,n=[],d=(v)=>v+9<=l&&s[v]==="<"&&s[v+1]==="/"&&(s[v+2]==="s"||s[v+2]==="S")&&(s[v+3]==="c"||s[v+3]==="C")&&(s[v+4]==="r"||s[v+4]==="R")&&(s[v+5]==="i"||s[v+5]==="I")&&(s[v+6]==="p"||s[v+6]==="P")&&(s[v+7]==="t"||s[v+7]==="T")&&(s[v+8]===">"||/\s/.test(s[v+8]));while(a<l){let v=s[a];if(d(a))return a;if(v==="/"&&s[a+1]==="/"){if(a=s.indexOf(`
|
|
1559
1559
|
`,a+2),a===-1)return-1;a+=1,g=!0;continue}if(v==="/"&&s[a+1]==="*"){let m=s.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,g=!0;continue}if(v==="/"&&g){let m=a+1,x=!1;while(m<l){let b=s[m];if(b==="\\"){m+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){m++;break}else if(b===`
|
|
1560
1560
|
`){m=-1;break}m++}if(m===-1){a++,g=!1;continue}while(m<l&&/[a-z]/.test(s[m]))m++;a=m,g=!1;continue}if(v==="'"||v==='"'){let m=v;a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]===m){a++;break}if(s[a]===`
|
|
1561
|
-
`)break;a++}g=!1;continue}if(v==="`"){a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,g=!0;break}a++}if(n.length===0)g=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++,g=!1;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,g=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;a++}return-1}function $n(s,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(s);if(!a)return null;let g=a.index+a[0].length,n=s.indexOf("</script>",g);if(n===-1)return null;let d=s.indexOf(">",n);if(d===-1)return null;return{start:a.index,end:d+1}}var gs=4096;async function pn(s,e,l){if(l.buildMode!=="serve"||e.length<gs)return null;let{registerServeModuleBundle:a}=await import("./chunk-
|
|
1561
|
+
`)break;a++}g=!1;continue}if(v==="`"){a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,g=!0;break}a++}if(n.length===0)g=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++,g=!1;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,g=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;a++}return-1}function $n(s,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(s);if(!a)return null;let g=a.index+a[0].length,n=s.indexOf("</script>",g);if(n===-1)return null;let d=s.indexOf(">",n);if(d===-1)return null;return{start:a.index,end:d+1}}var gs=4096;async function pn(s,e,l){if(l.buildMode!=="serve"||e.length<gs)return null;let{registerServeModuleBundle:a}=await import("./chunk-57ecpsqy.js");return`<script ${s} src="${a(e)}"></script>`}async function Zn(s,e,l){try{let{registeredModuleIdsIn:a,buildModuleRegistryScript:g}=await o("stx/client-module-registry",()=>import("./chunk-ve78svbr.js")),n=[],d=await g(a(...s),{minify:mi(e.buildMode,e.minifyClient),collectInputs:n});for(let v of n)l?.add(v);if(!d)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-57ecpsqy.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(d)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${d.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ms(s,e=""){let l=$n(s,"data-stx-runtime");if(!l)return s;let a=sr(s);if(a===-1||a===l.start){if(!e)return s;return s.slice(0,l.end)+e+s.slice(l.end)}if(a<l.start)return s.slice(0,a)+s.slice(l.start,l.end)+e+`
|
|
1562
1562
|
`+s.slice(a,l.start)+s.slice(l.end);let g=s.slice(l.start,l.end),n=s.slice(0,l.start)+s.slice(l.end),d=sr(n);if(d===-1)return g+e+`
|
|
1563
1563
|
`+n;return n.slice(0,d)+g+e+`
|
|
1564
1564
|
`+n.slice(d)}function hs(s){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return s.replace(e,(l,a,g)=>{let n=s.slice(0,g);return n.lastIndexOf("<")>n.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(s,e,l,a,g){if(a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return s;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=xe(s,l);let n=!e.__stxProcessingDepth;fn(e);for(let d of a._layerGraph?.configDependencies??[])g.add(d);if(n&&a.runtimeConfig)await bn(e,l,a.runtimeConfig);if(n)Tc(e),e.__stx_scope_seq??={n:0,key:Is(String(e.__filename??l))},e.__stx_head_injections=pi(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!T()&&!Sn())&&l&&l.endsWith(".stx"))So(s,l);try{return await oe.timeAsync("template-processing",async()=>{let d=await ys(s,e,l,a,g);if(n)d=Qo(d);if(n&&a.autoShell&&a.buildMode!=="compile"){let v=ke(a.app?.head,{known:Tr,source:"app.head"}),x=(e.__stx_runtime_head||null)??gi(),b=(e.__stx_head_raw||"").trim(),w,S=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(S)w=S[1].trim(),b=b.replace(S[0],"").trim();let _=e.__sections?.title,D=_?k(_,e,l):void 0,A=x.title||w||D,M=!x.title&&(!!w||!!D),I=x.meta||[],N=new Set(I.map((K)=>st(K)).filter(Boolean)),U={...v,...A&&{title:A},meta:[...(v.meta||[]).filter((K)=>!N.has(st(K))),...I],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
1565
1565
|
`),...x.htmlAttrs&&{htmlAttrs:Vc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},W=fi(d);if(d=Cr(d,U,{...M&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},W),W)d=Wc(d,v),d=_r(d,U.htmlAttrs);let O=d.match(/<!-- stx-layout: ([^ ]+) -->/);if(O&&d.includes("<head")){let K=O[1],G=vs(K);d=d.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
1566
1566
|
<meta name="stx-layout" content="${ln(K)}">
|
|
1567
|
-
<meta name="stx-layout-group" content="${ln(G)}">`)}let j=d.match(/function (__stx_setup_\w+)\(/),H=j?L(d):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){d=Xe(d,(G,Y)=>`<body${Y} data-stx="${j[1]}">`);let K=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");d=d.replace(K,"$1")}}if(n){let v=e.__stx_head_injections??pi(),m=Uc(d);if(m!==null)v.beforeClose.push(m);let x=tn(d);if(x!==null)v.afterOpen.push(x);if(a.offline?.enabled&&!d.includes("data-stx-offline"))v.beforeClose.push(nn);d=zc(d,v);let b=a.app?.colorMode;if(b)d=kr(d,b)}if(n)if($n(d,"data-stx-runtime")){let m=null,x=null,b=null,w=null,S=null;try{let{getStoreScript:D}=await o("stx/store-loader",()=>import("./chunk-
|
|
1567
|
+
<meta name="stx-layout-group" content="${ln(G)}">`)}let j=d.match(/function (__stx_setup_\w+)\(/),H=j?L(d):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){d=Xe(d,(G,Y)=>`<body${Y} data-stx="${j[1]}">`);let K=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");d=d.replace(K,"$1")}}if(n){let v=e.__stx_head_injections??pi(),m=Uc(d);if(m!==null)v.beforeClose.push(m);let x=tn(d);if(x!==null)v.afterOpen.push(x);if(a.offline?.enabled&&!d.includes("data-stx-offline"))v.beforeClose.push(nn);d=zc(d,v);let b=a.app?.colorMode;if(b)d=kr(d,b)}if(n)if($n(d,"data-stx-runtime")){let m=null,x=null,b=null,w=null,S=null;try{let{getStoreScript:D}=await o("stx/store-loader",()=>import("./chunk-5awvckb2.js")),A=a.storesDir,M=await D(A);if(M)b=`<script data-stx-stores>${M}</script>`,x=await pn("data-stx-stores",M,a)??b}catch{}m=await Zn([d,b],a,g);try{let{getFrameworkComposableScript:D}=await o("stx/framework-composables",()=>import("./chunk-pz837t6v.js"));S=await D(d)}catch{}try{let{getComposableScript:D}=await o("stx/composable-loader",()=>import("./chunk-hgrtnyp3.js")),A=a.composablesDir,M=[m,b,S].filter((N)=>N!==null),I=await D(a._layerComposableDirs??A,d,M);if(I)w=await pn('data-stx-scoped data-stx-run="always" data-stx-composables',I,a)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${I}</script>`}catch{}let _=[m,x,w,S].filter((D)=>D!==null).map((D)=>`
|
|
1568
1568
|
${D}`).join("");d=ms(d,_)}else{let m=await Zn([d],a,g);if(m){let x=d.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)d=d.slice(0,x)+m+`
|
|
1569
1569
|
`+d.slice(x)}}if(n)d=Hc(d);if(n&&e.__stx_inject_css!==!1)d=await y(d,void 0,a.buildMode==="serve",!0);else if(n)d=dn(d);if(d=d.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),d=hs(d),n&&e.__stx_runtime_config)d=Dt(d,e.__stx_runtime_config);if(n&&!e.__stx_defer_server_data){let v=vr(e);if(v){let m=/<head\b[^>]*>/i.exec(d),x=m?m.index+m[0].length:0;d=d.slice(0,x)+v+d.slice(x)}}return d})}catch(d){if(d instanceof q)throw d;let v=d instanceof Error?d.message:String(d),m=new ae(`Template processing failed: ${v}`,l,void 0,void 0,s.substring(0,200)+(s.length>200?"...":""));if(B.log(m,{filePath:l,context:e}),wn.logDetailedError(m,{filePath:l,template:s.substring(0,500)}),T()&&!a.debug)console.error(`[stx] ${ce.relative(process.cwd(),l)||l}: ${m.message}`);if(a.debug)throw m;return ui.createFallbackContent("Template Processing",m)}}async function ys(s,e,l,a,g){let n=process.cwd(),d={...a,partialsDir:a.partialsDir&&!ce.isAbsolute(a.partialsDir)?ce.resolve(n,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!ce.isAbsolute(a.componentsDir)?ce.resolve(n,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!ce.isAbsolute(a.layoutsDir)?ce.resolve(n,a.layoutsDir):a.layoutsDir},v=d,m=s;await xs(l,e),ws(e,v),m=await Se(()=>zt(m,e,l,v),m,(O)=>{B.log(O,{filePath:l,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${l}: ${O.message}`)}),m=m.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=pe(m,Oe,(O,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);m=x.output;let b=x.tokens,w=(O)=>b.length===0?O:O.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,H)=>b[Number(H)]??""),S="\x00STX_ESCAPED_AT\x00",_="\x00STX_ESC_MUSTACHE_OPEN\x00",D="\x00STX_ESC_MUSTACHE_CLOSE\x00";m=m.replace(/@@/g,S),m=m.replace(/@\{\{([\s\S]*?)\}\}/g,(O,j)=>`${_}${j}${D}`),m=Jt(m),m=await an(m,l,g);let A={};m=Qr(m,A);let M={...e.__sections||{}},I="",N=gt(mt(s)),U=/@nolayout\b/.test(m)||N===!1;if(/@nolayout\b/.test(m))m=m.replace(/@nolayout\b\s*/g,"");let W=m.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(W)I=W[1],m=m.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(I=N,!/@section\s*\(/.test(m))m=`@section('content')
|
|
1570
1570
|
${m.trim()}
|
|
@@ -1573,7 +1573,7 @@ ${m.trim()}
|
|
|
1573
1573
|
@endsection`}}if(I&&m.includes("<script")){let O=X(m),j=O.scripts.map((H)=>gn(H,l)??H);m=hr(O.output,j)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,j,H)=>(M[j]=H,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return O;try{let K=u(H.trim(),e);if(K===void 0)return O;let Y=(e.__stx_inline_section_values??=[]).push(K)-1;return M[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return O}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,j,H)=>{if(H.includes("@parent"))M[j]=H.replace("@parent",_e);else M[j]=H.trim();return""}),e.__sections=M,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,j,H)=>M[j]||H||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||"");if(m=es(m,A),I){let O=[],j=X(m),H=pe(j.output,un,(K,G)=>`\x00STX_ORPHAN_STYLE_${G}\x00`);if(m=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(K,G,Y)=>{let ee=G==="SCRIPT"?gn(j.scripts[Number(Y)],l):H.tokens[Number(Y)];if(ee)O.push(ee);return""}),O.length>0){let K=O.join(`
|
|
1574
1574
|
`);M.content=M.content?`${M.content}
|
|
1575
1575
|
${K}`:K,e.__sections=M}}if(I)try{let O;if(ce.isAbsolute(I))O=I,g.add(I);else O=await Se(()=>hn(I,l,d,g),null,()=>{throw new ae(`Failed to resolve layout path: ${I}`,l,void 0,void 0,`Layout referenced from ${l}`)});if(!O){let ee=(re)=>{if(!re)return[];try{let ie=ce.isAbsolute(re)?re:ce.resolve(process.cwd(),re);return fs.readdirSync(ie).filter((le)=>le.endsWith(".stx")).map((le)=>le.replace(/\.stx$/,""))}catch{return[]}},te=[...ee(d.layoutsDir),...ee(d.fallbackLayoutsDir)].filter((re,ie,le)=>le.indexOf(re)===ie).sort(),ue=`Layout not found: ${I} (referenced from ${l})`+(te.length>0?`. Available layouts: ${te.join(", ")}`:d.layoutsDir?`. No .stx layouts found in ${d.layoutsDir}`:"");if(B.log(Error(ue),{layoutPath:I,filePath:l,available:te},"error"),console.error(`[stx] ${ue}`),d.debug)throw new ae(ue,l);return m}let j=await Se(()=>Bun.file(O).text(),"",()=>{throw new ae(`Failed to read layout file: ${O}`,l,void 0,void 0,"Layout content could not be loaded")});j=cn(j,O);let H=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(d.debug)console.log(`Found nested layout: ${H[1]} in ${O}`);let ee={},te=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ie,le,be)=>(ee[le]=be.trim(),""));for(let[ie,le]of Object.entries(ee))if(M[ie]&&M[ie].includes(_e)){let be=M[ie].indexOf(_e);M[ie]=M[ie].slice(0,be)+le+M[ie].slice(be+_e.length)}else if(!M[ie])M[ie]=le;let ue={...e,__sections:M},re=`@layout('${H[1]}')${te}`;return await i(re,ue,O,d,g)}let K=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),G=Qr(K,A),Y={};return G=G.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ee,te,ue)=>(Y[te]=ue.trim(),`@slot('${te}')`)),G=G.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ee,te,ue)=>{if(M[te]){let re=M[te];if(re.includes(_e)){let ie=Y[te]||"",le=re.indexOf(_e);re=re.slice(0,le)+ie+re.slice(le+_e.length)}return re}return ue||""}),G=bs(G,M),G=G.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||""),G=es(G,A),e.__originalFilePath=l,m=await vn(G,e,O,d,g),m=`<!-- stx-layout: ${I} -->
|
|
1576
|
-
${m}`,w(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${I}: ${O instanceof Error?O.message:String(O)}`,l)}return w(await vn(m,e,l,d,g))}function bs(s,e){return s.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,g)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return g||""})}function ws(s,e){if(s.__stx_sfc_mode=!0,s.__stx_options=e,e.buildMode)s.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[g,n]of Object.entries(process.env))if(g.startsWith(l)&&n!==void 0)a[g]=n;s.$env=a}async function xs(s,e){await Se(()=>Kt(s,e),void 0,(l)=>{B.log(l,{filePath:s,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${s}: ${l.message}`)})}var ot="data-stx-source";function gn(s,e){if(!s)return s;let l=/^<script\b([^>]*)>/i.exec(s);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(ot))return s;return`<script ${ot}="${encodeURIComponent(e)}"${s.slice(7)}`}function ks(s){let e=new RegExp(`${ot}="([^"]*)"`).exec(s);return e?decodeURIComponent(e[1]):void 0}function mn(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function yn(s,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${mn(s)}</span><span style="display:block;margin-top:4px">${mn(l)}</span></div>`}async function Ss(s,e,l,a){let{scanScriptTags:g}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1576
|
+
${m}`,w(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${I}: ${O instanceof Error?O.message:String(O)}`,l)}return w(await vn(m,e,l,d,g))}function bs(s,e){return s.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,g)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return g||""})}function ws(s,e){if(s.__stx_sfc_mode=!0,s.__stx_options=e,e.buildMode)s.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[g,n]of Object.entries(process.env))if(g.startsWith(l)&&n!==void 0)a[g]=n;s.$env=a}async function xs(s,e){await Se(()=>Kt(s,e),void 0,(l)=>{B.log(l,{filePath:s,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${s}: ${l.message}`)})}var ot="data-stx-source";function gn(s,e){if(!s)return s;let l=/^<script\b([^>]*)>/i.exec(s);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(ot))return s;return`<script ${ot}="${encodeURIComponent(e)}"${s.slice(7)}`}function ks(s){let e=new RegExp(`${ot}="([^"]*)"`).exec(s);return e?decodeURIComponent(e[1]):void 0}function mn(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function yn(s,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${mn(s)}</span><span style="display:block;margin-top:4px">${mn(l)}</span></div>`}async function Ss(s,e,l,a){let{scanScriptTags:g}=await o("stx/signal-processing",()=>import("./chunk-ty5rncss.js")),n=[],d=!T()&&!Sn();for(let m of g(s)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let b=m.start+m.fullMatch.indexOf(">")+1,w=kn(s,b);if(w===-1)continue;let S=s.slice(b,w);if(!S.trim())continue;let _=ks(x)??l,D={index:m.start,length:w+9-m.start};try{let{extractVariables:A}=await o("stx/variable-extractor",()=>import("./chunk-mhpek1hj.js"));await A(S,e,_,{preserveExisting:!0,onFailure:(M)=>{if(M.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:_,kind:M.kind,message:M.message}),!d)return;n.push({...D,markup:yn(_,M.kind,M.message)})}})}catch(A){let M=A instanceof Error?A:Error(String(A));if(B.log(M,{filePath:_,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${_}: ${M.message}`),d)n.push({...D,markup:yn(_,"unknown",M.message)})}}if(n.length===0)return s;let v=s;for(let m of n.sort((x,b)=>b.index-x.index))v=v.slice(0,m.index)+m.markup+v.slice(m.index+m.length);return v}async function Es(s,e,l){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-04xtzbf6.js"));return a(s,e,{skipServer:!0})}catch(a){let g=a instanceof Error?a:Error(String(a));return B.log(g,{filePath:l,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${l}: ${g.message}`),s}}async function vn(s,e,l,a,g){let n=s,d=a;if(n=await Ss(n,e,l,a),n=await Bt(n,e,l),n=await Ft(n,e,l),n=await Es(n,e,l),n=await At(n,e,l,d),xe(n))n=Ao(n,e),n=os(n,e),n=ss(n,e);n=Po(n);let{processStreamDirectives:v}=await o("stx/streaming",()=>import("./chunk-0ktg5dw9.js"));n=v(n,e),n=nr(n,e,l,d,!0),n=await en(n,e,l,d,g),n=await ns(n,e,l,d,g),n=Ja(n,e,l,d);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-8dfq934n.js"));n=m(n,e,l);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-hrb9fmq0.js"));n=x(n,e,l);let{processTransitionDirectives:b,processTransitionAttributes:w}=await o("stx/transitions",()=>import("./chunk-sx1aer4p.js"));n=b(n,e,l),n=w(n);let{processErrorBoundaryDirectives:S,stripRenderFailedMarkers:_}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));n=S(n,e,l),n=_(n);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-5d1c504j.js"));n=D(n,e,l);let{processAsyncDirectives:A}=await o("stx/async-components",()=>import("./chunk-r5re2zj0.js"));n=A(n,e,l);let{processKeepAliveDirectives:M}=await o("stx/keep-alive",()=>import("./chunk-3nbvr34s.js"));n=M(n,e,l);let{processVirtualListDirectives:I,processVirtualGridDirectives:N,processInfiniteListDirectives:U}=await o("stx/virtual-scrolling",()=>import("./chunk-8w1ep4w3.js"));n=I(n,e,l),n=N(n,e,l),n=U(n,e,l);let{processPartialHydrationDirectives:W,processStaticDirectives:O}=await o("stx/partial-hydration",()=>import("./chunk-336t7zzz.js"));n=W(n,e,l),n=O(n);let{processComputedDirectives:j,processWatchDirectives:H}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));n=j(n,e,l),n=H(n,e,l);let{processFormValidationDirectives:K}=await o("stx/forms-validation",()=>import("./chunk-a82dg51h.js"));n=K(n,e,l);let{processHeadDirective:G,processTitleDirective:Y,processMetaDirective:ee,resetHead:te}=await o("stx/head",()=>import("./chunk-agjysd2b.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)te();let ue=G(n);if(n=ue.content,ue.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${ue.headContent}
|
|
1577
1577
|
`;if(n=Y(n,e),n=ee(n,e,l),n=Xt(n),n=Eo(n,e),n=Ct(n),n=Ut(n),n=await Zr(n,e,l,d,g),n=await ns(n,e,l,d,g),e.__stxProcessingDepth===1)n=$c(n,e);if(n=n.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),n=Qo(n),n=se(n,e,l),n=Yr(n),n=kc(n,e,{filePath:l,buildMode:d.buildMode}),n=To(n,e),n=$o(n,e),n=ze(n,e),n=Nt(n,e),n=Ht(n,e),n=await bt(n,e,l,d),n=await Za(n,e,l),n=await Qa(n,e,l,d),n=ec(n,e,l,d),n=jo(n,e,l,d),n=Bo(n,e,l),n=Fo(n,e,l,d),n=_t(n,e,l,d),n=As(n,e),n=Ps(n),n=_c(n),!d.skipEventDirectives)n=pc(n,e,l);if(n=vt(n,e,l),d.debug){let F=/\bx-data\s*=/.test(n),z=rs(s);if(F&&z)console.warn(`[stx] ${l}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1578
1578
|
Both work on the same page, but they manage separate scopes.
|
|
1579
1579
|
Prefer signals (state/derived/effect) for new components.`)}n=Wa(n,e),n=await k(n,e,l),n=Cc(n),n=Ec(n),n=pt(n);let{processXElementDirectives:re}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));n=re(n);let ie=e.__originalFilePath||l,le=De(e);if(n=await Io(n,d,ie,le),n=Ot(n,e),n=await Wt(n,e,l,d),d.media?.image?.autoSiblings){let F=d.publicDir||"public",{rewriteImagesWithSiblings:z}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-6h1qa3hw.js"));n=await z(n,{publicDir:F})}if(d.seo?.enabled)n=zo(n,e,d);let be=(F,z,J=!0)=>{if(!z)return F;let me=z.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ne=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(F),fe=ne?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ne[0]):null;if(me&&ne&&fe){if(J){let Te=ne.index+fe.index;F=F.slice(0,Te)+me[0]+F.slice(Te+fe[0].length)}if(z=z.replace(me[0],"").trim(),!z)return F}if(/<\/head>/i.test(F))return F.replace(/<\/head>/i,`${z}
|
|
@@ -1587,6 +1587,6 @@ ${lt()}
|
|
|
1587
1587
|
`+Te}else n=n.replace("</head>",`${z}
|
|
1588
1588
|
</head>`)}else if(n.includes("<body"))n=n.replace(/<body([^>]*)>/,`<body$1>
|
|
1589
1589
|
${z}`);else n=z+`
|
|
1590
|
-
`+n}{let{scanScriptTags:F}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1590
|
+
`+n}{let{scanScriptTags:F}=await o("stx/signal-processing",()=>import("./chunk-ty5rncss.js")),z=[];for(let J of F(n)){if(!/\bserver\b/i.test(J.attrs))continue;let me=J.start+J.fullMatch.indexOf(">")+1,ne=kn(n,me);if(ne===-1)continue;let fe=ne+9;while(fe<n.length&&/\s/.test(n[fe]))fe++;z.push({start:J.start,end:fe})}if(z.length>0){let J=Array(z.length+1),me=0;for(let ne=0;ne<z.length;ne++){let{start:fe,end:Te}=z[ne];J[ne]=n.slice(me,fe),me=Te}J[z.length]=n.slice(me),n=J.join("")}}let at=$s(n,l);if(at.hasScoped)n=at.html;let Rn=e.__stx_event_bindings||[],Ke=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(n),{scanScriptTags:Dn}=await o("stx/signal-processing",()=>import("./chunk-ty5rncss.js"));for(let F of Dn(n,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:F.fullMatch,attrs:F.attrs,content:F.body});for(let{match:F,attrs:z,content:J}of ct){Ke=!0;let me=J;Ie(J,l,a.strict,e.__originalFilePath);let ne=await Me(J,{eventBindings:Rn,attrs:z,hasColonDirectives:Mn,templateContent:s,filePath:l,projectRoot:process.cwd(),production:mi(a.buildMode,a.minifyClient),serverData:le});n=n.replace(F,()=>ne)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let F=e.__stx_event_bindings||[];if(F.length>0){let z=Ko(F);if(z){let J=n.lastIndexOf("</body>");n=J===-1?n+z:n.slice(0,J)+z+`
|
|
1591
1591
|
`+n.slice(J)}e.__stx_event_bindings=[]}}if(!ye(n)&&Ka(n))n=await or(n,d);if(n=Ga(n),d.csp?.enabled&&d.csp.useNonce&&typeof e.cspNonce==="string")n=Et(n,e.cspNonce);return n}
|
|
1592
1592
|
export{mt,Re,za,Jr,wo,xo,Zn,i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bn,ai}from"./chunk-
|
|
2
|
+
import{bn,ai}from"./chunk-xhpf68p4.js";import"./chunk-rbmt5w9v.js";export{ai as generateRuntimeConfigTypes,bn as prepareRuntimeConfig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{la,ua,da,pa,qm}from"./chunk-pqrgaahp.js";import"./chunk-x6hqe25e.js";import"./chunk-kn92y5yd.js";import"./chunk-hez09ssh.js";import"./chunk-rfb00eqz.js";import"./chunk-6h0n7h97.js";import"./chunk-x9wwd2ee.js";import"./chunk-jtf6sxgd.js";import"./chunk-nb65s3b5.js";import"./chunk-kbw75yd7.js";import"./chunk-jy8m3dah.js";import"./chunk-r3j4m04w.js";import"./chunk-5bm0nh5f.js";import"./chunk-gwq82dpy.js";import"./chunk-m5nzpjej.js";import"./chunk-8deed4r2.js";import"./chunk-5rjfaj0b.js";import"./chunk-b8a8900p.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import"./chunk-0azq3w1a.js";import"./chunk-xhpf68p4.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{la as buildNative,qm as default,ua as findCraftBinary,pa as getAvailableFormats,da as getAvailableTargets};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{sh,yf,Ro,rs,rr,Ao,Po,ss,os,is,Io,qa,bf,yt}from"./chunk-
|
|
2
|
+
import{sh,yf,Ro,rs,rr,Ao,Po,ss,os,is,Io,qa,bf,yt}from"./chunk-5bm0nh5f.js";import"./chunk-gwq82dpy.js";import"./chunk-m5nzpjej.js";import"./chunk-5rjfaj0b.js";import"./chunk-b8a8900p.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import{z}from"./chunk-0azq3w1a.js";import"./chunk-xhpf68p4.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{sh as clearScriptScanCache,ss as convertServerLoopAttributesToDirectives,Ao as convertSignalDirectivesToAttributes,os as convertSignalLoopsToAttributes,rr as extractClientSignalNames,z as extractExports,qa as findMarkupIndexOutsideScripts,rs as hasSignalsSyntax,Ro as parseLoopExpression,Po as preEvalLiteralReactiveIfs,is as processScriptSetup,Io as processSignals,bf as rewriteStxImportSpecifiers,yf as scanScriptTags,yt as stripStxRuntimeImports};
|
|
@@ -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-9vx6et01.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-8t9em8md.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-ejp4d8cq.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-n6carvxa.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,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{vn,O}from"./chunk-rbmt5w9v.js";import m from"fs";import e from"path";async function bn(r,o,i){if(r.__stx_runtime_config)return;let n=vn();if(n||i){r.__stx_runtime_config=n??O(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-
|
|
2
|
+
import{vn,O}from"./chunk-rbmt5w9v.js";import m from"fs";import e from"path";async function bn(r,o,i){if(r.__stx_runtime_config)return;let n=vn();if(n||i){r.__stx_runtime_config=n??O(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-pcsgj3a5.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=O(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function ai(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-5rjfaj0b.js";import{ro}from"./chunk-dnqzrktd.js";import p from"path";async function zg(t={}){let l=performance.now(),s=t.root||process.cwd(),e=await a(s),o=t.ssr?.routeRules??e.routeRules??{};if(ro(o),!e.ssr&&Object.keys(o).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let u,n;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");u=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-6r1wzzt3.js");n=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let d=Math.round(performance.now()-l);return{mode:r,ssg:u,ssr:n,duration:d}}
|
|
3
3
|
export{zg};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qe}from"./chunk-2mqzpzy7.js";import{gt,Bn}from"./chunk-k93mp66m.js";import{Ne,pn,Dc,Mc}from"./chunk-
|
|
2
|
+
import{Qe}from"./chunk-2mqzpzy7.js";import{gt,Bn}from"./chunk-k93mp66m.js";import{Ne,pn,Dc,Mc}from"./chunk-0azq3w1a.js";import{kr,_r,Cr,Tr,ke}from"./chunk-zkx2m308.js";import{O}from"./chunk-rbmt5w9v.js";import{ai}from"./chunk-xhpf68p4.js";import{y}from"./chunk-6h0n7h97.js";import{i}from"./chunk-rfb00eqz.js";import{j,a}from"./chunk-5rjfaj0b.js";import{ic}from"./chunk-3fwdxxh1.js";import{$n,Ue,Ce,Xi,Ji,Rn}from"./chunk-8csv4s4f.js";import{nn,yo}from"./chunk-0wfbhs15.js";import{An}from"./chunk-dnqzrktd.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{G}from"./chunk-gwq82dpy.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Bn():gt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=Qe(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Dc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Ne(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...j,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=$n(b)+Ue(b),P=Mc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:P,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:pn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Rg(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=ke(e.app?.head,{known:Tr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=An(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)nn(o,w);if(e.runtimeConfig)O(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=G(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let f=T(s.pattern),H=f.rendering==="prerender";if(H&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Cr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=kr(t.html,u);if(g.htmlAttrs)t.html=_r(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),H){let p=await Rn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ce(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),I=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:H}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(o,d);if(m.existsSync(E)){let{copied:s,bytes:f}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let F=Xn(o);if(F){let{copied:s,bytes:f}=Z(F,c.join(r,"public",Gn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Xt}/`)}let N={runtime:v.filename,router:x.filename},C=Xi(k,N,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await yo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await ai(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(ic(e._layerGraph),null,2));Ji(C,r);let K=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:N,outputDir:r,duration:K}}
|
|
4
4
|
export{Rg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{bl,qi,Cg,vl,wl,Eg,Tg}from"./chunk-11k6atcw.js";import"./chunk-2f3zw2wy.js";import"./chunk-hsqqhjhr.js";import"./chunk-0wfbhs15.js";import"./chunk-1xjv71dw.js";import"./chunk-5bm0nh5f.js";import"./chunk-gwq82dpy.js";import"./chunk-m5nzpjej.js";import"./chunk-5rjfaj0b.js";import"./chunk-b8a8900p.js";import"./chunk-4c86wr9a.js";import"./chunk-3fwdxxh1.js";import"./chunk-q7fh1xka.js";import"./chunk-2mqzpzy7.js";import{At,Of}from"./chunk-0azq3w1a.js";import"./chunk-xhpf68p4.js";import"./chunk-rbmt5w9v.js";import"./chunk-zkx2m308.js";import"./chunk-zn3c0ew5.js";import"./chunk-ez35607j.js";export{bl as buildVirtualSource,At as extractScriptBlocks,Of as extractTemplateExpressions,vl as findRuntimeTypeDeclarations,wl as findStxModuleDeclarations,Tg as formatTypecheckDiagnostics,Cg as sourcePathFor,Eg as typecheckStxFiles,qi as virtualPathFor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_}from"./chunk-ez35607j.js";import{A,kn}from"./chunk-zn3c0ew5.js";import{C,Y}from"./chunk-
|
|
2
|
+
import{_}from"./chunk-ez35607j.js";import{A,kn}from"./chunk-zn3c0ew5.js";import{C,Y}from"./chunk-0azq3w1a.js";import{a}from"./chunk-5rjfaj0b.js";import{Te,Qt,en,tn}from"./chunk-hsqqhjhr.js";import{yt}from"./chunk-5bm0nh5f.js";import{ft,jn,Kt,ce}from"./chunk-h6pmg82p.js";import{T,$r}from"./chunk-xaddgvkx.js";import p from"path";var c=new Map;function v(i,n){for(let s of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of i.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of i.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Im(i){let n;if(i)n=p.resolve(i);else{let t=await a();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${en()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ce(c,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Te(t))])],f=ft(l()),d=Kt(c,s,f);if(d!==void 0)return d||null;if(r.length===0)return ce(c,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let b=u.map((t)=>t.file),m=[],g=new Set,x=Y({loader:"ts",target:"browser",define:C()});for(let t of b)try{let e=await Bun.file(t).text(),y=p.basename(t,".ts");if(v(e,g),Qt(e))e=await tn(e,t,{projectRoot:process.cwd(),externalizeUserModules:T()});e=yt(e),e=A(e),e=kn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=x.transformSync(e),m.push(`// Store: ${y}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ce(c,s,f,""),null;let S=m.join(`
|
|
4
4
|
|
|
5
5
|
`),h=`;(function(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oe,de,pn,Pt,It,m,r,fe,p}from"./chunk-
|
|
2
|
+
import{oe,de,pn,Pt,It,m,r,fe,p}from"./chunk-0azq3w1a.js";import{mt,Re,za,Jr,wo,xo,i}from"./chunk-rfb00eqz.js";import{ae,xr,Se,B,wn}from"./chunk-zkx2m308.js";import{wt,lr,hs,ys,bs,xt,St,kt,_t,Ct,Et,Ze}from"./chunk-2mqzpzy7.js";import{ls,a,P}from"./chunk-5rjfaj0b.js";import{dt,Tn,_e,M,Ki,to,Br,Ue,Gi,Ce}from"./chunk-8csv4s4f.js";import{ir,ar}from"./chunk-8deed4r2.js";import{Cn}from"./chunk-hpg5bjzb.js";import{e,sn,tr,y}from"./chunk-6h0n7h97.js";import{Ge}from"./chunk-nb65s3b5.js";import{$e}from"./chunk-1xjv71dw.js";import{G,ye,be}from"./chunk-gwq82dpy.js";import{l}from"./chunk-qc93ce5h.js";import{K}from"./chunk-xaddgvkx.js";async function zn(t){try{let n=await Bun.file(t).text(),o=Nn(n),d=Un(n,t),s=Wn(n,o),c=Vn(n,o);return{file:t,metrics:o,issues:d,suggestions:s,performance:c}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Nn(t){let n=t.split(`
|
|
3
3
|
`),o=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),s=(o?o[1]:"").split(`
|
|
4
4
|
`).length,c={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};c.total=c.conditionals+c.loops+c.includes+c.custom;let f=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,h=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,g=f+u+h,b=(t.match(/<[A-Z][^>]*>/g)||[]).length,w=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,C=0;for(let T of n)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(c.total*0.5+g*0.1+b*0.3+(s>10?s*0.05:0)+v));return{lines:n.length,characters:t.length,directives:c,expressions:g,components:b,layouts:w,scriptLines:s,complexity:x}}function Un(t,n){let o=[],d=Kt(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 s=Kt(t,"foreach","endforeach");if(s>0)o.push({type:"error",category:"syntax",message:`Found ${s} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let c=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(c&&c.length>0)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 f=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(f>0)o.push({type:"warning",category:"security",message:`Found ${f} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let u=t.match(/<img[^>]*>/g);if(u){let b=u.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 h=t.split(`
|
|
5
5
|
`).filter((b)=>b.length>120);if(h.length>0)o.push({type:"info",category:"maintainability",message:`Found ${h.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 Wn(t,n){let o=[];if(n.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.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(n.directives.total===0&&n.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.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,n){let o=1;if(o+=n.directives.conditionals*0.1,o+=n.directives.loops*0.5,o+=n.directives.includes*2,o+=n.expressions*0.05,o+=n.components*1,n.scriptLines>10)o+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let s=[];if(o>10)s.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)s.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)s.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:s}}function Kt(t,n,o){let d=t.replace(/<!--[\s\S]*?-->/g,""),s=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,c=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(s-c)}async function Di(t=["**/*.stx"],n){let o=[],d=[];for(let c of t){let f=await Array.fromAsync(new Bun.Glob(c).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...f.filter((u)=>u.endsWith(".stx")))}for(let c of d)try{let f=await zn(c);o.push(f)}catch(f){console.warn(`Failed to analyze ${c}:`,f)}let s=qn(o);return{results:o,summary:s}}function qn(t){let n=t.length,o=t.reduce((g,b)=>g+b.metrics.lines,0),d=n>0?t.reduce((g,b)=>g+b.metrics.complexity,0)/n:0,s=t.reduce((g,b)=>g+b.issues.length,0),c={};t.forEach((g)=>{g.issues.forEach((b)=>{c[b.category]=(c[b.category]||0)+1})});let f=n>0?t.reduce((g,b)=>g+b.performance.estimatedRenderTime,0)/n:0,u=Math.max(1,Math.min(10,Math.round(10-f/2-d/2))),h=[];if(d>6)h.push("Project has high average complexity. Consider refactoring complex templates.");if(s>n*2)h.push("High number of issues detected. Run detailed analysis on individual files.");if(c.security>0)h.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:s,issuesByCategory:c,performanceScore:u,recommendations:h}}import{mkdir as Kn,readFile as Xn,readdir as Gn,stat as Xt,writeFile as Jn}from"fs/promises";import Te from"path";function en(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 Yn(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Qn(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function Zn(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function er(t){let n=[];async function o(d){let s=await Gn(d,{withFileTypes:!0});s.sort((c,f)=>c.name.localeCompare(f.name));for(let c of s){let f=Te.join(d,c.name);if(c.isDirectory()){if(!c.name.startsWith(".")&&c.name!=="node_modules")await o(f)}else if(c.isFile()&&c.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(c.name))n.push(f)}}return await o(t),n}function nr(t,n){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(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function rr(t,n){let o={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let s of d){if(!/\bclient\b/i.test(s[1])||/\bcomponent\b|\bstx:component\b/i.test(s[1]))continue;let c;try{c=new Bun.Transpiler({loader:"ts"}).transformSync(s[2])}catch(h){throw Error(`${n}: failed to transpile <script client> (${h.message})`)}let f=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,u;while(u=f.exec(c)){let h=u[1];if(tn.has(h))throw Error(`${n}: client ${en(h)}`);let g=f.lastIndex,b=1,w="",S=!1,C=g;for(;C<c.length&&b>0;C++){let x=c[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(`${n}: unterminated client function "${h}"`);let v=u[0].includes("async")?"async ":"";o[h]=`${v}${h}(${u[2]}) {${c.slice(g,C-1)}}`,f.lastIndex=C}}return o}function or(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Gt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
|
|
@@ -876,7 +876,7 @@ else {
|
|
|
876
876
|
};
|
|
877
877
|
})();
|
|
878
878
|
</script>
|
|
879
|
-
`}function Ne(t,n,o={}){let d=Fr(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function yt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function Tt(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import $t from"path";var nt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${$t.relative($t.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let f=await ls(o,d);if(c.push(...f),o.debug&&f.length>0)console.log(`Successfully built ${f.length} web components`)}catch(f){console.error("Failed to build web components:",f)}t.onLoad({filter:/\.stx$/},async({path:f})=>{try{let u=new Set;if(o.cache&&o.cachePath){let x=await ir(f,o);if(x){if(o.debug)console.log(`Using cached version of ${f}`);return{contents:x,loader:"html"}}}let h=await Se(()=>Bun.file(f).text(),"",(x)=>{throw new xr(`Failed to read stx file: ${f}`,f,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new xr(`stx file is empty: ${f}`,f);let{scriptContent:g,templateContent:b,allScripts:w}=oe.time("script-extraction",()=>{let x=h,T=de(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",O=[];for(let R of k){let D=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=R.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))L=D;else O.push(R)}let A=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:O}}),S={__filename:f,__dirname:$t.dirname(f),__stx:{webComponentsPath:s,builtComponents:c}};await Se(()=>m(g,S,f),void 0,(x)=>{let T=new ae(`Script execution failed in ${f}: ${x.message}`,f,void 0,void 0,g.substring(0,100));if(B.log(T,{filePath:f,scriptContent:g}),o.debug)throw T});let v=await oe.timeAsync("directive-processing",async()=>await i(b,S,f,o,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-
|
|
879
|
+
`}function Ne(t,n,o={}){let d=Fr(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function yt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var tt=null;function Tt(t){if(!tt)tt=new rn(t);return tt}function st(){if(tt)tt.stop(),tt=null}import $t from"path";var nt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${$t.relative($t.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let f=await ls(o,d);if(c.push(...f),o.debug&&f.length>0)console.log(`Successfully built ${f.length} web components`)}catch(f){console.error("Failed to build web components:",f)}t.onLoad({filter:/\.stx$/},async({path:f})=>{try{let u=new Set;if(o.cache&&o.cachePath){let x=await ir(f,o);if(x){if(o.debug)console.log(`Using cached version of ${f}`);return{contents:x,loader:"html"}}}let h=await Se(()=>Bun.file(f).text(),"",(x)=>{throw new xr(`Failed to read stx file: ${f}`,f,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new xr(`stx file is empty: ${f}`,f);let{scriptContent:g,templateContent:b,allScripts:w}=oe.time("script-extraction",()=>{let x=h,T=de(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",O=[];for(let R of k){let D=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=R.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))L=D;else O.push(R)}let A=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:O}}),S={__filename:f,__dirname:$t.dirname(f),__stx:{webComponentsPath:s,builtComponents:c}};await Se(()=>m(g,S,f),void 0,(x)=>{let T=new ae(`Script execution failed in ${f}: ${x.message}`,f,void 0,void 0,g.substring(0,100));if(B.log(T,{filePath:f,scriptContent:g}),o.debug)throw T});let v=await oe.timeAsync("directive-processing",async()=>await i(b,S,f,o,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-04xtzbf6.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
882
|
${T}`}if(v=await be(v),u.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await ar(f,v,u,o),o.debug)console.log(`Cached template ${f} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let h=u instanceof Error?u:new ae(`Plugin processing failed: ${String(u)}`,f);if(B.log(h,{filePath:f,buildConfig:t.config}),wn.logDetailedError(h,{filePath:f,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",h);let g=h,b=g.line||null,w=g.context||null;return{contents:o.debug||K()?`<!DOCTYPE html>
|
|
@@ -939,7 +939,7 @@ ${T}`}if(v=await be(v),u.forEach((x)=>d.add(x)),o.cache&&o.cachePath){if(await a
|
|
|
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 Or(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=ge.resolve(t);if(!Be.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,n);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=l(process.cwd(),"output");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let D={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[u],outdir:h,plugins:[D,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await b())return!1;let S=ge.dirname(u);await sn(S);let C=o;try{if(C=await Ve(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(s){let D=n.hmrPort||C+1;c=Tt({wsPort:D,verbose:!1}),f=c.start(D)}let v={},x=null,T;try{let{loadStxConfig:D}=await import("./chunk-
|
|
942
|
+
</html>`,loader:"html"}}})}};async function Or(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=ge.resolve(t);if(!Be.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,n);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=l(process.cwd(),"output");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let D={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[u],outdir:h,plugins:[D,nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await b())return!1;let S=ge.dirname(u);await sn(S);let C=o;try{if(C=await Ve(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(s){let D=n.hmrPort||C+1;c=Tt({wsPort:D,verbose:!1}),f=c.start(D)}let v={},x=null,T;try{let{loadStxConfig:D}=await import("./chunk-ddxrb5zk.js"),I=await D();if(T=n.stxOptions?.serverApi??I.serverApi,I?.apiRouter)x=I?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(I?.apiRoutes){v=I.apiRoutes;let V=Object.keys(v).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(I?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-79sjdpfy.js"),ve=I.broadcasting;await V(ve);let le=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Pe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Pe))try{let ne=await Y(Pe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:L}=await import("./chunk-kxp881ch.js"),O=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),s)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${f}${e.reset}`);let A=zr({port:C,async fetch(D){return Cn(D,await(async()=>{let I=new URL(D.url);if([h,ge.dirname(u),ge.join(process.cwd(),"public")].some((ne)=>L(ge.join(ne,I.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ne=await x.handleRequest(D);if(ne.status!==404)return ne}catch{}if(v[I.pathname])try{return await v[I.pathname](D)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await O(D);if(V)return V;if(I.pathname==="/")return(async()=>{let F=await y(g||"");if(s)F=Ne(F,f);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(h,I.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),F=ge.extname(Y).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let ve=ge.dirname(u),le=ge.join(ve,I.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),F=ge.extname(le).toLowerCase(),_="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}let Pe=ge.join(process.cwd(),"public",I.pathname);if(Be.existsSync(Pe)&&Be.statSync(Pe).isFile()){let ne=Bun.file(Pe),F=ge.extname(Pe).toLowerCase(),_="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ne.text(),Je=Fe.transformSync(ze);return new Response(Je,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":_="text/html";break;case".css":_="text/css";break;case".js":_="text/javascript";break;case".json":_="application/json";break;case".png":_="image/png";break;case".jpg":case".jpeg":_="image/jpeg";break;case".gif":_="image/gif";break;case".svg":_="image/svg+xml";break;case".ico":_="image/x-icon";break;case".woff":_="font/woff";break;case".woff2":_="font/woff2";break;case".ttf":_="font/ttf";break;case".otf":_="font/otf";break;case".eot":_="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":_}})}return new Response("Not Found",{status:404})})())},error(D){return new Response(`<pre>${D}
|
|
943
943
|
${D.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(`
|
|
@@ -1426,12 +1426,12 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
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(u.map((v)=>v.routeTemplate)),C=Object.entries(f).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Ee.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of u){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");C.push({route:x,filePath:Ee.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 ",L=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${L}`)}),console.log(`
|
|
1429
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(w.url.toString(),()=>{if(d)Ke.watch(c,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(c,{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}`),Ge.clear(),fe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function ln(t){try{return pn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Dr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=te.resolve(t),{loadStxConfig:h}=await import("./chunk-dveg90mc.js"),g=await h(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-333m1t0q.js"),S=n.stxOptions?.serverApi??g.serverApi,C=await b(u,S),v=g.root&&g.root!=="."?te.join(u,g.root):u,x=n.pagesDir||g.pagesDir||"pages",T=te.join(v,x);if(!me.existsSync(T)&&!g._layerPageDirs?.some((E)=>me.existsSync(E)))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=G(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 L=g?._pluginPageDirs||[],O=[];for(let{dir:E,prefix:j}of L)if(me.existsSync(E)){let z=G(te.dirname(E),{pagesDir:te.basename(E)});for(let Q of z){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;O.push({route:{...Q,pattern:q},prefix:j})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,R=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await Ki(u,n.stxOptions?.shell),D){if(R=await to(D,n.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(u,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}xt(),await kt(u);let I=St();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:E}=await import("./chunk-dveg90mc.js"),j=await E(u);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let z=Object.keys(V).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-79sjdpfy.js"),q=j.broadcasting;await z(q);let Oe=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Oe}/ws${e.reset}`);let we=te.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let N=await Q(we);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let ve=l(u,"output");me.mkdirSync(ve,{recursive:!0});let le=new Map,Pe=new Set,ne=async(E)=>{let j=ys(T,E);if(!j)return null;try{let z=await Bun.build({entrypoints:[j],outdir:ve,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!z.success)return null;let Q=z.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,_=async(E,j)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:q,loadStxConfig:Oe,injectRouterScript:we}=await import("./chunk-dveg90mc.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-kz45byxr.js"),X=await Oe(u),We=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(u,ie)},ce={...q,...X,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=We(ce.partialsDir),ce.componentsDir=We(ce.componentsDir),ce.layoutsDir=We(ce.layoutsDir),ce.storesDir=We(ce.storesDir||"stores"),ce.cachePath=We(ce.cachePath)??l(u,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(E.filePath);if(ie)try{if((await me.promises.stat(E.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let ke of ie.dependencies){if(!me.existsSync(ke)){He=!1;break}if((await me.promises.stat(ke)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let ke=ie.output;if(R)ke=Ue(ke,{preserveHead:!0});let ot=F.get(E.filePath);return{route:E,content:ke,status:ot?.status??await ln(E.filePath),headers:ot?.headers}}}}catch{}let Ie=await N(E.filePath,ce);if(Ie){let je=Ie;if(R)je=Ue(je,{preserveHead:!0});let He=F.get(E.filePath);return{route:E,content:je,status:He?.status??await ln(E.filePath),headers:He?.headers}}}let Z=re?await W(E.filePath):await Bun.file(E.filePath).text(),se=pn(Z),{classifyAllScripts:ue}=await import("./chunk-dveg90mc.js"),U=ue(Z),Le=U.server.map((ie)=>ie.content),De=Z;for(let ie of U.server)De=De.replace(ie.fullTag,"");let ee={__filename:E.filePath,__dirname:te.dirname(E.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,E.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ae=new Set,he;if(n.profile){let ie=performance.now();he=await z(De,ee,E.filePath,ce,Ae);let Ie=performance.now()-ie,je=te.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await z(De,ee,E.filePath,ce,Ae);if(!R)he=await we(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-mzpwx4wc.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(R)he=Ue(he,{preserveHead:!0});if(re&&H)await J(E.filePath,he,Ae,ce);let{extractStreamBoundaries:at}=await import("./chunk-dt6brr7c.js"),Ye=at(ee),rt=ee.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ie[ke]==="function"?await ie[ke]():void 0;return z(rt[ke],{...ee,$boundary:ot},E.filePath,Ie,new Set)}})),He=new Set(je.map((ke)=>ke.id));Ye=[...(Ye||[]).filter((ke)=>!He.has(ke.id)),...je]}if(Ye&&Ye.length>0)Pe.add(E.pattern);else Ye=void 0;let Wt=Pt(ee),Vt=It(ee);if(H)F.set(E.filePath,{status:Wt,headers:Vt});return{route:E,content:he,status:Wt??se,headers:Vt,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Fe=8,ze=async()=>{let E=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let z=n.prebuild===!1?k.filter((q)=>E.has(q.pattern)):k,Q=n.prebuild===!1?O.filter(({route:q})=>j.has(q.pattern)):O;for(let q=0;q<z.length;q+=Fe){let Oe=z.slice(q,q+Fe),we=await Promise.all(Oe.map((N)=>_(N)));for(let N of we)if(N)le.set(N.route.pattern,N)}for(let q=0;q<Q.length;q+=Fe){let Oe=Q.slice(q,q+Fe),we=await Promise.all(Oe.map(({route:N})=>_(N)));for(let N of we)if(N)A.set(N.route.pattern,N)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?k.length+O.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await sn(u);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let E=n.hmrPort||Xe+1;c=Tt({wsPort:E,verbose:!1}),f=c.start(E)}let Ot=(E,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${Q}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+E};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Xe,hostname:n.hostname,async fetch(E){let j=new URL(E.url),z=n.stxOptions?.offline??g.offline;if(j.pathname===wo&&z?.enabled){if(!["GET","HEAD"].includes(E.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(E.method==="HEAD"?null:xo(z,Jr()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=g?.publicDir||"public",q=te.join(u,Q,j.pathname),Oe=te.join(u,j.pathname),we=te.join(ve,j.pathname);if([q,Oe,we].some((H)=>w(H,u,S)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Oe).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(N?.isFile()&&!w(q,u,S))return zt(q);if(J?.isFile()&&!w(Oe,u,S))return zt(Oe);if(W?.isFile()&&!w(we,u,S))return zt(we);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(u,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-ak04tgvw.js"),re=await H(E,{publicDir:te.join(u,Q),cacheDir:l(u,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(E);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](E)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await C(E);if(pe)return pe;let X=lr(j.pathname,k);if(X){let H=le.get(X.route.pattern),re=Pe.has(X.route.pattern);if(!H||X.route.isDynamic&&Object.keys(X.params).length>0||re){let Z=await _(X.route,X.params);if(Z){if(H=Z,!X.route.isDynamic&&!re)le.set(X.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(X.route.filePath?mt(await Bun.file(X.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:X.params})){let De=await ne(404);if(De){let ee=De;if(ee=await y(ee,u),s)ee=Ne(ee,f);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=_t(j.pathname,X.params,ue,j.search),De=Ct(Le,null,E,{isServer:!0}),ee=await Et(ue.middleware,De);if(ee.redirect){let Ae=ee.redirect.path,he=ee.redirect.options.redirectCode||302,at=new Headers(ee.responseHeaders);return at.set("Location",Ae),new Response(null,{status:he,headers:at})}if(ee.abort){let{statusCode:Ae,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Ae}</title></head><body><h1>Error ${Ae}</h1><p>${he}</p></body></html>`,{status:Ae,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Ae=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${Ae}</head>`)}}let U=H.content;if(R&&Gi(E)){let Le=Ze(U),De=ye(U),ee=U.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Ae=ee?Tn(ee[1].trim()):"";if(Object.keys(X.params).length>0)U=Ot(U,X.params);U=await y(U,u);let he=g?.router?.container||"main";return U=Ce(U,he,!0),new Response(U,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":De?"true":"false",...Ae&&{"X-STX-Title":encodeURIComponent(Ae)},[za]:Jr(),...M(),"Cache-Control":dt}})}if(R)U=Br(R,U);if(Object.keys(X.params).length>0)U=Ot(U,X.params);if(U=await y(U,u),s)U=Ne(U,f);if(n.native)if(U.includes("<head>"))U=U.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 U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(n.titlebarHidden)if(U.includes("<head>"))U=U.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 U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:De}=await import("./chunk-dt6brr7c.js");return De(Le(U,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(U,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(O.length>0){let H=O.map((Z)=>Z.route),re=lr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await _(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(R)se=Br(R,se);if(Object.keys(re.params).length>0)se=Ot(se,re.params);if(se=await y(se,u),s)se=Ne(se,f);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of L)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=O.find(({route:U})=>U.pattern===Z||U.pattern===`${Z}/`);if(ue){let U=await _(ue.route);if(U)se=U,A.set(ue.route.pattern,U)}}if(se){let ue=se.content;if(R)ue=Br(R,ue);if(ue=await y(ue,u),s)ue=Ne(ue,f);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(wt(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=le.get("/");if(We){let H=We.content;if(H=await y(H,u),s)H=Ne(H,f);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,u),s)H=Ne(H,f);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
|
|
1429
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(w.url.toString(),()=>{if(d)Ke.watch(c,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(c,{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}`),Ge.clear(),fe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function ln(t){try{return pn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Dr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,f=n.hmrPort||o+1,u=te.resolve(t),{loadStxConfig:h}=await import("./chunk-ddxrb5zk.js"),g=await h(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-kxp881ch.js"),S=n.stxOptions?.serverApi??g.serverApi,C=await b(u,S),v=g.root&&g.root!=="."?te.join(u,g.root):u,x=n.pagesDir||g.pagesDir||"pages",T=te.join(v,x);if(!me.existsSync(T)&&!g._layerPageDirs?.some((E)=>me.existsSync(E)))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=G(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 L=g?._pluginPageDirs||[],O=[];for(let{dir:E,prefix:j}of L)if(me.existsSync(E)){let z=G(te.dirname(E),{pagesDir:te.basename(E)});for(let Q of z){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;O.push({route:{...Q,pattern:q},prefix:j})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,R=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await Ki(u,n.stxOptions?.shell),D){if(R=await to(D,n.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(u,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}xt(),await kt(u);let I=St();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:E}=await import("./chunk-ddxrb5zk.js"),j=await E(u);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let z=Object.keys(V).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Q}=await import("./chunk-79sjdpfy.js"),q=j.broadcasting;await z(q);let Oe=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Oe}/ws${e.reset}`);let we=te.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let N=await Q(we);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let ve=l(u,"output");me.mkdirSync(ve,{recursive:!0});let le=new Map,Pe=new Set,ne=async(E)=>{let j=ys(T,E);if(!j)return null;try{let z=await Bun.build({entrypoints:[j],outdir:ve,plugins:[nt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!z.success)return null;let Q=z.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},F=new Map,_=async(E,j)=>{try{let{processDirectives:z,extractVariables:Q,defaultConfig:q,loadStxConfig:Oe,injectRouterScript:we}=await import("./chunk-ddxrb5zk.js"),{checkCache:N,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-57ecpsqy.js"),X=await Oe(u),We=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(u,ie)},ce={...q,...X,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=We(ce.partialsDir),ce.componentsDir=We(ce.componentsDir),ce.layoutsDir=We(ce.layoutsDir),ce.storesDir=We(ce.storesDir||"stores"),ce.cachePath=We(ce.cachePath)??l(u,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(E.filePath);if(ie)try{if((await me.promises.stat(E.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let ke of ie.dependencies){if(!me.existsSync(ke)){He=!1;break}if((await me.promises.stat(ke)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let ke=ie.output;if(R)ke=Ue(ke,{preserveHead:!0});let ot=F.get(E.filePath);return{route:E,content:ke,status:ot?.status??await ln(E.filePath),headers:ot?.headers}}}}catch{}let Ie=await N(E.filePath,ce);if(Ie){let je=Ie;if(R)je=Ue(je,{preserveHead:!0});let He=F.get(E.filePath);return{route:E,content:je,status:He?.status??await ln(E.filePath),headers:He?.headers}}}let Z=re?await W(E.filePath):await Bun.file(E.filePath).text(),se=pn(Z),{classifyAllScripts:ue}=await import("./chunk-ddxrb5zk.js"),U=ue(Z),Le=U.server.map((ie)=>ie.content),De=Z;for(let ie of U.server)De=De.replace(ie.fullTag,"");let ee={__filename:E.filePath,__dirname:te.dirname(E.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,E.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ae=new Set,he;if(n.profile){let ie=performance.now();he=await z(De,ee,E.filePath,ce,Ae);let Ie=performance.now()-ie,je=te.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await z(De,ee,E.filePath,ce,Ae);if(!R)he=await we(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-04xtzbf6.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(R)he=Ue(he,{preserveHead:!0});if(re&&H)await J(E.filePath,he,Ae,ce);let{extractStreamBoundaries:at}=await import("./chunk-0ktg5dw9.js"),Ye=at(ee),rt=ee.__streamTemplates;if(rt&&typeof rt==="object"&&Object.keys(rt).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(rt).map((ke)=>({id:ke,render:async()=>{let ot=typeof ie[ke]==="function"?await ie[ke]():void 0;return z(rt[ke],{...ee,$boundary:ot},E.filePath,Ie,new Set)}})),He=new Set(je.map((ke)=>ke.id));Ye=[...(Ye||[]).filter((ke)=>!He.has(ke.id)),...je]}if(Ye&&Ye.length>0)Pe.add(E.pattern);else Ye=void 0;let Wt=Pt(ee),Vt=It(ee);if(H)F.set(E.filePath,{status:Wt,headers:Vt});return{route:E,content:he,status:Wt??se,headers:Vt,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Fe=8,ze=async()=>{let E=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let z=n.prebuild===!1?k.filter((q)=>E.has(q.pattern)):k,Q=n.prebuild===!1?O.filter(({route:q})=>j.has(q.pattern)):O;for(let q=0;q<z.length;q+=Fe){let Oe=z.slice(q,q+Fe),we=await Promise.all(Oe.map((N)=>_(N)));for(let N of we)if(N)le.set(N.route.pattern,N)}for(let q=0;q<Q.length;q+=Fe){let Oe=Q.slice(q,q+Fe),we=await Promise.all(Oe.map(({route:N})=>_(N)));for(let N of we)if(N)A.set(N.route.pattern,N)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?k.length+O.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await sn(u);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let E=n.hmrPort||Xe+1;c=Tt({wsPort:E,verbose:!1}),f=c.start(E)}let Ot=(E,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${Q}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+E};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Xe,hostname:n.hostname,async fetch(E){let j=new URL(E.url),z=n.stxOptions?.offline??g.offline;if(j.pathname===wo&&z?.enabled){if(!["GET","HEAD"].includes(E.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(E.method==="HEAD"?null:xo(z,Jr()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=g?.publicDir||"public",q=te.join(u,Q,j.pathname),Oe=te.join(u,j.pathname),we=te.join(ve,j.pathname);if([q,Oe,we].some((H)=>w(H,u,S)))return new Response("Not Found",{status:404});let[N,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Oe).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(N?.isFile()&&!w(q,u,S))return zt(q);if(J?.isFile()&&!w(Oe,u,S))return zt(Oe);if(W?.isFile()&&!w(we,u,S))return zt(we);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(u,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-ak04tgvw.js"),re=await H(E,{publicDir:te.join(u,Q),cacheDir:l(u,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(E);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](E)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await C(E);if(pe)return pe;let X=lr(j.pathname,k);if(X){let H=le.get(X.route.pattern),re=Pe.has(X.route.pattern);if(!H||X.route.isDynamic&&Object.keys(X.params).length>0||re){let Z=await _(X.route,X.params);if(Z){if(H=Z,!X.route.isDynamic&&!re)le.set(X.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(X.route.filePath?mt(await Bun.file(X.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:X.params})){let De=await ne(404);if(De){let ee=De;if(ee=await y(ee,u),s)ee=Ne(ee,f);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=_t(j.pathname,X.params,ue,j.search),De=Ct(Le,null,E,{isServer:!0}),ee=await Et(ue.middleware,De);if(ee.redirect){let Ae=ee.redirect.path,he=ee.redirect.options.redirectCode||302,at=new Headers(ee.responseHeaders);return at.set("Location",Ae),new Response(null,{status:he,headers:at})}if(ee.abort){let{statusCode:Ae,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${Ae}</title></head><body><h1>Error ${Ae}</h1><p>${he}</p></body></html>`,{status:Ae,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let Ae=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${Ae}</head>`)}}let U=H.content;if(R&&Gi(E)){let Le=Ze(U),De=ye(U),ee=U.match(/<title[^>]*>([\s\S]*?)<\/title>/i),Ae=ee?Tn(ee[1].trim()):"";if(Object.keys(X.params).length>0)U=Ot(U,X.params);U=await y(U,u);let he=g?.router?.container||"main";return U=Ce(U,he,!0),new Response(U,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":De?"true":"false",...Ae&&{"X-STX-Title":encodeURIComponent(Ae)},[za]:Jr(),...M(),"Cache-Control":dt}})}if(R)U=Br(R,U);if(Object.keys(X.params).length>0)U=Ot(U,X.params);if(U=await y(U,u),s)U=Ne(U,f);if(n.native)if(U.includes("<head>"))U=U.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 U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(n.titlebarHidden)if(U.includes("<head>"))U=U.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 U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:De}=await import("./chunk-0ktg5dw9.js");return De(Le(U,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(U,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(O.length>0){let H=O.map((Z)=>Z.route),re=lr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await _(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(R)se=Br(R,se);if(Object.keys(re.params).length>0)se=Ot(se,re.params);if(se=await y(se,u),s)se=Ne(se,f);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of L)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=O.find(({route:U})=>U.pattern===Z||U.pattern===`${Z}/`);if(ue){let U=await _(ue.route);if(U)se=U,A.set(ue.route.pattern,U)}}if(se){let ue=se.content;if(R)ue=Br(R,ue);if(ue=await y(ue,u),s)ue=Ne(ue,f);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(wt(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=le.get("/");if(We){let H=We.content;if(H=await y(H,u),s)H=Ne(H,f);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,u),s)H=Ne(H,f);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
|
|
1430
1430
|
${E.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:${Xe}/${e.reset}`),s)console.log(`${e.dim} HMR: ws://localhost:${f}${e.reset}`);console.log(`
|
|
1433
1433
|
${e.yellow}Routes:${e.reset}`);let Dt=[...bs(k,u)];for(let{route:E}of O)Dt.push(`${E.pattern}`);if(Dt.forEach((E,j)=>{let Q=j===Dt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${E}`)}),console.log(`
|
|
1434
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(At.url.toString(),()=>{if(c)st();At.stop()}),n.native){let E,j=te.join(T,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();E=ht(Q)}let z=g?.app?.window??{};await Qe(Xe,{title:g?.app?.head?.title||te.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(N)=>N.startsWith("public/")||N.startsWith("public\\"),j=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([u,...g._layerGraph?.layers.map((J)=>J.root)??[],...g._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of g._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...N].some((X)=>pe===X||pe.startsWith(`${X}${te.sep}`)))N.add(pe)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Oe(J,W,pe).catch((X)=>console.error("[stx] Layer rebuild failed:",X))}))},q=Promise.resolve(),Oe=(N,J,W)=>(q=q.catch(()=>{}).then(()=>we(N,J,W)),q),we=async(N,J,W)=>{if(!W||vt(W))return;if(bt(W)){if(g._layerGraph){let pe=await h(u);Object.assign(g,pe),k.splice(0,k.length,...G(v,{pagesDir:x,pagesDirs:pe._layerPageDirs?[T,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(E(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:X}=await import("./chunk-
|
|
1434
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(At.url.toString(),()=>{if(c)st();At.stop()}),n.native){let E,j=te.join(T,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();E=ht(Q)}let z=g?.app?.window??{};await Qe(Xe,{title:g?.app?.head?.title||te.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(N)=>N.startsWith("public/")||N.startsWith("public\\"),j=(N)=>{let J=N.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},z=new Map,Q=()=>{let N=new Set([u,...g._layerGraph?.layers.map((J)=>J.root)??[],...g._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of g._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...N].some((X)=>pe===X||pe.startsWith(`${X}${te.sep}`)))N.add(pe)}for(let[J,W]of z)if(!N.has(J))W.close(),z.delete(J);for(let J of N)if(!z.has(J)&&me.existsSync(J))z.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Oe(J,W,pe).catch((X)=>console.error("[stx] Layer rebuild failed:",X))}))},q=Promise.resolve(),Oe=(N,J,W)=>(q=q.catch(()=>{}).then(()=>we(N,J,W)),q),we=async(N,J,W)=>{if(!W||vt(W))return;if(bt(W)){if(g._layerGraph){let pe=await h(u);Object.assign(g,pe),k.splice(0,k.length,...G(v,{pagesDir:x,pagesDirs:pe._layerPageDirs?[T,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(E(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:X}=await import("./chunk-57ecpsqy.js");pe(te.resolve(N,W)),X.delete(te.resolve(N,W))}catch{}if(D&&W){if(te.resolve(N,W)===D||te.basename(D)===W){let X=await to(D,n.stxOptions||{});if(X)R=X}}if(await ze(),await tr(u),s&&c)c.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Ge.clear(),fe();try{let{invalidateFileCache:pe,templateCache:X}=await import("./chunk-57ecpsqy.js");pe(te.resolve(N,W)),X.delete(te.resolve(N,W))}catch{}if(await ze(),s&&c)c.reload(W)}}else if(yt(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),s&&c)c.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(c)st();At.stop(),process.exit(0)})}return!0}import Nt from"fs";import it from"path";async function Vr(t){try{let o=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],s=[],c=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,f;while((f=c.exec(d))!==null){let u=f[1],h=f[2]||f[3]||f[4];if(!h)continue;let g={name:h},b=u.match(/@type\s+\{([^}]+)\}/i);if(b)g.type=b[1].trim();if(u.match(/@required/i))g.required=!0;let S=u.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let C=u.split(`
|
|
1435
1435
|
`).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);g.description=C.join(" ").trim(),s.push(g)}if(s.length===0){let u=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(u){let g=u[1].split(",").map((b)=>b.trim()).filter(Boolean);for(let b of g){let[w]=b.split(":").map((S)=>S.trim());if(w)s.push({name:w})}}}return s}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function qr(t){try{let n=await Bun.file(t).text(),o=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.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,n=!1,o){let d=it.basename(t,".stx"),s=await Vr(t),c=await qr(t),f="";if(n&&o)f=`<${o}></${o}>`;else{let u=s.map((h)=>{if(h.type==="boolean")return`:${h.name}="true"`;return`${h.name}="value"`}).join(`
|
|
1437
1437
|
`);f=`<${d}
|