@stacksjs/stx 0.2.675 → 0.2.676
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-1e73whqh.js +2 -0
- package/dist/{chunk-hfbkbrwk.js → chunk-1rztwjdj.js} +3 -3
- package/dist/{chunk-6qh2mx6q.js → chunk-245sas8r.js} +2 -2
- package/dist/{chunk-8jdbrcgt.js → chunk-304dbbsw.js} +5 -5
- package/dist/{chunk-5fh9m8fm.js → chunk-34e8e8te.js} +1 -1
- package/dist/{chunk-n615cbxq.js → chunk-3bfegbpw.js} +1 -1
- package/dist/chunk-3gdt16xa.js +2 -0
- package/dist/{chunk-03hhanvm.js → chunk-4jnv2v5e.js} +1 -1
- package/dist/{chunk-nw44qq6h.js → chunk-4rk5qnqf.js} +1 -1
- package/dist/{chunk-etbpzmxv.js → chunk-526mf3fr.js} +1 -1
- package/dist/{chunk-z6mrnh98.js → chunk-54zkkxmb.js} +1 -1
- package/dist/{chunk-6ncvb8gp.js → chunk-551s7ha0.js} +3 -3
- package/dist/{chunk-4e5jrxbn.js → chunk-5v7vm8cv.js} +5 -5
- package/dist/{chunk-93z9f2be.js → chunk-6bwca55g.js} +6 -6
- package/dist/{chunk-nvbyscdh.js → chunk-707sx5sk.js} +1 -1
- package/dist/chunk-78d5tn4r.js +2 -0
- package/dist/{chunk-09gchq7d.js → chunk-8aq07a1j.js} +3 -3
- package/dist/{chunk-1s2y6f4b.js → chunk-909ymsjz.js} +1 -1
- package/dist/{chunk-5zvrbms2.js → chunk-a2zb5fgg.js} +2 -2
- package/dist/chunk-b18x0v21.js +2 -0
- package/dist/{chunk-hg0dd64a.js → chunk-b23vscaq.js} +1 -1
- package/dist/{chunk-qdkwg2b8.js → chunk-be2rswkw.js} +2 -2
- package/dist/chunk-bm42rsaa.js +2 -0
- package/dist/{chunk-ram7pa4k.js → chunk-bpj387yx.js} +2 -2
- package/dist/{chunk-w0vpvcj0.js → chunk-c4enpsj8.js} +1 -1
- package/dist/chunk-cdbaanmx.js +2 -0
- package/dist/{chunk-c2rq9pap.js → chunk-cs8wq7nv.js} +1 -1
- package/dist/chunk-d2xf5hh9.js +2 -0
- package/dist/{chunk-8xxc5edr.js → chunk-d4ch6exz.js} +1 -1
- package/dist/chunk-dda8pdya.js +2 -0
- package/dist/{chunk-t9bsgbwv.js → chunk-dmd7mgjw.js} +2 -2
- package/dist/chunk-ds91e0fe.js +2 -0
- package/dist/{chunk-dba795e1.js → chunk-dxh45gve.js} +1 -1
- package/dist/{chunk-q7tfqavs.js → chunk-ehzd1yc6.js} +2 -2
- package/dist/{chunk-ammn4wbd.js → chunk-etz2dmec.js} +1 -1
- package/dist/{chunk-g98gafg7.js → chunk-fbrgz3s8.js} +1 -1
- package/dist/{chunk-7475sm3m.js → chunk-fd72t30s.js} +1 -1
- package/dist/{chunk-db5017x8.js → chunk-fdvfzknd.js} +1 -1
- package/dist/{chunk-nv0jjhtd.js → chunk-ft3f9nj0.js} +1 -1
- package/dist/{chunk-p6g58hwg.js → chunk-g12ht81a.js} +1 -1
- package/dist/chunk-g6gqja52.js +2 -0
- package/dist/{chunk-ggf4z3bv.js → chunk-ga5kjf9b.js} +3 -3
- package/dist/{chunk-mvz825w0.js → chunk-ghm9f13q.js} +1 -1
- package/dist/chunk-gz5rvwgx.js +2 -0
- package/dist/chunk-hqj28381.js +3 -0
- package/dist/{chunk-z4bfgvb3.js → chunk-j60jye3e.js} +3 -3
- package/dist/chunk-jjet6qxq.js +2 -0
- package/dist/chunk-jk7chxkt.js +2 -0
- package/dist/{chunk-shft9r9d.js → chunk-kn34esxw.js} +1 -1
- package/dist/{chunk-9azagdq6.js → chunk-krcd3039.js} +13 -13
- package/dist/{chunk-wtvy9r5w.js → chunk-kxj8e1gd.js} +3 -3
- package/dist/{chunk-xrrx2ddz.js → chunk-mjsebtg6.js} +1 -1
- package/dist/{chunk-29wj0c68.js → chunk-mq915g3j.js} +2 -2
- package/dist/chunk-n63r9b4f.js +2 -0
- package/dist/{chunk-z17sy8g3.js → chunk-n8wvqnfc.js} +2 -2
- package/dist/{chunk-hz8dj5jy.js → chunk-n94ts3t9.js} +2 -2
- package/dist/{chunk-8md2707p.js → chunk-p27ptd9f.js} +12 -12
- package/dist/{chunk-9ybjsfyp.js → chunk-p9az13b2.js} +2 -2
- package/dist/chunk-pwn0j1vq.js +2 -0
- package/dist/{chunk-4x5dk7a4.js → chunk-q1jcf6vm.js} +1 -1
- package/dist/{chunk-vf6yaymh.js → chunk-q3nnaxf9.js} +1 -1
- package/dist/{chunk-54fazdmn.js → chunk-qbzqary0.js} +1 -1
- package/dist/{chunk-kzb04293.js → chunk-qwdcts9w.js} +3 -3
- package/dist/chunk-rc79yyqx.js +2 -0
- package/dist/{chunk-xdn6rtq2.js → chunk-rfc5pdv2.js} +1 -1
- package/dist/{chunk-xayfz35c.js → chunk-rnws0dh3.js} +1 -1
- package/dist/{chunk-gc4w2s5n.js → chunk-rxxajm31.js} +2 -2
- package/dist/{chunk-2xv29pfj.js → chunk-s73z8zss.js} +1 -1
- package/dist/{chunk-81rdyz2n.js → chunk-sptewgky.js} +1 -1
- package/dist/{chunk-0thxpgtp.js → chunk-sqh3tvtw.js} +1 -1
- package/dist/{chunk-j6x7ryyn.js → chunk-tmqrbs98.js} +22 -11
- package/dist/{chunk-xtnxvmdb.js → chunk-vay5v6sj.js} +1 -1
- package/dist/chunk-vewt3464.js +2 -0
- package/dist/chunk-whzvx5w5.js +2 -0
- package/dist/chunk-wk1gt95z.js +2 -0
- package/dist/{chunk-8an7vcxx.js → chunk-x63f2ywm.js} +1 -1
- package/dist/chunk-xk7cp691.js +2 -0
- package/dist/{chunk-e4ezpevb.js → chunk-xnx06qqt.js} +1 -1
- package/dist/{chunk-yaccg2c0.js → chunk-y34tyrpb.js} +1 -1
- package/dist/{chunk-3vwkyjan.js → chunk-z35ftpqp.js} +12 -12
- package/dist/{chunk-7q699phs.js → chunk-z7ghjs7w.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client/signals-for-runtime.js +16 -5
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-1wdawkn8.js +0 -2
- package/dist/chunk-41q5rww8.js +0 -2
- package/dist/chunk-4c5tk71j.js +0 -2
- package/dist/chunk-57ege36s.js +0 -2
- package/dist/chunk-5n4c99y5.js +0 -2
- package/dist/chunk-6rftdp7c.js +0 -2
- package/dist/chunk-7s6hypn5.js +0 -2
- package/dist/chunk-7ym269yp.js +0 -2
- package/dist/chunk-855h3crg.js +0 -2
- package/dist/chunk-bpf3xxng.js +0 -3
- package/dist/chunk-dasxbb9y.js +0 -2
- package/dist/chunk-e02ne8zd.js +0 -2
- package/dist/chunk-fqa5ej45.js +0 -2
- package/dist/chunk-hz5eh77e.js +0 -2
- package/dist/chunk-prc5dxp1.js +0 -2
- package/dist/chunk-qwdgx34g.js +0 -2
- package/dist/chunk-r6t1712p.js +0 -2
- package/dist/chunk-s5q9ztvj.js +0 -2
- package/dist/chunk-sfpymq5h.js +0 -2
- package/dist/chunk-t8tst3sk.js +0 -2
- package/dist/chunk-xh5mh8kn.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{To,$a,s,Tt,re,S,Pe,cn,Ie,de,
|
|
2
|
+
import{To,$a,s,Tt,re,S,Pe,cn,Ie,de,K,cr,ln,gs,Ba,dn,dr,hs,ys,Fa,Oo,za,Ha,Va,Ua,Ne,De,bs,je,n,gn,m,d,H,J,we,k,_}from"./chunk-z35ftpqp.js";import{l,p,E,t,ie,V,a,xe,Uo,D,bn,Wo,Lt,qo,rc,mr,sc,rt,oc,hr,ic,vn,Ko,ac,yr,vr,Se,Go}from"./chunk-qwdcts9w.js";import{Nt}from"./chunk-9wdd7eq6.js";import{hn}from"./chunk-sqh3tvtw.js";import{h}from"./chunk-551s7ha0.js";import{rr,ss}from"./chunk-f26n6y9p.js";import{pa,fa,er,Je,ga,R}from"./chunk-245sas8r.js";import{bo,vo,wo,xo}from"./chunk-y34tyrpb.js";import{aa,Hr}from"./chunk-ehzd1yc6.js";import{jr,Br,Fr}from"./chunk-304dbbsw.js";import{Vr,lo,uo,Ur,Wr,po}from"./chunk-n94ts3t9.js";import{Lr,Gn}from"./chunk-j60jye3e.js";import{to}from"./chunk-078qg8r5.js";import{ne,oo,io,ao}from"./chunk-xnx06qqt.js";import{Jn,he,la,Yn,ua}from"./chunk-5v7vm8cv.js";import{q,Ge}from"./chunk-a2zb5fgg.js";import{ma,ha}from"./chunk-d4ch6exz.js";import{C,wn,Xo}from"./chunk-hh58k0nh.js";import ds from"fs";import ce from"path";function lt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -347,7 +347,7 @@ else {
|
|
|
347
347
|
|
|
348
348
|
console.log('[stx] Lifecycle runtime initialized');
|
|
349
349
|
})();
|
|
350
|
-
`}function
|
|
350
|
+
`}function Ke(c){return Symbol(c)}var Ts=Ke("theme"),Cs=Ke("router"),As=Ke("i18n");import*as dt from"crypto";function ut(c){let e=/\$(\w+)\./g,u=[],i;while((i=e.exec(c))!==null)if(!u.includes(i[1]))u.push(i[1]);return u}function In(){return`stx-${dt.randomBytes(4).toString("hex")}`}function On(c){return/\$\w+\./.test(c)}function Pn(c){if(!/\{\{[^}]*\$\w/.test(c)||!/\$\w+\./.test(c))return{html:c,bindings:[],stores:new Set};let e=[],u=new Set,i=/<(\w+)([^>]*?)(\s*\/?>)/g,g=c;return g=g.replace(i,(r,f,v,y)=>{if(["script","style","template"].includes(f.toLowerCase()))return r;if(!v.includes("{{"))return r;let x=[],b=!1,w=v,T=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,A=[...v.matchAll(T)];for(let I of A){let P=I[0],N=I[1],U=I[2];if(On(U)){b=!0;let W=U.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(W){let L=W[1];if(x.push({attr:N,expr:L,fullMatch:P,originalAttr:N}),ut(L).forEach((B)=>u.add(B)),N==="text")w=w.replace(P,"");else if(N==="class")w=w.replace(P,'class=""');else if(N==="disabled"||N==="hidden")w=w.replace(P,"");else w=w.replace(P,`${N}=""`)}}}if(!b)return r;let O=w.match(/\bid\s*=\s*"([^"]+)"/),M;if(O)M=O[1];else M=In(),w=` id="${M}"${w}`;for(let I of x)e.push({elementId:M,attribute:I.attr,expression:I.expr,stores:ut(I.expr)});return`<${f}${w}${y}`}),{html:g,bindings:e,stores:u}}function Ln(c,e){if(c.length===0)return"";let u=Array.from(e),i=`
|
|
351
351
|
<script>
|
|
352
352
|
(function() {
|
|
353
353
|
'use strict';
|
|
@@ -562,7 +562,7 @@ ${e.inlineScript}
|
|
|
562
562
|
`;if(!e.scriptUrl)return"";let u=[];if(e.scriptId)u.push(`id="${pe(e.scriptId)}"`);if(e.attributes)for(let[g,r]of Object.entries(e.attributes))u.push(`${pe(g)}="${pe(r)}"`);return`
|
|
563
563
|
<!-- Custom Analytics -->
|
|
564
564
|
<script${u.length>0?` ${u.join(" ")}`:""} src="${pe(e.scriptUrl)}" defer></script>
|
|
565
|
-
`}function ft(c,e){let u=jn(e);if(!u)return c;if(!c.includes("</head>")){let i=c.lastIndexOf("</body>");if(i!==-1)return c.slice(0,i)+u+c.slice(i);return c+u}return c.replace("</head>",`${u}</head>`)}function pe(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function gt(c){let e=c.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function mt(c){let e=c?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}var Vn=0,zn=0;function ht(c,e){let u=c.match(new RegExp(`${e}\\s*=\\s*"([^"]*)"`,"i"));if(u)return u[1];let i=c.match(new RegExp(`${e}\\s*=\\s*'([^']*)'`,"i"));if(i)return i[1];return null}function Wn(c){let e=[],u=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,i;while((i=u.exec(c))!==null){let[g,r,f]=i,v=i.index,y=ht(f,"x-data");if(!y)continue;let x=`__stx_scope_${Vn++}`,b=ht(f,"x-init"),w=Xn(c,r,v+g.length),T=c.slice(v,w.endIndex),A=
|
|
565
|
+
`}function ft(c,e){let u=jn(e);if(!u)return c;if(!c.includes("</head>")){let i=c.lastIndexOf("</body>");if(i!==-1)return c.slice(0,i)+u+c.slice(i);return c+u}return c.replace("</head>",`${u}</head>`)}function pe(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function gt(c){let e=c.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function mt(c){let e=c?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}var Vn=0,zn=0;function ht(c,e){let u=c.match(new RegExp(`${e}\\s*=\\s*"([^"]*)"`,"i"));if(u)return u[1];let i=c.match(new RegExp(`${e}\\s*=\\s*'([^']*)'`,"i"));if(i)return i[1];return null}function Wn(c){let e=[],u=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,i;while((i=u.exec(c))!==null){let[g,r,f]=i,v=i.index,y=ht(f,"x-data");if(!y)continue;let x=`__stx_scope_${Vn++}`,b=ht(f,"x-init"),w=Xn(c,r,v+g.length),T=c.slice(v,w.endIndex),A=Kn(T);e.push({id:x,selector:`[data-stx-scope="${x}"]`,stateExpr:y,initExpr:b,bindings:[],refs:A})}return e}function Xn(c,e,u){let i=1,g=u,r=new RegExp(`<${e}(?:\\s|>)`,"gi"),f=new RegExp(`</${e}>`,"gi"),v=new RegExp(`<${e}[^>]*/\\s*>`,"gi");while(i>0&&g<c.length){r.lastIndex=g,f.lastIndex=g,v.lastIndex=g;let y=r.exec(c),x=f.exec(c),b=v.exec(c);if(b&&b.index<(y?.index??1/0)){g=b.index+b[0].length;continue}if(!x)return{endIndex:c.length};if(y&&y.index<x.index)i++,g=y.index+y[0].length;else{if(i--,i===0)return{endIndex:x.index+x[0].length};g=x.index+x[0].length}}return{endIndex:c.length}}function Kn(c){let e=new Map,u=c.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,g;while((g=i.exec(u))!==null){let[,r,f]=g,v=Zn(r);e.set(f,v)}return e}function Zn(c){let e=c.match(/\bid\s*=\s*["']([^"']*)["']/);if(e)return e[1];return`__stx_el_${zn++}`}function Qn(){return`
|
|
566
566
|
// STX Reactive Runtime - x-cloak and transition CSS
|
|
567
567
|
(function() {
|
|
568
568
|
var style = document.createElement('style');
|
|
@@ -854,22 +854,22 @@ ${I}
|
|
|
854
854
|
</style>`;i=i.replace(x,P),v.lastIndex=0}catch(I){}}}return i}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function us(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(i,g,r,f)=>{let v=it.resolve(u,f);return`${g}${r}${v.split(it.sep).join("/")}${r}`})}function un(c,e){if(!e||!c.includes("<script"))return c;return c.replace(ls,(u,i,g,r)=>`${i}${us(g,e)}${r}`)}var Te="<!--PARENT_CONTENT_PLACEHOLDER-->";function pn(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Sn(c,e){let u=c.length,i=e,g=!0,r=[],f=(v)=>v+9<=u&&c[v]==="<"&&c[v+1]==="/"&&(c[v+2]==="s"||c[v+2]==="S")&&(c[v+3]==="c"||c[v+3]==="C")&&(c[v+4]==="r"||c[v+4]==="R")&&(c[v+5]==="i"||c[v+5]==="I")&&(c[v+6]==="p"||c[v+6]==="P")&&(c[v+7]==="t"||c[v+7]==="T")&&(c[v+8]===">"||/\s/.test(c[v+8]));while(i<u){let v=c[i];if(f(i))return i;if(v==="/"&&c[i+1]==="/"){if(i=c.indexOf(`
|
|
855
855
|
`,i+2),i===-1)return-1;i+=1,g=!0;continue}if(v==="/"&&c[i+1]==="*"){let y=c.indexOf("*/",i+2);if(y===-1)return-1;i=y+2,g=!0;continue}if(v==="/"&&g){let y=i+1,x=!1;while(y<u){let b=c[y];if(b==="\\"){y+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){y++;break}else if(b===`
|
|
856
856
|
`){y=-1;break}y++}if(y===-1){i++,g=!1;continue}while(y<u&&/[a-z]/.test(c[y]))y++;i=y,g=!1;continue}if(v==="'"||v==='"'){let y=v;i++;while(i<u){if(c[i]==="\\"){i+=2;continue}if(c[i]===y){i++;break}if(c[i]===`
|
|
857
|
-
`)break;i++}g=!1;continue}if(v==="`"){i++;while(i<u){if(c[i]==="\\"){i+=2;continue}if(c[i]==="`"){i++;break}if(c[i]==="$"&&c[i+1]==="{"){r.push(!0),i+=2,g=!0;break}i++}if(r.length===0)g=!1;continue}if(v==="}"&&r.length>0){r.pop(),i++;while(i<u){if(c[i]==="\\"){i+=2;continue}if(c[i]==="`"){i++,g=!1;break}if(c[i]==="$"&&c[i+1]==="{"){r.push(!0),i+=2,g=!0;break}i++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;i++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!i)return null;let g=i.index+i[0].length,r=c.indexOf("</script>",g);if(r===-1)return null;let f=c.indexOf(">",r);if(f===-1)return null;return{start:i.index,end:f+1}}var ps=4096;async function fn(c,e,u){if(u.buildMode!=="serve"||e.length<ps)return null;let{registerServeModuleBundle:i}=await import("./chunk-
|
|
857
|
+
`)break;i++}g=!1;continue}if(v==="`"){i++;while(i<u){if(c[i]==="\\"){i+=2;continue}if(c[i]==="`"){i++;break}if(c[i]==="$"&&c[i+1]==="{"){r.push(!0),i+=2,g=!0;break}i++}if(r.length===0)g=!1;continue}if(v==="}"&&r.length>0){r.pop(),i++;while(i<u){if(c[i]==="\\"){i+=2;continue}if(c[i]==="`"){i++,g=!1;break}if(c[i]==="$"&&c[i+1]==="{"){r.push(!0),i+=2,g=!0;break}i++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;i++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!i)return null;let g=i.index+i[0].length,r=c.indexOf("</script>",g);if(r===-1)return null;let f=c.indexOf(">",r);if(f===-1)return null;return{start:i.index,end:f+1}}var ps=4096;async function fn(c,e,u){if(u.buildMode!=="serve"||e.length<ps)return null;let{registerServeModuleBundle:i}=await import("./chunk-c4enpsj8.js");return`<script ${c} src="${i(e)}"></script>`}async function Un(c,e,u){try{let{registeredModuleIdsIn:i,buildModuleRegistryScript:g}=await s("stx/client-module-registry",()=>import("./chunk-sptewgky.js")),r=[],f=await g(i(...c),{minify:Xo(e.buildMode),collectInputs:r});for(let v of r)u?.add(v);if(!f)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-c4enpsj8.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(f)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${f.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function fs(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let i=Jn(c);if(i===-1||i===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(i<u.start)return c.slice(0,i)+c.slice(u.start,u.end)+e+`
|
|
858
858
|
`+c.slice(i,u.start)+c.slice(u.end);let g=c.slice(u.start,u.end),r=c.slice(0,u.start)+c.slice(u.end),f=Jn(r);if(f===-1)return g+e+`
|
|
859
859
|
`+r;return r.slice(0,f)+g+e+`
|
|
860
|
-
`+r.slice(f)}function ms(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,i,g)=>{let r=c.slice(0,g);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${i}}}`:`{<!--stx-literal-->{${i}}}`})}async function o(c,e,u,i,g){if(i.ssr===!1&&!i.autoShell&&i.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=we(c,u);let r=!e.__stxProcessingDepth;dn(e);for(let f of i._layerGraph?.configDependencies??[])g.add(f);if(r&&i.runtimeConfig)await hn(e,u,i.runtimeConfig);if(r)Va(e),e.__stx_scope_seq??={n:0,key:bs(String(e.__filename??u))},e.__stx_head_injections=qo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((i.debug||!C()&&!wn())&&u&&u.endsWith(".stx"))to(c,u);try{return await re.timeAsync("template-processing",async()=>{let f=await vs(c,e,u,i,g);if(r)f=Oo(f);if(r&&i.autoShell&&i.buildMode!=="compile"){let v=Se(i.app?.head,{known:vr,source:"app.head"}),x=(e.__stx_runtime_head||null)??
|
|
861
|
-
`),...x.htmlAttrs&&{htmlAttrs:oc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},W=
|
|
860
|
+
`+r.slice(f)}function ms(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,i,g)=>{let r=c.slice(0,g);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${i}}}`:`{<!--stx-literal-->{${i}}}`})}async function o(c,e,u,i,g){if(i.ssr===!1&&!i.autoShell&&i.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=we(c,u);let r=!e.__stxProcessingDepth;dn(e);for(let f of i._layerGraph?.configDependencies??[])g.add(f);if(r&&i.runtimeConfig)await hn(e,u,i.runtimeConfig);if(r)Va(e),e.__stx_scope_seq??={n:0,key:bs(String(e.__filename??u))},e.__stx_head_injections=qo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((i.debug||!C()&&!wn())&&u&&u.endsWith(".stx"))to(c,u);try{return await re.timeAsync("template-processing",async()=>{let f=await vs(c,e,u,i,g);if(r)f=Oo(f);if(r&&i.autoShell&&i.buildMode!=="compile"){let v=Se(i.app?.head,{known:vr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Go(),b=(e.__stx_head_raw||"").trim(),w,T=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(T)w=T[1].trim(),b=b.replace(T[0],"").trim();let A=e.__sections?.title,O=A?k(A,e,u):void 0,M=x.title||w||O,I=!x.title&&(!!w||!!O),P=x.meta||[],N=new Set(P.map((X)=>rt(X)).filter(Boolean)),U={...v,...M&&{title:M},meta:[...(v.meta||[]).filter((X)=>!N.has(rt(X))),...P],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
861
|
+
`),...x.htmlAttrs&&{htmlAttrs:oc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},W=Ko(f);if(f=yr(f,U,{...I&&{titleIsHtml:!0},...i.app?.colorMode&&{colorMode:i.app.colorMode}},W),W)f=ac(f,v),f=hr(f,U.htmlAttrs);let L=f.match(/<!-- stx-layout: ([^ ]+) -->/);if(L&&f.includes("<head")){let X=L[1],G=ss(X);f=f.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
862
862
|
<meta name="stx-layout" content="${pn(X)}">
|
|
863
|
-
<meta name="stx-layout-group" content="${pn(
|
|
863
|
+
<meta name="stx-layout-group" content="${pn(G)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),B=j?q(f):null;if(j&&B&&!/\bdata-stx=/.test(B.tag)){f=Ge(f,(G,Y)=>`<body${Y} data-stx="${j[1]}">`);let X=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(X,"$1")}}if(r){let v=e.__stx_head_injections??qo(),y=ic(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(i.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=rc(f,v);let b=i.app?.colorMode;if(b)f=mr(f,b)}if(r)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await s("stx/store-loader",()=>import("./chunk-jjet6qxq.js")),M=i.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await fn("data-stx-stores",I,i)??b}catch{}y=await Un([f,b],i,g);try{let{getFrameworkComposableScript:O}=await s("stx/framework-composables",()=>import("./chunk-g12ht81a.js"));T=await O(f)}catch{}try{let{getComposableScript:O}=await s("stx/composable-loader",()=>import("./chunk-1e73whqh.js")),M=i.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(i._layerComposableDirs??M,f,I);if(P)w=await fn('data-stx-scoped data-stx-run="always" data-stx-composables',P,i)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
|
|
864
864
|
${O}`).join("");f=fs(f,A)}else{let y=await Un([f],i,g);if(y){let x=f.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)f=f.slice(0,x)+y+`
|
|
865
865
|
`+f.slice(x)}}if(r)f=sc(f);if(r&&e.__stx_inject_css!==!1)f=await h(f,void 0,i.buildMode==="serve",!0);else if(r)f=ln(f);if(f=f.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),f=ms(f),r&&e.__stx_runtime_config)f=Nt(f,e.__stx_runtime_config);if(r&&!e.__stx_defer_server_data){let v=dr(e);if(v){let y=/<head\b[^>]*>/i.exec(f),x=y?y.index+y[0].length:0;f=f.slice(0,x)+v+f.slice(x)}}return f})}catch(f){if(f instanceof V)throw f;let v=f instanceof Error?f.message:String(f),y=new ie(`Template processing failed: ${v}`,u,void 0,void 0,c.substring(0,200)+(c.length>200?"...":""));if(D.log(y,{filePath:u,context:e}),bn.logDetailedError(y,{filePath:u,template:c.substring(0,500)}),C()&&!i.debug)console.error(`[stx] ${ce.relative(process.cwd(),u)||u}: ${y.message}`);if(i.debug)throw y;return Uo.createFallbackContent("Template Processing",y)}}async function vs(c,e,u,i,g){let r=process.cwd(),f={...i,partialsDir:i.partialsDir&&!ce.isAbsolute(i.partialsDir)?ce.resolve(r,i.partialsDir):i.partialsDir,componentsDir:i.componentsDir&&!ce.isAbsolute(i.componentsDir)?ce.resolve(r,i.componentsDir):i.componentsDir,layoutsDir:i.layoutsDir&&!ce.isAbsolute(i.layoutsDir)?ce.resolve(r,i.layoutsDir):i.layoutsDir},v=f,y=c;await ks(u,e),xs(e,v),y=await xe(()=>zt(y,e,u,v),y,(L)=>{D.log(L,{filePath:u,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${u}: ${L.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=de(y,Ie,(L,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);y=x.output;let b=x.tokens,w=(L)=>b.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,B)=>b[Number(B)]??""),T="\x00STX_ESCAPED_AT\x00",A="\x00STX_ESC_MUSTACHE_OPEN\x00",O="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,T),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(L,j)=>`${A}${j}${O}`),y=Jt(y),y=await an(y,u,g);let M={};y=Br(y,M);let I={...e.__sections||{}},P="",N=mt(gt(c)),U=/@nolayout\b/.test(y)||N===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let W=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(W)P=W[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(P=N,!/@section\s*\(/.test(y))y=`@section('content')
|
|
866
866
|
${y.trim()}
|
|
867
|
-
@endsection`}if(!P&&!U&&v.defaultLayout){let L=vn(y),j=/@section\s*\(/.test(y);if(!L||j){let B="",X=ce.dirname(u),
|
|
867
|
+
@endsection`}if(!P&&!U&&v.defaultLayout){let L=vn(y),j=/@section\s*\(/.test(y);if(!L||j){let B="",X=ce.dirname(u),G=v.layoutsDir?ce.dirname(v.layoutsDir):process.cwd();for(let Y=0;Y<20;Y++){let ee=ce.join(X,"_layout.stx");if(await n(ee)){B=ee;break}let te=ce.dirname(X);if(te===X||te.length<G.length)break;X=te}if(B)P=B;else if(v.layoutsDir){let Y=ce.isAbsolute(v.layoutsDir)?v.layoutsDir:ce.resolve(process.cwd(),v.layoutsDir),ee=ce.join(Y,`${v.defaultLayout}.stx`);if(await n(ee))P=ee}if(P&&!j)y=`@section('content')
|
|
868
868
|
${y.trim()}
|
|
869
|
-
@endsection`}}if(P&&y.includes("<script")){let L=
|
|
869
|
+
@endsection`}}if(P&&y.includes("<script")){let L=K(y),j=L.scripts.map((B)=>mn(B,u)??B);y=cr(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,B)=>(I[j]=B,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,B)=>{if(/^(['"]).*\1$/.test(B.trim()))return L;try{let X=l(B.trim(),e);if(X===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(X)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,B)=>{if(B.includes("@parent"))I[j]=B.replace("@parent",Te);else I[j]=B.trim();return""}),e.__sections=I,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,j,B)=>I[j]||B||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||"");if(y=Fr(y,M),P){let L=[],j=K(y),B=de(j.output,cn,(X,G)=>`\x00STX_ORPHAN_STYLE_${G}\x00`);if(y=B.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(X,G,Y)=>{let ee=G==="SCRIPT"?mn(j.scripts[Number(Y)],u):B.tokens[Number(Y)];if(ee)L.push(ee);return""}),L.length>0){let X=L.join(`
|
|
870
870
|
`);I.content=I.content?`${I.content}
|
|
871
|
-
${X}`:X,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,g.add(P);else L=await xe(()=>gn(P,u,f,g),null,()=>{throw new ie(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ee=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return ds.readdirSync(ae).filter((le)=>le.endsWith(".stx")).map((le)=>le.replace(/\.stx$/,""))}catch{return[]}},te=[...ee(f.layoutsDir),...ee(f.fallbackLayoutsDir)].filter((oe,ae,le)=>le.indexOf(oe)===ae).sort(),ue=`Layout not found: ${P} (referenced from ${u})`+(te.length>0?`. Available layouts: ${te.join(", ")}`:f.layoutsDir?`. No .stx layouts found in ${f.layoutsDir}`:"");if(D.log(Error(ue),{layoutPath:P,filePath:u,available:te},"error"),console.error(`[stx] ${ue}`),f.debug)throw new ie(ue,u);return y}let j=await xe(()=>Bun.file(L).text(),"",()=>{throw new ie(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=un(j,L);let B=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(B){if(f.debug)console.log(`Found nested layout: ${B[1]} in ${L}`);let ee={},te=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,le,be)=>(ee[le]=be.trim(),""));for(let[ae,le]of Object.entries(ee))if(I[ae]&&I[ae].includes(Te)){let be=I[ae].indexOf(Te);I[ae]=I[ae].slice(0,be)+le+I[ae].slice(be+Te.length)}else if(!I[ae])I[ae]=le;let ue={...e,__sections:I},oe=`@layout('${B[1]}')${te}`;return await o(oe,ue,L,f,g)}let X=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),
|
|
872
|
-
${y}`,w(y)}catch(L){if(L instanceof V)throw L;throw new ie(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,i,g)=>{let r=e[i];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",i={};for(let[g,r]of Object.entries(process.env))if(g.startsWith(u)&&r!==void 0)i[g]=r;c.$env=i}async function ks(c,e){await xe(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function mn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function yn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${yn(c)}</span><span style="display:block;margin-top:4px">${yn(u)}</span></div>`}async function $s(c,e,u,i){let{scanScriptTags:g}=await s("stx/signal-processing",()=>import("./chunk-
|
|
871
|
+
${X}`:X,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,g.add(P);else L=await xe(()=>gn(P,u,f,g),null,()=>{throw new ie(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ee=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return ds.readdirSync(ae).filter((le)=>le.endsWith(".stx")).map((le)=>le.replace(/\.stx$/,""))}catch{return[]}},te=[...ee(f.layoutsDir),...ee(f.fallbackLayoutsDir)].filter((oe,ae,le)=>le.indexOf(oe)===ae).sort(),ue=`Layout not found: ${P} (referenced from ${u})`+(te.length>0?`. Available layouts: ${te.join(", ")}`:f.layoutsDir?`. No .stx layouts found in ${f.layoutsDir}`:"");if(D.log(Error(ue),{layoutPath:P,filePath:u,available:te},"error"),console.error(`[stx] ${ue}`),f.debug)throw new ie(ue,u);return y}let j=await xe(()=>Bun.file(L).text(),"",()=>{throw new ie(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=un(j,L);let B=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(B){if(f.debug)console.log(`Found nested layout: ${B[1]} in ${L}`);let ee={},te=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,le,be)=>(ee[le]=be.trim(),""));for(let[ae,le]of Object.entries(ee))if(I[ae]&&I[ae].includes(Te)){let be=I[ae].indexOf(Te);I[ae]=I[ae].slice(0,be)+le+I[ae].slice(be+Te.length)}else if(!I[ae])I[ae]=le;let ue={...e,__sections:I},oe=`@layout('${B[1]}')${te}`;return await o(oe,ue,L,f,g)}let X=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),G=Br(X,M),Y={};return G=G.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ee,te,ue)=>(Y[te]=ue.trim(),`@slot('${te}')`)),G=G.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ee,te,ue)=>{if(I[te]){let oe=I[te];if(oe.includes(Te)){let ae=Y[te]||"",le=oe.indexOf(Te);oe=oe.slice(0,le)+ae+oe.slice(le+Te.length)}return oe}return ue||""}),G=ws(G,I),G=G.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||""),G=Fr(G,M),e.__originalFilePath=u,y=await kn(G,e,L,f,g),y=`<!-- stx-layout: ${P} -->
|
|
872
|
+
${y}`,w(y)}catch(L){if(L instanceof V)throw L;throw new ie(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,i,g)=>{let r=e[i];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",i={};for(let[g,r]of Object.entries(process.env))if(g.startsWith(u)&&r!==void 0)i[g]=r;c.$env=i}async function ks(c,e){await xe(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function mn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function yn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${yn(c)}</span><span style="display:block;margin-top:4px">${yn(u)}</span></div>`}async function $s(c,e,u,i){let{scanScriptTags:g}=await s("stx/signal-processing",()=>import("./chunk-fd72t30s.js")),r=[],f=!C()&&!wn();for(let y of g(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await s("stx/variable-extractor",()=>import("./chunk-whzvx5w5.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(i?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!f)return;r.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),f)r.push({...O,markup:xn(A,"unknown",I.message)})}}if(r.length===0)return c;let v=c;for(let y of r.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:i}=await s("stx/expressions",()=>import("./chunk-q1jcf6vm.js"));return i(c,e,{skipServer:!0})}catch(i){let g=i instanceof Error?i:Error(String(i));return D.log(g,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${g.message}`),c}}async function kn(c,e,u,i,g){let r=c,f=i;if(r=await $s(r,e,u,i),r=await Bt(r,e,u),r=await Ft(r,e,u),r=await Es(r,e,u),r=await At(r,e,u,f),we(r))r=lo(r,e),r=Wr(r,e),r=Ur(r,e);r=uo(r);let{processStreamDirectives:v}=await s("stx/streaming",()=>import("./chunk-vewt3464.js"));r=v(r,e),r=Gn(r,e,u,f,!0),r=await en(r,e,u,f,g),r=await Hr(r,e,u,f,g),r=pa(r,e,u,f);let{processDeferDirectives:y}=await s("stx/defer",()=>import("./chunk-3xx9d934.js"));r=y(r,e,u);let{processTeleportDirectives:x}=await s("stx/teleport",()=>import("./chunk-tz09earb.js"));r=x(r,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await s("stx/transitions",()=>import("./chunk-ggwvnpwj.js"));r=b(r,e,u),r=w(r);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await s("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));r=T(r,e,u),r=A(r);let{processSuspenseDirectives:O}=await s("stx/suspense",()=>import("./chunk-3wsm9g9c.js"));r=O(r,e,u);let{processAsyncDirectives:M}=await s("stx/async-components",()=>import("./chunk-swxznm5v.js"));r=M(r,e,u);let{processKeepAliveDirectives:I}=await s("stx/keep-alive",()=>import("./chunk-s8qe247r.js"));r=I(r,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:U}=await s("stx/virtual-scrolling",()=>import("./chunk-ft3f9nj0.js"));r=P(r,e,u),r=N(r,e,u),r=U(r,e,u);let{processPartialHydrationDirectives:W,processStaticDirectives:L}=await s("stx/partial-hydration",()=>import("./chunk-3bfegbpw.js"));r=W(r,e,u),r=L(r);let{processComputedDirectives:j,processWatchDirectives:B}=await s("stx/computed",()=>import("./chunk-1xdzcy9d.js"));r=j(r,e,u),r=B(r,e,u);let{processFormValidationDirectives:X}=await s("stx/forms-validation",()=>import("./chunk-etz2dmec.js"));r=X(r,e,u);let{processHeadDirective:G,processTitleDirective:Y,processMetaDirective:ee,resetHead:te}=await s("stx/head",()=>import("./chunk-909ymsjz.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)te();let ue=G(r);if(r=ue.content,ue.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${ue.headContent}
|
|
873
873
|
`;if(r=Y(r,e),r=ee(r,e,u),r=Xt(r),r=oo(r,e),r=Ct(r),r=Ut(r),r=await jr(r,e,u,f,g),r=await Hr(r,e,u,f,g),e.__stxProcessingDepth===1)r=Ua(r,e);if(r=r.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),r=Oo(r),r=ne(r,e,u),r=Lr(r),r=Ba(r,e,{filePath:u,buildMode:f.buildMode}),r=io(r,e),r=ao(r,e),r=ze(r,e),r=jt(r,e),r=Ht(r,e),r=await bt(r,e,u,f),r=await ga(r,e,u),r=await ma(r,e,u,f),r=ha(r,e,u,f),r=bo(r,e,u,f),r=vo(r,e,u),r=wo(r,e,u,f),r=Et(r,e,u,f),r=hs(r,e),r=ys(r),r=Fa(r),!f.skipEventDirectives)r=$a(r,e,u);if(r=vt(r,e,u),f.debug){let F=/\bx-data\s*=/.test(r),z=Vr(c);if(F&&z)console.warn(`[stx] ${u}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
874
874
|
Both work on the same page, but they manage separate scopes.
|
|
875
875
|
Prefer signals (state/derived/effect) for new components.`)}r=aa(r,e),r=await k(r,e,u),r=za(r),r=Ha(r),r=pt(r);let{processXElementDirectives:oe}=await s("stx/x-element",()=>import("./chunk-zhxdpzga.js"));r=oe(r);let ae=e.__originalFilePath||u,le=Ne(e);if(r=await po(r,f,ae,le),r=It(r,e),r=await Wt(r,e,u,f),f.media?.image?.autoSiblings){let F=f.publicDir||"public",{rewriteImagesWithSiblings:z}=await s("stx/image-optimization/auto-sibling",()=>import("./chunk-gx6wxmbv.js"));r=await z(r,{publicDir:F})}if(f.seo?.enabled)r=xo(r,e,f);let be=(F,z,Z=!0)=>{if(!z)return F;let me=z.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),se=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(F),fe=se?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(se[0]):null;if(me&&se&&fe){if(Z){let Ce=se.index+fe.index;F=F.slice(0,Ce)+me[0]+F.slice(Ce+fe[0].length)}if(z=z.replace(me[0],"").trim(),!z)return F}if(/<\/head>/i.test(F))return F.replace(/<\/head>/i,`${z}
|
|
@@ -877,12 +877,12 @@ ${y}`,w(y)}catch(L){if(L instanceof V)throw L;throw new ie(`Error processing lay
|
|
|
877
877
|
${z}`);if(/<html\b[^>]*>/i.test(F))return F.replace(/(<html\b[^>]*>)/i,`$1
|
|
878
878
|
<head>
|
|
879
879
|
${z}
|
|
880
|
-
</head>`);return F},{renderHead:En,getHead:_n}=await s("stx/head",()=>import("./chunk-
|
|
880
|
+
</head>`);return F},{renderHead:En,getHead:_n}=await s("stx/head",()=>import("./chunk-909ymsjz.js")),Oe=e.__stx_runtime_head??_n();if(Oe.title||Oe.meta?.length||Oe.link?.length){let F=En(Oe);if(F)r=be(r,F)}if(ue.headContent)r=be(r,ue.headContent,!Oe.title);if(f.csp?.enabled&&f.csp.addMetaTag)r=St(r,f.csp,e);if(f.analytics?.enabled)r=ft(r,f);if(f.heatmap?.enabled)r=fa(r,f);if(f.pwa?.enabled&&f.pwa.autoInject!==!1){let{injectPwaTags:F}=await s("stx/pwa/inject",()=>import("./chunk-xna6b7km.js"));r=F(r,f)}let Tn=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(r),Cn=/\bSTX\.\w+/.test(r),An=/window\.STX\s*=/.test(r);if(Tn&&Cn&&!An){let z=`<script data-stx-scoped data-stx-run="once">
|
|
881
881
|
${lt()}
|
|
882
882
|
</script>`;if(r.includes("</head>")){let Z=r.indexOf("</head>"),se=r.slice(0,Z).indexOf("<script");if(se!==-1){let fe=r.slice(0,se),Ce=r.slice(se);r=fe+z+`
|
|
883
883
|
`+Ce}else r=r.replace("</head>",`${z}
|
|
884
884
|
</head>`)}else if(r.includes("<body"))r=r.replace(/<body([^>]*)>/,`<body$1>
|
|
885
885
|
${z}`);else r=z+`
|
|
886
|
-
`+r}{let{scanScriptTags:F}=await s("stx/signal-processing",()=>import("./chunk-
|
|
886
|
+
`+r}{let{scanScriptTags:F}=await s("stx/signal-processing",()=>import("./chunk-fd72t30s.js")),z=[];for(let Z of F(r)){if(!/\bserver\b/i.test(Z.attrs))continue;let me=Z.start+Z.fullMatch.indexOf(">")+1,se=Sn(r,me);if(se===-1)continue;let fe=se+9;while(fe<r.length&&/\s/.test(r[fe]))fe++;z.push({start:Z.start,end:fe})}if(z.length>0){let Z=Array(z.length+1),me=0;for(let se=0;se<z.length;se++){let{start:fe,end:Ce}=z[se];Z[se]=r.slice(me,fe),me=Ce}Z[z.length]=r.slice(me),r=Z.join("")}}let at=gs(r,u);if(at.hasScoped)r=at.html;let Rn=e.__stx_event_bindings||[],Xe=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(r),{scanScriptTags:Dn}=await s("stx/signal-processing",()=>import("./chunk-fd72t30s.js"));for(let F of Dn(r,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:F.fullMatch,attrs:F.attrs,content:F.body});for(let{match:F,attrs:z,content:Z}of ct){Xe=!0;let me=Z;Pe(Z,u,i.strict,e.__originalFilePath);let se=await De(Z,{eventBindings:Rn,attrs:z,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:Xo(i.buildMode),serverData:le});r=r.replace(F,()=>se)}if(Xe)e.__stx_event_bindings=[];if(!Xe&&e.__stxProcessingDepth===1){let F=e.__stx_event_bindings||[];if(F.length>0){let z=To(F);if(z){let Z=r.lastIndexOf("</body>");r=Z===-1?r+z:r.slice(0,Z)+z+`
|
|
887
887
|
`+r.slice(Z)}e.__stx_event_bindings=[]}}if(!he(r)&&la(r))r=await Yn(r,f);if(r=ua(r),f.csp?.enabled&&f.csp.useNonce&&typeof e.cspNonce==="string")r=$t(r,e.cspNonce);return r}
|
|
888
888
|
export{gt,$e,ra,eo,Un,o};
|
|
@@ -142,7 +142,7 @@ function Mi(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
142
142
|
${x}
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
|
-
`})}function
|
|
145
|
+
`})}function Kc(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
|
|
146
146
|
<div class="virtual-grid-item"
|
|
147
147
|
style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
|
|
148
148
|
data-index="${I}">
|
|
@@ -212,5 +212,5 @@ function Mi(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
212
212
|
});
|
|
213
213
|
})();
|
|
214
214
|
</script>
|
|
215
|
-
`})}var nd={createVirtualList:Mi,processVirtualListDirectives:Li,processInfiniteListDirectives:qc,processVirtualGridDirectives:
|
|
216
|
-
export{Mi,Li,Uc,Wc,qc,
|
|
215
|
+
`})}var nd={createVirtualList:Mi,processVirtualListDirectives:Li,processInfiniteListDirectives:qc,processVirtualGridDirectives:Kc,generateVirtualListCSS:Uc,useVirtualList:Wc};
|
|
216
|
+
export{Mi,Li,Uc,Wc,qc,Kc,nd};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bo,vo,wo,xo,Zr,Qr,Ep,Tp,$p,Rp,es,Ap}from"./chunk-
|
|
2
|
+
import{bo,vo,wo,xo,Zr,Qr,Ep,Tp,$p,Rp,es,Ap}from"./chunk-y34tyrpb.js";import"./chunk-qwdcts9w.js";export{Ap as generateDefaultRobotsTxt,es as generateRobotsTxt,Tp as generateSitemap,$p as generateSitemapIndex,xo as injectSeoTags,Zr as metaDirective,bo as processMetaDirectives,wo as processSeoDirective,vo as processStructuredData,Ep as registerSeoDirectives,Rp as scanForSitemapEntries,Qr as structuredDataDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-78yjmbbs.js";import"./chunk-6beg47t4.js";import{g}from"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-78yjmbbs.js";import"./chunk-6beg47t4.js";import{g}from"./chunk-z35ftpqp.js";import"./chunk-qwdcts9w.js";import"./chunk-9wdd7eq6.js";import"./chunk-sqh3tvtw.js";import{Ft,Ps,zt,ui,ot,di,Is,Ht,fi,Vt}from"./chunk-028e9fty.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{di("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),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(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.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 pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-wk1gt95z.js"),p={},u=h(n);if(u)try{await g(u,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-wk1gt95z.js"),c={...r},n=h(e);if(n)try{await g(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Ht(t);at(t,r);let s=Vt(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=fi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await Ht(t);at(t,m);let f=Vt(t.config,m);if(ct(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{El,Hr}from"./chunk-ehzd1yc6.js";import"./chunk-xnx06qqt.js";import"./chunk-dxh45gve.js";import{ur}from"./chunk-z35ftpqp.js";import"./chunk-sqh3tvtw.js";import"./chunk-9wdd7eq6.js";import{tt}from"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{tt as freeIdentifiers,Hr as processComponents,El as processESImports,ur as rendersAsElement};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as
|
|
3
|
-
export{Fu,zu,Hu,Vu,jc,Uu,Wu,qu,Gu,
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as Gu}from"ts-broadcasting";import{Broadcast as Xu,BroadcastServer as Ju}from"ts-broadcasting";var e=null,u=[];function Fu(){return e}async function zu(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Hu(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function Vu(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();jc(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function jc(n,t,r){if(!i())return;s.send(n,t,r)}function Uu(n,t,r){if(!i())return;s.toUser(n,t,r)}function Wu(n,t,r){if(!i())return;s.toUsers(n,t,r)}function qu(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function Ku(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{Fu,zu,Hu,Vu,jc,Uu,Wu,qu,Ku,Gu,Xu,Ju};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st,dc}from"./chunk-78yjmbbs.js";import{T}from"./chunk-6beg47t4.js";import{L,is,s,an,F,se,Aa,It,fn,Me,Le}from"./chunk-
|
|
2
|
+
import{st,dc}from"./chunk-78yjmbbs.js";import{T}from"./chunk-6beg47t4.js";import{L,is,s,an,F,se,Aa,It,fn,Me,Le}from"./chunk-z35ftpqp.js";import{Yn}from"./chunk-5v7vm8cv.js";import{q}from"./chunk-a2zb5fgg.js";import{rn}from"./chunk-dxh45gve.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Q=65536,J=4,O=new Map;function hp(){O.clear()}function K(e){let o=[];for(let n of se(e,F)){let t=n.token.match(/^<script\b([^>]*)>/i),r=n.token.match(/<\/script\s*>$/i);if(!t||!r)continue;let a=t[0].length,f=n.token.length-r[0].length;o.push(Object.freeze({fullMatch:n.token,attrs:t[1],body:n.token.slice(a,f),start:n.start,end:n.end}))}return o}function Tl(e,o={}){let n=e.length>=Q,t=n?O.get(e):void 0;if(t===void 0){if(t=K(e),n)Aa(O,J),O.set(e,t)}let r=o.skipAttrs;if(!r)return t.slice();let a=[];for(let f of t)if(r.lastIndex=0,!r.test(f.attrs))a.push(f);return a}function co(e){let o=e.trim(),n=o.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(n){let r=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:c}=W(a);if(f)return{style:"as",iterable:r,itemVar:f,indexVar:c}}let t=o.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let r=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:c}=W(r);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:c}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function W(e){let o=e.trim(),n=o.match(/^(\w+)\s*=>\s*(\w+)$/);if(n)return{itemVar:n[2],indexVar:n[1]};let t=o.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let r=o.match(/^(\w+)\s*,\s*(\w+)$/);if(r)return{itemVar:r[1],indexVar:r[2]};let a=o.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Vr(e,o){return dc(e,o)}function Y(e){let o=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,n=0,t;while((t=o.exec(e))!==null){let r=t[1];if(r.startsWith("if"))n++;else if(r==="endif")n--;else if(n===0)return!0}return!1}function Xn(e){let o=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,r;while((r=n.exec(e))!==null){let a=r[1],f;while((f=t.exec(a))!==null)o.add(f[1])}return o}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let o=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),n=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=se(e,(a,f)=>{o.lastIndex=f;let c=o.exec(a);if(!c||c.index!==f||!n.test(c[2]))return-1;return o.lastIndex}),r=[];for(let a of t){o.lastIndex=0;let f=o.exec(a.token);if(!f)continue;let c=f[2].match(n),p=co(c?.[1]??c?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let i=f[1],g=/\/\s*>$/.test(a.token)||M.has(i.toLowerCase())?a.end:z(e,a.start,i,a.end);if(g!==-1)r.push({start:a.start,end:g,vars:new Set(h)})}return r}var B=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 te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function Z(e,o,n,t){if(!e)return!1;let r=te(e),a=!1,f=!1,c=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(r))!==null){let l=h[1];if(r.slice(0,h.index).trimEnd().endsWith("."))continue;if(B.has(l))continue;if(o.has(l)||t?.has(l))a=!0;else if(n&&l in n)f=!0}let i=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,u;while((u=i.exec(r))!==null){let l=u[1];if(r.slice(0,u.index).trimEnd().endsWith("."))continue;if(B.has(l)||n&&l in n)continue;c=!0}return(a||c)&&!f}function N(e,o,n){let t=n===void 0?` ${o}`:` ${o}="${n.replace(/"/g,""")}"`,r=e.trim(),a=r.match(H);if(a&&ne(a[3],a[1])){let[,f,c,p]=a;return`<${f}${c}${t}>${p}</${f}>`}return`<template${t}>${r}</template>`}function ne(e,o){let n=new RegExp(`<(/)?${o}(?=[\\s/>])`,"gi"),t=0,r;while((r=n.exec(e))!==null)if(r[1]){if(t--,t<0)return!1}else t++;return!0}function lo(e,o){let n=Xn(e);function t(r){let a=r,f=ee(r),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,i=[];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(),S=d,w=1,E=S,m=/@(if\s*\(|endif)/g;m.lastIndex=S;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))w++;else if(x[1]==="endif"){if(w--,w===0){E=x.index+x[0].length;break}}if(w!==0)continue;let y=a.substring(S,E-6).trim(),R;if(Y(y)){let _=rn(a.substring(u,E));if(_.length===0)continue;let I=_[0].branches.filter((v)=>v.type!=="else"),k=c(u);if(!(I.length>0&&I.every((v)=>Z(v.condition,n,o,k))))continue;R=_[0].branches.map((v)=>{let V=t(v.content);if(v.type==="elseif")return N(V,"@else-if",v.condition??"");if(v.type==="else")return N(V,"@else");return N(V,"@if",v.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!Z(b,n,o,c(u)))continue;R=N(t(y),"@if",b)}i.push({start:u,end:E,replacement:R}),p.lastIndex=E}for(let u=i.length-1;u>=0;u--){let{start:g,end:l,replacement:d}=i[u];a=a.substring(0,g)+d+a.substring(l)}return a}return t(e)}function re(e){let o=e.trim();if(o==="")return;if(o==="true")return!0;if(o==="false")return!1;if(o==="null")return!1;if(o==="undefined")return!1;if(o==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(o)){let r=Number(o);return r!==0&&!Number.isNaN(r)}let n=o.match(/^'((?:\\.|[^'\\])*)'$/);if(n)return n[1].length>0;let t=o.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var M=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),U=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function z(e,o,n,t){if(M.has(n.toLowerCase()))return t;let r=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}U.lastIndex=c;let h=U.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()===r){if(f--,c+=g[0].length,f===0)return c;continue}c+=g[0].length;continue}let i=/^<([a-z][\w-]*)\b/i.exec(e.slice(c,c+64));if(!i){c++;continue}let u=e.indexOf(">",c);if(u===-1)return-1;if(i[1].toLowerCase()===r){let g=e.slice(c,u+1);if(!(/\/\s*>$/.test(g)||M.has(r)))f++}c=u+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,o){let n=o,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 r=e.indexOf(">",n);if(r===-1)return!1;let a=e.slice(n,r+1);return ce.test(a)}function uo(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 o=[],n=/<([a-zA-Z][\w-]*)/y,t=/\s/,r=new Set([":if",":show","x-if","x-show","@if","@show"]);se(e,(i,u)=>{n.lastIndex=u;let g=n.exec(i);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=n.lastIndex,d;while(l<i.length){let b=l;while(l<i.length&&t.test(i[l]))l++;let S=l;if(i[S]==="/"){S++;while(S<i.length&&t.test(i[S]))S++}if(i[S]===">"){if(d)o.push({start:u,end:S+1,tag:g[1],...d});return-1}if(l===b)return-1;let w=l;while(l<i.length&&!t.test(i[l])&&i[l]!=="="&&i[l]!==">")l++;if(l===w)return-1;let E=i.slice(w,l);if(E.startsWith("@")&&E.includes("("))return-1;let m=l,x=l;while(x<i.length&&t.test(i[x]))x++;if(i[x]!=="="){l=m;continue}x++;while(x<i.length&&t.test(i[x]))x++;let y=i[x];if(y==='"'||y==="'"){let R=i.indexOf(y,x+1);if(R===-1)return-1;if(!d&&y==='"'&&r.has(E))d={attrName:E,attrStart:b,attrEnd:R+1,value:i.slice(x+1,R)};l=R+1}else{l=x;while(l<i.length&&!t.test(i[l])&&i[l]!==">")l++}}return-1});let a=[],f=-1;for(let i of o){let{start:u,end:g,tag:l,attrName:d,value:b}=i;if(u<f)continue;let S=re(b);if(S===void 0)continue;let m=/\/\s*>$/.test(e.slice(u,g))||M.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(S===!0){let y=e.slice(u,i.attrStart)+e.slice(i.attrEnd,g);a.push({start:u,end:g,replacement:y});continue}a.push({start:u,end:m,replacement:""}),f=m}if(a.length===0)return e;a.sort((i,u)=>i.start-u.start);let c=[],p=-1;for(let i of a){if(i.start<p)continue;c.push(i),p=i.end}let h=e;for(let i=c.length-1;i>=0;i--){let{start:u,end:g,replacement:l}=c[i];h=h.substring(0,u)+l+h.substring(g)}return h}var G=[":for","@for","x-for"];function Ur(e,o){if(!o||Object.keys(o).length===0)return e;if(!G.some((c)=>e.includes(`${c}=`)))return e;let n=Xn(e);if(Array.isArray(o.__stx_client_signal_names)){for(let c of o.__stx_client_signal_names)if(typeof c==="string")n.add(c)}let t=e,r=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(t))!==null){let[c,p,h]=f,i=f.index,u=i+c.length,g=G.map((R)=>({attr:R,m:new RegExp(`\\s${R}="([^"]*)"`).exec(h)})).find((R)=>R.m!==null);if(!g||!g.m)continue;let l=co(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||n.has(d)||!(d in o))continue;let b=z(t,i,p,u);if(b===-1)continue;let S=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),w=t.slice(u,b-`</${p}>`.length),E={...o,[l.itemVar]:void 0};if(l.indexVar)E[l.indexVar]=void 0;let m=Ur(w,E),x=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,y=p.toLowerCase()==="template"?m:`<${p}${S}>${m}</${p}>`;r.push({start:i,end:b,replacement:`@foreach(${x})${y}@endforeach`}),a.lastIndex=b}for(let c=r.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=r[c];t=t.slice(0,p)+i+t.slice(h)}return t}function Wr(e,o){let n=e,t=/@(for|foreach)\s*\(/g,r,a=[],f=[];while((r=t.exec(n))!==null){let c=r[1],p=r.index,h=p+r[0].length,i=1,u=h;while(u<n.length&&i>0){if(n[u]==="(")i++;else if(n[u]===")")i--;u++}if(i!==0)continue;let g=n.substring(h,u-1).trim(),l=u,d=co(g),b=c==="for"?"@endfor":"@endforeach",S=1,w=l,E=c==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${c}\\s*\\(|end${c})`,"g");E.lastIndex=l;let m;while((m=E.exec(n))!==null)if(m[1].startsWith(c))S++;else if(S--,S===0){w=m.index+m[0].length;break}if(S!==0)continue;let x=()=>{let A=[d.itemVar,d.indexVar].filter(Boolean);if(A.length)f.push({start:p,end:w,vars:A})};if(d.iterable){let A=d.iterable.trim();if(A.startsWith("[")||A.startsWith("{")||A.startsWith("'")||A.startsWith('"')||A.startsWith("`")||/^-?\d/.test(A)){x();continue}let C=A.split(/[.[(]/)[0].trim(),v=o?C in o:!1,V=f.some((P)=>p>P.start&&p<P.end&&P.vars.includes(C));if(C&&(v||V)){x();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let y=n.substring(l,w-b.length).trim(),R=o?{...o}:{};if(d.itemVar)delete R[d.itemVar];if(d.indexVar)delete R[d.indexVar];let _=Wr(y,R),I=_.match(H),k;if(I){let[,A,C,v]=I;k=`<${A}${C} @for="${g}">${v}</${A}>`}else k=`<template @for="${g}">${_}</template>`;a.push({start:p,end:w,replacement:k}),t.lastIndex=w}for(let c=a.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=a[c];n=n.substring(0,p)+i+n.substring(h)}return n}function le(e){let o=new Set,n=[],t=0,r=0,a=e.length,f=(i)=>{let u=t+1;while(u<a){let g=e[u];if(g==="\\"){u+=2;continue}if(g===i)return u+1;u++}return a},c=()=>{let i=t+2;while(i<a&&e[i]!==`
|
|
4
4
|
`)i++;return i},p=()=>{let i=t+2;while(i<a-1){if(e[i]==="*"&&e[i+1]==="/")return i+2;i++}return a},h=(i)=>{let u=i,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 i=e[t];if(i==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(i==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(i==='"'||i==="'"||i==="`"){let u=f(i);n.push(e.slice(t,u)),t=u;continue}if(i==="{"){r++,n.push(i),t++;continue}if(i==="}"){r--,n.push(i),t++;continue}if(r===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(o.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}o.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(i),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,o,n){for(let t of n){if(t.start>=o)return!1;if(t.end>e)return!0}return!1}function fe(e,o,n){let t=0;while(t<e.length){let r=e.indexOf(o,t);if(r===-1)return!1;if(!D(r,r+o.length,n))return!0;t=r+o.length}return!1}function de(e,o){if(fe(e,"<body",o)){let r=new RegExp(`<body(${j})>`,"g"),a;while((a=r.exec(e))!==null)if(!D(a.index,a.index+a[0].length,o))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=n.exec(e))!==null){if(D(t.index,t.index+t[0].length,o))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,o,n,t){let r=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)r.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else r.push(e.slice(f,h))};for(let h of o){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),r.join("")}async function qr(e,o,n,t={}){let r=Tl(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 s("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 i=e[t];if(i==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(i==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(i==='"'||i==="'"||i==="`"){let u=f(i);n.push(e.slice(t,u)),t=u;continue}if(i==="{"){r++,n.push(i),t++;continue}if(i==="}"){r--,n.push(i),t++;continue}if(r===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(o.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}o.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(i),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,o,n){for(let t of n){if(t.start>=o)return!1;if(t.end>e)return!0}return!1}function fe(e,o,n){let t=0;while(t<e.length){let r=e.indexOf(o,t);if(r===-1)return!1;if(!D(r,r+o.length,n))return!0;t=r+o.length}return!1}function de(e,o){if(fe(e,"<body",o)){let r=new RegExp(`<body(${j})>`,"g"),a;while((a=r.exec(e))!==null)if(!D(a.index,a.index+a[0].length,o))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=n.exec(e))!==null){if(D(t.index,t.index+t[0].length,o))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,o,n,t){let r=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)r.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else r.push(e.slice(f,h))};for(let h of o){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),r.join("")}async function qr(e,o,n,t={}){let r=Tl(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 s("stx/client-script-bundler",()=>import("./chunk-cs8wq7nv.js"));for(let m of r){let x=m.body;if(Me(m.attrs))x=Le(x);if(t.forceClientSetup||a.test(x)){f.push({content:x,start:m.start,end:m.end});continue}if(!c(x))continue;try{let y=await p(It(x).code,o||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(y))f.push({content:x,start:m.start,end:m.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let h=`${o??""}\x00${f.map((m)=>m.content).join("\x00")}`,i=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,u=[];for(let m=0;m<f.length;m++){let x=f[m].bundled??It(f[m].content).code;if(!f[m].bundled&&c(x))x=await p(x,o||"",{projectRoot:process.cwd()});x=ht(x);let y=T(x);u.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
|
|
6
6
|
${y}`)}let g=u.join(`
|
|
7
7
|
|
|
8
8
|
`);g=le(g);let d=L(g).split(",").map((m)=>m.trim()).filter(Boolean),b=fn(g,n),S=`
|