@stacksjs/stx 0.2.678 → 0.2.679
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-3gdr3nyq.js → chunk-0fjwqs9h.js} +1 -1
- package/dist/{chunk-xrrzwta9.js → chunk-0v35wpm7.js} +1 -1
- package/dist/{chunk-mj39dydr.js → chunk-1dkcakve.js} +1 -1
- package/dist/chunk-1gg5vxe8.js +2 -0
- package/dist/{chunk-0wwwd7mt.js → chunk-1j0sarne.js} +2 -2
- package/dist/{chunk-mae8arvd.js → chunk-26ps9djm.js} +2 -2
- package/dist/{chunk-6tz95v2x.js → chunk-2933mvwr.js} +2 -2
- package/dist/{chunk-2xbdd0r8.js → chunk-2hmyj5wh.js} +1 -1
- package/dist/{chunk-xaxswtkb.js → chunk-2pvcp0y6.js} +4 -4
- package/dist/chunk-2yzwrvq1.js +2 -0
- package/dist/{chunk-aze0xdtt.js → chunk-3xyv2fec.js} +1 -1
- package/dist/{chunk-91gfv93w.js → chunk-48ma0qcr.js} +1 -1
- package/dist/chunk-52x079ax.js +2 -0
- package/dist/{chunk-ta030rdc.js → chunk-53e9ta3g.js} +1 -1
- package/dist/{chunk-9e3w8am7.js → chunk-5fmxn52y.js} +1 -1
- package/dist/{chunk-y5yrbhdq.js → chunk-61ww9d2z.js} +1 -1
- package/dist/chunk-75zc8w68.js +2 -0
- package/dist/chunk-7b3phzx4.js +2 -0
- package/dist/{chunk-syxcw8xt.js → chunk-7z7zp8xq.js} +1 -1
- package/dist/{chunk-sr4ptszn.js → chunk-87em5xdg.js} +6 -6
- package/dist/{chunk-cvz3qhme.js → chunk-8xr8y9sq.js} +1 -1
- package/dist/{chunk-p8h6r83g.js → chunk-9rs12v0r.js} +1 -1
- package/dist/{chunk-cyarez4b.js → chunk-ac75vk0w.js} +1 -1
- package/dist/{chunk-9bx4b0r1.js → chunk-aw3jfdca.js} +1 -1
- package/dist/{chunk-nrekjc5a.js → chunk-b0th3d8q.js} +5 -5
- package/dist/{chunk-yqsxwpkn.js → chunk-ccmc5rqj.js} +1 -1
- package/dist/{chunk-53papj9w.js → chunk-chy90834.js} +1 -1
- package/dist/{chunk-gm2kbxpe.js → chunk-cwmazy7y.js} +1 -1
- package/dist/{chunk-jb0w5518.js → chunk-d40zjm6k.js} +1 -1
- package/dist/{chunk-sm4stc69.js → chunk-dnjbzwwn.js} +1 -1
- package/dist/{chunk-3kq5y6m2.js → chunk-drmgwjnb.js} +5 -5
- package/dist/{chunk-cra0fqzw.js → chunk-ft1ht0b3.js} +1 -1
- package/dist/{chunk-wje0xr3z.js → chunk-j388n7v2.js} +1 -1
- package/dist/{chunk-1zrepav2.js → chunk-k093pr2w.js} +1 -1
- package/dist/{chunk-j9p2mtqv.js → chunk-k4x8v39k.js} +1 -1
- package/dist/{chunk-jsvvf8x5.js → chunk-kcp392wy.js} +1 -1
- package/dist/{chunk-2qnm4abn.js → chunk-kejrhccx.js} +1 -1
- package/dist/{chunk-xgsyhefw.js → chunk-kmj127rm.js} +1 -1
- package/dist/chunk-m0f3strn.js +2 -0
- package/dist/{chunk-tevmv0ex.js → chunk-n8f0zw1y.js} +2 -2
- package/dist/chunk-nadgej53.js +2 -0
- package/dist/{chunk-5hznhyx0.js → chunk-nb3kkvet.js} +1 -1
- package/dist/{chunk-aywaxzf4.js → chunk-nh3kd03f.js} +1 -1
- package/dist/chunk-nw2zh40z.js +2 -0
- package/dist/{chunk-cmy9n7as.js → chunk-p01b07se.js} +4 -4
- package/dist/chunk-p99an8rj.js +2 -0
- package/dist/chunk-pgvwysxq.js +2 -0
- package/dist/{chunk-hgpt35ht.js → chunk-pz3mg7hr.js} +1 -1
- package/dist/{chunk-ng5vcdsy.js → chunk-qvefcnyb.js} +1 -1
- package/dist/{chunk-gbxjpqv2.js → chunk-qyf3jcy1.js} +1 -1
- package/dist/{chunk-hbsnj1db.js → chunk-t3gmm1ja.js} +1 -1
- package/dist/{chunk-vvfwhawg.js → chunk-tbb4en1q.js} +1 -1
- package/dist/{chunk-vjh43kr3.js → chunk-tsrf4zzy.js} +1 -1
- package/dist/{chunk-3m7rj46m.js → chunk-tx4wfk5v.js} +1 -1
- package/dist/chunk-vct8a1qf.js +20 -0
- package/dist/{chunk-cpp0p1eq.js → chunk-wc5tt6da.js} +1 -1
- package/dist/{chunk-1at6tyv1.js → chunk-wejabf6y.js} +3 -3
- package/dist/{chunk-7ev6gq40.js → chunk-wt7rp7wc.js} +2 -2
- package/dist/{chunk-pqeqkn06.js → chunk-xyk2zxkk.js} +1 -1
- package/dist/{chunk-nq6kw7ze.js → chunk-y4ncmvf2.js} +1 -1
- package/dist/{chunk-d9mt7q55.js → chunk-yxw8gbnh.js} +2 -2
- package/dist/chunk-zcbp27x1.js +2 -0
- package/dist/cli.js +7 -7
- package/dist/client-script-bundler.d.ts +1 -1
- package/dist/client-script-bundler.js +7 -6
- 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/package.json +5 -5
- package/dist/chunk-0dbsfvs9.js +0 -2
- package/dist/chunk-47b1qj75.js +0 -2
- package/dist/chunk-7ndbf386.js +0 -2
- package/dist/chunk-a9kjbpp1.js +0 -2
- package/dist/chunk-brwm3qgd.js +0 -2
- package/dist/chunk-mem1tzzk.js +0 -2
- package/dist/chunk-pk55ne76.js +0 -2
- package/dist/chunk-pt789fn7.js +0 -2
- package/dist/chunk-r5y241js.js +0 -2
- package/dist/chunk-vq86p4dy.js +0 -20
- package/dist/chunk-x3gsf7at.js +0 -2
- package/dist/chunk-xgxkw2n1.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{l,p,E,u,V}from"./chunk-qwdcts9w.js";import{L,os,B,Pe,ue,ur,Me,Le,n,m,we,k}from"./chunk-
|
|
2
|
+
import{l,p,E,u,V}from"./chunk-qwdcts9w.js";import{L,os,B,Pe,ue,ur,Me,Le,n,m,we,k}from"./chunk-87em5xdg.js";import{st}from"./chunk-78yjmbbs.js";import{T}from"./chunk-6beg47t4.js";import{ne}from"./chunk-xnx06qqt.js";import{q,Ge}from"./chunk-a2zb5fgg.js";import{C,wn}from"./chunk-hh58k0nh.js";import A from"path";import{existsSync as St}from"fs";function at(a,t){let c=0;for(let i=t;i<a.length;i++){let b=a[i];if(b==="("||b==="["||b==="{")c++;else if(b===")"||b==="]"||b==="}")c--;else if(b===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,b=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=b.exec(i);while(s){let f=s.index,e=f+s[0].length-1,D=1,U=e+1;while(U<i.length&&D>0){if(i[U]==="(")D++;else if(i[U]===")")D--;U++}if(D!==0)break;let it=i.substring(e+1,U-1),j=`${c}(${it})`;i=i.substring(0,f)+j+i.substring(U),b.lastIndex=f+j.length,s=b.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,b=0,s=0,f=t.length,e=(j)=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]===j){s++;return}s++}},D=()=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]==="`"){s++;return}if(t[s]==="$"&&t[s+1]==="{"){s+=2;let j=1;while(s<f&&j>0)if(t[s]==="{")j++,s++;else if(t[s]==="}")j--,s++;else if(t[s]==="'"||t[s]==='"')e(t[s]);else if(t[s]==="`")D();else s++;continue}s++}},U=()=>{if(t[s]==="/"&&t[s+1]==="/"){while(s<f&&t[s]!==`
|
|
3
3
|
`)s++;return!0}if(t[s]==="/"&&t[s+1]==="*"){s+=2;while(s<f-1&&!(t[s]==="*"&&t[s+1]==="/"))s++;return s+=2,!0}return!1},it=()=>{if(b!==0)return;let j=t.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let Z=j[2];if(!i.has(Z))c.push(Z),i.add(Z);return}let et=t.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let Z=et[1];if(!i.has(Z))c.push(Z),i.add(Z);return}let Y=t.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let Z=Y[1];if(!i.has(Z))c.push(Z),i.add(Z)}};while(s<f){if(U())continue;if(t[s]==="'"||t[s]==='"'){e(t[s]);continue}if(t[s]==="`"){D();continue}if(t[s]==="{"){b++,s++;continue}if(t[s]==="}"){b--,s++;continue}if(b===0&&/[a-z]/i.test(t[s])&&(s===0||/\s|[;{}()]/.test(t[s-1])))it();s++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${st("var",c)}
|
|
@@ -44,10 +44,10 @@ ${s}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(q(a)){let b=q(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:Ge(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function pp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Cl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],U=f[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!U)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Ke=new B(500),ia=new Set;function fp(){ia.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ia}async function jr(a,t,c,i,b,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let g=R.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let d=e.substring(g+1,_-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=U(O,f,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${d})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=x.exec(e))!==null){let r=g.index,_=r+g[0].length-1,d=1,o=_+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),H=O.substring(W+1).trim(),z=H.match(/^\s*['"]([^'"]+)['"]/);if(!z){x.lastIndex=o;continue}let w=z[1],J=H.substring(z[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,rt="";if(tt){let ot=U(w,f,c);if(ot&&await Bun.file(ot).exists())b.add(ot);rt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,H,z]=O;try{let w,J=v.trim();if(p(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[H]:I},P=await et(W,M,a,x);N+=P}else if(z)N=await et(z,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+m("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=d.slice(O[0].length),H,z=v.match(/^\s*,\s*\{/);if(z){v=v.slice(z[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}H=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(H)try{I=E(H,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=U(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,x);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function U(h,R,x){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let z of i._layerPartialDirs??[]){let w=A.resolve(z,g);if(w.startsWith(`${A.resolve(z)}${A.sep}`)&&St(w))return w}d=A.resolve(R,g)}else d=A.resolve(_,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,H=A.dirname(_);if(o.startsWith(H+A.sep)){if(!A.relative(H,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:f}),m("Include",R,c,x,g)}async function et(h,R={},x,g){let r=U(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,g);let _=A.resolve(r);if(s.has(_)){let d=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,x,g)}try{b.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(y){let K=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${K}`,x,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(q(a)){let b=q(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:Ge(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function pp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Cl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],U=f[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!U)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Ke=new B(500),ia=new Set;function fp(){ia.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ia}async function jr(a,t,c,i,b,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let g=R.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let d=e.substring(g+1,_-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=U(O,f,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${d})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=x.exec(e))!==null){let r=g.index,_=r+g[0].length-1,d=1,o=_+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),H=O.substring(W+1).trim(),z=H.match(/^\s*['"]([^'"]+)['"]/);if(!z){x.lastIndex=o;continue}let w=z[1],J=H.substring(z[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,rt="";if(tt){let ot=U(w,f,c);if(ot&&await Bun.file(ot).exists())b.add(ot);rt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,H,z]=O;try{let w,J=v.trim();if(p(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[H]:I},P=await et(W,M,a,x);N+=P}else if(z)N=await et(z,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+m("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=d.slice(O[0].length),H,z=v.match(/^\s*,\s*\{/);if(z){v=v.slice(z[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}H=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(H)try{I=E(H,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=U(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,x);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function U(h,R,x){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let z of i._layerPartialDirs??[]){let w=A.resolve(z,g);if(w.startsWith(`${A.resolve(z)}${A.sep}`)&&St(w))return w}d=A.resolve(R,g)}else d=A.resolve(_,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,H=A.dirname(_);if(o.startsWith(H+A.sep)){if(!A.relative(H,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:f}),m("Include",R,c,x,g)}async function et(h,R={},x,g){let r=U(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,g);let _=A.resolve(r);if(s.has(_)){let d=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,x,g)}try{b.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(y){let K=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${K}`,x,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-m0f3strn.js");d=y(d,t)}if(d&&(i.debug||!C()&&!wn()))try{let{warnUnbalancedTags:y}=await import("./chunk-e492je6q.js");y(d,r)}catch{}try{let{processESImports:y}=await import("./chunk-pz3mg7hr.js");d=await y(d,t,r,i,b)}catch(y){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,y instanceof Error?y.message:y)}let o=d,O=ue(o);if(O)o=O.content.trim();let v=d.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),H="";if(v)H=`<style${v[1]}>${v[2]}</style>`;let z=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,K,S)=>{if(!ft(K))return"";return z.push({attrs:K,body:S}),`__STX_DATA_BLOCK_${z.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...t};w.__stx_signals_gate=we(d,r);for(let[y,K]of Object.entries(R))w[y]=K;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,N=[...d.matchAll(J)].sort((y,K)=>{let S=(y[1]||"").includes("server"),X=(K[1]||"").includes("server");return Number(X)-Number(S)}),I="",M=null,P=!1,tt=!1;for(let y of N){let K=y[1]||"",S=y[2]||"";if(ft(K))continue;let X=K.includes("server"),wt=Me(K);if(!X&&!/\bsrc\s*=/i.test(K))Pe(S,r,i.strict);if(!X&&S.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-0v35wpm7.js");S=F(S,w,h)}let ct="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-k093pr2w.js"),nt=F(S,{filePath:r,projectRoot:process.cwd()});S=nt.code,ct=Q(nt.styles)}catch(F){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,F instanceof Error?F.message:F)}if(wt&&S.trim())S=Le(S);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-k093pr2w.js");S=Q(S).code;let{hasUserImports:nt,bundleClientScript:bt}=await import("./chunk-t3gmm1ja.js");if(nt(S))S=await bt(S,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-tsrf4zzy.js");S=F(S)}let dt=$t(S);if(!X){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-k093pr2w.js"),nt=Q(S,F(w));if(nt)S=`${nt}
|
|
48
48
|
${S}`}if(dt&&!X){P=!0,M=ut(r,t);let F=T(S),Q=gt(F,M);I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(z.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-5fmxn52y.js");await F(S,w,r)}catch(F){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,F)}if(!X&&!dt){let F=K.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=T(S),nt=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(nt))tt=!0;I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${F?` ${F}`:""}>${nt}</script>
|
|
50
|
+
`}}if(z.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-0v35wpm7.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(K,S)=>{let X=z[Number(S)];return`<script${X.attrs}>${y(X.body,w,h)}</script>`})}if(M){let y=It(o,M);if(o=y.html,y.mergedIntoExisting){let S=M,X=y.mergedIntoExisting;I=I.split(`'${S}'`).join(`'${X}'`).split(`"${S}"`).join(`"${X}"`),M=X}else if(!y.stamped&&P&&!lt.has(r))lt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(y.stamped&&y.root!=="body"&&(P||tt)&&!pt.has(r)){let S=Cl(o);if(S.length>1)pt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares ${P?"signals":"bindings"} and has ${S.length} top-level elements (${S.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let K=y.stamped&&y.root!==null&&ur(y.root);I=Rt(I,K?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await jr(o,w,r,i,b,s);let{processLoops:rt,reportDeferredLoopWarnings:ot}=await import("./chunk-75zc8w68.js"),G=rt(o,w,r,void 0,!0);G=ne(G,w,r),G=ot(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-mjsebtg6.js");if(G=ht(G,w,r,i),G=_t(G,w,r),G=xt(G,w,r,i),G=k(G,w,r),H)G+=`
|
|
51
51
|
`+H;if(I)G+=`
|
|
52
52
|
`+I;return G}catch(d){if(d instanceof V)throw d;let o=d instanceof Error?d.message:String(d);return j(h,`Error processing include ${h}: ${o}`,x,g)}}let Y=/@include\s*\(/g,Z;while((Z=Y.exec(e))!==null){let h=Z.index,R=h+Z[0].length-1,x=1,g=R+1;while(g<e.length&&x>0){if(e[g]==="(")x++;else if(e[g]===")")x--;g++}if(x!==0)break;let r=e.substring(h,g),_=e.substring(R+1,g-1),d=_.match(/^\s*['"]([^'"]+)['"]/);if(!d){Y.lastIndex=g;continue}let o=d[1],O,W=_.substring(d[0].length),v=at(W,0);if(v!==-1)O=W.substring(v+1).trim();let H={};if(O)try{H=E(O,t)}catch(w){let J=w instanceof Error?w.message:String(w);e=e.replace(r,m("Include",`Error parsing include variables for ${o}: ${J}`,c,a,h)),Y.lastIndex=0;continue}let z=await et(o,H,a,h);e=e.substring(0,h)+z+e.substring(g),Y.lastIndex=0}return e}function Br(a,t){let c=a;function i(b,s,f,e){let D=b,U=!0;while(U){U=!1;let it=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),j=D.match(it);if(!j||j.index===void 0)break;let et=j.index,Y=j[1],Z=et+j[0].length,h=new RegExp(`@${s}\\(`),R=new RegExp(`@${f}(?![a-z])`),x=1,g=Z,r=-1;while(x>0&&g<D.length){let d=D.slice(g),o=d.match(h),O=d.match(R),W=o?g+o.index:1/0,v=O?g+O.index:1/0;if(W<v)x++,g=W+(o[0].length||1);else if(v<1/0){if(x--,x===0){r=v;break}g=v+f.length+1}else break}if(r===-1)break;let _=D.slice(Z,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(_);else t[Y].push(_);D=D.substring(0,et)+D.substring(r+`@${f}`.length),U=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function Fr(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Bu}from"./chunk-ccmc5rqj.js";import"./chunk-n8f0zw1y.js";import"./chunk-tmqrbs98.js";import"./chunk-48ma0qcr.js";import"./chunk-7z7zp8xq.js";import"./chunk-b0th3d8q.js";import"./chunk-wt7rp7wc.js";import"./chunk-078qg8r5.js";import"./chunk-1dkcakve.js";import"./chunk-p01b07se.js";import"./chunk-chy90834.js";import"./chunk-xnx06qqt.js";import"./chunk-1j0sarne.js";import"./chunk-2pvcp0y6.js";import"./chunk-dxh45gve.js";import"./chunk-2hmyj5wh.js";import"./chunk-2933mvwr.js";import"./chunk-3xyv2fec.js";import"./chunk-dera8fmc.js";import"./chunk-q3gactm1.js";import"./chunk-y34tyrpb.js";import"./chunk-f26n6y9p.js";import"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{Bu as buildForProduction};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{_c,Cc}from"./chunk-drmgwjnb.js";import"./chunk-tx4wfk5v.js";import"./chunk-qvefcnyb.js";import"./chunk-mn47s2ef.js";import"./chunk-bh19ezq0.js";import"./chunk-nb3kkvet.js";import"./chunk-6ycyaf5g.js";import"./chunk-ccmc5rqj.js";import"./chunk-n8f0zw1y.js";import"./chunk-n8wvqnfc.js";import"./chunk-1b9thkg5.js";import"./chunk-k4x8v39k.js";import"./chunk-wr1gm35v.js";import"./chunk-xyk2zxkk.js";import"./chunk-x4q4bx3q.js";import"./chunk-kxj8e1gd.js";import"./chunk-ga5kjf9b.js";import"./chunk-y4ncmvf2.js";import"./chunk-q4rejyd2.js";import"./chunk-d40zjm6k.js";import"./chunk-wscnjtss.js";import"./chunk-k06n5bjp.js";import"./chunk-5z0q3qv3.js";import"./chunk-78x52gz3.js";import"./chunk-4fhbh04h.js";import"./chunk-x7wr720m.js";import"./chunk-tbb4en1q.js";import"./chunk-9rs12v0r.js";import"./chunk-tmqrbs98.js";import"./chunk-yxw8gbnh.js";import"./chunk-qr7a378v.js";import"./chunk-97h9ga3b.js";import{Gt}from"./chunk-48ma0qcr.js";import"./chunk-vct8a1qf.js";import"./chunk-7z7zp8xq.js";import"./chunk-374nhgyf.js";import{$e,o}from"./chunk-b0th3d8q.js";import"./chunk-wt7rp7wc.js";import"./chunk-078qg8r5.js";import"./chunk-1dkcakve.js";import"./chunk-p01b07se.js";import"./chunk-chy90834.js";import"./chunk-xnx06qqt.js";import"./chunk-1j0sarne.js";import{ye}from"./chunk-2pvcp0y6.js";import"./chunk-dxh45gve.js";import{Zn,Qn}from"./chunk-2hmyj5wh.js";import{Xr,N,i}from"./chunk-2933mvwr.js";import"./chunk-3xyv2fec.js";import"./chunk-dera8fmc.js";import"./chunk-q3gactm1.js";import"./chunk-y34tyrpb.js";import"./chunk-f26n6y9p.js";import{g,De}from"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";import"./chunk-vg1pg6yt.js";import"./chunk-vd5w1jaz.js";export{Xr as buildWebComponents,Qn as cacheTemplate,Zn as checkCache,Gt as classifyAllScripts,_c as createMiddleware,Cc as createRoute,N as defaultConfig,g as extractVariables,ye as injectRouterScript,i as loadStxConfig,De as processClientScript,o as processDirectives,$e as readMarkdownFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{El,Hr}from"./chunk-
|
|
2
|
+
import{El,Hr}from"./chunk-chy90834.js";import"./chunk-xnx06qqt.js";import"./chunk-dxh45gve.js";import{ur}from"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import{tt}from"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{tt as freeIdentifiers,Hr as processComponents,El as processESImports,ur as rendersAsElement};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B}from"./chunk-
|
|
2
|
+
import{B}from"./chunk-87em5xdg.js";import{Be,A,Nt}from"./chunk-9wdd7eq6.js";import{ut,ke,O,_e,Ii,Hs,Oi,Cn}from"./chunk-n8f0zw1y.js";import{vt,le,Ye}from"./chunk-f26n6y9p.js";import{Zs}from"./chunk-7z7zp8xq.js";import{En}from"./chunk-wav0xbnb.js";import{he}from"./chunk-2pvcp0y6.js";import Z from"fs";import T from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((o)=>e.startsWith(o)))return!1;return te.some((o)=>e.startsWith(o))}function oe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function kn(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??re))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await K(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await ee(a),ie(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new B(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",O(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ke(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,N=async()=>{let s=await o();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",O(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return a();x=N().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):a()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Pu(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=Ii(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=En(r.routeRules),f=new G,h=Zs(e,r.apiRoutes??[]),g=Bun.file(T.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?A(l):void 0,v=new Map,N=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=T.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Nt(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Ye(i.html)),M.set(n.pattern,he(i.html));let X=T.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let P=await Bun.file(X).text();N.set(n.pattern,m?Nt(P,m):P)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=le(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let E=ce({port:o,async fetch(n){return kn(n,await Be(m??A(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),L=pe[R]||"application/octet-stream",_=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=ke(n),C=null,q={};if(C=s.get(i)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let c=i.match(p);if(c){C=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!C){let p=vt(i)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=a(i),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=N.get(C.pattern);if(c){let R=x.get(C.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...O(),...k.cache?{}:{"Cache-Control":ut}}})}}let d=Hs(n.method),u=v.get(C.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=v.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...O(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:_,status:I,headers:D}=await Cn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return Oi(L,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-m0f3strn.js"),j=new Headers({...O(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(P&&!d){let V=Ye(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",he(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(P&&!d?_e(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...O(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",O(w.get("Vary")).Vary),P&&!d){let S=Ye(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",he(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(_e(c,r.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(c,{status:I??u.status??200,headers:w})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
3
|
export{kn,Pu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{cp,sa,lp,oa,wl,xl,nn,Kn,up,Sl,kl,dp,h}from"./chunk-
|
|
2
|
+
import{cp,sa,lp,oa,wl,xl,nn,Kn,up,Sl,kl,dp,h}from"./chunk-wt7rp7wc.js";import"./chunk-2hmyj5wh.js";import"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{nn as buildCss,Sl as extractClassNames,xl as fingerprintConfig,kl as generateCss,up as getCachedCSS,cp as getCssServeAsset,h as injectCss,sa as loadCssEngine,oa as loadCssEngineConfig,Kn as rebuildCss,lp as resetCssCache,wl as resolveUserCssConfig,dp as withLinkedModuleBundles};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{pl,fl,Ee,gl,ta,Xt,Jt,ip,na,Yt,Hn,ml,hl,yl,Xs,Zt,bl,Qt,vl}from"./chunk-
|
|
2
|
+
import{pl,fl,Ee,gl,ta,Xt,Jt,ip,na,Yt,Hn,ml,hl,yl,Xs,Zt,bl,Qt,vl}from"./chunk-vct8a1qf.js";import"./chunk-7z7zp8xq.js";import"./chunk-374nhgyf.js";import"./chunk-2933mvwr.js";import"./chunk-3xyv2fec.js";import"./chunk-dera8fmc.js";import"./chunk-q3gactm1.js";import"./chunk-y34tyrpb.js";import"./chunk-f26n6y9p.js";import"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{Hn as MODULE_SPECIFIER_PREFIX,pl as bundleCacheDir,fl as bundleCacheEntryLimit,Qt as bundleClientScript,Jt as clearBundleFailures,Ee as clientBundleDependencies,Xt as getBundleFailures,Yt as hasUserImports,Zt as moduleSubstitutionKey,hl as normalizeRegistrySpecifiers,bl as queueClientBundleBuild,ta as recordBundleFailure,ml as registryIdForPath,na as resolveBundlerFallback,yl as rewriteRegistryImports,ip as setBundlerFallbackMode,gl as shouldLogBundlerDiagnostics,vl as tempBuildName,Xs as withModuleSubstitutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-78yjmbbs.js";import{T,xn}from"./chunk-6beg47t4.js";import{S,X}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-78yjmbbs.js";import{T,xn}from"./chunk-6beg47t4.js";import{S,X}from"./chunk-87em5xdg.js";import{i}from"./chunk-2933mvwr.js";import{Ee,Yt,Zt,Qt}from"./chunk-vct8a1qf.js";import{ht}from"./chunk-1j0sarne.js";import{pt,Nn,qt,ae}from"./chunk-2pga7zzb.js";import{C,wr}from"./chunk-hh58k0nh.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.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 c.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 c.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 Hd(c){let n;if(c)n=p.resolve(c);else{let t=await i();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Zt()}`,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 ae(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ee(t))])],f=pt(l()),d=qt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ae(a,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 y=u.map((t)=>t.file),m=[],g=new Set,v=X({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Yt(e))e=await Qt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=xn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ae(a,s,f,""),null;let h=m.join(`
|
|
4
4
|
|
|
5
5
|
`),w=`;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hp,Tl,co,Vr,Xn,lo,uo,Ur,Wr,qr,po,ca,$l,ht}from"./chunk-
|
|
2
|
+
import{hp,Tl,co,Vr,Xn,lo,uo,Ur,Wr,qr,po,ca,$l,ht}from"./chunk-1j0sarne.js";import"./chunk-2pvcp0y6.js";import"./chunk-dxh45gve.js";import"./chunk-2933mvwr.js";import"./chunk-3xyv2fec.js";import"./chunk-dera8fmc.js";import"./chunk-q3gactm1.js";import"./chunk-y34tyrpb.js";import"./chunk-f26n6y9p.js";import{L}from"./chunk-87em5xdg.js";import"./chunk-wc5tt6da.js";import"./chunk-9wdd7eq6.js";import"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{hp as clearScriptScanCache,Ur as convertServerLoopAttributesToDirectives,lo as convertSignalDirectivesToAttributes,Wr as convertSignalLoopsToAttributes,Xn as extractClientSignalNames,L as extractExports,ca as findMarkupIndexOutsideScripts,Vr as hasSignalsSyntax,co as parseLoopExpression,uo as preEvalLiteralReactiveIfs,qr as processScriptSetup,po as processSignals,$l as rewriteStxImportSpecifiers,Tl as scanScriptTags,ht as stripStxRuntimeImports};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-87em5xdg.js";import{o}from"./chunk-b0th3d8q.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,n)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Vn,Te}from"./chunk-374nhgyf.js";import{L,b,ir,us,S}from"./chunk-87em5xdg.js";import{i,R}from"./chunk-2933mvwr.js";import{Qs}from"./chunk-7z7zp8xq.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-mf19qxgv.js";import{r,fe}from"./chunk-tst8p27s.js";import d from"path";import B from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Qs(t,e,n)}var ot=2;function pl(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function nt(t,e){let n=t;for(let o of xt(e))if(o!==d.sep)n=n.split(o).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let o=e;try{o=B.realpathSync(e)}catch{}n=[...new Set([e,o])].sort((u,m)=>m.length-u.length),st.set(e,n)}return n}function $t(t,e){try{let n=B.statSync(t),o=d.resolve(e),u=t.startsWith(`${o}${d.sep}`);return{path:u?d.relative(o,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(B.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function yt(t,e){for(let n of t){let o=at(n,e);try{let u=B.statSync(o);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(B.readFileSync(o)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,bt=100;function fl(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function wt(t){let e=G.get(t)??0;if(e>0&&e<bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await B.promises.readdir(t)).filter((l)=>l.endsWith(".js")),o=fl();if(n.length<=o)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await B.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,y)=>y.at-l.at);for(let l of m.slice(o)){let y=l.name.slice(0,-3);await B.promises.rm(d.join(t,`${y}.js`),{force:!0}),await B.promises.rm(d.join(t,`${y}.deps.json`),{force:!0})}C("pruned bundle cache to",o,"entries")}catch{}}function Ee(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function gl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(gl())console.log("[stx:bundler]",...t)}var Y=[];function ta(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Xt(){return Y.slice()}function Jt(){Y.length=0}var Z;function ip(t){Z=t}function na(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Yt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let o=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=o.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Hn="stx-module:",St=/\.(?:[cm]?[jt]sx?|json)$/i;function ml(t,e){return d.relative(t,e).split(d.sep).join("/")}function hl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,o,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Hn)?`${o}${u}${l}${u}`:n})}function yl(t,e){let n=0,o=(m)=>{let l=`__stxMod${n++}`,y=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${y}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(y)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let y of m.split(",")){let I=y.trim();if(!I)continue;let j=I.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let _=j[1].startsWith('"')?JSON.parse(j[1]):j[1],p=j[2]??_;e.push(`var ${p} = ${l}[${JSON.stringify(_)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,y)=>{let I=y.slice(Hn.length),j=o(I),_=l.trim(),p=_.match(/^([\w$]+)\s*(?:,\s*|$)/);if(p&&!_.startsWith("{")&&!_.startsWith("*"))e.push(`var ${p[1]} = ${j}.default;`),_=_.slice(p[0].length).trim();let s=_.match(/^\*\s*as\s+([\w$]+)$/);if(s)e.push(`var ${s[1]} = ${j};`);else if(_.startsWith("{"))u(_.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(o(l.slice(Hn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(B.existsSync(n)&&B.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function Xs(t,e){let n=new Bun.CryptoHasher("md5");for(let[o,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${o}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Zt(){return K.getStore()?.key??""}function vt(t,e,n,o,u,m,l=new Map,y,I){let j=(p,s,a)=>{if(X(s,t,y))return null;if(!m||p!==n||!St.test(s))return null;try{if(!B.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(s);let w=`${Hn}${ml(process.cwd(),s)}`;return l.set(a,w),{path:w,external:!0}},_=(p,s)=>{let a=p===n?e:d.dirname(p),w=d.resolve(a,s);return rt(w)??w};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{if(s.path===n)return{path:n};let a=rt(s.path);if(a){let w=j(s.importer,a,s.path);if(w)return w;if(a!==n)u.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=_(s.importer,s.path),w=j(s.importer,a,s.path);if(w)return w;return u.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),w=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let x of w)if(B.existsSync(x)&&B.statSync(x,{throwIfNoEntry:!1})?.isFile()){let N=j(s.importer,x,s.path);if(N)return N;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",x),u.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),m)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Hn}npm:${s.path}`;return l.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(s.path===n)return{contents:o,loader:"ts"};if(X(s.path,t,y))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),w=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)u.add(s.path);let x=I?.get(s.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:B.readFileSync(s.path,"utf8"),loader:w}})}}}var H=new Map,P=b(64),it=Symbol.for("stx.client-bundle-build-queue");function bl(t){let e=globalThis,o=(e[it]??Promise.resolve()).then(t,t);return e[it]=o.then(()=>{return},()=>{return}),o}async function Qt(t,e,n={}){let o=n.projectRoot||process.cwd(),u=(await i(o)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,y=n.expose?.length?[...new Set(n.expose)].sort():void 0,I=n.cacheDir||pl(o),j=K.getStore(),_=new Bun.CryptoHasher("md5");_.update(`${ht}\x00${Qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${y?y.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,o)}\x00${nt(e,o)}`);let p=_.digest("hex").slice(0,12),s=d.join(I,`${p}.js`),a=P.get(s);if(a){if(us(a.files)&&a.files.every((F)=>!X(F.path,o,u))){C("memo hit:",p);let F=a.files.map((A)=>A.path);return q(e,F),n.collectInputs?.push(...F),a.code}P.delete(s),C("memo invalidated by dep change:",p)}let w=d.join(I,`${p}.deps.json`),x=Bun.file(s);if(await x.exists()){let F=Bun.file(w),A=!1,O=null;if(await F.exists())try{let D=JSON.parse(await F.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&yt(D.files,o))O=ir(D.files.map((g)=>at(g,o))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,o,u))}catch{A=!1}if(A){if(C("cache hit:",p),O)q(e,O.map((U)=>U.path)),n.collectInputs?.push(...O.map((U)=>U.path));let D=await x.text(),g=new Date;if(B.promises.utimes(s,g,g).catch(()=>{}),O)P.set(s,{code:D,files:O});return D}C("cache invalidated by dep change:",p)}let N=H.get(p);if(N){let F=await N;if(n.collectInputs)n.collectInputs.push(...(P.get(s)?.files??[]).map((A)=>A.path));return F}let V=bl(()=>jt(t,e,{projectRoot:o,minify:m,cacheDir:I,hash:p,cachePath:s,depsPath:w,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:y,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(p,V);try{return await V}finally{H.delete(p)}}var Bt=0;function vl(t){return`${t}-${process.pid}-${++Bt}`}async function jt(t,e,n){let{projectRoot:o,minify:u,cacheDir:m,hash:l,cachePath:y,depsPath:I,externalizeUserModules:j}=n,_=c(o,"bundle-tmp"),p=vl(l),s=d.join(o,`.stx-client-${p}.ts`),a=d.join(_,"out",p);B.mkdirSync(a,{recursive:!0});let w=d.dirname(e),x=new Set,N=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,F=r(t),{depths:A,balanced:O}=fe(F),D=(E)=>!O||A[E]===0,g;while((g=N.exec(F))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((E)=>{let f=_t(E);if(f)x.add(f)});else if(g[3])x.add(g[3])}while((g=V.exec(F))!==null){if(g[1])continue;if(!D(g.index))continue;x.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(F))!==null){if(!D(g.index))continue;let E=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(E&&Q.some((f)=>f.test(E)))continue;if(g[1])x.add(g[1]);if(g[2])x.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let k=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(k)x.add(k)}}for(let E of F.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of E[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)x.delete(v)}let lt=x.size>0?`
|
|
3
|
+
export { ${[...x].join(", ")} }`:"";C("bundling:",l,"from:",d.basename(e));let tt=new Set,et=new Map;try{let E=await Bun.build({entrypoints:[s],outdir:a,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[vt(o,w,s,t+lt,tt,j,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...S()},root:o});if(!E.success){let M=E.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${d.basename(e)}`,z=Vn(E.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",M),ta(e||"",M,z),n.throwOnFailure||na()==="error")throw Error(M);return t}let f="";for(let h of E.outputs){f=await h.text();break}let v=[];for(let h of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let M of h[1].split(",")){let z=M.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){v.push([z[2],z[1]]);continue}let T=M.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))v.push([T,T])}if(n.expose){let h=new Set(n.expose);for(let M=v.length-1;M>=0;M--)if(!h.has(v[M][0]))v.splice(M,1)}let k=[];f=yl(hl(f,et),k);let ut=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,dt=new Set(L(t,!0).split(",").map((h)=>h.trim())),pt=v.map(([h,M])=>`get ${JSON.stringify(h)}() { return ${M} }${dt.has(h)?`, set ${JSON.stringify(h)}(__stxValue_${M}) { ${M} = __stxValue_${M} }`:""}`).join(", "),ft=v.map(([h])=>`var ${h} = undefined;`).join(`
|
|
4
|
+
`),mt=v.map(([h])=>`${h} = ${J}[${JSON.stringify(h)}];`).join(`
|
|
5
|
+
`);if(f=`${ut.join(`
|
|
6
|
+
`)}
|
|
7
|
+
${ft}
|
|
8
|
+
var ${J} = (function() {
|
|
9
|
+
${k.join(`
|
|
10
|
+
`)}
|
|
11
|
+
${f}
|
|
12
|
+
return { ${pt} };
|
|
13
|
+
})();
|
|
14
|
+
${mt}
|
|
15
|
+
var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiveBindings;
|
|
16
|
+
Object.keys(${J}).forEach(function(name) {
|
|
17
|
+
if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
|
|
18
|
+
Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${J}, name));
|
|
19
|
+
});`.trim(),C("bundled:",l,"output:",f.length,"bytes"),x.size>0&&v.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${l}); serving the unbundled source and not caching this result`),t;B.mkdirSync(m,{recursive:!0}),await Bun.write(y,f);let W=ir(tt);return await Bun.write(I,JSON.stringify({metadataVersion:ot,files:W.map((h)=>$t(h.path,o)).filter((h)=>h!==null)})),q(e,W.map((h)=>h.path)),n.collectInputs?.push(...W.map((h)=>h.path)),P.set(y,{code:f,files:W}),await wt(m),f}catch(E){let f=Vn(E,e||void 0),v=Te(E,e||void 0);if(console.warn(`[stx:bundler] error: ${v}`),ta(e||"",v,f),n.throwOnFailure||na()==="error")throw E;return t}finally{try{B.rmSync(a,{recursive:!0,force:!0})}catch{}}}function _t(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let o=e.indexOf(":");if(o!==-1)e=e.slice(o+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
|
|
20
|
+
export{pl,fl,Ee,gl,ta,Xt,Jt,ip,na,Yt,Hn,ml,hl,yl,Xs,Zt,bl,Qt,vl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yn,A}from"./chunk-9wdd7eq6.js";import m from"fs";import e from"path";async function hn(r,o,i){if(r.__stx_runtime_config)return;let n=yn();if(n||i){r.__stx_runtime_config=n??A(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{yn,A}from"./chunk-9wdd7eq6.js";import m from"fs";import e from"path";async function hn(r,o,i){if(r.__stx_runtime_config)return;let n=yn();if(n||i){r.__stx_runtime_config=n??A(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-ft1ht0b3.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=A(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function zo(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??{})} }
|