@stacksjs/stx 0.2.353 → 0.2.354
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-jhh9a133.js → chunk-04x3vny9.js} +1 -1
- package/dist/{chunk-3xq6vafa.js → chunk-1apnswz7.js} +1 -1
- package/dist/{chunk-ptag4104.js → chunk-1qvf8ase.js} +1 -1
- package/dist/chunk-2wb3pgp4.js +12 -0
- package/dist/{chunk-av590rpt.js → chunk-32x78na8.js} +1 -1
- package/dist/{chunk-0ptbqqjn.js → chunk-3nx7z086.js} +2 -2
- package/dist/{chunk-2ztc1c69.js → chunk-3z4d7kmp.js} +1 -1
- package/dist/{chunk-yma78dgm.js → chunk-4b2vsawv.js} +1 -1
- package/dist/{chunk-90f1exy0.js → chunk-5wbdbcvf.js} +2 -2
- package/dist/{chunk-pyxrf1yq.js → chunk-616fn77w.js} +1 -1
- package/dist/{chunk-g8gyg75c.js → chunk-62nz9v8t.js} +1 -1
- package/dist/{chunk-b86rzqhh.js → chunk-6k5a03pw.js} +1 -1
- package/dist/{chunk-tge90dcm.js → chunk-6r3aavbv.js} +1 -1
- package/dist/{chunk-x069zavs.js → chunk-6zrg2mmc.js} +1 -1
- package/dist/{chunk-47bw0sdp.js → chunk-70zk8tj2.js} +1 -1
- package/dist/{chunk-dtqgqwvg.js → chunk-84bhnp6p.js} +1 -1
- package/dist/{chunk-x7v4t7sd.js → chunk-88e14er7.js} +1 -1
- package/dist/chunk-8yydz0hk.js +2 -0
- package/dist/{chunk-qeh9d34h.js → chunk-9e20mgwc.js} +1 -1
- package/dist/{chunk-c5984fa1.js → chunk-a1knndrh.js} +8 -8
- package/dist/{chunk-65sbtwdm.js → chunk-a7yxvxke.js} +1 -1
- package/dist/{chunk-5f24zdpz.js → chunk-a8ghkfh6.js} +1 -1
- package/dist/{chunk-8v2k21n4.js → chunk-a9w1ds4w.js} +1 -1
- package/dist/{chunk-hdgcn4pr.js → chunk-aanwshk6.js} +1 -1
- package/dist/{chunk-7yqnsb6r.js → chunk-ahfj7dc7.js} +1 -1
- package/dist/{chunk-aqfpwbpa.js → chunk-avye7h5s.js} +1 -1
- package/dist/{chunk-ytnby89m.js → chunk-bed5f4bp.js} +1 -1
- package/dist/{chunk-mncxf2ba.js → chunk-epqd3eah.js} +1 -1
- package/dist/{chunk-njewrge9.js → chunk-f85f75jh.js} +1 -1
- package/dist/{chunk-fkx0m7qh.js → chunk-g5mhck0r.js} +1 -1
- package/dist/{chunk-trpgj79r.js → chunk-g7msqva8.js} +2 -2
- package/dist/{chunk-cp9swtsm.js → chunk-gtqbvt3a.js} +1 -1
- package/dist/{chunk-ag8t9t8y.js → chunk-h5jt4mxx.js} +1 -1
- package/dist/{chunk-tg1ke8te.js → chunk-hay8nwv3.js} +1 -1
- package/dist/{chunk-ybz74n47.js → chunk-hysq9e9t.js} +1 -1
- package/dist/{chunk-sevmpyg5.js → chunk-m6dstr44.js} +1 -1
- package/dist/{chunk-8xj54kfq.js → chunk-mmnf2pac.js} +1 -1
- package/dist/{chunk-fcr2kg64.js → chunk-msq8xvhp.js} +16 -16
- package/dist/{chunk-pwzd7c1z.js → chunk-ngjkzaj7.js} +1 -1
- package/dist/{chunk-vf1kq4zw.js → chunk-ntzzhw3w.js} +1 -1
- package/dist/{chunk-cm1v88jj.js → chunk-px0bs815.js} +1 -1
- package/dist/{chunk-zwjnf7zb.js → chunk-qw92p9za.js} +1 -1
- package/dist/{chunk-x5dh3gje.js → chunk-rjwnw5hj.js} +1 -1
- package/dist/{chunk-vjnvjev0.js → chunk-tmr3xq5d.js} +1 -1
- package/dist/chunk-tpk6wm38.js +2 -0
- package/dist/{chunk-sa4gad49.js → chunk-v0e259x2.js} +1 -1
- package/dist/{chunk-1pmwpb04.js → chunk-vw4b7g24.js} +1 -1
- package/dist/{chunk-qq3zttws.js → chunk-x2n1x19t.js} +1 -1
- package/dist/{chunk-9113j510.js → chunk-z23sc9p4.js} +1 -1
- package/dist/{chunk-zgcmre3w.js → chunk-zks9ft7n.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/strip-literals.d.ts +14 -5
- package/dist/strip-literals.js +54 -1
- package/package.json +5 -5
- package/dist/chunk-bqdfbwdf.js +0 -11
- package/dist/chunk-xtntgyfn.js +0 -2
- package/dist/chunk-ynxq28xq.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ei as s}from"./chunk-
|
|
2
|
+
import{ei as s}from"./chunk-6r3aavbv.js";import{$l as a,Kp as v,Lp as i,Mp as t,Pp as e,Qp as HH,Rp as KH,Sp as QH,Tp as YH,Up as ZH,sr as $H}from"./chunk-msq8xvhp.js";import{nt as h}from"./chunk-y2f41kaq.js";import{vv as f}from"./chunk-72x62kch.js";import{existsSync as jH,readFileSync as WH}from"fs";import z from"path";function AH(Q,K="",V=""){let L=Q.startLine>1?`
|
|
3
3
|
`.repeat(Q.startLine-1):"",U=t(i(Q.code)),X=Q.kind==="client"||Q.kind==="plain"?HH(K,Q.code):"";return QH(`${L+U}
|
|
4
4
|
${X}
|
|
5
5
|
export {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$p as k,Ho as a,Jo as b,Lo as c,Mo as d,Vp as e,Wp as f,Xp as g,Yp as h,Zp as i,_p as j,aq as l,bq as m,cq as n,dq as o,eq as p,fq as q,gq as r,hq as s,iq as t,jq as u,kq as v,lq as w,mq as x,nq as y}from"./chunk-
|
|
2
|
+
import{$p as k,Ho as a,Jo as b,Lo as c,Mo as d,Vp as e,Wp as f,Xp as g,Yp as h,Zp as i,_p as j,aq as l,bq as m,cq as n,dq as o,eq as p,fq as q,gq as r,hq as s,iq as t,jq as u,kq as v,lq as w,mq as x,nq as y}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{e as validateTemplate,g as validateDirective,o as userComponentFileExists,m as transpileTypeScript,q as slotContentHasExpressions,k as shouldTranspileTypeScript,n as scopeOnRootElement,u as resolveTemplatePath,s as renderComponentWithSlot,j as isJavaScriptScript,p as isHydrateTrigger,d as hasVariables,h as hasDirectives,v as getSourceLineInfo,l as getSharedTranspiler,f as getPositionInfo,y as getComponentCacheStats,t as fileExists,a as extractVariables,c as extractScriptFromTemplate,i as extractDirectiveNames,w as createDetailedErrorMessage,b as convertToCommonJS,r as componentClientSignalNames,x as clearComponentCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fo as b,go as c,ho as d}from"./chunk-
|
|
2
|
+
import{fo as b,go as c,ho as d}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import{mv as a}from"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{b as rendersAsElement,c as processESImports,d as processComponents,a as freeIdentifiers};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function G(H,M){let j=H[M],J=M+1;while(J<H.length){if(H[J]==="\\"){J+=2;continue}if(H[J]===j)return J+1;J++}return H.length}function K(H,M){let j=M+1;while(j<H.length){if(H[j]==="\\"){j+=2;continue}if(H[j]==="`")return j+1;if(H[j]==="$"&&H[j+1]==="{"){if(j=F(H,j+2),j<H.length)j++;continue}j++}return H.length}function F(H,M){let j=1,J=M;while(J<H.length){let U=H[J];if(U==="\\"){J+=2;continue}if(U==='"'||U==="'"){J=G(H,J);continue}if(U==="`"){J=K(H,J);continue}if(U==="/"&&H[J+1]==="/"){while(J<H.length&&H[J]!==`
|
|
3
|
+
`)J++;continue}if(U==="/"&&H[J+1]==="*"){J+=2;while(J<H.length&&H.slice(J,J+2)!=="*/")J++;J+=2;continue}if(U==="{"){j++,J++;continue}if(U==="}"){if(j--,j===0)return J;J++;continue}J++}return H.length}var O=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function P(H,M){if(M)return O.has(M);return!(H===")"||H==="]"||H===z)}var z="\x00";function Q(H,M){let j=M+1,J=!1;while(j<H.length){let U=H[j];if(U===`
|
|
4
|
+
`)return-1;if(U==="\\"){j+=2;continue}if(U==="[")J=!0;else if(U==="]")J=!1;else if(U==="/"&&!J){j++;while(j<H.length&&/[a-z]/i.test(H[j]))j++;return j}j++}return-1}function X(H){let M="",j=0,J="",U="";while(j<H.length){let Z=H.slice(j,j+2);if(Z==="//"){while(j<H.length&&H[j]!==`
|
|
5
|
+
`)M+=" ",j++;continue}if(Z==="/*"){while(j<H.length&&H.slice(j,j+2)!=="*/")M+=H[j]===`
|
|
6
|
+
`?`
|
|
7
|
+
`:" ",j++;M+=" ",j+=2;continue}let V=H[j];if(V==='"'||V==="'"){let $=V;M+=" ",j++;while(j<H.length&&H[j]!==$){if(H[j]==="\\"){M+=" ",j+=2;continue}M+=H[j]===`
|
|
8
|
+
`?`
|
|
9
|
+
`:" ",j++}M+=" ",j++,J=z,U="";continue}if(V==="/"&&P(J,U)){let $=Q(H,j);if($!==-1){M+=`/${" ".repeat($-j-2)}/`,j=$,J=z,U="";continue}}if(V==="`"){M+=" ",j++;while(j<H.length&&H[j]!=="`"){if(H[j]==="\\"){M+=" ",j+=2;continue}if(H[j]==="$"&&H[j+1]==="{"){let $=j+2,B=F(H,$);if(M+=" ",M+=X(H.slice($,B)),B<H.length)M+=" ";j=B+1;continue}M+=H[j]===`
|
|
10
|
+
`?`
|
|
11
|
+
`:" ",j++}M+=" ",j++,J=z,U="";continue}if(M+=V,j++,/[\w$]/.test(V))U=/[\w$]/.test(J)?U+V:V,J=V;else if(!/\s/.test(V))J=V,U=""}return M}function Y(H){let M=new Uint16Array(H.length),j=0,J=!0;for(let U=0;U<H.length;U++){let Z=H[U];if(Z===")"||Z==="]"||Z==="}")if(j===0)J=!1;else j--;if(M[U]=j,Z==="("||Z==="["||Z==="{")j++}return{depths:M,balanced:J&&j===0}}
|
|
12
|
+
export{F as ks,X as ls,Y as ms};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qr as a,rr as b,sr as c,tr as d,ur as e,vr as f}from"./chunk-
|
|
2
|
+
import{qr as a,rr as b,sr as c,tr as d,ur as e,vr as f}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$m as T,Ho as k,Jp as w,Sl as A,Tl as b,Zn as M,an as y,km as B,lo as R,mm as F,qr as P,zo as x}from"./chunk-
|
|
2
|
+
import{$m as T,Ho as k,Jp as w,Sl as A,Tl as b,Zn as M,an as y,km as B,lo as R,mm as F,qr as P,zo as x}from"./chunk-msq8xvhp.js";import{Nw as v}from"./chunk-ejqpq0wc.js";function j(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,Y){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(Y?.some((X)=>q>=X.start&&N<=X.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,Y)=>J.start-Y.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function D(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>b(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as f,resolve as H}from"path";function S(K){let z=K,G=M(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],Y=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],X=$[2],E=$[0],Z=N.includes("server");if(Y(X))J.push(E);else if(Z)Q.push(X);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,X,E=[];while((X=N.exec(q))!==null){let Z=X.index+X[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:X.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -14,5 +14,5 @@ ${Q.join(`
|
|
|
14
14
|
`)}`}else{if(G.processClientScripts!==!1&&Q.length>0){let N=Y.__stx_event_bindings||[],X=B(Y),Z=(await Promise.all(Q.map(async(I)=>{let W=I.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!W)return I;return await F(W[1],{eventBindings:N,templateContent:q,serverData:X,filePath:z})}))).join(`
|
|
15
15
|
`);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${Z}
|
|
16
16
|
$1`);else q+=`
|
|
17
|
-
${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCss:N}=await import("./chunk-
|
|
17
|
+
${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCss:N}=await import("./chunk-avye7h5s.js");q=await N(q)}catch{}return q}
|
|
18
18
|
export{j as ok,C as pk,D as qk,o as rk,r as sk,V as tk};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jj as b,Kj as c,Lj as d,Mj as e,Nj as f,Oj as g,Pj as h,Qj as i,Rj as j,Sj as k,Tj as l,Uj as m,Vj as n,Wj as o}from"./chunk-
|
|
2
|
+
import{Jj as b,Kj as c,Lj as d,Mj as e,Nj as f,Oj as g,Pj as h,Qj as i,Rj as j,Sj as k,Tj as l,Uj as m,Vj as n,Wj as o}from"./chunk-mmnf2pac.js";import{tl as a}from"./chunk-fvsefztj.js";import"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{b as templateCache,j as registerServeModuleBundle,c as readFileCached,e as invalidateFileCacheByDir,d as invalidateFileCache,o as hashFilePath,k as getServeModuleBundle,i as getServeClientAsset,g as getCachedSignalsRuntime,h as getCachedRouterScript,l as clearDevCaches,m as checkCache,n as cacheTemplate,a as cacheEngineFingerprint,f as __setSignalsGeneratorsForTest};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Gp as b,Hp as c,Ip as d,Jp as e,lo as a}from"./chunk-
|
|
2
|
+
import{Gp as b,Hp as c,Ip as d,Jp as e,lo as a}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Ho as V}from"./chunk-
|
|
2
|
+
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Ho as V}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import{Nw as F}from"./chunk-ejqpq0wc.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${z}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-
|
|
559
|
+
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-4b2vsawv.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-4b2vsawv.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
560
560
|
`)}function jz(z){return z.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function A(z){let J=[],Z=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
561
561
|
`)}function Dz(z,J){let Z=`<script>window.__stxProps = ${JSON.stringify(J)};</script>`;return z+Z}function Lz(z){return z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function Oz(z,J){let Z=await I(z);f(z,Z);let K=v(z.config,Z);g(z,K),console.log(` Found ${Z.length} story files`);let $=typeof J.host==="string"?J.host:J.host===!0?"0.0.0.0":"localhost",X=new k(z.root),B=new T(z.root),Y=new M(z.root),W=s(),j=Bun.serve({port:J.port,hostname:$,fetch:async(Q,D)=>{let O=new URL(Q.url).pathname;if(O==="/__hmr"){if(D.upgrade(Q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(O.startsWith("/api/"))return Cz(z,O,Q,{presetsManager:X,bookmarksManager:B,analyticsTracker:Y});return kz(z,O,J.port)},websocket:{open(Q){W.open(Q)},close(Q){W.close(Q)},message(Q,D){W.message(Q,D)}}}),U=`http://${$}:${J.port}`,_=Uz(z,async(Q,D)=>{console.log(` [${Q}] ${D.relativePath}`);let L=await I(z);f(z,L);let O=v(z.config,L);if(g(z,O),Q==="add")a(D.id,{fileName:D.fileName});else if(Q==="unlink")o(D.id);else n(D.id,{fileName:D.fileName})});if(J.open){let Q=U;try{let{exec:D}=await import("child_process"),L=process.platform;D(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} ${Q}`)}catch{}}return{server:j,url:U,close:async()=>{_(),j.stop()}}}async function Cz(z,J,Z,K){let{presetsManager:$,bookmarksManager:X,analyticsTracker:B}=K;if(J==="/api/stories")return Response.json({files:z.storyFiles.map((Y)=>({id:Y.id,fileName:Y.fileName,relativePath:Y.relativePath,treePath:Y.treePath})),tree:z.tree});if(J.startsWith("/api/story/")){let Y=J.slice(11),W=z.storyFiles.find((j)=>j.id===Y);if(!W)return new Response("Story not found",{status:404});try{let j=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:j})}catch{return new Response("Error reading story",{status:500})}}if(J==="/api/config")return Response.json({theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets});if(J.startsWith("/api/render/")){let Y=new URL(Z.url),W=J.slice(12).split("/"),j=W[0],U=W[1]||"default",_,Q=Y.searchParams.get("props");if(Q)try{_=JSON.parse(Q)}catch{}let D=z.storyFiles.find((L)=>L.id===j);if(!D)return new Response("Story not found",{status:404});try{let L=await Bz(z,D,U,_);return Response.json({html:L.html,css:L.css,js:L.js,errors:L.errors,duration:L.duration})}catch(L){return Response.json({html:"",css:"",js:"",errors:[L instanceof Error?L.message:String(L)],duration:0},{status:500})}}if(J==="/api/presets"&&Z.method==="GET")return Response.json({presets:$.getAllPresets()});if(J==="/api/presets"&&Z.method==="POST")try{let Y=await Z.json(),W=$.createPreset(Y.name,Y.props,{componentId:Y.componentId,description:Y.description});return await $.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/presets/")&&!J.includes("/use")&&Z.method==="GET"){let Y=J.slice(13),W=$.getPreset(Y);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(J.endsWith("/use")&&Z.method==="POST"){let Y=J.slice(13,-4),W=$.usePreset(Y);if(!W)return new Response("Preset not found",{status:404});return await $.save(),Response.json(W)}if(J.startsWith("/api/presets/")&&Z.method==="DELETE"){let Y=J.slice(13);if(!$.deletePreset(Y))return new Response("Preset not found",{status:404});return await $.save(),Response.json({success:!0})}if(J==="/api/bookmarks"&&Z.method==="GET")return Response.json({bookmarks:X.getAllBookmarks()});if(J==="/api/bookmarks"&&Z.method==="POST")try{let Y=await Z.json(),W=X.addBookmark(Y.storyId,Y.variantId,Y.props,{name:Y.name,notes:Y.notes,color:Y.color});return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/bookmarks/toggle"&&Z.method==="POST")try{let Y=await Z.json(),W=X.toggleBookmark(Y.storyId,Y.variantId,Y.props);return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/bookmarks/")&&J!=="/api/bookmarks/toggle"&&Z.method==="GET"){let Y=J.slice(15),W=X.getBookmark(Y);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(J.startsWith("/api/bookmarks/")&&Z.method==="DELETE"){let Y=J.slice(15);if(!X.deleteBookmark(Y))return new Response("Bookmark not found",{status:404});return await X.save(),Response.json({success:!0})}if(J==="/api/analytics/track"&&Z.method==="POST")try{let Y=await Z.json();if(Y.type==="view"&&Y.componentId)B.trackView(Y.componentId,Y.variantId);else if(Y.type==="prop_change"&&Y.componentId&&Y.propName)B.trackPropChange(Y.componentId,Y.propName,null);else if(Y.type==="variant_switch"&&Y.componentId&&Y.variantId)B.trackVariantSwitch(Y.componentId,Y.variantId);else if(Y.type==="search"&&Y.query)B.trackSearch(Y.query,0);return await B.save(),Response.json({success:!0})}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/analytics/summary"&&Z.method==="GET")return Response.json({mostViewed:B.getMostViewedComponents(10),mostChangedProps:B.getMostChangedProps(10),searchAnalytics:B.getSearchAnalytics()});if(J.startsWith("/api/analytics/component/")&&Z.method==="GET"){let Y=J.slice(25),W=z.storyFiles.find((U)=>U.id===Y),j=B.getComponentAnalytics(Y,W?.fileName||Y);return Response.json(j)}return new Response("Not found",{status:404})}function kz(z,J,Z){let K=Sz(z,Z);return new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Sz(z,J){let{theme:Z}=z.config,K=Z.title||"STX Story",$=`ws://localhost:${J}/__hmr`,X=r($);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${Z.darkClass||"dark"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{kk as a,lk as b,mk as c,nk as d}from"./chunk-
|
|
2
|
+
import{kk as a,lk as b,mk as c,nk as d}from"./chunk-84bhnp6p.js";import"./chunk-3nx7z086.js";import"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ig as e,kg as kF,lg as UF,mg as wF,ug as EF}from"./chunk-
|
|
2
|
+
import{ig as e,kg as kF,lg as UF,mg as wF,ug as EF}from"./chunk-g7msqva8.js";import{xg as BF}from"./chunk-57atgbyq.js";import{nj as l,oj as d}from"./chunk-8m0g0h4x.js";import{Ck as HF,Dk as IF,Ek as KF}from"./chunk-c0n802j1.js";import{ml as YF,ol as ZF}from"./chunk-ngjkzaj7.js";import{Fp as VF,Jp as r,Op as o,Wm as s,io as zF,ip as $F,nm as p,pm as i,qr as t,sr as M,xp as GF}from"./chunk-msq8xvhp.js";import{ss as XF}from"./chunk-89mqnh67.js";import{it as qF}from"./chunk-9e20mgwc.js";import{Ct as WF}from"./chunk-gtqbvt3a.js";import{Ht as QF}from"./chunk-vhta1be7.js";import{Aw as h,Dw as _F}from"./chunk-swvm1wgn.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>o(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...t,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=e(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
|
|
3
3
|
[stx build] Done in ${D}ms \u2014 ${R.length} pages compiled`),{pageCount:R.length,assets:S,outputDir:X,duration:D}}
|
|
4
4
|
export{u as Rf,c as Sf,a as Tf,bF as Uf,FF as Vf,qJ as Wf};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ag as ZJ,cg as g,eg as A,kg as n,ng as GJ,qg as WJ,sg as YJ,ug as jJ}from"./chunk-
|
|
2
|
+
import{ag as ZJ,cg as g,eg as A,kg as n,ng as GJ,qg as WJ,sg as YJ,ug as jJ}from"./chunk-g7msqva8.js";import{xg as $J}from"./chunk-57atgbyq.js";import{ql as XJ}from"./chunk-ngjkzaj7.js";import{ko as h}from"./chunk-msq8xvhp.js";import{Cs as e}from"./chunk-9e20mgwc.js";import{Dt as QJ,Ht as i,Jt as p}from"./chunk-vhta1be7.js";import{Dw as VJ,Xv as KJ,yw as l}from"./chunk-swvm1wgn.js";import{Nw as DJ}from"./chunk-ejqpq0wc.js";import JJ from"fs";import k from"path";var{serve:wJ}=globalThis.Bun;VJ();import y from"zlib";import{promisify as a}from"util";var IJ=a(y.brotliCompress),OJ=a(y.gzip),UJ=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],BJ=["text/event-stream","multipart/x-mixed-replace"],_J=1024;function zJ(K){if(!K)return!1;let J=K.toLowerCase();if(BJ.some((G)=>J.startsWith(G)))return!1;return UJ.some((G)=>J.startsWith(G))}function FJ(K){let J=new Map;for(let G of K.split(",")){let[Z,...W]=G.trim().split(";"),O=Z.trim().toLowerCase();if(!O)continue;let U=1;for(let B of W){let w=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(B);if(!w)continue;let F=Number.parseFloat(w[1]);if(Number.isFinite(F))U=F}J.set(O,U)}return J}function LJ(K){if(!K)return null;let J=FJ(K),G=J.get("*"),Z=(W)=>J.get(W)??G??0;if(Z("br")>0)return"br";if(Z("gzip")>0)return"gzip";return null}async function t(K,J,G={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!zJ(J.headers.get("content-type")))return J;let Z=LJ(K.headers.get("accept-encoding"));if(!Z)return J;let W;try{W=new Uint8Array(await J.arrayBuffer())}catch{return J}let O=()=>new Response(W,{status:J.status,statusText:J.statusText,headers:s(J.headers)});if(W.length<(G.threshold??_J))return O();try{let U=Z==="br"?await IJ(W,{params:{[y.constants.BROTLI_PARAM_QUALITY]:G.quality??5,[y.constants.BROTLI_PARAM_SIZE_HINT]:W.length}}):await OJ(W);if(U.length>=W.length)return O();let B=s(J.headers);return B.set("Content-Encoding",Z),B.set("Content-Length",String(U.length)),new Response(U,{status:J.status,statusText:J.statusText,headers:B})}catch{return O()}}function s(K){let J=new Headers(K),G=J.get("Vary");if(!G)return J.set("Vary","Accept-Encoding"),J;if(!G.split(",").some((W)=>W.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${G}, Accept-Encoding`);return J}class d{now;entries=new e(1000,{maxBytes:33554432,sizeOf:(K)=>K.body.byteLength+JSON.stringify(K.headers).length*2});pending=new Map;generation=0;constructor(K=Date.now){this.now=K}invalidate(K){this.generation++,this.pending.clear();for(let J of Array.from(this.entries.keys()))if(K===void 0||this.entries.get(J)?.path===K)this.entries.delete(J)}async respond(K,J,G){let Z,W=async()=>{let X=Z??await G();return X.headers.set("Cache-Control","private, no-store"),X.headers.set("Vary",A(X.headers.get("Vary")).Vary),X};if(!J||K.method!=="GET"||K.headers.has("Cookie")||K.headers.has("Authorization")||K.headers.has("Range"))return W();let O=new URL(K.url),U=`${O.origin}${O.pathname}${O.search}|${g(K)?"fragment":"document"}`,B=this.entries.get(U),w=(X)=>{let T=new Headers(X.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-X.created)/1000)))),new Response(X.body.slice(0),{headers:T})},F=B?(this.now()-B.created)/1000:1/0;if(B&&F<J.maxAge)return w(B);let S=this.generation,q=async()=>{let X=await G();Z=X;let T=(X.headers.get("Vary")??"").toLowerCase().split(",").map((L)=>L.trim()).filter(Boolean);if(X.status!==200||X.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(X.headers.get("Cache-Control")??"")||T.some((L)=>L!=="x-stx-router"&&L!=="accept-encoding"))return null;let M=await X.clone().arrayBuffer();if(M.byteLength>1048576)return null;X.headers.set("Vary",A(X.headers.get("Vary")).Vary);let Q={body:M,headers:Array.from(X.headers.entries()),created:this.now(),path:O.pathname};if(this.generation===S)this.entries.set(U,Q);return Q},H=this.pending.get(U);if(!H){if(this.pending.size>=1000)return W();H=q().finally(()=>{if(this.pending.get(U)===H)this.pending.delete(U)}),this.pending.set(U,H)}if(B&&F<J.maxAge+(J.swr??0))return H.catch(()=>{}),w(B);let x=await H;return x?w(x):W()}}var HJ={".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 uJ(K={}){let J=k.resolve(K.outputDir||".output"),G=K.port??3000,Z=GJ(J);if(!Z)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Z.routes.length} routes...`);let W=$J(Z.routeRules),O=new d,U=XJ(J,Z.apiRoutes??[]),B=Bun.file(k.join(J,"server/runtime-config.json")),w=K.runtimeConfig??(await B.exists()?await B.json():void 0),F=w?i(w):void 0,S=new Map,q=new Map,H=new Map,x=new Map;for(let Q of Z.routes)try{let L=k.join(J,Q.compiledPath),Y=JSON.parse(await Bun.file(L).text());if(F)Y.html=p(Y.html,F);S.set(Q.pattern,Y),H.set(Q.pattern,l(Y.html)),x.set(Q.pattern,h(Y.html));let C=k.join(J,Q.fragmentPath);if(await Bun.file(C).exists()){let P=await Bun.file(C).text();q.set(Q.pattern,F?p(P,F):P)}}catch(L){console.warn(`[stx] Failed to load route ${Q.pattern}:`,L)}let X=new Map,T=[];for(let Q of Z.routes)if(Q.hasParams){let{regex:L,params:Y}=KJ(Q.pattern);T.push({regex:L,route:Q,paramNames:Y})}else X.set(Q.pattern,Q);let M=wJ({port:G,async fetch(Q){return t(Q,await QJ(F??i(),async()=>{let Y=new URL(Q.url).pathname;if(K.onRequest){let j=await K.onRequest(Q);if(j)return j}if(K.apiRouter){let j=await K.apiRouter.handleRequest(Q);if(j.status!==404)return j}if(K.apiRoutes?.[Y])return K.apiRoutes[Y](Q);let C=await U(Q);if(C)return C;if((Q.method==="GET"||Q.method==="HEAD")&&Y!=="/"){let j=k.resolve(J,"public"),_;try{_=decodeURIComponent(Y)}catch{_=Y}if(!_.includes("\x00")){let I=k.resolve(j,`.${_}`);if(I===j||I.startsWith(`${j}${k.sep}`))try{if(JJ.existsSync(I)&&JJ.statSync(I).isFile()){let z=k.extname(I).toLowerCase(),E=HJ[z]||"application/octet-stream",v=Y.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(Y);return new Response(Bun.file(I),{headers:{"Content-Type":E,"Cache-Control":v?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=g(Q),D=null,o={};if(D=X.get(Y)||null,!D)for(let{regex:j,route:_,paramNames:I}of T){let $=Y.match(j);if($){D=_,I.forEach((z,E)=>{o[z]=$[E+1]});break}}if(!D){let j=X.get("/404")||null;if(j){let _=S.get(j.pattern);if(_)return new Response(_.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let R=W(Y),r=Object.keys(R).length>0;return O.respond(Q,R.cache,async()=>{let j=S.get(D.pattern);if(P&&Q.method==="GET"&&j&&!j.hasServerScripts&&Object.keys(j.placeholders).length===0){let $=q.get(D.pattern);if($){let z=H.get(D.pattern);return new Response($,{status:j.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...x.has(D.pattern)?{"X-STX-Runtime":x.get(D.pattern)?"true":"false"}:{},...z?{"X-STX-Layout":z.layout,"X-STX-Layout-Group":z.group}:{},...A(),...R.cache?{}:{"Cache-Control":ZJ}}})}}let _=WJ(Q.method),I=S.get(D.pattern);if(!I){let $=X.get("/500")||null;if($){let z=S.get($.pattern);if(z)return new Response(z.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(D.prerendered&&_)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!_&&!I.hasServerScripts&&Object.keys(I.placeholders).length===0)return new Response(I.html,{status:I.status??200,headers:{"Content-Type":"text/html",...A(),"Cache-Control":"public, max-age=60"}});try{let{html:$,boundaries:z,redirect:E,cookies:v,status:m,headers:c}=await jJ(I,{params:o,request:Q,method:Q.method,__stx_strict_hydration:r,__stx_runtime_config:F});if(E)return YJ(E,v,c);if(z&&z.length>0){let{renderStreamingPage:N,streamToResponse:u}=await import("./chunk-h5jt4mxx.js"),b=new Headers({...A(),...c,"Cache-Control":"private, no-store"});for(let f of v??[])b.append("Set-Cookie",f);if(P&&!_){let f=l($);b.set("X-STX-Fragment","true"),b.set("X-STX-Runtime",h($)?"true":"false"),b.set("X-STX-Layout",f.layout),b.set("X-STX-Layout-Group",f.group)}return u(N(P&&!_?n($,Z.routerContainer||"main"):$,z,{timeoutMs:30000}),{status:m??I.status??200,headers:b})}let V=new Headers({"Content-Type":"text/html",...A(),...R.cache?{}:{"Cache-Control":"private, no-store"}});for(let N of v??[])V.append("Set-Cookie",N);for(let[N,u]of Object.entries(c??{}))V.set(N,u);if(V.set("Vary",A(V.get("Vary")).Vary),P&&!_){let N=l($);return V.set("X-STX-Fragment","true"),V.set("X-STX-Runtime",h($)?"true":"false"),V.set("X-STX-Layout",N.layout),V.set("X-STX-Layout-Group",N.group),new Response(n($,Z.routerContainer||"main"),{status:m??I.status??200,headers:V})}return new Response($,{status:m??I.status??200,headers:V})}catch($){if(console.error(`[stx] Hydration error for ${Y}:`,$),r)return new Response("Internal Server Error",{status:500});return new Response(I.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${M.port}`),console.log(`[stx] Serving ${Z.routes.length} routes (${S.size} pre-loaded)`),{port:M.port,stop:()=>{O.invalidate(),M.stop()},invalidate:(Q)=>O.invalidate(Q)}}
|
|
3
3
|
export{zJ as Ve,LJ as We,t as Xe,uJ as Ye};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ji as T,Ki as u,Li as A}from"./chunk-7we3xfde.js";import{Zk as g,el as h,kl as b}from"./chunk-
|
|
2
|
+
import{Ji as T,Ki as u,Li as A}from"./chunk-7we3xfde.js";import{Zk as g,el as h,kl as b}from"./chunk-epqd3eah.js";import{am as k,aq as B,sr as I,yo as f}from"./chunk-msq8xvhp.js";import{qv as D,rv as S}from"./chunk-wj21f1e0.js";import{vv as F}from"./chunk-72x62kch.js";import P from"path";var j=new Map,K=new Map,n=["composables","functions"];function p(z){let H=P.basename(z,".ts");return H==="index"||H==="types"||z.endsWith(".d.ts")}async function r(z){if(z)return P.resolve(z);let H=`<default>:${process.cwd()}`,Y=K.get(H);if(Y!==void 0)return Y;let J=await l();if(J!==null)K.set(H,J);return J}async function l(){let z=await I(),H=z.root||process.cwd(),Y=z.composablesDir;if(Y)return P.resolve(H,Y);for(let J of n){let V=P.resolve(H,J);try{let Z=new Bun.Glob("**/*.ts");for await(let W of Z.scan({cwd:V,absolute:!0}))if(!p(W))return V}catch{}}return null}async function m(z){let H=Array.isArray(z)?z:z?[P.resolve(z)]:(await I())._layerComposableDirs??[await r()].filter((J)=>!!J),Y=new Map;for(let J of H){let V=new Bun.Glob("**/*.ts");try{for await(let Z of V.scan({cwd:J,absolute:!0})){let W=P.relative(J,Z);if(!p(Z)&&!Y.has(W))Y.set(W,Z)}}catch{}}return{key:H.join("\x00"),files:[...Y.values()].sort()}}async function Wq(z){let{files:H}=await m(z),Y=B({loader:"ts",target:"browser",define:k()}),J=[];for(let V of H)try{let Z=await Bun.file(V).text(),W=Y.scan(Z).exports.filter((G)=>G!=="default");if(W.length>0)J.push({file:V,names:W})}catch{}return J}function c(z,H){return new RegExp(`\\b${H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(z)}function a(z,H,Y){let J=new Map;for(let{file:G,names:$}of z)for(let O of $)if(!J.has(O))J.set(O,G);let V=(G)=>{let $=[];for(let[O,w]of J)if(c(G,O))$.push(w);return $},Z=new Set,W=Y.flatMap(V);while(W.length>0){let G=[];for(let $ of W){if(Z.has($))continue;Z.add($);for(let O of V(H.get($)??""))if(!Z.has(O))G.push(O)}W=G}return Z}async function Yq(z,H,Y){let{key:J,files:V}=await m(z);if(!J)return null;let Z=()=>[...new Set([...V,...V.flatMap((q)=>g(q))])],W=T(Z());if(V.length===0)return A(j,J,W,""),null;V.sort();let G=B({loader:"ts",target:"browser",define:k()}),$=new Map,O=[];for(let q of V)try{let Q=await Bun.file(q).text();$.set(q,Q);let U=G.scan(Q).exports.filter((X)=>X!=="default");if(U.length>0)O.push({file:q,names:U})}catch{$.set(q,"")}let w=H===void 0?new Set(V):a(O,$,Y?[H,...Y]:[H]);if(w.size===0)return null;let _=V.filter((q)=>w.has(q)),M=`${J}\x00${_.join("\x00")}`,v=u(j,M,W);if(v!==void 0)return v||null;let R=[],L=new Set,C=new Set;for(let q of _)try{let Q=$.get(q)??await Bun.file(q).text(),U=P.basename(q,".ts");for(let X of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])C.add(X[1]);try{for(let X of G.scan(Q).exports)if(X!=="default")L.add(X)}catch{}if(Q=D(Q),h(Q))Q=await b(Q,q,{projectRoot:process.cwd(),externalizeUserModules:!1}),Q=f(Q);Q=S(Q),Q=Q.replace(/^export\s+(default\s+)?/gm,""),Q=G.transformSync(Q),R.push(`// Composable: ${U}
|
|
3
3
|
${Q.trim()}`)}catch(Q){console.warn(`[stx] Failed to load composable ${q}:`,Q)}if(R.length===0||L.size===0)return A(j,M,W,""),null;let t=[...L].map((q)=>` try { if (!(${JSON.stringify(q)} in __c)) __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
|
|
4
4
|
`),N=JSON.stringify([...L]),E=R.join(`
|
|
5
5
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Am as b}from"./chunk-
|
|
2
|
+
import{Am as b}from"./chunk-msq8xvhp.js";import{kv as L,ov as R}from"./chunk-avwywzsj.js";function P(j,U){let Q=1,J=U,B="<template",z="</template";while(J<j.length&&Q>0){let G=j.indexOf("<",J);if(G===-1)break;if(J=G,j.startsWith(B,J)&&(J+B.length>=j.length||/[\s>\/]/.test(j[J+B.length]))){Q++,J+=B.length;continue}if(j.startsWith(z,J)){let W=j.indexOf(">",J+z.length);if(W!==-1){if(Q--,Q===0)return W+1;J=W+1;continue}}J++}return Q===0?J:-1}var F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function O(j,U){let Q=null;for(let J=U;J<j.length;J++){let B=j[J];if(Q){if(B==="\\"){J++;continue}if(B===Q)Q=null;continue}if(B==='"'||B==="'"){Q=B;continue}if(B===">")return J+1}return-1}function I(j,U,Q){let J=U.toLowerCase(),B=1,z=Q;while(z<j.length){let G=j.indexOf("<",z);if(G===-1)return-1;if(j.startsWith("<!--",G)){let $=j.indexOf("-->",G+4);z=$===-1?j.length:$+3;continue}let W=O(j,G+1);if(W===-1)return-1;let Z=j.slice(G,W),Y=Z.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(Y&&Y[2].toLowerCase()===J){if(Y[1]==="/"){if(B--,B===0)return W}else if(!/\/\s*>$/.test(Z))B++}z=W}return-1}function w(j){let U=[],Q=[],J=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[2].toLowerCase();if(Z[1]==="/"){let X=Q.lastIndexOf(Y);if(X!==-1)Q.splice(X);B=G;continue}let $=/\/\s*>$/.test(W),K=Q.length===0?W.match(J):null;if(K){let X=K[1]||K[2],H=W.replace(J,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),_=$||F.has(Y)?-1:I(j,Y,G);if(_===-1)U.push({start:z,end:G,slotName:X,element:H}),B=G;else U.push({start:z,end:_,slotName:X,element:H+j.slice(G,_)}),B=_;continue}if(!$&&!F.has(Y)){if(Q.push(Y),Y==="script"||Y==="style"){let X=j.toLowerCase().indexOf(`</${Y}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function D(j){let U=[],Q=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[1]==="/",$=Z[2].toLowerCase();if(Y){let X=Q.lastIndexOf($);if(X!==-1)Q.splice(X);B=G;continue}if($==="template"&&Q.length===0){let X=W.match(J);if(X){let H=P(j,G);if(H!==-1){let _=X[1]||X[2]||X[3];U.push({start:z,end:H,slotName:_,content:j.slice(G,H-11).trim(),propsBinding:X[4]||void 0}),B=H;continue}}}if(!/\/\s*>$/.test(W)&&!F.has($)){if(Q.push($),$==="script"||$==="style"){let X=j.toLowerCase().indexOf(`</${$}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function v(j){let U={default:"",named:new Map},Q=j,J=D(j);for(let z of J)U.named.set(z.slotName,{name:z.slotName,content:z.content,propsBinding:z.propsBinding});J.sort((z,G)=>G.start-z.start);for(let z of J)Q=Q.slice(0,z.start)+Q.slice(z.end);let B=w(Q);for(let z of B){let G=U.named.get(z.slotName);if(G)G.content+=z.element;else U.named.set(z.slotName,{name:z.slotName,content:z.element})}for(let z=B.length-1;z>=0;z--){let G=B[z];Q=Q.slice(0,G.start)+Q.slice(G.end)}return U.default=Q.trim(),U}function S(j){let U=j.match(/name\s*=\s*["']([^"']+)["']/),Q=U?U[1]:"",J={},B=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,z;while((z=B.exec(j))!==null)J[z[1]]=z[2];let G=j.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),W=G?G[1].trim():"";return{name:Q,props:J,defaultContent:W}}async function k(j,U,Q,J){if(!j)return Q;let B=j.content;if(j.propsBinding&&Object.keys(U).length>0){let z=j.propsBinding.trim(),G={...J};if(z.startsWith("{")&&z.endsWith("}")){let W=z.slice(1,-1).split(",").map((Z)=>Z.trim()).filter(Boolean);for(let Z of W){let[Y,$]=Z.split(":").map((X)=>X.trim()),K=$||Y;if(U[Y]!==void 0)G[K]=U[Y]}}else G[z]=U;B=N(B,G)}return B}function N(j,U){return j.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Q,J)=>{try{let B=J.trim(),z=y(B,U);return b(String(z??""))}catch{return`{{ ${J} }}`}})}function y(j,U){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(j)){let J=j.split("."),B=U;for(let z of J)if(B&&typeof B==="object"&&z in B)B=B[z];else return;return B}let Q=j.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Q){let[,J,B,z]=Q,G=U[J],W=parseInt(z,10);if(typeof G==="number")switch(B){case"+":return G+W;case"-":return G-W;case"*":return G*W;case"/":return G/W}}try{if(!L(j))return;return R(j,Object.keys(U))(...Object.values(U))}catch{return}}async function T(j,U,Q){let J=j;J=await C(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,W,Z,Y)=>{let $=U.named.get(W),K=Y?.trim()||"",X=Z||"",H={},_=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,q;while((q=_.exec(X))!==null){let A=q[1],V=q[2];H[A]=y(V,Q)}return await k($,H,K,Q)});let z=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(z,(G,W,Z)=>{if(/\bname\s*=/.test(W||""))return G;let Y=Z?.trim()||"";return U.default||Y}),J}async function C(j,U,Q){let J=[],B=[];j.replace(U,(W,...Z)=>{let Y=Z[Z.length-2];return B.push({match:W,index:Y}),J.push(Q(W,...Z.slice(0,-2))),W});let z=await Promise.all(J),G=j;for(let W=B.length-1;W>=0;W--){let{match:Z,index:Y}=B[W];G=G.slice(0,Y)+z[W]+G.slice(Y+Z.length)}return G}function E(j){let U=v(j);return{defaultSlot:U.default,namedSlots:U.named}}async function x(j,U,Q,J){return await T(j,{default:U,named:Q},J)}
|
|
3
3
|
export{v as Kg,S as Lg,k as Mg,T as Ng,E as Og,x as Pg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Co as a,Do as b,Eo as c,Fo as d,Go as e,Ho as f,Io as g,Jo as h,Ko as i,Lo as j,Mo as k}from"./chunk-
|
|
2
|
+
import{Co as a,Do as b,Eo as c,Fo as d,Go as e,Ho as f,Io as g,Jo as h,Ko as i,Lo as j,Mo as k}from"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{b as stripTypeScript,i as splitDeclaration,d as isSyntaxFailure,c as isModuleResolutionFailure,e as isMissingBindingFailure,g as isCompleteImport,k as hasVariables,f as extractVariables,j as extractScriptFromTemplate,h as convertToCommonJS,a as STX_ENGINE_BINDING_NAMES};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rk as m}from"./chunk-
|
|
2
|
+
import{rk as m}from"./chunk-3nx7z086.js";import{Nw as z}from"./chunk-ejqpq0wc.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wf as a}from"./chunk-
|
|
2
|
+
import{Wf as a}from"./chunk-62nz9v8t.js";import"./chunk-g7msqva8.js";import"./chunk-57atgbyq.js";import"./chunk-8m0g0h4x.js";import"./chunk-e4g8wz6t.js";import"./chunk-c0n802j1.js";import"./chunk-ngjkzaj7.js";import"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{a as buildForProduction};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ue as a}from"./chunk-g5mhck0r.js";import"./chunk-57atgbyq.js";import"./chunk-msq8xvhp.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-2wb3pgp4.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-9e20mgwc.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-gtqbvt3a.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-swvm1wgn.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{a as buildApp};
|
|
@@ -18,7 +18,7 @@ catch (e) {
|
|
|
18
18
|
}
|
|
19
19
|
throw e;
|
|
20
20
|
}
|
|
21
|
-
`),U.set(X,q)}return q(...V)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:j,context:Q.slice()});return j}clear(){this.pool.length=0,this.fnCache.clear()}}var xQ=new AJ;class _J{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(J){this.enabled=J}isEnabled(){return this.enabled}setBudget(J,Q){this.budgets.set(J,{warnThreshold:0.8,action:"warn",...Q})}setBudgets(J){for(let[Q,Z]of Object.entries(J))this.setBudget(Q,Z)}removeBudget(J){this.budgets.delete(J)}getBudgets(){let J={};for(let[Q,Z]of this.budgets.entries())J[Q]=Z;return J}onViolation(J){this.violationHandlers.push(J)}offViolation(J){let Q=this.violationHandlers.indexOf(J);if(Q!==-1)this.violationHandlers.splice(Q,1)}time(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}async timeAsync(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=await Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}checkBudget(J,Q){let Z=this.budgets.get(J);if(!Z)return;let $=Q/Z.maxTime*100,U=Z.warnThreshold!==void 0?Q>=Z.maxTime*Z.warnThreshold&&Q<Z.maxTime:!1,F=Q>=Z.maxTime;if(!U&&!F)return;let j={label:J,actualTime:Q,budgetTime:Z.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:U};this.violations.push(j);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(j)}catch{}let V=U?`[Performance Warning] "${J}" took ${Q.toFixed(2)}ms (${$.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${J}" took ${Q.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(V);break;case"warn":console.warn(V);break;case"error":console.error(V);break;case"throw":if(F)throw Error(V);else console.warn(V);break}}recordTime(J,Q){let Z=this.metrics.get(J);if(Z)Z.count++,Z.totalTime+=Q,Z.maxTime=Math.max(Z.maxTime,Q),Z.minTime=Math.min(Z.minTime,Q);else this.metrics.set(J,{count:1,totalTime:Q,maxTime:Q,minTime:Q})}getStats(J){if(J){let Z=this.metrics.get(J);if(!Z)return{};let $=this.budgets.get(J);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:$?.maxTime,budgetUtilization:$?Z.totalTime/Z.count/$.maxTime*100:void 0}}let Q={};for(let[Z,$]of this.metrics.entries()){let U=this.budgets.get(Z);Q[Z]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:U?.maxTime,budgetUtilization:U?$.totalTime/$.count/U.maxTime*100:void 0}}return Q}getViolations(J){if(J)return this.violations.filter((Q)=>Q.label===J);return[...this.violations]}getViolationStats(){let J={},Q=0,Z=0;for(let $ of this.violations)if(J[$.label]=(J[$.label]||0)+1,$.isWarning)Q++;else Z++;return{total:this.violations.length,byLabel:J,warnings:Q,errors:Z}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var a=null;function ZQ(){if(!a)a=new _J;return a}var EQ=new Proxy({},{get(J,Q){return ZQ()[Q]}});var RJ=[];function TJ(J){let Q=new s(J);return RJ.push(Q),Q}function CQ(){for(let J of RJ)J.clear()}function t(J,...Q){return`${Q.map((Z)=>String(Z??"")).join("\x00")}\x00${J.length}\x00${Bun.hash(J)}`}function gQ(J){let Q=[];for(let Z of new Set(J))try{Q.push({path:Z,mtimeMs:vJ.statSync(Z).mtimeMs})}catch{}return Q}function uQ(J){for(let Q of J)try{if(vJ.statSync(Q.path).mtimeMs!==Q.mtimeMs)return!1}catch{return!1}return!0}var B=null,JJ=!1,D=null,_="",M=!1,yJ=256,I=new Map,H=new Map,T=null,fJ=null,b=new Map;function k(J){return Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)}function e(J,Q){if(I.has(J))I.delete(J);else if(I.size>=yJ)I.delete(I.keys().next().value);I.set(J,Q)}function UQ(J){let Q=k(J);if(H.has(Q))H.delete(Q);else if(H.size>=yJ)H.delete(H.keys().next().value);return H.set(Q,J),Q}function lQ(J){let Q=H.get(J);if(Q===void 0)return;return H.delete(J),H.set(J,Q),Q}async function FQ(J,Q=T){if(!Q)return null;try{let Z=Bun.file(G.join(Q,`cw-${k(J)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function jQ(J,Q,Z=T){if(!Z)return;try{if(!fs.existsSync(Z))fs.mkdirSync(Z,{recursive:!0});await Bun.write(G.join(Z,`cw-${k(J)}.css`),Q)}catch{}}async function kJ(J){try{let Q=await import(J);if(Q&&Q.CSSGenerator)return{CSSGenerator:Q.CSSGenerator,config:Q.config,build:Q.build,defaultConfig:Q.defaultConfig,extractClasses:Q.extractClasses}}catch{}return null}var WQ=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],XQ=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function VQ(){let J=[],Q=process.cwd();while(Q!==G.dirname(Q)){for(let Z of["node_modules","pantry"])for(let $ of WQ)J.push(G.join(Q,Z,...$));Q=G.dirname(Q)}return J}function qQ(){let J=[],Q=process.env.HOME||process.env.USERPROFILE||"",Z=[Q&&G.join(Q,"Code","Tools","ts-css"),Q&&G.join(Q,"Code","Tools","crosswind"),Q&&G.join(Q,"repos","stacks-org","ts-css"),Q&&G.join(Q,"repos","stacks-org","crosswind"),G.join(process.cwd(),"..","ts-css"),G.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let $ of Z)J.push(G.join($,"packages","toolkit","dist","engine","index.js")),J.push(G.join($,"packages","toolkit","src","engine","index.ts"));if(Q)J.push(G.join(Q,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return J}async function CJ(){if(JJ)return B;JJ=!0;try{let J=async(U)=>{for(let F of U){if(!await Bun.file(F).exists())continue;let j=await kJ(F);if(j){if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded from ${G.dirname(G.dirname(F))}`);return j}}return null};if(process.env.CROSSWIND_SRC){let U=G.resolve(process.env.CROSSWIND_SRC),F=await J([U]);if(!F)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${U}`);return B=F,B}let Q=await J(VQ());if(Q)return B=Q,B;let Z=XQ;for(let U of Z){let F=await kJ(U);if(F){if(B=F,!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded`);return B}}let $=await J(qQ());if($)return B=$,B;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${Y.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${Y.reset}`),console.warn(`${Y.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${Y.reset}`),null}}function oQ(){QJ.clear(),B=null,JJ=!1,D=null,_="",I.clear(),H.clear(),fJ=null,b.clear()}var xJ=!1;async function gJ(J){try{let Q=bJ({name:"css",cwd:J})?"css":bJ({name:"crosswind",cwd:J})?"crosswind":null;if(!Q)return null;if(Q==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!xJ)xJ=!0,console.warn(`${Y.yellow}[ts-css]${Y.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:Z}=await import("bunfig"),$=await Z({name:Q,cwd:J,defaultConfig:{},checkEnv:!1,verbose:!1});if(!$?.path||!$.config||Object.keys($.config).length===0)return null;let U=G.relative(J,$.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from ${U||$.path}`);return $.config}catch(Q){if(Q instanceof Error&&Q.name==="ConfigNotFoundError")return null;return console.warn(`${Y.yellow}[ts-css]${Y.reset} Failed to load css config:`,Q instanceof Error?Q.message:Q),null}}async function zQ(J){let Q=null;try{let{loadStxConfig:Z}=await import("./chunk-av590rpt.js"),$=await Z(J);if($.css)if(typeof $.css==="string"){let U=G.isAbsolute($.css)?$.css:G.resolve(J,$.css);if(await Bun.file(U).exists()){let F=await import(U);Q=F.default||F,console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(Q={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let U=G.isAbsolute($.css.config)?$.css.config:G.resolve(J,$.css.config);if(await Bun.file(U).exists()){let F=await import(U);Q={...F.default||F,...Q}}}console.log(`${Y.green}[ts-css]${Y.reset} Using inline CSS config from stx.config.ts`)}}catch{}return Q||await gJ(J)}function GQ(J){try{let Q=new WeakSet;return k(JSON.stringify(J??{},(Z,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(Q.has($))return"[circular]";Q.add($)}return $})??"")}catch{return"unhashable"}}async function YQ(J){if(M)return _;M=!0;try{let Q=await CJ();if(!Q||!Q.build)return M=!1,"";if(!D)D=await gJ(J);if(!D)return M=!1,"";let Z=Q.defaultConfig?.theme||{},$=D.theme||{},U={...Q.defaultConfig,...D,theme:{...Z,...$,extend:{...Z.extend||{},...$.extend||{}}}},F=performance.now(),j=await Q.build(U),V=performance.now()-F;if(_=j.css,console.log(`${Y.cyan}[ts-css]${Y.reset} Built ${j.classes.size} classes in ${V.toFixed(1)}ms`),U.output){let W=G.isAbsolute(U.output)?U.output:G.join(J,U.output),X=G.dirname(W);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(W,j.css)}return M=!1,j.css}catch(Q){return console.error(`${Y.red}[ts-css]${Y.reset} Build error:`,Q),M=!1,_}}async function aQ(J){D=null,await YQ(J)}function sQ(){return _}function wQ(J){let Q=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,$=Z.exec(J);while($!==null){for(let j of $[1].split(/\s+/))if(j.trim())Q.add(j.trim());$=Z.exec(J)}let U=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,F=U.exec(J);while(F!==null){let j=F[1].match(/'([^']+)'/g);if(j){for(let V of j)for(let W of V.slice(1,-1).split(/\s+/))if(W.trim())Q.add(W.trim())}F=U.exec(J)}return Q}var QJ=TJ(64);async function LQ(J,Q){let Z=()=>b.get(Q?G.resolve(Q):process.cwd())?.fingerprint??null,$=QJ.get(t(J,Q,Z()));if($!==void 0)return $;let U=await BQ(J,Q);if(U)QJ.set(t(J,Q,Z()),U);return U}async function BQ(J,Q){try{let Z=await CJ();if(!Z)return"";let $=typeof Z.extractClasses==="function"?Z.extractClasses(J):wQ(J);if($.size===0)return"";let U=Q?G.resolve(Q):process.cwd(),F=SJ(U,"cache");if(!T)T=F;let j=b.get(U);if(!j){let L=await zQ(U);j={config:L,fingerprint:GQ(L)},b.set(U,j),fJ=j.fingerprint}let V=[...$].sort().join(" "),W=`${j.fingerprint||"default"}::${V}`,X=I.get(W);if(X!==void 0)return e(W,X),X;let q=await FQ(W,F);if(q!==null)return e(W,q),q;let z=Z.defaultConfig||Z.config,w=j.config||{},O=YJ(z,w),{safelist:K,includePreflight:$J,minify:ZJ,tokenCSS:uJ}=O,x=O.config,E=new Z.CSSGenerator(x),S=x.shortcuts||w.shortcuts||{},UJ=Object.keys(S).filter((L)=>$.has(L)||K.includes(L));for(let L of K)if(!S[L])E.generate(L);for(let L of $)if(!S[L])E.generate(L);let P="";if(UJ.length>0){let L=new Z.CSSGenerator(x);for(let dJ of UJ)L.generate(dJ);if(P=L.toCSS(!1,ZJ),P&&!P.endsWith(`
|
|
21
|
+
`),U.set(X,q)}return q(...V)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:j,context:Q.slice()});return j}clear(){this.pool.length=0,this.fnCache.clear()}}var xQ=new AJ;class _J{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(J){this.enabled=J}isEnabled(){return this.enabled}setBudget(J,Q){this.budgets.set(J,{warnThreshold:0.8,action:"warn",...Q})}setBudgets(J){for(let[Q,Z]of Object.entries(J))this.setBudget(Q,Z)}removeBudget(J){this.budgets.delete(J)}getBudgets(){let J={};for(let[Q,Z]of this.budgets.entries())J[Q]=Z;return J}onViolation(J){this.violationHandlers.push(J)}offViolation(J){let Q=this.violationHandlers.indexOf(J);if(Q!==-1)this.violationHandlers.splice(Q,1)}time(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}async timeAsync(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=await Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}checkBudget(J,Q){let Z=this.budgets.get(J);if(!Z)return;let $=Q/Z.maxTime*100,U=Z.warnThreshold!==void 0?Q>=Z.maxTime*Z.warnThreshold&&Q<Z.maxTime:!1,F=Q>=Z.maxTime;if(!U&&!F)return;let j={label:J,actualTime:Q,budgetTime:Z.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:U};this.violations.push(j);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(j)}catch{}let V=U?`[Performance Warning] "${J}" took ${Q.toFixed(2)}ms (${$.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${J}" took ${Q.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(V);break;case"warn":console.warn(V);break;case"error":console.error(V);break;case"throw":if(F)throw Error(V);else console.warn(V);break}}recordTime(J,Q){let Z=this.metrics.get(J);if(Z)Z.count++,Z.totalTime+=Q,Z.maxTime=Math.max(Z.maxTime,Q),Z.minTime=Math.min(Z.minTime,Q);else this.metrics.set(J,{count:1,totalTime:Q,maxTime:Q,minTime:Q})}getStats(J){if(J){let Z=this.metrics.get(J);if(!Z)return{};let $=this.budgets.get(J);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:$?.maxTime,budgetUtilization:$?Z.totalTime/Z.count/$.maxTime*100:void 0}}let Q={};for(let[Z,$]of this.metrics.entries()){let U=this.budgets.get(Z);Q[Z]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:U?.maxTime,budgetUtilization:U?$.totalTime/$.count/U.maxTime*100:void 0}}return Q}getViolations(J){if(J)return this.violations.filter((Q)=>Q.label===J);return[...this.violations]}getViolationStats(){let J={},Q=0,Z=0;for(let $ of this.violations)if(J[$.label]=(J[$.label]||0)+1,$.isWarning)Q++;else Z++;return{total:this.violations.length,byLabel:J,warnings:Q,errors:Z}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var a=null;function ZQ(){if(!a)a=new _J;return a}var EQ=new Proxy({},{get(J,Q){return ZQ()[Q]}});var RJ=[];function TJ(J){let Q=new s(J);return RJ.push(Q),Q}function CQ(){for(let J of RJ)J.clear()}function t(J,...Q){return`${Q.map((Z)=>String(Z??"")).join("\x00")}\x00${J.length}\x00${Bun.hash(J)}`}function gQ(J){let Q=[];for(let Z of new Set(J))try{Q.push({path:Z,mtimeMs:vJ.statSync(Z).mtimeMs})}catch{}return Q}function uQ(J){for(let Q of J)try{if(vJ.statSync(Q.path).mtimeMs!==Q.mtimeMs)return!1}catch{return!1}return!0}var B=null,JJ=!1,D=null,_="",M=!1,yJ=256,I=new Map,H=new Map,T=null,fJ=null,b=new Map;function k(J){return Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)}function e(J,Q){if(I.has(J))I.delete(J);else if(I.size>=yJ)I.delete(I.keys().next().value);I.set(J,Q)}function UQ(J){let Q=k(J);if(H.has(Q))H.delete(Q);else if(H.size>=yJ)H.delete(H.keys().next().value);return H.set(Q,J),Q}function lQ(J){let Q=H.get(J);if(Q===void 0)return;return H.delete(J),H.set(J,Q),Q}async function FQ(J,Q=T){if(!Q)return null;try{let Z=Bun.file(G.join(Q,`cw-${k(J)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function jQ(J,Q,Z=T){if(!Z)return;try{if(!fs.existsSync(Z))fs.mkdirSync(Z,{recursive:!0});await Bun.write(G.join(Z,`cw-${k(J)}.css`),Q)}catch{}}async function kJ(J){try{let Q=await import(J);if(Q&&Q.CSSGenerator)return{CSSGenerator:Q.CSSGenerator,config:Q.config,build:Q.build,defaultConfig:Q.defaultConfig,extractClasses:Q.extractClasses}}catch{}return null}var WQ=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],XQ=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function VQ(){let J=[],Q=process.cwd();while(Q!==G.dirname(Q)){for(let Z of["node_modules","pantry"])for(let $ of WQ)J.push(G.join(Q,Z,...$));Q=G.dirname(Q)}return J}function qQ(){let J=[],Q=process.env.HOME||process.env.USERPROFILE||"",Z=[Q&&G.join(Q,"Code","Tools","ts-css"),Q&&G.join(Q,"Code","Tools","crosswind"),Q&&G.join(Q,"repos","stacks-org","ts-css"),Q&&G.join(Q,"repos","stacks-org","crosswind"),G.join(process.cwd(),"..","ts-css"),G.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let $ of Z)J.push(G.join($,"packages","toolkit","dist","engine","index.js")),J.push(G.join($,"packages","toolkit","src","engine","index.ts"));if(Q)J.push(G.join(Q,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return J}async function CJ(){if(JJ)return B;JJ=!0;try{let J=async(U)=>{for(let F of U){if(!await Bun.file(F).exists())continue;let j=await kJ(F);if(j){if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded from ${G.dirname(G.dirname(F))}`);return j}}return null};if(process.env.CROSSWIND_SRC){let U=G.resolve(process.env.CROSSWIND_SRC),F=await J([U]);if(!F)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${U}`);return B=F,B}let Q=await J(VQ());if(Q)return B=Q,B;let Z=XQ;for(let U of Z){let F=await kJ(U);if(F){if(B=F,!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded`);return B}}let $=await J(qQ());if($)return B=$,B;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${Y.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${Y.reset}`),console.warn(`${Y.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${Y.reset}`),null}}function oQ(){QJ.clear(),B=null,JJ=!1,D=null,_="",I.clear(),H.clear(),fJ=null,b.clear()}var xJ=!1;async function gJ(J){try{let Q=bJ({name:"css",cwd:J})?"css":bJ({name:"crosswind",cwd:J})?"crosswind":null;if(!Q)return null;if(Q==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!xJ)xJ=!0,console.warn(`${Y.yellow}[ts-css]${Y.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:Z}=await import("bunfig"),$=await Z({name:Q,cwd:J,defaultConfig:{},checkEnv:!1,verbose:!1});if(!$?.path||!$.config||Object.keys($.config).length===0)return null;let U=G.relative(J,$.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from ${U||$.path}`);return $.config}catch(Q){if(Q instanceof Error&&Q.name==="ConfigNotFoundError")return null;return console.warn(`${Y.yellow}[ts-css]${Y.reset} Failed to load css config:`,Q instanceof Error?Q.message:Q),null}}async function zQ(J){let Q=null;try{let{loadStxConfig:Z}=await import("./chunk-32x78na8.js"),$=await Z(J);if($.css)if(typeof $.css==="string"){let U=G.isAbsolute($.css)?$.css:G.resolve(J,$.css);if(await Bun.file(U).exists()){let F=await import(U);Q=F.default||F,console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(Q={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let U=G.isAbsolute($.css.config)?$.css.config:G.resolve(J,$.css.config);if(await Bun.file(U).exists()){let F=await import(U);Q={...F.default||F,...Q}}}console.log(`${Y.green}[ts-css]${Y.reset} Using inline CSS config from stx.config.ts`)}}catch{}return Q||await gJ(J)}function GQ(J){try{let Q=new WeakSet;return k(JSON.stringify(J??{},(Z,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(Q.has($))return"[circular]";Q.add($)}return $})??"")}catch{return"unhashable"}}async function YQ(J){if(M)return _;M=!0;try{let Q=await CJ();if(!Q||!Q.build)return M=!1,"";if(!D)D=await gJ(J);if(!D)return M=!1,"";let Z=Q.defaultConfig?.theme||{},$=D.theme||{},U={...Q.defaultConfig,...D,theme:{...Z,...$,extend:{...Z.extend||{},...$.extend||{}}}},F=performance.now(),j=await Q.build(U),V=performance.now()-F;if(_=j.css,console.log(`${Y.cyan}[ts-css]${Y.reset} Built ${j.classes.size} classes in ${V.toFixed(1)}ms`),U.output){let W=G.isAbsolute(U.output)?U.output:G.join(J,U.output),X=G.dirname(W);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(W,j.css)}return M=!1,j.css}catch(Q){return console.error(`${Y.red}[ts-css]${Y.reset} Build error:`,Q),M=!1,_}}async function aQ(J){D=null,await YQ(J)}function sQ(){return _}function wQ(J){let Q=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,$=Z.exec(J);while($!==null){for(let j of $[1].split(/\s+/))if(j.trim())Q.add(j.trim());$=Z.exec(J)}let U=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,F=U.exec(J);while(F!==null){let j=F[1].match(/'([^']+)'/g);if(j){for(let V of j)for(let W of V.slice(1,-1).split(/\s+/))if(W.trim())Q.add(W.trim())}F=U.exec(J)}return Q}var QJ=TJ(64);async function LQ(J,Q){let Z=()=>b.get(Q?G.resolve(Q):process.cwd())?.fingerprint??null,$=QJ.get(t(J,Q,Z()));if($!==void 0)return $;let U=await BQ(J,Q);if(U)QJ.set(t(J,Q,Z()),U);return U}async function BQ(J,Q){try{let Z=await CJ();if(!Z)return"";let $=typeof Z.extractClasses==="function"?Z.extractClasses(J):wQ(J);if($.size===0)return"";let U=Q?G.resolve(Q):process.cwd(),F=SJ(U,"cache");if(!T)T=F;let j=b.get(U);if(!j){let L=await zQ(U);j={config:L,fingerprint:GQ(L)},b.set(U,j),fJ=j.fingerprint}let V=[...$].sort().join(" "),W=`${j.fingerprint||"default"}::${V}`,X=I.get(W);if(X!==void 0)return e(W,X),X;let q=await FQ(W,F);if(q!==null)return e(W,q),q;let z=Z.defaultConfig||Z.config,w=j.config||{},O=YJ(z,w),{safelist:K,includePreflight:$J,minify:ZJ,tokenCSS:uJ}=O,x=O.config,E=new Z.CSSGenerator(x),S=x.shortcuts||w.shortcuts||{},UJ=Object.keys(S).filter((L)=>$.has(L)||K.includes(L));for(let L of K)if(!S[L])E.generate(L);for(let L of $)if(!S[L])E.generate(L);let P="";if(UJ.length>0){let L=new Z.CSSGenerator(x);for(let dJ of UJ)L.generate(dJ);if(P=L.toCSS(!1,ZJ),P&&!P.endsWith(`
|
|
22
22
|
`))P+=`
|
|
23
23
|
`}let A=P+E.toCSS($J,ZJ);return A=uJ+A,e(W,A),jQ(W,A,F),A}catch(Z){return console.warn("Failed to generate Css CSS:",Z),""}}async function tQ(J,Q,Z=!1,$=!1){let U=await LQ(J,Q);if(!U)return $?o(J):J;let F=Z?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${UQ(U)}.css">`:`<style data-css="generated">
|
|
24
24
|
${U}
|