@stacksjs/stx 0.2.758 → 0.2.760
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-f3fwfttx.js → chunk-0ggwm837.js} +12 -12
- package/dist/{chunk-0qt3y5zb.js → chunk-0y2zzqsq.js} +24 -24
- package/dist/chunk-1khg5vjs.js +2 -0
- package/dist/{chunk-gcrgt1j2.js → chunk-2qz891k4.js} +8 -8
- package/dist/{chunk-nybxw7xw.js → chunk-30j6mbrf.js} +4 -4
- package/dist/{chunk-xqnhe9xs.js → chunk-3kmwgpm1.js} +1 -1
- package/dist/{chunk-f0mz5x0r.js → chunk-3m9vrhja.js} +2 -2
- package/dist/{chunk-g5b9vard.js → chunk-3wfewscj.js} +1 -1
- package/dist/chunk-5e2ez5n0.js +2 -0
- package/dist/{chunk-vjtctvbp.js → chunk-5vmbycy5.js} +1 -1
- package/dist/{chunk-kvk51kvr.js → chunk-76679dw7.js} +7 -7
- package/dist/chunk-7kac7hdw.js +2 -0
- package/dist/chunk-7nz28a6c.js +16 -0
- package/dist/{chunk-tjg5scx1.js → chunk-7v2srnpv.js} +7 -7
- package/dist/chunk-8av44gw2.js +2 -0
- package/dist/{chunk-4g9a1mfd.js → chunk-94ymndc5.js} +5 -5
- package/dist/chunk-9epeb4sn.js +2 -0
- package/dist/{chunk-5xewgfbr.js → chunk-9zmb7dcv.js} +1 -1
- package/dist/{chunk-w4hwjv4p.js → chunk-afj19nsj.js} +1 -1
- package/dist/chunk-akgt21vw.js +2 -0
- package/dist/chunk-b561wv5x.js +2 -0
- package/dist/chunk-bfdd0nmc.js +2 -0
- package/dist/{chunk-gdbsw33d.js → chunk-bsgg8zzk.js} +1 -1
- package/dist/{chunk-y71wek1c.js → chunk-c9xq89nt.js} +1 -1
- package/dist/{chunk-3wch2q79.js → chunk-cr7mn65s.js} +1 -1
- package/dist/{chunk-hxncrvvt.js → chunk-e9kajy9a.js} +1 -1
- package/dist/{chunk-76fcwbe1.js → chunk-eazvp48w.js} +1 -1
- package/dist/{chunk-095k5n7r.js → chunk-ec5q50ve.js} +1 -1
- package/dist/{chunk-h6y7e70h.js → chunk-ec8gn2m0.js} +1 -1
- package/dist/{chunk-xa340w7v.js → chunk-ej1jkt9a.js} +9 -9
- package/dist/{chunk-51ysw6de.js → chunk-ex2397dc.js} +1 -1
- package/dist/chunk-f4j42tsg.js +2 -0
- package/dist/{chunk-pr544gsc.js → chunk-frk6rzrq.js} +1 -1
- package/dist/{chunk-7rxcvaqk.js → chunk-g4e6egrr.js} +2 -2
- package/dist/{chunk-n7rhyv4s.js → chunk-gk775pcy.js} +32 -25
- package/dist/{chunk-eb4ektwd.js → chunk-ha6tr22a.js} +1 -1
- package/dist/{chunk-45vgm3rg.js → chunk-hfbzfrpv.js} +1 -1
- package/dist/chunk-htc7pasb.js +2 -0
- package/dist/{chunk-77753cb1.js → chunk-jfvr1135.js} +1 -1
- package/dist/{chunk-yxec5wv3.js → chunk-m220n98m.js} +1 -1
- package/dist/{chunk-ej5gqq99.js → chunk-mmdfjmgk.js} +5 -5
- package/dist/chunk-mreh1t5x.js +2 -0
- package/dist/{chunk-b6ff2b4g.js → chunk-n7s4n62j.js} +2 -2
- package/dist/{chunk-79y41h1d.js → chunk-n839v6az.js} +1 -1
- package/dist/{chunk-sg1ngm0t.js → chunk-n8s5301s.js} +1 -1
- package/dist/chunk-py7g5hxd.js +2 -0
- package/dist/{chunk-qr43ypb3.js → chunk-q49ykyq9.js} +2 -2
- package/dist/{chunk-qpwkv0dt.js → chunk-q9npggak.js} +1 -1
- package/dist/{chunk-0fwyht9f.js → chunk-qvcs4f4v.js} +1 -1
- package/dist/{chunk-8jw6vam7.js → chunk-qw9kgzb3.js} +2 -2
- package/dist/{chunk-wg4w9kyr.js → chunk-rcfmwx8r.js} +1 -1
- package/dist/{chunk-0t0zkvvf.js → chunk-rprewgyj.js} +1 -1
- package/dist/chunk-s0wst4wj.js +2 -0
- package/dist/{chunk-y519aphy.js → chunk-se28p2xy.js} +3 -3
- package/dist/chunk-stddpecv.js +2 -0
- package/dist/{chunk-mgjd9901.js → chunk-tdjw105v.js} +1 -1
- package/dist/chunk-tp2g09ca.js +3 -0
- package/dist/{chunk-9qkcqayf.js → chunk-v5afjcy3.js} +1 -1
- package/dist/{chunk-ztx2qfp0.js → chunk-vtv7165t.js} +1 -1
- package/dist/{chunk-w2brsv9r.js → chunk-vvc39v6p.js} +2 -2
- package/dist/{chunk-p97g1hp2.js → chunk-wpgq0tq4.js} +1 -1
- package/dist/{chunk-34wn90sb.js → chunk-wz5m7ybz.js} +1 -1
- package/dist/{chunk-pdmq0bs2.js → chunk-xabs41cv.js} +1 -1
- package/dist/{chunk-qwds327k.js → chunk-xgegyttg.js} +2 -2
- package/dist/{chunk-9bnf116a.js → chunk-xsf7ax50.js} +1 -1
- package/dist/{chunk-ekfwfejr.js → chunk-y8srg0q3.js} +3 -3
- package/dist/chunk-zg5xh20b.js +2 -0
- package/dist/cli.js +8 -8
- package/dist/client-module-registry.js +1 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/bundle.js +8 -3
- package/dist/native/compiler/html-to-ir.js +32 -0
- package/dist/native/compiler/render-screen.js +1 -1
- package/dist/native/compiler/setup-script.d.ts +1 -0
- package/dist/native/compiler/shared-scripts.js +10 -0
- package/dist/native/runtime/compact-document.d.ts +20 -0
- package/dist/native/runtime/compact-document.js +101 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/store-loader.d.ts +1 -1
- package/dist/store-loader.js +36 -1
- package/package.json +5 -5
- package/dist/chunk-0kh5er8n.js +0 -2
- package/dist/chunk-2h2nb3te.js +0 -2
- package/dist/chunk-3d5qje8h.js +0 -11
- package/dist/chunk-4c8fxydq.js +0 -2
- package/dist/chunk-4rfwk37d.js +0 -2
- package/dist/chunk-8pm47pxy.js +0 -2
- package/dist/chunk-a863vjea.js +0 -2
- package/dist/chunk-bq6s6pbn.js +0 -2
- package/dist/chunk-c61rmtkj.js +0 -3
- package/dist/chunk-e2t1h7xj.js +0 -2
- package/dist/chunk-f47x45xj.js +0 -2
- package/dist/chunk-hfhnj7w0.js +0 -2
- package/dist/chunk-q21f5svg.js +0 -2
- package/dist/chunk-vy00ch1r.js +0 -2
- package/dist/chunk-wvttb8gs.js +0 -2
- package/dist/chunk-yrsg9rrr.js +0 -2
- package/dist/chunk-zmf8xmfx.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{dr}from"./chunk-z8k3fx4r.js";import{_r}from"./chunk-465resq9.js";import{a}from"./chunk-
|
|
2
|
+
import{dr}from"./chunk-z8k3fx4r.js";import{_r}from"./chunk-465resq9.js";import{a}from"./chunk-q49ykyq9.js";import{L,Xe}from"./chunk-f4gqzg1y.js";import{oc}from"./chunk-fjxhga6w.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function or(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let d=e.indexOf("-->",n+4);r=d===-1?e.length:d+3;continue}p.lastIndex=n;let c=p.exec(e);if(c){x.lastIndex=n+c[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let o=b.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}S.lastIndex=n;let u=S.exec(e);if(u){if(t>0)t--;r=n+u[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?s:n;r=n+1}return-1}function G(e,r={}){return new dr(e,r).routes}import w from"path";var T=new Map;async function y(e,r){let t=e,s=r;if(!t||!s)try{let u=await a();t||=u?.pagesDir||"pages",s||=u?.root||"."}catch{t||="pages",s||="."}let n=w.isAbsolute(t)?t:w.join(s,t),c=T.get(n);if(c)return c;let o=[];try{o=G(".",{pagesDir:n,emit:!1}).map((u)=>u.regex.source).filter(Boolean)}catch{o=[]}return T.set(n,o),o}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return O(JSON.stringify(e))}function ye(e){return e.includes("data-stx-runtime")}function rc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function f(e,r){let t=or(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
|
|
3
3
|
`+e.slice(t);let n=_r(e);if(n!==null)return`${e.slice(0,n)}
|
|
4
4
|
${r}${e.slice(n)}`;if(e.includes("</head>")){let o=e.indexOf("</head>");return e.slice(0,o)+r+`
|
|
5
5
|
`+e.slice(o)}if(L(e))return Xe(e,(o)=>`${o}
|
|
6
6
|
${r}`);return`${r}
|
|
7
|
-
${e}`}async function ir(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-
|
|
7
|
+
${e}`}async function ir(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-e9kajy9a.js"),{url:c}=await n("runtime",r.debug===!0);return f(e,`<script data-stx-runtime src="${c}"></script>`)}if(r.buildMode==="compile")return f(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-e9kajy9a.js"),s=await t(r.debug);return f(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function sc(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${oc()}</script>`,t=e.lastIndexOf("</body>");if(t===-1)return`${e}
|
|
8
8
|
${r}`;return`${e.slice(0,t)}${r}
|
|
9
|
-
${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function be(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-
|
|
9
|
+
${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function be(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-e9kajy9a.js");n=`<script data-stx-owned-routes src="${h(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(g)};
|
|
10
10
|
`)}"></script>
|
|
11
11
|
`}else i.ownedRoutes=g}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${l(i)};</script>
|
|
12
|
-
`}let{getCachedRouterScript:c,getServeClientAsset:o}=await import("./chunk-
|
|
12
|
+
`}let{getCachedRouterScript:c,getServeClientAsset:o}=await import("./chunk-e9kajy9a.js"),u=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await c()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+s+n+u+`
|
|
13
13
|
</body>`+e.slice(d+7)}
|
|
14
14
|
export{or,G,ye,rc,ir,sc,be};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rn,ko,_o,Co,ch,Eo}from"./chunk-
|
|
2
|
+
import{rn,ko,_o,Co,ch,Eo}from"./chunk-afj19nsj.js";import"./chunk-5q9ss7ty.js";import"./chunk-z8k3fx4r.js";import"./chunk-gs373714.js";export{_o as buildServerApi,ch as createServerApi,rn as discoverServerApi,ko as generateApiTypes,Eo as isServerApiSource,Co as productionApiDispatcher};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ot,ol}from"./chunk-
|
|
2
|
+
import{ot,ol}from"./chunk-xgegyttg.js";import{A}from"./chunk-89h4snzd.js";import{z,Es,o,un,W,S,_c,Ot,hn,Le,je}from"./chunk-0ggwm837.js";import{ir}from"./chunk-30j6mbrf.js";import{L}from"./chunk-f4gqzg1y.js";import{an}from"./chunk-3kfbs0mw.js";var D=`(?:"[^"]*"|'[^']*'|[^>"'])*`,q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,J=65536,K=4,M=new Map;function yh(){M.clear()}function Y(e){let i=[];for(let n of S(e,W)){let t=n.token.match(/^<script\b([^>]*)>/i),s=n.token.match(/<\/script\s*>$/i);if(!t||!s)continue;let a=t[0].length,f=n.token.length-s[0].length;i.push(Object.freeze({fullMatch:n.token,attrs:t[1],body:n.token.slice(a,f),start:n.start,end:n.end}))}return i}function as(e,i={}){let n=e.length>=J,t=n?M.get(e):void 0;if(t===void 0){if(t=Y(e),n)_c(M,K),M.set(e,t)}let s=i.skipAttrs;if(!s)return t.slice();let a=[];for(let f of t)if(s.lastIndex=0,!s.test(f.attrs))a.push(f);return a}function Mo(e){let i=e.trim(),n=i.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(n){let s=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:c}=F(a);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:c}}let t=i.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let s=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:c}=F(s);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:c}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function F(e){let i=e.trim(),n=i.match(/^(\w+)\s*=>\s*(\w+)$/);if(n)return{itemVar:n[2],indexVar:n[1]};let t=i.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let s=i.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let a=i.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function cs(e,i){return ol(e,i)}function ee(e){let i=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,n=0,t;while((t=i.exec(e))!==null){let s=t[1];if(s.startsWith("if"))n++;else if(s==="endif")n--;else if(n===0)return!0}return!1}function sr(e){let i=new Set,n=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=n.exec(e))!==null){let a=s[1],f;while((f=t.exec(a))!==null)i.add(f[1])}return i}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let i=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${D})>`,"iy"),n=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=S(e,(a,f)=>{i.lastIndex=f;let c=i.exec(a);if(!c||c.index!==f||!n.test(c[2]))return-1;return i.lastIndex}),s=[];for(let a of t){i.lastIndex=0;let f=i.exec(a.token);if(!f)continue;let c=f[2].match(n),p=Mo(c?.[1]??c?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let r=f[1],g=/\/\s*>$/.test(a.token)||P.has(r.toLowerCase())?a.end:Z(e,a.start,r,a.end);if(g!==-1)s.push({start:a.start,end:g,vars:new Set(h)})}return s}var U=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function G(e,i,n,t){if(!e)return!1;let s=ne(e),a=!1,f=!1,c=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(s))!==null){let l=h[1];if(s.slice(0,h.index).trimEnd().endsWith("."))continue;if(U.has(l))continue;if(i.has(l)||t?.has(l))a=!0;else if(n&&l in n)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,u;while((u=r.exec(s))!==null){let l=u[1];if(s.slice(0,u.index).trimEnd().endsWith("."))continue;if(U.has(l)||n&&l in n)continue;c=!0}return(a||c)&&!f}function O(e,i,n){let t=n===void 0?` ${i}`:` ${i}="${n.replace(/"/g,""")}"`,s=e.trim(),a=s.match(q);if(a&&se(a[3],a[1])){let[,f,c,p]=a;return`<${f}${c}${t}>${p}</${f}>`}return`<template${t}>${s}</template>`}function se(e,i){let n=new RegExp(`<(/)?${i}(?=[\\s/>])`,"gi"),t=0,s;while((s=n.exec(e))!==null)if(s[1]){if(t--,t<0)return!1}else t++;return!0}function Lo(e,i){let n=sr(e);function t(s){let a=s,f=te(s),c=(u)=>{let g=new Set;for(let l of f)if(u>l.start&&u<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,h,r=[];while((h=p.exec(a))!==null){let u=h.index,g=u+h[0].length,l=1,d=g;while(d<a.length&&l>0){if(a[d]==="(")l++;else if(a[d]===")")l--;d++}if(l!==0)continue;let b=a.substring(g,d-1).trim(),w=d,E=1,y=w,m=/@(if\s*\(|endif)/g;m.lastIndex=w;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))E++;else if(x[1]==="endif"){if(E--,E===0){y=x.index+x[0].length;break}}if(E!==0)continue;let R=a.substring(w,y-6).trim(),v;if(ee(R)){let I=an(a.substring(u,y));if(I.length===0)continue;let k=I[0].branches.filter((C)=>C.type!=="else"),V=c(u);if(!(k.length>0&&k.every((C)=>G(C.condition,n,i,V))))continue;v=I[0].branches.map((C)=>{let N=t(C.content);if(C.type==="elseif")return O(N,"@else-if",C.condition??"");if(C.type==="else")return O(N,"@else");return O(N,"@if",C.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!G(b,n,i,c(u)))continue;v=O(t(R),"@if",b)}r.push({start:u,end:y,replacement:v}),p.lastIndex=y}for(let u=r.length-1;u>=0;u--){let{start:g,end:l,replacement:d}=r[u];a=a.substring(0,g)+d+a.substring(l)}return a}return t(e)}function re(e){let i=e.trim();if(i==="")return;if(i==="true")return!0;if(i==="false")return!1;if(i==="null")return!1;if(i==="undefined")return!1;if(i==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(i)){let s=Number(i);return s!==0&&!Number.isNaN(s)}let n=i.match(/^'((?:\\.|[^'\\])*)'$/);if(n)return n[1].length>0;let t=i.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var P=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),X=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function Z(e,i,n,t){if(P.has(n.toLowerCase()))return t;let s=n.toLowerCase(),a=e.length,f=1,c=t;while(c<a){let p=e.indexOf("<",c);if(p===-1)return-1;if(c=p,e.startsWith("<!--",c)){let g=e.indexOf("-->",c+4);if(g===-1)return-1;c=g+3;continue}X.lastIndex=c;let h=X.exec(e);if(h){let g=e.indexOf(">",c);if(g===-1)return-1;if(e[g-1]==="/"){c=g+1;continue}let l=h[1].toLowerCase()==="script"?ie:oe;l.lastIndex=c;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;c=b+1;continue}if(e[c+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(c,c+64));if(!g){c++;continue}if(g[1].toLowerCase()===s){if(f--,c+=g[0].length,f===0)return c;continue}c+=g[0].length;continue}let r=/^<([a-z][\w-]*)\b/i.exec(e.slice(c,c+64));if(!r){c++;continue}let u=e.indexOf(">",c);if(u===-1)return-1;if(r[1].toLowerCase()===s){let g=e.slice(c,u+1);if(!(/\/\s*>$/.test(g)||P.has(s)))f++}c=u+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,i){let n=i,t=e.length;for(;;){while(n<t&&e[n]!=="<")n++;if(n>=t)return!1;if(e.startsWith("<!--",n)){let f=e.indexOf("-->",n+4);if(f===-1)return!1;n=f+3;continue}break}if(e[n+1]==="/")return!1;let s=e.indexOf(">",n);if(s===-1)return!1;let a=e.slice(n,s+1);return ce.test(a)}function jo(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let i=[],n=/<([a-zA-Z][\w-]*)/y,t=/\s/,s=new Set([":if",":show","x-if","x-show","@if","@show"]);S(e,(r,u)=>{n.lastIndex=u;let g=n.exec(r);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=n.lastIndex,d;while(l<r.length){let b=l;while(l<r.length&&t.test(r[l]))l++;let w=l;if(r[w]==="/"){w++;while(w<r.length&&t.test(r[w]))w++}if(r[w]===">"){if(d)i.push({start:u,end:w+1,tag:g[1],...d});return-1}if(l===b)return-1;let E=l;while(l<r.length&&!t.test(r[l])&&r[l]!=="="&&r[l]!==">")l++;if(l===E)return-1;let y=r.slice(E,l);if(y.startsWith("@")&&y.includes("("))return-1;let m=l,x=l;while(x<r.length&&t.test(r[x]))x++;if(r[x]!=="="){l=m;continue}x++;while(x<r.length&&t.test(r[x]))x++;let R=r[x];if(R==='"'||R==="'"){let v=r.indexOf(R,x+1);if(v===-1)return-1;if(!d&&R==='"'&&s.has(y))d={attrName:y,attrStart:b,attrEnd:v+1,value:r.slice(x+1,v)};l=v+1}else{l=x;while(l<r.length&&!t.test(r[l])&&r[l]!==">")l++}}return-1});let a=[],f=-1;for(let r of i){let{start:u,end:g,tag:l,attrName:d,value:b}=r;if(u<f)continue;let w=re(b);if(w===void 0)continue;let m=/\/\s*>$/.test(e.slice(u,g))||P.has(l.toLowerCase())?g:Z(e,u,l,g);if(m===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ae(e,m))continue;if(w===!0){let R=e.slice(u,r.attrStart)+e.slice(r.attrEnd,g);a.push({start:u,end:g,replacement:R});continue}a.push({start:u,end:m,replacement:""}),f=m}if(a.length===0)return e;a.sort((r,u)=>r.start-u.start);let c=[],p=-1;for(let r of a){if(r.start<p)continue;c.push(r),p=r.end}let h=e;for(let r=c.length-1;r>=0;r--){let{start:u,end:g,replacement:l}=c[r];h=h.substring(0,u)+l+h.substring(g)}return h}var H=[":for","@for","x-for"];function ls(e,i){if(!i||Object.keys(i).length===0)return e;if(!H.some((c)=>e.includes(`${c}=`)))return e;let n=sr(e);if(Array.isArray(i.__stx_client_signal_names)){for(let c of i.__stx_client_signal_names)if(typeof c==="string")n.add(c)}let t=e,s=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(t))!==null){let[c,p,h]=f,r=f.index,u=r+c.length,g=H.map((v)=>({attr:v,m:new RegExp(`\\s${v}="([^"]*)"`).exec(h)})).find((v)=>v.m!==null);if(!g||!g.m)continue;let l=Mo(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||n.has(d)||!(d in i))continue;let b=Z(t,r,p,u);if(b===-1)continue;let w=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),E=t.slice(u,b-`</${p}>`.length),y={...i,[l.itemVar]:void 0};if(l.indexVar)y[l.indexVar]=void 0;let m=ls(E,y),x=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,R=p.toLowerCase()==="template"?m:`<${p}${w}>${m}</${p}>`;s.push({start:r,end:b,replacement:`@foreach(${x})${R}@endforeach`}),a.lastIndex=b}for(let c=s.length-1;c>=0;c--){let{start:p,end:h,replacement:r}=s[c];t=t.slice(0,p)+r+t.slice(h)}return t}function us(e,i){let n=e,t=/@(for|foreach)\s*\(/g,s,a=[],f=[];while((s=t.exec(n))!==null){let c=s[1],p=s.index,h=p+s[0].length,r=1,u=h;while(u<n.length&&r>0){if(n[u]==="(")r++;else if(n[u]===")")r--;u++}if(r!==0)continue;let g=n.substring(h,u-1).trim(),l=u,d=Mo(g),b=c==="for"?"@endfor":"@endforeach",w=1,E=l,y=c==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${c}\\s*\\(|end${c})`,"g");y.lastIndex=l;let m;while((m=y.exec(n))!==null)if(m[1].startsWith(c))w++;else if(w--,w===0){E=m.index+m[0].length;break}if(w!==0)continue;let x=()=>{let _=[d.itemVar,d.indexVar].filter(Boolean);if(_.length)f.push({start:p,end:E,vars:_})};if(d.iterable){let _=d.iterable.trim();if(_.startsWith("[")||_.startsWith("{")||_.startsWith("'")||_.startsWith('"')||_.startsWith("`")||/^-?\d/.test(_)){x();continue}let T=_.split(/[.[(]/)[0].trim(),C=i?T in i:!1,N=f.some((j)=>p>j.start&&p<j.end&&j.vars.includes(T));if(T&&(C||N)){x();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let R=n.substring(l,E-b.length).trim(),v=i?{...i}:{};if(d.itemVar)delete v[d.itemVar];if(d.indexVar)delete v[d.indexVar];let I=us(R,v),k=I.match(q),V;if(k){let[,_,T,C]=k;V=`<${_}${T} @for="${g}">${C}</${_}>`}else V=`<template @for="${g}">${I}</template>`;a.push({start:p,end:E,replacement:V}),t.lastIndex=E}for(let c=a.length-1;c>=0;c--){let{start:p,end:h,replacement:r}=a[c];n=n.substring(0,p)+r+n.substring(h)}return n}function le(e){let i=new Set,n=[],t=0,s=0,a=e.length,f=(r)=>{let u=t+1;while(u<a){let g=e[u];if(g==="\\"){u+=2;continue}if(g===r)return u+1;u++}return a},c=()=>{let r=t+2;while(r<a&&e[r]!==`
|
|
4
4
|
`)r++;return r},p=()=>{let r=t+2;while(r<a-1){if(e[r]==="*"&&e[r+1]==="/")return r+2;r++}return a},h=(r)=>{let u=r,g=0;while(u<a){let l=e[u];if(l==="/"&&e[u+1]==="/"){let d=u+2;while(d<a&&e[d]!==`
|
|
5
|
-
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let r=e[t];if(r==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(r==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(r==='"'||r==="'"||r==="`"){let u=f(r);n.push(e.slice(t,u)),t=u;continue}if(r==="{"){s++,n.push(r),t++;continue}if(r==="}"){s--,n.push(r),t++;continue}if(s===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(i.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}i.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(r),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function B(e,i,n){for(let t of n){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function fe(e,i,n){let t=0;while(t<e.length){let s=e.indexOf(i,t);if(s===-1)return!1;if(!B(s,s+i.length,n))return!0;t=s+i.length}return!1}function de(e,i){if(fe(e,"<body",i)){let s=new RegExp(`<body(${D})>`,"g"),a;while((a=s.exec(e))!==null)if(!B(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${D})>`,"gi"),t;while((t=n.exec(e))!==null){if(B(t.index,t.index+t[0].length,i))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,i,n,t){let s=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)s.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else s.push(e.slice(f,h))};for(let h of i){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),s.join("")}async function ds(e,i,n,t={}){let s=as(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-
|
|
5
|
+
`)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let r=e[t];if(r==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(r==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(r==='"'||r==="'"||r==="`"){let u=f(r);n.push(e.slice(t,u)),t=u;continue}if(r==="{"){s++,n.push(r),t++;continue}if(r==="}"){s--,n.push(r),t++;continue}if(s===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(i.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}i.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(r),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function B(e,i,n){for(let t of n){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function fe(e,i,n){let t=0;while(t<e.length){let s=e.indexOf(i,t);if(s===-1)return!1;if(!B(s,s+i.length,n))return!0;t=s+i.length}return!1}function de(e,i){if(fe(e,"<body",i)){let s=new RegExp(`<body(${D})>`,"g"),a;while((a=s.exec(e))!==null)if(!B(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${D})>`,"gi"),t;while((t=n.exec(e))!==null){if(B(t.index,t.index+t[0].length,i))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,i,n,t){let s=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)s.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else s.push(e.slice(f,h))};for(let h of i){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),s.join("")}async function ds(e,i,n,t={}){let s=as(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-tdjw105v.js"));for(let m of s){let x=m.body;if(Le(m.attrs))x=je(x);if(t.forceClientSetup||a.test(x)){f.push({content:x,start:m.start,end:m.end});continue}if(!c(x))continue;try{let R=await p(Ot(x).code,i||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(R))f.push({content:x,start:m.start,end:m.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let h=`${i??""}\x00${f.map((m)=>m.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,u=[];for(let m=0;m<f.length;m++){let x=f[m].bundled??Ot(f[m].content).code;if(!f[m].bundled&&c(x))x=await p(x,i||"",{projectRoot:process.cwd()});x=yt(x);let R=A(x);u.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
|
|
6
6
|
${R}`)}let g=u.join(`
|
|
7
7
|
|
|
8
8
|
`);g=le(g);let d=z(g).split(",").map((m)=>m.trim()).filter(Boolean),b=hn(g,n),w=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,ai,Bc,Fc,Zf,Qf,eg,tg,ng,Ls,rg,Le,Y,je,sg,Sr,og,Vc,di,Be,r,yn,Uc,h,fe,Oh}from"./chunk-
|
|
2
|
+
import{m,ai,Bc,Fc,Zf,Qf,eg,tg,ng,Ls,rg,Le,Y,je,sg,Sr,og,Vc,di,Be,r,yn,Uc,h,fe,Oh}from"./chunk-0ggwm837.js";import"./chunk-bsgg8zzk.js";import"./chunk-gs373714.js";import"./chunk-465resq9.js";import"./chunk-89h4snzd.js";import"./chunk-xgegyttg.js";export{fe as clearComponentCache,di as componentClientSignalNames,ai as convertToCommonJS,h as createDetailedErrorMessage,ng as extractDirectiveNames,Bc as extractScriptFromTemplate,m as extractVariables,r as fileExists,Oh as getComponentCacheStats,Qf as getPositionInfo,Y as getSharedTranspiler,Uc as getSourceLineInfo,tg as hasDirectives,Fc as hasVariables,og as isHydrateTrigger,rg as isJavaScriptScript,Be as renderComponentWithSlot,yn as resolveTemplatePath,sg as scopeOnRootElement,Ls as scopeSequenceKey,Le as shouldTranspileTypeScript,Vc as slotContentHasExpressions,je as transpileTypeScript,Sr as userComponentFileExists,eg as validateDirective,Zf as validateTemplate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{vl,wl}from"./chunk-94ymndc5.js";import"./chunk-y8srg0q3.js";import"./chunk-5vmbycy5.js";import"./chunk-asp7ett1.js";import"./chunk-j04v4rgf.js";import"./chunk-7v2srnpv.js";import"./chunk-s4y26fk6.js";import"./chunk-rcfmwx8r.js";import"./chunk-se28p2xy.js";import"./chunk-t6qn1374.js";import"./chunk-prej5pk6.js";import"./chunk-m220n98m.js";import"./chunk-r4sawwmp.js";import"./chunk-n8s5301s.js";import"./chunk-myynywry.js";import"./chunk-vh1d5eqk.js";import"./chunk-bsq9zg9j.js";import"./chunk-n7s4n62j.js";import"./chunk-hk98vptc.js";import"./chunk-rprewgyj.js";import"./chunk-7g9vd5fv.js";import"./chunk-7r7j7vwt.js";import"./chunk-hmydy949.js";import"./chunk-gs6wc7sr.js";import"./chunk-w8p1y4c0.js";import"./chunk-tb56j1zt.js";import"./chunk-7nz28a6c.js";import"./chunk-76679dw7.js";import"./chunk-eazvp48w.js";import"./chunk-qw9kgzb3.js";import"./chunk-pes27snj.js";import"./chunk-3nxe5xmy.js";import{Yt}from"./chunk-vtv7165t.js";import"./chunk-frk6rzrq.js";import"./chunk-afj19nsj.js";import"./chunk-19safa6y.js";import{Re,i}from"./chunk-0y2zzqsq.js";import"./chunk-g4e6egrr.js";import"./chunk-jt28zh50.js";import"./chunk-mmdfjmgk.js";import"./chunk-2qz891k4.js";import"./chunk-q9npggak.js";import"./chunk-tp2g09ca.js";import"./chunk-sgm6tg8h.js";import"./chunk-3m9vrhja.js";import{be}from"./chunk-30j6mbrf.js";import"./chunk-3kfbs0mw.js";import{ar,cr}from"./chunk-wz5m7ybz.js";import{ms,j,a}from"./chunk-q49ykyq9.js";import"./chunk-xsf7ax50.js";import"./chunk-yp6w740k.js";import"./chunk-5q9ss7ty.js";import"./chunk-3cn9y08d.js";import"./chunk-z8k3fx4r.js";import{m,Me}from"./chunk-0ggwm837.js";import"./chunk-bsgg8zzk.js";import"./chunk-gs373714.js";import"./chunk-465resq9.js";import"./chunk-89h4snzd.js";import"./chunk-xgegyttg.js";import"./chunk-dh9aagwm.js";import"./chunk-j4snweyz.js";export{ms as buildWebComponents,cr as cacheTemplate,ar as checkCache,Yt as classifyAllScripts,vl as createMiddleware,wl as createRoute,j as defaultConfig,m as extractVariables,be as injectRouterScript,a as loadStxConfig,Me as processClientScript,i as processDirectives,Re as readMarkdownFile};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{U}from"./chunk-
|
|
2
|
+
import{U}from"./chunk-0ggwm837.js";import{Fe,O,Dt}from"./chunk-gs373714.js";import{dt,_e,M,Ce,sa,lo,oa,An}from"./chunk-se28p2xy.js";import{wt,ue,Ze}from"./chunk-z8k3fx4r.js";import{Co}from"./chunk-afj19nsj.js";import{Pn}from"./chunk-jb1dk0w7.js";import{ye}from"./chunk-30j6mbrf.js";import Z from"fs";import T from"path";var{serve:ce}=globalThis.Bun;import H from"zlib";import{promisify as Q}from"util";var K=Q(H.brotliCompress),ee=Q(H.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,V=new Map,z=0;function ie(t,e){if(e.length>Y/8)return;V.set(t,e),z+=e.length;for(let[o,r]of V){if(z<=Y)break;V.delete(o),z-=r.length}}async function En(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=V.get(g);if(!l)l=r==="br"?await K(a,{params:{[H.constants.BROTLI_PARAM_QUALITY]:h,[H.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 U(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",M(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}|${_e(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,_=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",M(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=_().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 A=await x;return A?l(A):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 Ig(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=sa(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=Pn(r.routeRules),f=new G,h=Co(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?O(l):void 0,v=new Map,_=new Map,x=new Map,A=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=Dt(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Ze(i.html)),A.set(n.pattern,ye(i.html));let j=T.join(e,n.fragmentPath);if(await Bun.file(j).exists()){let P=await Bun.file(j).text();_.set(n.pattern,m?Dt(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}=ue(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 En(n,await Fe(m??O(),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 j=await h(n);if(j)return j;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(),B=pe[R]||"application/octet-stream",X=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":X?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=_e(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,B)=>{q[R]=c[B+1]});break}}if(!C){let p=wt(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 N=a(i),W=Object.keys(N).length>0;return f.respond(n,N.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=_.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",...A.has(C.pattern)?{"X-STX-Runtime":A.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...M(),...N.cache?{}:{"Cache-Control":dt}}})}}let d=lo(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",...M(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:B,cookies:X,status:F,headers:I}=await An(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return oa(B,X,I);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:D}=await import("./chunk-bfdd0nmc.js"),L=new Headers({...M(),...I,"Cache-Control":"private, no-store"});for(let k of X??[])L.append("Set-Cookie",k);if(P&&!d){let k=Ze(c);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",ye(c)?"true":"false"),L.set("X-STX-Layout",k.layout),L.set("X-STX-Layout-Group",k.group)}return D(S(P&&!d?Ce(c,r.routerContainer||"main",!0):c,R,{timeoutMs:30000}),{status:F??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...M(),...N.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of X??[])w.append("Set-Cookie",S);for(let[S,D]of Object.entries(I??{}))w.set(S,D);if(w.set("Vary",M(w.get("Vary")).Vary),P&&!d){let S=Ze(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ye(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ce(c,r.routerContainer||"main",!0),{status:F??u.status??200,headers:w})}return new Response(c,{status:F??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{En,Ig};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
${r.trim()}`)}catch(r){console.warn(`[stx] Failed to load composable ${o}:`,r)}if(
|
|
4
|
-
`),j=JSON.stringify([...
|
|
2
|
+
import{k}from"./chunk-xgegyttg.js";import{A,_n}from"./chunk-89h4snzd.js";import{ln,w,x,C,Y}from"./chunk-0ggwm837.js";import{a}from"./chunk-q49ykyq9.js";import{Te,en,tn,nn}from"./chunk-frk6rzrq.js";import{yt}from"./chunk-3m9vrhja.js";import{ft,Bn,Kt,ce}from"./chunk-kb8654dp.js";import{T,Ar}from"./chunk-t4mpq6t0.js";import b from"path";var y=new Map,N=new Map,D=w(64),E=new Map,X=["composables","functions"];function z(t){let n=b.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Z(t){if(t)return b.resolve(t);let n=`<default>:${process.cwd()}`,i=E.get(n);if(i!==void 0)return i;let e=await q();if(e!==null)E.set(n,e);return e}async function q(){let t=await a(),n=t.root||process.cwd(),i=t.composablesDir;if(i)return b.resolve(n,i);for(let e of X){let s=b.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function G(t){let n=Array.isArray(t)?t:t?[b.resolve(t)]:(await a())._layerComposableDirs??[await Z()].filter((e)=>!!e),i=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=b.relative(e,d);if(!z(d)&&!i.has(c))i.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...i.values()].sort()}}async function po(t){let{files:n}=await G(t),i=Y({loader:"ts",target:"browser",define:C()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=i.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Q(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function J(t,n){let i=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?i.has(s):Q(t,s))e.add(s);return e}var U=w(64);function V(t,n){let i=x(t,n.size),e=U.get(i);if(e)return e;let s;try{s=ln(t,n)}catch{s=J(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(i,s),s}function ee(t,n,i){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of J(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of V(u,d))l.push(e.get(f));return l},m=new Set,p=i.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function qm(t,n,i){let{key:e,files:s}=await G(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((o)=>Te(o))])],c=ft(d());if(s.length===0)return ce(y,e,c,""),null;s.sort();let m=Y({loader:"ts",target:"browser",define:C()}),p=Kt(N,e,c);if(!p){let o=new Map,r=[];for(let g of s)try{let h=await Bun.file(g).text();o.set(g,h);let _=m.scan(h).exports.filter((W)=>W!=="default");if(_.length>0)r.push({file:g,names:_})}catch{o.set(g,"")}p=ce(N,e,c,{codeByFile:o,modules:r})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let o=i?[n,...i]:[n],r=x(o.join("\x00"),e,o.length,c),g=D.get(r);if(f=g??ee(l,u,o),!g)D.set(r,f)}if(f.size===0)return null;let I=s.filter((o)=>f.has(o)),v=`${e}\x00${I.join("\x00")}\x00${tn()}`,F=Kt(y,v,c);if(F!==void 0)return F||null;let B=[],S=new Set,R=new Set;for(let o of I)try{let r=u.get(o)??await Bun.file(o).text(),g=b.basename(o,".ts");for(let _ of r.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let h=[];try{for(let _ of m.scan(r).exports)if(_!=="default")S.add(_),h.push(_)}catch{}if(r=A(r),en(r))r=await nn(r,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:h}),r=yt(r);r=_n(r),r=r.replace(/^export\s+(default\s+)?/gm,""),r=m.transformSync(r),B.push(`// Composable: ${g}
|
|
3
|
+
${r.trim()}`)}catch(r){console.warn(`[stx] Failed to load composable ${o}:`,r)}if(B.length===0||S.size===0)return ce(y,v,c,""),null;let L=[...S].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
|
+
`),j=JSON.stringify([...S]),M=B.join(`
|
|
5
5
|
|
|
6
|
-
`),H=
|
|
7
|
-
`),P=JSON.stringify(new Bun.CryptoHasher("md5").update(`${j}\x00${
|
|
6
|
+
`),H=k.filter((o)=>!R.has(o)&&new RegExp(`\\b${o}\\b`).test(M)).map((o)=>`var ${o} = __stx[${JSON.stringify(o)}];`).join(`
|
|
7
|
+
`),P=JSON.stringify(new Bun.CryptoHasher("md5").update(`${j}\x00${M}`).digest("hex").slice(0,12)),K=`;(function(){
|
|
8
8
|
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
9
|
if (__bundles[${P}]) return;
|
|
10
10
|
__bundles[${P}] = true;
|
|
@@ -13,7 +13,7 @@ window.__composables = window.__composables || {};
|
|
|
13
13
|
var __c = window.__composables;
|
|
14
14
|
var __stx = window.stx || {};
|
|
15
15
|
${H}
|
|
16
|
-
${
|
|
16
|
+
${M}
|
|
17
17
|
${L}
|
|
18
18
|
var __names = ${j};
|
|
19
19
|
for (var __i = 0; __i < __names.length; __i++) {
|
|
@@ -29,5 +29,5 @@ ${L}
|
|
|
29
29
|
window[__n] = __c[__n];
|
|
30
30
|
__published[__n] = true;
|
|
31
31
|
}
|
|
32
|
-
})();`,O=T()?Ar(K):K;return c=ft(d()),ce(
|
|
32
|
+
})();`,O=T()?Ar(K):K;return c=ft(d()),ce(y,v,c,O),O}function Km(){y.clear(),Bn(),N.clear(),D.clear(),E.clear()}
|
|
33
33
|
export{po,qm,Km};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ig}from"./chunk-5vmbycy5.js";import"./chunk-se28p2xy.js";import"./chunk-vtv7165t.js";import"./chunk-afj19nsj.js";import"./chunk-tp2g09ca.js";import"./chunk-30j6mbrf.js";import"./chunk-q49ykyq9.js";import"./chunk-xsf7ax50.js";import"./chunk-yp6w740k.js";import"./chunk-5q9ss7ty.js";import"./chunk-3cn9y08d.js";import"./chunk-z8k3fx4r.js";import"./chunk-0ggwm837.js";import"./chunk-bsgg8zzk.js";import"./chunk-gs373714.js";import"./chunk-465resq9.js";import"./chunk-89h4snzd.js";import"./chunk-xgegyttg.js";export{Ig as startProductionServer};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{k}from"./chunk-xgegyttg.js";import{A,_n}from"./chunk-89h4snzd.js";import{C,Y}from"./chunk-0ggwm837.js";import{a}from"./chunk-q49ykyq9.js";import{Te,en,tn,nn}from"./chunk-frk6rzrq.js";import{yt}from"./chunk-3m9vrhja.js";import{ft,Bn,Kt,ce}from"./chunk-kb8654dp.js";import{T,Ar}from"./chunk-t4mpq6t0.js";import S from"path";function U(c,n){for(let t of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(t[1])n.add(t[1]);for(let t of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let e of(t[1]??"").split(",")){let s=((e.includes(":")?e.split(":").pop():e)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(s))n.add(s)}for(let t of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let e of(t[1]??"").split(",")){let r=e.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}var h=new Map;async function v(c,n=T()){let t;if(c)t=S.resolve(c);else{let l=await a();t=S.resolve(l.root||process.cwd(),l.storesDir||"stores")}let e=`${t}\x00${tn()}\x00${n?"shared":"inline"}`,r=new Bun.Glob("*.ts"),s=[];try{for await(let l of r.scan({cwd:t,absolute:!0})){let o=S.basename(l,".ts");if(["index","types"].includes(o))continue;if(l.includes(".d.ts"))continue;s.push(l)}}catch{return ce(h,e,"",{chunks:[]}),null}let i=()=>[...new Set([...s,...s.flatMap((l)=>Te(l))])],f=ft(i()),d=Kt(h,e,f);if(d!==void 0)return d.chunks.length>0?d:null;if(s.length===0)return ce(h,e,f,{chunks:[]}),null;let m=[];for(let l of s){let o=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(o)})}m.sort((l,o)=>{if(l.hasUseStore===o.hasUseStore)return 0;return l.hasUseStore?1:-1});let g=m.map((l)=>l.file),u=[],p=Y({loader:"ts",target:"browser",define:C()});for(let l of g)try{let o=await Bun.file(l).text(),b=S.basename(l,".ts"),x=new Set;U(o,x);let _=[...o.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((R)=>R[2]),M=o.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(en(o))o=await nn(o,l,{projectRoot:process.cwd(),externalizeUserModules:n});o=yt(o),o=A(o),o=_n(o),o=o.replace(/^export\s+(default\s+)?/gm,""),o=p.transformSync(o),u.push({name:b,ids:_.length===M?_:[],declared:x,code:`// Store: ${b}
|
|
3
|
+
${o.trim()}`})}catch(o){console.warn(`[stx] Failed to load store ${l}:`,o)}if(u.length===0)return ce(h,e,f,{chunks:[]}),null;f=ft(i());let w={chunks:u};return ce(h,e,f,w),w}function E(c){let n=new Set;for(let s of c)for(let i of s.declared)n.add(i);let t=c.map((s)=>s.code).join(`
|
|
4
|
+
|
|
5
|
+
`),r=`;(function(){
|
|
6
|
+
var __stx = window.stx || {};
|
|
7
|
+
${k.filter((s)=>!n.has(s)&&new RegExp(`\\b${s}\\b`).test(t)).map((s)=>`var ${s} = __stx[${JSON.stringify(s)}];`).join(`
|
|
8
|
+
`)}
|
|
9
|
+
${t}
|
|
10
|
+
})();`;return T()?Ar(r):r}function B(c){let n=new Set;for(let t of c.matchAll(/^(?:export\s+)?(?:async\s+)?(?:const|let|var|function\*?|class)\s+([A-Z_a-z$][\w$]*)/gm))n.add(t[1]);for(let t of c.matchAll(/^(?:const|let|var)\s*[{[]([^=]*)[}\]]\s*=/gm))for(let e of(t[1]??"").split(",")){let r=(e.includes(":")?e.split(":").pop():e).replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}return n}function I(c){let n=c.map((t)=>B(t.code));for(let[t,e]of c.entries())for(let[r,s]of n.entries()){if(r===t)continue;for(let i of s){if(n[t].has(i)||e.declared.has(i))continue;if(new RegExp(`(?<![\\w$.])${i.replace(/\$/g,"\\$")}(?![\\w$])`).test(e.code))return null}}return c.map((t,e)=>{let r=new Set([...t.declared,...n[e]]);return`function() {
|
|
11
|
+
var __stx = window.stx || {};
|
|
12
|
+
${k.filter((i)=>!r.has(i)&&new RegExp(`\\b${i}\\b`).test(t.code)).map((i)=>`var ${i} = __stx[${JSON.stringify(i)}];`).join(`
|
|
13
|
+
`)}
|
|
14
|
+
${t.code}
|
|
15
|
+
}`})}var y=new WeakMap;async function Vm(c){let n=await v(c);if(!n)return null;let t=y.get(n);if(t===void 0)t=E(n.chunks),y.set(n,t);return t}function pa(...c){let n=new Set,t=!1;for(let e of c){if(!e)continue;if(/__STX_STORES__|\b_stores\b/.test(e))t=!0;let r=e.match(/\buseStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(r===0)continue;let s=0;for(let i of e.matchAll(/\buseStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1\s*[,)]/g))n.add(i[2]),s++;if(s!==r)t=!0}return{names:n,all:t}}async function Um(c,n,t={}){let e=await v(c,t.sharedModules);if(!e)return null;let{chunks:r}=e,s=pa(...n),i;if(s.all||r.some((f)=>f.ids.length===0))i=r;else{let f=new Map;for(let u of r)for(let p of u.ids)f.set(p,u);let d=new Set,m=[...s.names],g=!1;while(m.length>0&&!g){let u=f.get(m.pop());if(!u||d.has(u))continue;d.add(u);let p=pa(u.code);if(p.all)g=!0;else m.push(...p.names)}i=g?r:r.filter((u)=>d.has(u))}if(i.length===0)return null;return{code:E(i),stores:i.map((f)=>f.name),functions:I(i)}}function Wm(){h.clear(),Bn()}
|
|
16
|
+
export{Vm,pa,Um,Wm};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`).length;s.push({line:
|
|
4
|
-
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:xe(r,u.kind)})}}}return s}import
|
|
2
|
+
import{k}from"./chunk-xgegyttg.js";import{we,At,ti,ni,Cc,Ec,Tc,$c,Is,si,Rc,Ac,Pc,mn}from"./chunk-0ggwm837.js";import{a}from"./chunk-q49ykyq9.js";import{po}from"./chunk-76679dw7.js";import{l}from"./chunk-c05r0rzw.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=mn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),ye=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function xe(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let c of u.code.matchAll(Y)){let g=c.index+c[0].indexOf("{")+1;for(let m of c[1].matchAll(/[^,]+/g)){let x=m[0];if(/^\s*type\s/.test(x))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(x);if(!y)continue;let r=y[1];if(!ye.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
|
+
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
|
+
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:xe(r,u.kind)})}}}return s}import T from"path";var Se="@stacksjs/stx-typescript-plugin";function ke(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=ke(e,s);if(!u)return;let i=new Set,c=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let x=m.compilerOptions?.plugins;if(Array.isArray(x)){let r=x.find((p)=>p?.name===Se),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=c(f);if(p!==void 0)return p}return};return c(u)??void 0}function Rl(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=si(e)+ni(ti(e.code)),c=e.kind==="client"||e.kind==="plain"?Tc(t,e.code):"";return Is(`${u+i}
|
|
6
6
|
${c}
|
|
7
7
|
export {}
|
|
8
|
-
`,s)}var $e=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function ve(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(
|
|
8
|
+
`,s)}var $e=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function ve(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(k),u=[];for(let{file:i,names:c}of e){let g=JSON.stringify(i.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let m of c){if(s.has(m)||$e.has(m))continue;s.add(m),t.push(`declare const ${m}: typeof import(${g})[${JSON.stringify(m)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
|
|
9
9
|
`)}function Qi(e,t,s){return`${e}.__stx_${t}${s}.ts`}function Mg(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Al(){return se("stx.d.ts")}function Pl(){return se("stx-module.d.ts")}function se(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function re(e){let t="",s=!1,u=!1;for(let i=0;i<e.length;i++){let c=e[i];if(s){if(t+=c,u)u=!1;else if(c==="\\")u=!0;else if(c==='"')s=!1;continue}if(c==='"'){s=!0,t+=c;continue}if(c==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
|
|
10
10
|
`)i++;t+=`
|
|
11
11
|
`;continue}if(c==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=c}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(re(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(M(r)){s=r;break}let f=h.dirname(t);if(f===t)break;t=f}if(!s)return{};let u=new Set,i=s,c,g,m=s;while(i&&!u.has(i)){u.add(i);let r;try{r=JSON.parse(re(K(i,"utf8")))}catch{break}let f=r?.compilerOptions??{};if(!c&&f.paths&&typeof f.paths==="object")c=f.paths,m=i;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(i),f.baseUrl);if(c&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!c)return{};let x=g??h.dirname(m),y={};for(let[r,f]of Object.entries(c)){if(!Array.isArray(f))continue;y[r]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(x,p):p)}return{paths:y}}async function Lg(e,t={}){let s=t.client!==!1,u=t.server!==!1,i=t.templates!==!1,c=t.componentsDir??(i?(await a()).componentsDir:void 0),g=new Map,m=new Map,x=[],y=[],r=0,f=0,p=Al();for(let n of e){let o=await Bun.file(n).text(),b=At(o).filter((d)=>{if(d.kind==="server")return u;return s}),S=At(o).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
|
|
12
|
-
`);for(let d of ne(o,b))x.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&S){let d=b.filter((
|
|
12
|
+
`);for(let d of ne(o,b))x.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&S){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>$c(S,O.code)))];if(E.length>0)m.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=h.dirname(h.resolve(n)),v=i?Rc(o,{runtimeGlobals:!p,originDir:D,filePath:h.resolve(n),componentsDir:c}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(b.length===0&&R===0)continue;if(y.push(n),r+=b.length,f+=R,b.forEach((d,E)=>{g.set(Qi(n,d.kind,E),{source:Rl(d,S,D),origin:n,kind:d.kind})}),v&&R>0)g.set(Qi(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:x,checkedFiles:y,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>h.resolve(n)),oe=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,M);for(let n of oe?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?Pl():null;if(G)w.push(G);let X=`${l()}/typecheck/__stx_globals.d.ts`,ce=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Cc(p?Ec(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...k.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...we.map((n)=>`declare const ${n}: any`)].join(`
|
|
13
13
|
`),ve(await po())].filter(Boolean).join(`
|
|
14
|
-
`),
|
|
15
|
-
`)){let b=o.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,S,
|
|
14
|
+
`),_=`${l()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(X,ce);let N=new Map,ae=0;for(let[n,o]of g){let b=`${ae++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${_}/${b}`,o.source),N.set(b,o)}let le={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Oe(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},F=async(n,o)=>{let b=`${_}/tsconfig${o===1?"":`.${o}`}.json`;await Bun.write(b,JSON.stringify({compilerOptions:le,files:n.map((D)=>`${_}/${D}`).concat(X,...w)},null,2));let S=Bun.spawnSync(["bun","x","tsc","-p",b,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(S.stdout)+new TextDecoder().decode(S.stderr),exitCode:S.exitCode??0}},V=await F([...N.keys()],1),J=V.output,I=[],U=V.exitCode,W=0,ue=new Set(w.map((n)=>n.split("/").pop())),z=0,B=new Set,q=(n)=>{for(let o of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
|
|
15
|
+
`)){let b=o.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,S,D,v,R,d,E]=b,O=S.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Q;if(C.virtual){let P=Pc(C.virtual,A,L);if(!P?.expression)continue;if(Ac(P,Number(d)))continue;A=P.line,L=P.column,Q=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Q})}};q(J);let pe=W,de=z;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((o)=>!B.has(o));q((await F(n,2)).output)}if(s)for(let[n,o]of m){if(o.names.length===0)continue;I.push({file:n,line:o.line,column:1,code:0,message:`${o.names.length===1?"1 value reaches":`${o.names.length} values reach`} this block on the implicit bridge and ${o.names.length===1?"is":"are"} untyped: ${o.names.join(", ")}. Declare them with defineClientPayload({ ${o.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:o.kind})}I.push(...x);let H=new Set,j=I.filter((n)=>{let o=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(o))return!1;return H.add(o),!0});j.sort((n,o)=>n.file.localeCompare(o.file)||n.line-o.line||n.column-o.column);let Z=de>0&&j.length===0,fe=Z||U!==0&&pe===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
16
16
|
${J.trim().split(`
|
|
17
17
|
`).slice(0,12).join(`
|
|
18
18
|
`)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:y,blockCount:r,expressionCount:f,failure:fe}}function jg(e){return e.map((t)=>{let s=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${s}`}).join(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fg}from"./chunk-rcfmwx8r.js";import"./chunk-se28p2xy.js";import"./chunk-eazvp48w.js";import"./chunk-vtv7165t.js";import"./chunk-afj19nsj.js";import"./chunk-0y2zzqsq.js";import"./chunk-g4e6egrr.js";import"./chunk-jt28zh50.js";import"./chunk-mmdfjmgk.js";import"./chunk-2qz891k4.js";import"./chunk-q9npggak.js";import"./chunk-tp2g09ca.js";import"./chunk-sgm6tg8h.js";import"./chunk-3m9vrhja.js";import"./chunk-30j6mbrf.js";import"./chunk-3kfbs0mw.js";import"./chunk-wz5m7ybz.js";import"./chunk-q49ykyq9.js";import"./chunk-xsf7ax50.js";import"./chunk-yp6w740k.js";import"./chunk-5q9ss7ty.js";import"./chunk-3cn9y08d.js";import"./chunk-z8k3fx4r.js";import"./chunk-0ggwm837.js";import"./chunk-bsgg8zzk.js";import"./chunk-gs373714.js";import"./chunk-465resq9.js";import"./chunk-89h4snzd.js";import"./chunk-xgegyttg.js";export{Fg as buildForProduction};
|