@stacksjs/stx 0.2.865 → 0.2.867
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-031dn0yr.js +2 -0
- package/dist/{chunk-98v8smzf.js → chunk-1mmyxay3.js} +1 -1
- package/dist/{chunk-hdyacfen.js → chunk-1vwgddct.js} +1 -1
- package/dist/chunk-23zpvmw5.js +2 -0
- package/dist/chunk-2h41y75x.js +2 -0
- package/dist/{chunk-et9pa7gr.js → chunk-2v0jdfhg.js} +1 -1
- package/dist/{chunk-764f1sf1.js → chunk-3a4tfycz.js} +1 -1
- package/dist/{chunk-efjmpq6r.js → chunk-3nyh76r3.js} +2 -2
- package/dist/{chunk-5ep1qbjt.js → chunk-4yhd0mg6.js} +1 -1
- package/dist/{chunk-w19myass.js → chunk-5tt1xbeh.js} +1 -1
- package/dist/{chunk-v4pswhj1.js → chunk-66eszw4f.js} +1 -1
- package/dist/{chunk-p8apfhg9.js → chunk-6c5g6sv6.js} +1 -1
- package/dist/{chunk-67xreg70.js → chunk-6d39636b.js} +3 -3
- package/dist/{chunk-4q0rgnw0.js → chunk-73c3awyw.js} +2 -2
- package/dist/{chunk-x95031qg.js → chunk-7fg2sj1z.js} +1 -1
- package/dist/{chunk-e8y2c1sq.js → chunk-7qmr1z81.js} +1 -1
- package/dist/{chunk-dy1d7ep7.js → chunk-9vzeea7p.js} +1 -1
- package/dist/{chunk-g8zgfmk3.js → chunk-a76dtc8w.js} +1 -1
- package/dist/chunk-acrgy1m7.js +2 -0
- package/dist/chunk-apkna83n.js +2 -0
- package/dist/{chunk-6pqfar3p.js → chunk-b3wc86ez.js} +1 -1
- package/dist/chunk-bx29jsqg.js +2 -0
- package/dist/{chunk-fbtm3frc.js → chunk-c6rcrh48.js} +2 -2
- package/dist/{chunk-angv3d3s.js → chunk-c9mkbjk5.js} +1 -1
- package/dist/{chunk-dx2t73jn.js → chunk-cr0msawk.js} +4 -4
- package/dist/chunk-cwdg0v05.js +2 -0
- package/dist/{chunk-razx95wk.js → chunk-cwdvmvc6.js} +1 -1
- package/dist/{chunk-j4mtcbvz.js → chunk-d0cjw1gn.js} +5 -5
- package/dist/{chunk-a2yk8sw0.js → chunk-d60bvtmy.js} +4 -4
- package/dist/{chunk-c60qda5c.js → chunk-ea5pm30m.js} +1 -1
- package/dist/{chunk-rb41t77f.js → chunk-efywv35k.js} +1 -1
- package/dist/{chunk-fnha6bbj.js → chunk-enxzwz0j.js} +2 -2
- package/dist/{chunk-16qzr5ga.js → chunk-f0kcmckh.js} +1 -1
- package/dist/chunk-fkbh874c.js +2 -0
- package/dist/{chunk-rkd27m4m.js → chunk-fpya25cc.js} +6 -6
- package/dist/{chunk-zacjg4p1.js → chunk-gxqcnn5r.js} +1 -1
- package/dist/{chunk-46x7a1cj.js → chunk-h1hcjx7e.js} +1 -1
- package/dist/{chunk-bzt73fj0.js → chunk-jn335zs0.js} +1 -1
- package/dist/{chunk-gwa31y9x.js → chunk-k15hxcgs.js} +1 -1
- package/dist/{chunk-f57t1bcs.js → chunk-kandgxsh.js} +1 -1
- package/dist/{chunk-x1zzy6c7.js → chunk-kd82s3ry.js} +1 -1
- package/dist/{chunk-8efn9agz.js → chunk-mnf4gktz.js} +2 -2
- package/dist/{chunk-mkyn95mf.js → chunk-mzr29qkj.js} +1 -1
- package/dist/{chunk-0dyec13e.js → chunk-pqjmse0r.js} +1 -1
- package/dist/{chunk-xempkjvd.js → chunk-q13dgfe1.js} +1 -1
- package/dist/{chunk-78eyz4ch.js → chunk-qbf8re0y.js} +1 -1
- package/dist/{chunk-9tsp5ytb.js → chunk-qvjxg8yz.js} +1 -1
- package/dist/{chunk-97cyjqa5.js → chunk-qx8czb2j.js} +1 -1
- package/dist/{chunk-hwqrejq3.js → chunk-rd751nw3.js} +1 -1
- package/dist/{chunk-xt1cxmkx.js → chunk-rnvw07ca.js} +2 -2
- package/dist/chunk-s21bj83r.js +3 -0
- package/dist/{chunk-w1vk83kx.js → chunk-t5jfh1bs.js} +1 -1
- package/dist/{chunk-zfd9dmsn.js → chunk-tzey0xq2.js} +4 -4
- package/dist/{chunk-c57g2mtw.js → chunk-v2712w9b.js} +1 -1
- package/dist/{chunk-fm9kas0a.js → chunk-v5kjwkz2.js} +1 -1
- package/dist/{chunk-86xt8cs8.js → chunk-vdj4m9z2.js} +1 -1
- package/dist/{chunk-ajkqbjbp.js → chunk-vkb353c3.js} +1 -1
- package/dist/{chunk-p2f308sq.js → chunk-w6k6nkvq.js} +1 -1
- package/dist/{chunk-yq0kcw7h.js → chunk-x5ap19jt.js} +1 -1
- package/dist/{chunk-aqn8y42n.js → chunk-xebx3ryb.js} +1 -1
- package/dist/{chunk-f5vdse5a.js → chunk-xfvedjvb.js} +1 -1
- package/dist/chunk-xzb0w6mf.js +2 -0
- package/dist/{chunk-gp7derwj.js → chunk-ywp7tmyg.js} +1 -1
- package/dist/{chunk-4sfrfag1.js → chunk-yzh9rsqp.js} +4 -4
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/floating-actions-web.d.ts +1 -0
- package/dist/native/floating-actions-web.js +6 -2
- package/dist/native/primitives/FloatingActions.stx +5 -2
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-2hq6mq6r.js +0 -2
- package/dist/chunk-2qjyzekc.js +0 -3
- package/dist/chunk-49r1z20v.js +0 -2
- package/dist/chunk-4b0mjyn7.js +0 -2
- package/dist/chunk-77km1je8.js +0 -2
- package/dist/chunk-822gnnpd.js +0 -2
- package/dist/chunk-c2bhc5wg.js +0 -2
- package/dist/chunk-tx6t331f.js +0 -2
- package/dist/chunk-z4yzk0d4.js +0 -2
- package/dist/chunk-z98qxjne.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ft,El}from"./chunk-qjey0jk6.js";import{N}from"./chunk-farh4p7f.js";import{q,Bs,o,ue,X,w,Uc,zt,kn,Ve,Ue}from"./chunk-
|
|
2
|
+
import{ft,El}from"./chunk-qjey0jk6.js";import{N}from"./chunk-farh4p7f.js";import{q,Bs,o,ue,X,w,Uc,zt,kn,Ve,Ue}from"./chunk-fpya25cc.js";import{mr}from"./chunk-cr0msawk.js";import{H}from"./chunk-8s6s6nd0.js";import{hn}from"./chunk-5dvkphbe.js";var U=`(?:"[^"]*"|'[^']*'|[^>"'])*`,G=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Q=65536,J=4,M=new Map;function Zh(){M.clear()}function K(e){let c=[];for(let t of w(e,X)){let n=t.token.match(/^<script\b([^>]*)>/i),s=t.token.match(/<\/script\s*>$/i);if(!n||!s)continue;let u=n[0].length,f=t.token.length-s[0].length;c.push(Object.freeze({fullMatch:t.token,attrs:n[1],body:t.token.slice(u,f),start:t.start,end:t.end}))}return c}function vs(e,c={}){let t=e.length>=Q,n=t?M.get(e):void 0;if(n===void 0){if(n=K(e),t)Uc(M,J),M.set(e,n)}let s=c.skipAttrs;if(!s)return n.slice();let u=[];for(let f of n)if(s.lastIndex=0,!s.test(f.attrs))u.push(f);return u}function Yo(e){let c=e.trim(),t=c.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(t){let s=t[1].trim(),u=t[2].trim(),{itemVar:f,indexVar:i}=D(u);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:i}}let n=c.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(n){let s=n[1].trim(),u=n[2].trim(),{itemVar:f,indexVar:i}=D(s);if(f)return{style:"in",iterable:u,itemVar:f,indexVar:i}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function D(e){let c=e.trim(),t=c.match(/^(\w+)\s*=>\s*(\w+)$/);if(t)return{itemVar:t[2],indexVar:t[1]};let n=c.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(n)return{itemVar:n[1],indexVar:n[2]||null};let s=c.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let u=c.match(/^(\w+)$/);if(u)return{itemVar:u[1],indexVar:null};return{itemVar:null,indexVar:null}}function xs(e,c){return El(e,c)}function Y(e){let c=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,t=0,n;while((n=c.exec(e))!==null){let s=n[1];if(s.startsWith("if"))t++;else if(s==="endif")t--;else if(t===0)return!0}return!1}function fr(e){let c=new Set,t=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,n=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=t.exec(e))!==null){let u=s[1],f;while((f=n.exec(u))!==null)c.add(f[1])}return c}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let c=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${U})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=w(e,(u,f)=>{c.lastIndex=f;let i=c.exec(u);if(!i||i.index!==f||!t.test(i[2]))return-1;return c.lastIndex}),s=[];for(let u of n){c.lastIndex=0;let f=c.exec(u.token);if(!f)continue;let i=f[2].match(t),p=Yo(i?.[1]??i?.[2]??""),m=[p.itemVar,p.indexVar].filter(Boolean);if(m.length===0)continue;let r=f[1],g=/\/\s*>$/.test(u.token)||O.has(r.toLowerCase())?u.end:j(e,u.start,r,u.end);if(g!==-1)s.push({start:u.start,end:g,vars:new Set(m)})}return s}var z=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 W(e,c,t,n){if(!e)return!1;let s=te(e),u=!1,f=!1,i=!1,p=/([a-zA-Z_$][\w$]*)/g,m;while((m=p.exec(s))!==null){let l=m[1];if(s.slice(0,m.index).trimEnd().endsWith("."))continue;if(z.has(l))continue;if(c.has(l)||n?.has(l))u=!0;else if(t&&l in t)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,a;while((a=r.exec(s))!==null){let l=a[1];if(s.slice(0,a.index).trimEnd().endsWith("."))continue;if(z.has(l)||t&&l in t)continue;i=!0}return(u||i)&&!f}function L(e,c,t){let n=t===void 0?` ${c}`:` ${c}="${t.replace(/"/g,""")}"`,s=e.trim(),u=s.match(G);if(u&&ne(u[3],u[1])){let[,f,i,p]=u;return`<${f}${i}${n}>${p}</${f}>`}return`<template${n}>${s}</template>`}function ne(e,c){let t=new RegExp(`<(/)?${c}(?=[\\s/>])`,"gi"),n=0,s;while((s=t.exec(e))!==null)if(s[1]){if(n--,n<0)return!1}else n++;return!0}function Zo(e,c){let t=fr(e);function n(s){let u=s,f=ee(s),i=(a)=>{let g=new Set;for(let l of f)if(a>l.start&&a<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,m,r=[];while((m=p.exec(u))!==null){let a=m.index,g=a+m[0].length,l=1,d=g;while(d<u.length&&l>0){if(u[d]==="(")l++;else if(u[d]===")")l--;d++}if(l!==0)continue;let b=u.substring(g,d-1).trim(),S=d,E=1,y=S,x=/@(if\s*\(|endif)/g;x.lastIndex=S;let h;while((h=x.exec(u))!==null)if(h[1].startsWith("if"))E++;else if(h[1]==="endif"){if(E--,E===0){y=h.index+h[0].length;break}}if(E!==0)continue;let R=u.substring(S,y-6).trim(),A;if(Y(R)){let C=hn(u.substring(a,y));if(C.length===0)continue;let T=C[0].branches.filter((_)=>_.type!=="else"),k=i(a);if(!(T.length>0&&T.every((_)=>W(_.condition,t,c,k))))continue;A=C[0].branches.map((_)=>{let V=n(_.content);if(_.type==="elseif")return L(V,"@else-if",_.condition??"");if(_.type==="else")return L(V,"@else");return L(V,"@if",_.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!W(b,t,c,i(a)))continue;A=L(n(R),"@if",b)}r.push({start:a,end:y,replacement:A}),p.lastIndex=y}for(let a=r.length-1;a>=0;a--){let{start:g,end:l,replacement:d}=r[a];u=u.substring(0,g)+d+u.substring(l)}return u}return n(e)}function se(e){let c=e.trim();if(c==="")return;if(c==="true")return!0;if(c==="false")return!1;if(c==="null")return!1;if(c==="undefined")return!1;if(c==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(c)){let s=Number(c);return s!==0&&!Number.isNaN(s)}let t=c.match(/^'((?:\\.|[^'\\])*)'$/);if(t)return t[1].length>0;let n=c.match(/^"((?:\\.|[^"\\])*)"$/);if(n)return n[1].length>0;return}var O=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),B=/<(script|style)\b/iy,re=/<\/script/gi,ie=/<\/style/gi;function j(e,c,t,n){if(O.has(t.toLowerCase()))return n;let s=t.toLowerCase(),u=e.length,f=1,i=n;while(i<u){let p=e.indexOf("<",i);if(p===-1)return-1;if(i=p,e.startsWith("<!--",i)){let g=e.indexOf("-->",i+4);if(g===-1)return-1;i=g+3;continue}B.lastIndex=i;let m=B.exec(e);if(m){let g=e.indexOf(">",i);if(g===-1)return-1;if(e[g-1]==="/"){i=g+1;continue}let l=m[1].toLowerCase()==="script"?re:ie;l.lastIndex=i;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;i=b+1;continue}if(e[i+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(i,i+64));if(!g){i++;continue}if(g[1].toLowerCase()===s){if(f--,i+=g[0].length,f===0)return i;continue}i+=g[0].length;continue}let r=/^<([a-z][\w-]*)\b/i.exec(e.slice(i,i+64));if(!r){i++;continue}let a=e.indexOf(">",i);if(a===-1)return-1;if(r[1].toLowerCase()===s){let g=e.slice(i,a+1);if(!(/\/\s*>$/.test(g)||O.has(s)))f++}i=a+1}return-1}var oe=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ce(e,c){let t=c,n=e.length;for(;;){while(t<n&&e[t]!=="<")t++;if(t>=n)return!1;if(e.startsWith("<!--",t)){let f=e.indexOf("-->",t+4);if(f===-1)return!1;t=f+3;continue}break}if(e[t+1]==="/")return!1;let s=e.indexOf(">",t);if(s===-1)return!1;let u=e.slice(t,s+1);return oe.test(u)}function Qo(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 c=[],t=/<([a-zA-Z][\w-]*)/y,n=/\s/,s=new Set([":if",":show","x-if","x-show","@if","@show"]);w(e,(r,a)=>{t.lastIndex=a;let g=t.exec(r);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=t.lastIndex,d;while(l<r.length){let b=l;while(l<r.length&&n.test(r[l]))l++;let S=l;if(r[S]==="/"){S++;while(S<r.length&&n.test(r[S]))S++}if(r[S]===">"){if(d)c.push({start:a,end:S+1,tag:g[1],...d});return-1}if(l===b)return-1;let E=l;while(l<r.length&&!n.test(r[l])&&r[l]!=="="&&r[l]!==">")l++;if(l===E)return-1;let y=r.slice(E,l);if(y.startsWith("@")&&y.includes("("))return-1;let x=l,h=l;while(h<r.length&&n.test(r[h]))h++;if(r[h]!=="="){l=x;continue}h++;while(h<r.length&&n.test(r[h]))h++;let R=r[h];if(R==='"'||R==="'"){let A=r.indexOf(R,h+1);if(A===-1)return-1;if(!d&&R==='"'&&s.has(y))d={attrName:y,attrStart:b,attrEnd:A+1,value:r.slice(h+1,A)};l=A+1}else{l=h;while(l<r.length&&!n.test(r[l])&&r[l]!==">")l++}}return-1});let u=[],f=-1;for(let r of c){let{start:a,end:g,tag:l,attrName:d,value:b}=r;if(a<f)continue;let S=se(b);if(S===void 0)continue;let x=/\/\s*>$/.test(e.slice(a,g))||O.has(l.toLowerCase())?g:j(e,a,l,g);if(x===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ce(e,x))continue;if(S===!0){let R=e.slice(a,r.attrStart)+e.slice(r.attrEnd,g);u.push({start:a,end:g,replacement:R});continue}u.push({start:a,end:x,replacement:""}),f=x}if(u.length===0)return e;u.sort((r,a)=>r.start-a.start);let i=[],p=-1;for(let r of u){if(r.start<p)continue;i.push(r),p=r.end}let m=e;for(let r=i.length-1;r>=0;r--){let{start:a,end:g,replacement:l}=i[r];m=m.substring(0,a)+l+m.substring(g)}return m}var Z=[":for","@for","x-for"];function Zf(e){let c=/(\s)((?::|@|x-|v-)[\w.:-]+)\s*=\s*"([^"]*\{\{[^"]*)"/g;return e.replace(c,(t,n,s,u)=>{let f=u.replace(/'((?:[^'\\]|\\.)*)'/g,(i,p)=>{if(!p.includes("{{"))return i;return`\`${p.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{\s*([^}]+?)\s*\}\}/g,(r,a)=>`\${${a}}`)}\``});return`${n}${s}="${f}"`})}function Ss(e,c){if(!c||Object.keys(c).length===0)return e;if(!Z.some((i)=>e.includes(`${i}=`)))return e;let t=fr(e);if(Array.isArray(c.__stx_client_signal_names)){for(let i of c.__stx_client_signal_names)if(typeof i==="string")t.add(i)}let n=e,s=[],u=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=u.exec(n))!==null){let[i,p,m]=f,r=f.index,a=r+i.length,g=Z.map((A)=>({attr:A,m:new RegExp(`\\s${A}="([^"]*)"`).exec(m)})).find((A)=>A.m!==null);if(!g||!g.m)continue;let l=Yo(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||t.has(d)||!(d in c))continue;let b=j(n,r,p,a);if(b===-1)continue;let S=m.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),E=n.slice(a,b-`</${p}>`.length),y={...c,[l.itemVar]:void 0};if(l.indexVar)y[l.indexVar]=void 0;let x=Ss(E,y),h=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,R=p.toLowerCase()==="template"?x:`<${p}${S}>${x}</${p}>`;s.push({start:r,end:b,replacement:`@foreach(${h})${R}@endforeach`}),u.lastIndex=b}for(let i=s.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=s[i];n=n.slice(0,p)+r+n.slice(m)}return n}function ks(e,c){let t=e,n=/@(for|foreach)\s*\(/g,s,u=[],f=[];while((s=n.exec(t))!==null){let i=s[1],p=s.index,m=p+s[0].length,r=1,a=m;while(a<t.length&&r>0){if(t[a]==="(")r++;else if(t[a]===")")r--;a++}if(r!==0)continue;let g=t.substring(m,a-1).trim(),l=a,d=Yo(g),b=i==="for"?"@endfor":"@endforeach",S=1,E=l,y=i==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${i}\\s*\\(|end${i})`,"g");y.lastIndex=l;let x;while((x=y.exec(t))!==null)if(x[1].startsWith(i))S++;else if(S--,S===0){E=x.index+x[0].length;break}if(S!==0)continue;let h=()=>{let v=[d.itemVar,d.indexVar].filter(Boolean);if(v.length)f.push({start:p,end:E,vars:v})};if(d.iterable){let v=d.iterable.trim();if(v.startsWith("[")||v.startsWith("{")||v.startsWith("'")||v.startsWith('"')||v.startsWith("`")||/^-?\d/.test(v)){h();continue}let I=v.split(/[.[(]/)[0].trim(),_=c?I in c:!1,V=f.some((P)=>p>P.start&&p<P.end&&P.vars.includes(I));if(I&&(_||V)){h();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let R=t.substring(l,E-b.length).trim(),A=c?{...c}:{};if(d.itemVar)delete A[d.itemVar];if(d.indexVar)delete A[d.indexVar];let C=Zf(ks(R,A)),T=C.match(G),k;if(T){let[,v,I,_]=T;k=`<${v}${I} @for="${g}">${_}</${v}>`}else k=`<template @for="${g}">${C}</template>`;u.push({start:p,end:E,replacement:k}),n.lastIndex=E}for(let i=u.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=u[i];t=t.substring(0,p)+r+t.substring(m)}return t}function ae(e){let c=new Set,t=[],n=0,s=0,u=e.length,f=(r)=>{let a=n+1;while(a<u){let g=e[a];if(g==="\\"){a+=2;continue}if(g===r)return a+1;a++}return u},i=()=>{let r=n+2;while(r<u&&e[r]!==`
|
|
4
4
|
`)r++;return r},p=()=>{let r=n+2;while(r<u-1){if(e[r]==="*"&&e[r+1]==="/")return r+2;r++}return u},m=(r)=>{let a=r,g=0;while(a<u){let l=e[a];if(l==="/"&&e[a+1]==="/"){let d=a+2;while(d<u&&e[d]!==`
|
|
5
|
-
`)d++;a=d;continue}if(l==="/"&&e[a+1]==="*"){let d=a+2;while(d<u-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;a=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=a+1;while(d<u){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}a=d;continue}if(l==="("||l==="["||l==="{"){g++,a++;continue}if(l===")"||l==="]"||l==="}"){g--,a++;continue}if(l===";"&&g===0)return a+1;a++}return u};while(n<u){let r=e[n];if(r==="/"&&e[n+1]==="/"){let a=i();t.push(e.slice(n,a)),n=a;continue}if(r==="/"&&e[n+1]==="*"){let a=p();t.push(e.slice(n,a)),n=a;continue}if(r==='"'||r==="'"||r==="`"){let a=f(r);t.push(e.slice(n,a)),n=a;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let a=n>0?e[n-1]:"";if(a===""||/\s/.test(a)||a===";"||a==="}"||a==="{"){let l=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=m(n+l[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=b;continue}c.add(d),t.push(e.slice(n,b)),n=b;continue}}}t.push(r),n++}return t.join("")}var le=new Set(["script","style","html","head","meta","link","title","!doctype"]);function fe(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${U})>`,"iy"),t=null,n=null;return w(e,(s,u)=>{c.lastIndex=u;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=u+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!le.has(i))t=p;return u+f[0].length}),n??t}function de(e,c,t,n){let s=[],u=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),u,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function _s(e,c,t,n={}){let s=vs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),u=/\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:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-
|
|
5
|
+
`)d++;a=d;continue}if(l==="/"&&e[a+1]==="*"){let d=a+2;while(d<u-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;a=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=a+1;while(d<u){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}a=d;continue}if(l==="("||l==="["||l==="{"){g++,a++;continue}if(l===")"||l==="]"||l==="}"){g--,a++;continue}if(l===";"&&g===0)return a+1;a++}return u};while(n<u){let r=e[n];if(r==="/"&&e[n+1]==="/"){let a=i();t.push(e.slice(n,a)),n=a;continue}if(r==="/"&&e[n+1]==="*"){let a=p();t.push(e.slice(n,a)),n=a;continue}if(r==='"'||r==="'"||r==="`"){let a=f(r);t.push(e.slice(n,a)),n=a;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let a=n>0?e[n-1]:"";if(a===""||/\s/.test(a)||a===";"||a==="}"||a==="{"){let l=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=m(n+l[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=b;continue}c.add(d),t.push(e.slice(n,b)),n=b;continue}}}t.push(r),n++}return t.join("")}var le=new Set(["script","style","html","head","meta","link","title","!doctype"]);function fe(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${U})>`,"iy"),t=null,n=null;return w(e,(s,u)=>{c.lastIndex=u;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=u+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!le.has(i))t=p;return u+f[0].length}),n??t}function de(e,c,t,n){let s=[],u=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),u,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function _s(e,c,t,n={}){let s=vs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),u=/\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:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-7fg2sj1z.js"));for(let x of s){let h=x.body;if(Ve(x.attrs))h=Ue(h);if(n.forceClientSetup||u.test(h)){f.push({content:h,start:x.start,end:x.end});continue}if(!i(h))continue;try{let R=await p(zt(h).code,c||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(u.test(R))f.push({content:h,start:x.start,end:x.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let m=`${c??""}\x00${f.map((x)=>x.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(m).toString(36).slice(0,10)}`,a=[];for(let x=0;x<f.length;x++){let h=f[x].bundled??zt(f[x].content).code;if(!f[x].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=Ct(h);let R=N(h);a.push(`// \u2500\u2500 merged signal script #${x+1} \u2500\u2500
|
|
6
6
|
${R}`)}let g=a.join(`
|
|
7
7
|
|
|
8
8
|
`);g=ae(g);let d=q(g).split(",").map((x)=>x.trim()).filter(Boolean),b=kn(g,t),S=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V,rg,ri,$c,a,M,iy,ay}from"./chunk-
|
|
2
|
+
import{V,rg,ri,$c,a,M,iy,ay}from"./chunk-rnvw07ca.js";import"./chunk-t5jfh1bs.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-83tvkw4y.js";import"./chunk-kh6njq2r.js";import"./chunk-fpya25cc.js";import"./chunk-pqjmse0r.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{M as config,V as defaultConfig,iy as defineStxConfig,ri as discoverConfig,a as loadStxConfig,$c as resolveInstalledPackage,rg as resolveStxDirectories,ay as validateConfig};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{vr}from"./chunk-kh6njq2r.js";import{Nr}from"./chunk-g0xn80gz.js";import{a}from"./chunk-
|
|
2
|
+
import{vr}from"./chunk-kh6njq2r.js";import{Nr}from"./chunk-g0xn80gz.js";import{a}from"./chunk-rnvw07ca.js";import{H,nt}from"./chunk-8s6s6nd0.js";import{_c}from"./chunk-hmdkf6c6.js";import{D,c}from"./chunk-fd1bpv35.js";var x=/<style\b[^>]*>/iy,R=/<\/style>/gi,b=/<script\b[^>]*>/iy,S=/<template(?=[\s>/])[^>]*>/iy,w=/<\/template\s*>/iy;function gr(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let g=e.indexOf("-->",n+4);r=g===-1?e.length:g+3;continue}x.lastIndex=n;let u=x.exec(e);if(u){R.lastIndex=n+u[0].length;let g=R.exec(e);r=g===null?e.length:g.index+8;continue}S.lastIndex=n;let o=S.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}w.lastIndex=n;let d=w.exec(e);if(d){if(t>0)t--;r=n+d[0].length;continue}if(b.lastIndex=n,b.test(e))return t>0?s:n;r=n+1}return-1}function Z(e,r={}){return new vr(e,r).routes}import y from"path";var T=new Map;async function h(e,r){let t=e,s=r;if(!t||!s)try{let d=await a();t||=d?.pagesDir||"pages",s||=d?.root||"."}catch{t||="pages",s||="."}let n=y.isAbsolute(t)?t:y.join(s,t),u=T.get(n);if(u)return u;let o=[];try{o=Z(".",{pagesDir:n,emit:!1}).map((d)=>d.regex.source).filter(Boolean)}catch{o=[]}return T.set(n,o),o}function E(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return E(JSON.stringify(e))}function ke(e){return e.includes("data-stx-runtime")}function Sc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function p(e,r){let t=gr(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
|
|
3
3
|
`+e.slice(t);let n=Nr(e);if(n!==null)return`${e.slice(0,n)}
|
|
4
4
|
${r}${e.slice(n)}`;if(e.includes("</head>")){let o=D(e);return e.slice(0,o)+r+`
|
|
5
5
|
`+e.slice(o)}if(H(e))return nt(e,(o)=>`${o}
|
|
6
6
|
${r}`);return`${r}
|
|
7
|
-
${e}`}async function mr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-
|
|
7
|
+
${e}`}async function mr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-2v0jdfhg.js"),{url:u}=await n("runtime",r.debug===!0);return p(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return p(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-2v0jdfhg.js"),s=await t(r.debug);return p(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function O(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function kc(e){if(e.includes("data-stx-tooltip-runtime")||!O(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${_c()}</script>`,t=c(e);if(t===-1)return`${e}
|
|
8
8
|
${r}`;return`${e.slice(0,t)}${r}
|
|
9
|
-
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function M(e){return C.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function _e(e,r){if(!e.includes("</body>"))return e;if(M(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:_}=await import("./chunk-
|
|
9
|
+
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function M(e){return C.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function _e(e,r){if(!e.includes("</body>"))return e;if(M(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:_}=await import("./chunk-2v0jdfhg.js");n=`<script data-stx-owned-routes src="${_(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(f)};
|
|
10
10
|
`)}"></script>
|
|
11
11
|
`}else i.ownedRoutes=f}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${l(i)};</script>
|
|
12
|
-
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-
|
|
12
|
+
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-2v0jdfhg.js"),d=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,g=c(e);return e.slice(0,g)+s+n+d+`
|
|
13
13
|
</body>`+e.slice(g+7)}
|
|
14
14
|
export{gr,Z,ke,Sc,mr,kc,_e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{dm}from"./chunk-7qmr1z81.js";import"./chunk-6d39636b.js";import"./chunk-qx8czb2j.js";import"./chunk-3a4tfycz.js";import"./chunk-s21bj83r.js";import"./chunk-cr0msawk.js";import"./chunk-rnvw07ca.js";import"./chunk-t5jfh1bs.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-83tvkw4y.js";import"./chunk-kh6njq2r.js";import"./chunk-fpya25cc.js";import"./chunk-pqjmse0r.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{dm as startProductionServer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ym,Aa,_u,Zm,Qm,eh,th,nh,Cu,Eu,rh,sh,oh,ih}from"./chunk-
|
|
2
|
+
import{Ym,Aa,_u,Zm,Qm,eh,th,nh,Cu,Eu,rh,sh,oh,ih}from"./chunk-qvjxg8yz.js";import"./chunk-d60bvtmy.js";import"./chunk-73c3awyw.js";import"./chunk-tzey0xq2.js";import"./chunk-q1wxgw5s.js";import"./chunk-h1hcjx7e.js";import"./chunk-s21bj83r.js";import"./chunk-q13dgfe1.js";import"./chunk-jbgj2hph.js";import"./chunk-c6rcrh48.js";import"./chunk-cr0msawk.js";import"./chunk-5dvkphbe.js";import"./chunk-kandgxsh.js";import"./chunk-rnvw07ca.js";import"./chunk-t5jfh1bs.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-83tvkw4y.js";import"./chunk-kh6njq2r.js";import"./chunk-fpya25cc.js";import"./chunk-pqjmse0r.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{_u as SUSPENSE_RESOLVER_RUNTIME,Aa as buildSuspenseResolveScript,nh as createStreamRenderer,eh as extractStreamBoundaries,ih as generateHydrationRuntime,Eu as islandDirective,sh as processSectionDirectives,Qm as processStreamDirectives,rh as registerStreamingDirectives,Zm as renderStreamingPage,Ym as streamTemplate,th as streamTemplateSimple,oh as streamToResponse,Cu as streamingSuspenseDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{he,vn,Bt,Ft,h,s,be,g}from"./chunk-
|
|
2
|
+
import{he,vn,Bt,Ft,h,s,be,g}from"./chunk-fpya25cc.js";import{kt,Ne,hc,ps,zo,Ho,i}from"./chunk-d60bvtmy.js";import{pe,re,Or,$e,U,Rn}from"./chunk-g0xn80gz.js";import{$t,wr,Ns,Ds,Ms,Rt,At,Pt,It,Ot,Nt,ot}from"./chunk-kh6njq2r.js";import{$s,a,M}from"./chunk-rnvw07ca.js";import{wt,en,Ae,z,wa,So,Qr,Je,va,Ye,Pe}from"./chunk-6d39636b.js";import{hr,yr}from"./chunk-kandgxsh.js";import{e,mn,dr,x}from"./chunk-73c3awyw.js";import{tt}from"./chunk-tzey0xq2.js";import{Oe}from"./chunk-9zrvh3pz.js";import{Dn}from"./chunk-7qmr1z81.js";import{Z,ke,_e}from"./chunk-cr0msawk.js";import{l}from"./chunk-46pxmpeb.js";import{Y}from"./chunk-bwdbj60y.js";import{c,f}from"./chunk-fd1bpv35.js";async function Wn(t){try{let n=await Bun.file(t).text(),r=Vn(n),p=qn(n,t),o=Kn(n,r),d=Xn(n,r);return{file:t,metrics:r,issues:p,suggestions:o,performance:d}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Vn(t){let n=t.split(`
|
|
3
3
|
`),r=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),o=(r?r[1]:"").split(`
|
|
4
4
|
`).length,d={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};d.total=d.conditionals+d.loops+d.includes+d.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,m=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,y=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,b=u+m+y,w=(t.match(/<[A-Z][^>]*>/g)||[]).length,S=(t.match(/@(?:layout|extends)\(/g)||[]).length,T=0,R=0;for(let C of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(C)&&!/@end/.test(C)&&!/@else/.test(C))R++,T=Math.max(T,R);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(C))R--;let k=T>=4?3:0,v=Math.min(10,Math.ceil(d.total*0.5+b*0.1+w*0.3+(o>10?o*0.05:0)+k));return{lines:n.length,characters:t.length,directives:d,expressions:b,components:w,layouts:S,scriptLines:o,complexity:v}}function qn(t,n){let r=[],p=Yt(t,"if","endif");if(p>0)r.push({type:"error",category:"syntax",message:`Found ${p} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let o=Yt(t,"foreach","endforeach");if(o>0)r.push({type:"error",category:"syntax",message:`Found ${o} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)r.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)r.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=t.match(/<img[^>]*>/g);if(m){let w=m.filter((S)=>!S.includes("alt="));if(w.length>0)r.push({type:"warning",category:"accessibility",message:`Found ${w.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let y=t.split(`
|
|
5
5
|
`).filter((w)=>w.length>120);if(y.length>0)r.push({type:"info",category:"maintainability",message:`Found ${y.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let b=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(b>3)r.push({type:"info",category:"maintainability",message:`Found ${b} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return r}function Kn(t,n){let r=[];if(n.complexity>7)r.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)r.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)r.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)r.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let p=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)r.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)r.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)r.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return r}function Xn(t,n){let r=1;if(r+=n.directives.conditionals*0.1,r+=n.directives.loops*0.5,r+=n.directives.includes*2,r+=n.expressions*0.05,r+=n.components*1,n.scriptLines>10)r+=n.scriptLines*0.1;let p;if(n.expressions===0&&n.directives.total===0)p="high";else if(n.expressions<5&&n.directives.total<3)p="medium";else p="low";let o=[];if(r>10)o.push("Consider optimizing template complexity");if(p==="low"&&n.directives.total>5)o.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)o.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(r*100)/100,complexityScore:n.complexity,cacheability:p,recommendations:o}}function Yt(t,n,r){let p=t.replace(/<!--[\s\S]*?-->/g,""),o=(p.match(new RegExp(`@${n}\\b`,"g"))||[]).length,d=(p.match(new RegExp(`@${r}\\b`,"g"))||[]).length;return Math.abs(o-d)}async function ia(t=["**/*.stx"],n){let r=[],p=[];for(let d of t){let u=await Array.fromAsync(new Bun.Glob(d).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));p.push(...u.filter((m)=>m.endsWith(".stx")))}for(let d of p)try{let u=await Wn(d);r.push(u)}catch(u){console.warn(`Failed to analyze ${d}:`,u)}let o=Gn(r);return{results:r,summary:o}}function Gn(t){let n=t.length,r=t.reduce((b,w)=>b+w.metrics.lines,0),p=n>0?t.reduce((b,w)=>b+w.metrics.complexity,0)/n:0,o=t.reduce((b,w)=>b+w.issues.length,0),d={};t.forEach((b)=>{b.issues.forEach((w)=>{d[w.category]=(d[w.category]||0)+1})});let u=n>0?t.reduce((b,w)=>b+w.performance.estimatedRenderTime,0)/n:0,m=Math.max(1,Math.min(10,Math.round(10-u/2-p/2))),y=[];if(p>6)y.push("Project has high average complexity. Consider refactoring complex templates.");if(o>n*2)y.push("High number of issues detected. Run detailed analysis on individual files.");if(d.security>0)y.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:r,avgComplexity:Math.round(p*100)/100,totalIssues:o,issuesByCategory:d,performanceScore:m,recommendations:y}}import{mkdir as Jn,readFile as Yn,readdir as Qn,stat as Qt,writeFile as Zn}from"fs/promises";import Te from"path";function sn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var an=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function er(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function tr(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function nr(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function rr(t){let n=[];async function r(p){let o=await Qn(p,{withFileTypes:!0});o.sort((d,u)=>d.name.localeCompare(u.name));for(let d of o){let u=Te.join(p,d.name);if(d.isDirectory()){if(!d.name.startsWith(".")&&d.name!=="node_modules")await r(u)}else if(d.isFile()&&d.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(d.name))n.push(u)}}return await r(t),n}function or(t,n){let r=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!r)return{};let p=r[1].trim();if(!p)return{};try{return JSON.parse(p)}catch(o){throw Error(`${n}: <script component> must contain JSON metadata (${o.message})`)}}function sr(t,n){let r={},p=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let o of p){if(!/\bclient\b/i.test(o[1])||/\bcomponent\b|\bstx:component\b/i.test(o[1]))continue;let d;try{d=new Bun.Transpiler({loader:"ts"}).transformSync(o[2])}catch(y){throw Error(`${n}: failed to transpile <script client> (${y.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,m;while(m=u.exec(d)){let y=m[1];if(an.has(y))throw Error(`${n}: client ${sn(y)}`);let b=u.lastIndex,w=1,S="",T=!1,R=b;for(;R<d.length&&w>0;R++){let v=d[R];if(T){T=!1;continue}if(S){if(v==="\\")T=!0;else if(v===S)S="";continue}if(v==='"'||v==="'"||v==="`")S=v;else if(v==="{")w++;else if(v==="}")w--}if(w!==0)throw Error(`${n}: unterminated client function "${y}"`);let k=m[0].includes("async")?"async ":"";r[y]=`${k}${y}(${m[2]}) {${d.slice(b,R-1)}}`,u.lastIndex=R}}return r}function ir(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Zt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
|
|
@@ -887,7 +887,7 @@ else {
|
|
|
887
887
|
};
|
|
888
888
|
})();
|
|
889
889
|
</script>
|
|
890
|
-
`}function We(t,n,r={}){let p=Fr(n,r),o=c(t);if(o!==-1)return t.slice(0,o)+p+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${p}</html>`);return t+p}function bt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function xt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((p)=>n.endsWith(p))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var rt=null;function St(t){if(!rt)rt=new cn(t);return rt}function ct(){if(rt)rt.stop(),rt=null}import Tt from"path";var st={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},p=new Set,o=r.webComponents?.enabled?`./${Tt.relative(Tt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",d=[];if(r.webComponents?.enabled)try{let u=await $s(r,p);if(d.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(r.cache&&r.cachePath){let v=await hr(u,r);if(v){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:v,loader:"html"}}}let y=await $e(()=>Bun.file(u).text(),"",(v)=>{throw new Or(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${v.message}`)});if(!y)throw new Or(`stx file is empty: ${u}`,u);let{scriptContent:b,templateContent:w,allScripts:S}=pe.time("script-extraction",()=>{let v=y,C=he(y);if(C)v=C.content.trim();let L=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",P=[];for(let E of L){let _=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",j=E.match(/<script\b([^>]*)>/i),K=j?j[1]:"";if(/\bserver\b/i.test(K))O=_;else P.push(E)}let D=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:D,allScripts:P}}),T={__filename:u,__dirname:Tt.dirname(u),__stx:{webComponentsPath:o,builtComponents:d}};await $e(()=>h(b,T,u),void 0,(v)=>{let C=new re(`Script execution failed in ${u}: ${v.message}`,u,void 0,void 0,b.substring(0,100));if(U.log(C,{filePath:u,scriptContent:b}),r.debug)throw C});let k=await pe.timeAsync("directive-processing",async()=>await i(w,T,u,r,m));if(S.length>0){let{interpolateScriptsInTemplate:v}=await import("./chunk-
|
|
890
|
+
`}function We(t,n,r={}){let p=Fr(n,r),o=c(t);if(o!==-1)return t.slice(0,o)+p+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${p}</html>`);return t+p}function bt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function xt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((p)=>n.endsWith(p))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var rt=null;function St(t){if(!rt)rt=new cn(t);return rt}function ct(){if(rt)rt.stop(),rt=null}import Tt from"path";var st={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},p=new Set,o=r.webComponents?.enabled?`./${Tt.relative(Tt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",d=[];if(r.webComponents?.enabled)try{let u=await $s(r,p);if(d.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(r.cache&&r.cachePath){let v=await hr(u,r);if(v){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:v,loader:"html"}}}let y=await $e(()=>Bun.file(u).text(),"",(v)=>{throw new Or(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${v.message}`)});if(!y)throw new Or(`stx file is empty: ${u}`,u);let{scriptContent:b,templateContent:w,allScripts:S}=pe.time("script-extraction",()=>{let v=y,C=he(y);if(C)v=C.content.trim();let L=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",P=[];for(let E of L){let _=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",j=E.match(/<script\b([^>]*)>/i),K=j?j[1]:"";if(/\bserver\b/i.test(K))O=_;else P.push(E)}let D=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:D,allScripts:P}}),T={__filename:u,__dirname:Tt.dirname(u),__stx:{webComponentsPath:o,builtComponents:d}};await $e(()=>h(b,T,u),void 0,(v)=>{let C=new re(`Script execution failed in ${u}: ${v.message}`,u,void 0,void 0,b.substring(0,100));if(U.log(C,{filePath:u,scriptContent:b}),r.debug)throw C});let k=await pe.timeAsync("directive-processing",async()=>await i(w,T,u,r,m));if(S.length>0){let{interpolateScriptsInTemplate:v}=await import("./chunk-v2712w9b.js"),C=v(S.join(`
|
|
891
891
|
`),T),L=k.search(/<\/body>/i);if(L!==-1)k=k.slice(0,L)+C+`
|
|
892
892
|
`+k.slice(L);else k+=`
|
|
893
893
|
${C}`}if(k=await _e(k),m.forEach((v)=>p.add(v)),r.cache&&r.cachePath){if(await yr(u,k,m,r),r.debug)console.log(`Cached template ${u} with ${m.size} dependencies`)}return{contents:k,loader:"html"}}catch(m){let y=m instanceof Error?m:new re(`Plugin processing failed: ${String(m)}`,u);if(U.log(y,{filePath:u,buildConfig:t.config}),Rn.logDetailedError(y,{filePath:u,plugin:"bun-plugin-stx"}),r.debug)console.error("stx Plugin Error:",y);let b=y,w=b.line||null,S=b.context||null;return{contents:r.debug||Y()?`<!DOCTYPE html>
|
|
@@ -950,7 +950,7 @@ ${C}`}if(k=await _e(k),m.forEach((v)=>p.add(v)),r.cache&&r.cachePath){if(await y
|
|
|
950
950
|
<h1>Something went wrong</h1>
|
|
951
951
|
<p>An internal error occurred. Please try again later.</p>
|
|
952
952
|
</body>
|
|
953
|
-
</html>`,loader:"html"}}})}};async function Kr(t,n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=ge.resolve(t);if(!Fe.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Wt(m,n);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let y=l(process.cwd(),"output");Fe.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let b=null,w=async()=>{try{let _={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(de)=>({path:de.path,external:!0}))}},j=await Bun.build({entrypoints:[m],outdir:y,plugins:[_,st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!j.success)return console.error(`${e.red}Build failed:${e.reset}`,j.logs),!1;let K=j.outputs.find((ve)=>ve.path.endsWith(".html"));if(!K)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return b=await Bun.file(K.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await w())return!1;let T=ge.dirname(m);await mn(T);let R=r;try{if(R=await qe(r),R!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let _=n.hmrPort||R+1;d=St({wsPort:_,verbose:!1}),u=d.start(_)}let k={},v=null,C;try{let{loadStxConfig:_}=await import("./chunk-
|
|
953
|
+
</html>`,loader:"html"}}})}};async function Kr(t,n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=ge.resolve(t);if(!Fe.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Wt(m,n);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let y=l(process.cwd(),"output");Fe.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let b=null,w=async()=>{try{let _={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(de)=>({path:de.path,external:!0}))}},j=await Bun.build({entrypoints:[m],outdir:y,plugins:[_,st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!j.success)return console.error(`${e.red}Build failed:${e.reset}`,j.logs),!1;let K=j.outputs.find((ve)=>ve.path.endsWith(".html"));if(!K)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return b=await Bun.file(K.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await w())return!1;let T=ge.dirname(m);await mn(T);let R=r;try{if(R=await qe(r),R!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let _=n.hmrPort||R+1;d=St({wsPort:_,verbose:!1}),u=d.start(_)}let k={},v=null,C;try{let{loadStxConfig:_}=await import("./chunk-bx29jsqg.js"),j=await _();if(C=n.stxOptions?.serverApi??j.serverApi,j?.apiRouter)v=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){k=j.apiRoutes;let K=Object.keys(k).length;if(K>0)console.log(`${e.blue}Loaded ${e.bright}${K} API route${K>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:K,loadChannels:Q}=await import("./chunk-rqa92xm4.js"),ve=j.broadcasting;await K(ve);let de=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${de}/ws${e.reset}`);let Re=ge.join(process.cwd(),"channels.ts");if(Fe.existsSync(Re))try{let se=await Q(Re);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(K){console.warn(`${e.yellow}Broadcasting failed to start: ${K.message}${e.reset}`)}}catch{}let{createServerApi:L,isServerApiSource:O}=await import("./chunk-4yhd0mg6.js"),P=await L(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let D=zr({port:R,async fetch(_){return Dn(_,await(async()=>{let j=new URL(_.url);if([y,ge.dirname(m),ge.join(process.cwd(),"public")].some((se)=>O(ge.join(se,j.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(v)try{let se=await v.handleRequest(_);if(se.status!==404)return se}catch{}if(k[j.pathname])try{return await k[j.pathname](_)}catch(se){return new Response(JSON.stringify({error:se.message}),{status:500,headers:{"Content-Type":"application/json"}})}let K=await P(_);if(K)return K;if(j.pathname==="/")return(async()=>{let N=await x(b||"");if(o)N=We(N,u);if(n.native)if(N.includes("<head>"))N=N.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(n.titlebarHidden)if(N.includes("<head>"))N=N.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;return N})().then((N)=>new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Q=ge.join(y,j.pathname);if(Fe.existsSync(Q)&&Fe.statSync(Q).isFile()){let se=Bun.file(Q),N=ge.extname(Q).toLowerCase(),I="text/plain";if(N===".ts"||N===".tsx"){let ze=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Ue=await se.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":I}})}let ve=ge.dirname(m),de=ge.join(ve,j.pathname);if(Fe.existsSync(de)&&Fe.statSync(de).isFile()){let se=Bun.file(de),N=ge.extname(de).toLowerCase(),I="text/plain";if(N===".ts"||N===".tsx"){let ze=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Ue=await se.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":I}})}let Re=ge.join(process.cwd(),"public",j.pathname);if(Fe.existsSync(Re)&&Fe.statSync(Re).isFile()){let se=Bun.file(Re),N=ge.extname(Re).toLowerCase(),I="application/octet-stream";if(N===".ts"||N===".tsx"){let ze=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),Ue=await se.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(se,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})})())},error(_){return new Response(`<pre>${_}
|
|
954
954
|
${_.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
955
955
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
956
956
|
${e.bright}\u2192 ${e.cyan}http://localhost:${R}/${e.reset}`),console.log(`
|
|
@@ -1435,12 +1435,12 @@ ${k.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
1435
1435
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1436
1436
|
${e.bright}\u2192 ${e.cyan}http://localhost:${w}/${e.reset}`),console.log(`
|
|
1437
1437
|
${e.yellow}Routes:${e.reset}`);let T=new Set(m.map((k)=>k.routeTemplate)),R=Object.entries(u).filter(([k])=>!T.has(k)).sort(([k],[v])=>k.localeCompare(v)).map(([k,v])=>({route:k==="/"?"/":k,filePath:Ce.relative(process.cwd(),v.filePath),fileType:v.fileType}));for(let k of m){let v=k.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");R.push({route:v,filePath:Ce.relative(process.cwd(),k.filePath),fileType:"stx"})}if(R.sort((k,v)=>k.route.localeCompare(v.route)),R.forEach((k,v)=>{let L=v===R.length-1?"\u2514\u2500 ":"\u251C\u2500 ",O=k.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${L}${k.route}${e.reset} \u2192 ${e.bright}${k.filePath}${e.reset} ${O}`)}),console.log(`
|
|
1438
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(S.url.toString(),()=>{if(p)Xe.watch(d,{recursive:!0}).close();S.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let k=Xe.watch(d,{recursive:!0},async(v,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),tt.clear(),be(),await y()});process.on("SIGINT",()=>{k.close(),S.stop(),process.exit(0)})}return!0}function dn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import me from"fs";import oe from"path";async function un(t){try{return vn(await Bun.file(t).text())}catch{return}}function Vt(t){let n=Bun.file(t),r=oe.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},d=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":p[r]||"application/octet-stream",...d}})}async function Xr(t=".",n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=oe.resolve(t),{loadStxConfig:y}=await import("./chunk-822gnnpd.js"),b=await y(m),{createServerApi:w,isServerApiSource:S}=await import("./chunk-5ep1qbjt.js"),T=n.stxOptions?.serverApi??b.serverApi,R=await w(m,T),k=b.root&&b.root!=="."?oe.join(m,b.root):m,v=n.pagesDir||b.pagesDir||"pages",C=oe.join(k,v);if(!me.existsSync(C)&&!b._layerPageDirs?.some((A)=>me.existsSync(A)))return console.error(`${e.red}Error: No '${v}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${v}/index.stx for the homepage.${e.reset}`),!1;let L=Z(k,{pagesDir:v,pagesDirs:b._layerPageDirs?[C,...b._layerPageDirs.slice(1)]:void 0});if(L.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${L.length}${e.blue} routes${e.reset}`);let O=b?._pluginPageDirs||[],P=[];for(let{dir:A,prefix:B}of O)if(me.existsSync(A)){let W=Z(oe.dirname(A),{pagesDir:oe.basename(A)});for(let ee of W){let X=B==="/"?ee.pattern:`${B}${ee.pattern==="/"?"":ee.pattern}`;P.push({route:{...ee,pattern:X},prefix:B})}if(W.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${W.length}${e.blue} routes at ${e.cyan}${B}${e.reset}`)}let D=new Map,E=null,_=null;if(n.stxOptions?.shell!==!1){if(_=await wa(m,n.stxOptions?.shell),_){if(E=await So(_,n.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Rt(),await Pt(m);let j=At();if(j.length>0)console.log(`${e.blue}Loaded ${e.bright}${j.length}${e.blue} middleware: ${e.dim}${j.join(", ")}${e.reset}`);let K={},Q=null;try{let{loadStxConfig:A}=await import("./chunk-822gnnpd.js"),B=await A(m);if(B?.apiRouter)Q=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){K=B.apiRoutes;let W=Object.keys(K).length;if(W>0)console.log(`${e.blue}Loaded ${e.bright}${W} API route${W>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:W,loadChannels:ee}=await import("./chunk-rqa92xm4.js"),X=B.broadcasting;await W(X);let Ee=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ee}/ws${e.reset}`);let we=oe.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let V=await ee(we);console.log(`${e.blue}Loaded ${e.bright}${V} broadcast channel${V!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(V){console.warn(`${e.yellow}Failed to load channels.ts: ${V.message}${e.reset}`)}}catch(W){console.warn(`${e.yellow}Broadcasting failed to start: ${W.message}${e.reset}`)}}catch{}let ve=l(m,"output");me.mkdirSync(ve,{recursive:!0});let de=new Map,Re=new Set,se=async(A)=>{let B=Ds(C,A);if(!B)return null;try{let W=await Bun.build({entrypoints:[B],outdir:ve,plugins:[st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!W.success)return null;let ee=W.outputs.find((X)=>X.path.endsWith(".html"));if(!ee)return null;return await Bun.file(ee.path).text()}catch{return null}},N=new Map,I=async(A,B)=>{try{let{processDirectives:W,extractVariables:ee,defaultConfig:X,loadStxConfig:Ee,injectRouterScript:we}=await import("./chunk-822gnnpd.js"),{checkCache:V,cacheTemplate:J,readFileCached:q,templateCache:ue}=await import("./chunk-et9pa7gr.js"),G=await Ee(m),Ve=(ce)=>{if(!ce)return ce;if(oe.isAbsolute(ce))return ce;return oe.resolve(m,ce)},le={...X,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)le.debug=!0;le.partialsDir=Ve(le.partialsDir),le.componentsDir=Ve(le.componentsDir),le.layoutsDir=Ve(le.layoutsDir),le.storesDir=Ve(le.storesDir||"stores"),le.cachePath=Ve(le.cachePath)??l(m,"cache");let H=!B&&!n.profile,ie=le.cache!==!1;if(ie&&H){let ce=ue.get(A.filePath);if(ce)try{if((await me.promises.stat(A.filePath)).mtime.getTime()<=ce.mtime){let He=!0;for(let Se of ce.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ce.mtime){He=!1;break}}if(He){let Se=ce.output;if(E)Se=Je(Se,{preserveHead:!0});let at=N.get(A.filePath);return{route:A,content:Se,status:at?.status??await un(A.filePath),headers:at?.headers}}}}catch{}let je=await V(A.filePath,le);if(je){let Be=je;if(E)Be=Je(Be,{preserveHead:!0});let He=N.get(A.filePath);return{route:A,content:Be,status:He?.status??await un(A.filePath),headers:He?.headers}}}let te=ie?await q(A.filePath):await Bun.file(A.filePath).text(),ae=vn(te),{classifyAllScripts:fe}=await import("./chunk-822gnnpd.js"),F=fe(te),Ie=F.server.map((ce)=>ce.content),Me=te;for(let ce of F.server)Me=Me.replace(ce.fullTag,"");let ne={__filename:A.filePath,__dirname:oe.dirname(A.filePath),__stx_options:le,params:B??{},__stx_runtime_head:{}};for(let ce of Ie)try{await ee(ce,ne,A.filePath)}catch(je){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,je?.message||je)}let De=new Set,ye;if(n.profile){let ce=performance.now();ye=await W(Me,ne,A.filePath,le,De);let je=performance.now()-ce,Be=oe.relative(m,A.filePath)||A.filePath;console.log(`[stx:profile] ${Be} \u2192 ${je.toFixed(2)}ms`)}else ye=await W(Me,ne,A.filePath,le,De);if(!E)ye=await we(ye,{router:le.router});{let{interpolateScriptExpressions:ce}=await import("./chunk-c57g2mtw.js");ye=ye.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(je,Be,He)=>{if(!/function\s+__stx_setup_/.test(He))return je;return`<script${Be}>${ce(He,ne)}</script>`})}if(E)ye=Je(ye,{preserveHead:!0});if(ie&&H)await J(A.filePath,ye,De,le);let{extractStreamBoundaries:pt}=await import("./chunk-razx95wk.js"),Ze=pt(ne),it=ne.__streamTemplates;if(it&&typeof it==="object"&&Object.keys(it).length>0){let ce=ne.streamBoundaries||{},je={...le,autoShell:!1},Be=Object.keys(it).map((Se)=>({id:Se,render:async()=>{let at=typeof ce[Se]==="function"?await ce[Se]():void 0;return W(it[Se],{...ne,$boundary:at},A.filePath,je,new Set)}})),He=new Set(Be.map((Se)=>Se.id));Ze=[...(Ze||[]).filter((Se)=>!He.has(Se.id)),...Be]}if(Ze&&Ze.length>0)Re.add(A.pattern);else Ze=void 0;let Xt=Bt(ne),Gt=Ft(ne);if(H)N.set(A.filePath,{status:Xt,headers:Gt});return{route:A,content:ye,status:Xt??ae,headers:Gt,boundaries:Ze}}catch(W){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,W),null}},ze=8,Ue=async()=>{let A=new Set(de.keys()),B=new Set(D.keys());de.clear(),D.clear();let W=n.prebuild===!1?L.filter((X)=>A.has(X.pattern)):L,ee=n.prebuild===!1?P.filter(({route:X})=>B.has(X.pattern)):P;for(let X=0;X<W.length;X+=ze){let Ee=W.slice(X,X+ze),we=await Promise.all(Ee.map((V)=>I(V)));for(let V of we)if(V)de.set(V.route.pattern,V)}for(let X=0;X<ee.length;X+=ze){let Ee=ee.slice(X,X+ze),we=await Promise.all(Ee.map(({route:V})=>I(V)));for(let V of we)if(V)D.set(V.route.pattern,V)}return de.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?L.length+P.length>0:await Ue()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await mn(m);let Ge=r;try{if(Ge=await qe(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||Ge+1;d=St({wsPort:A,verbose:!1}),u=d.start(A)}let Et=(A,B)=>{let ee=`<script data-stx-route-params>(function(){var p=${JSON.stringify(B).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(A.includes("</head>"))return f(A,ee,"");if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${ee}`);return ee+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Ur({port:Ge,hostname:n.hostname,async fetch(A){let B=new URL(A.url),W=n.stxOptions?.offline??b.offline;if(B.pathname===zo&&W?.enabled){if(!["GET","HEAD"].includes(A.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(A.method==="HEAD"?null:Ho(W,ps()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let ee=b?.publicDir||"public",X=oe.join(m,ee,B.pathname),Ee=oe.join(m,B.pathname),we=oe.join(ve,B.pathname);if([X,Ee,we].some((H)=>S(H,m,T)))return new Response("Not Found",{status:404});let[V,J,q]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Ee).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(V?.isFile()&&!S(X,m,T))return Vt(X);if(J?.isFile()&&!S(Ee,m,T))return Vt(Ee);if(q?.isFile()&&!S(we,m,T))return Vt(we);if(B.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(B.pathname.slice(16));if(H)try{let ie=`<${H} />`,te={...buildConfig,autoShell:!1},ae=await processDirectives(ie,{},oe.join(m,"components",`${H}.stx`),te,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(B.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-z1rs6b4x.js"),ie=await H(A,{publicDir:oe.join(m,ee),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Q)try{let H=await Q.handleRequest(A);if(H.status!==404)return H}catch{}if(K[B.pathname])try{return await K[B.pathname](A)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await R(A);if(ue)return ue;let G=wr(B.pathname,L);if(G){let H=de.get(G.route.pattern),ie=Re.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let te=await I(G.route,G.params);if(te){if(H=te,!G.route.isDynamic&&!ie)de.set(G.route.pattern,te)}}if(H){let te=H.status??200,ae=H.headers??{},fe=(G.route.filePath?kt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Me=await se(404);if(Me){let ne=Me;if(ne=await x(ne,m),o)ne=We(ne,u);return new Response(ne,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Ie=It(B.pathname,G.params,fe,B.search),Me=Ot(Ie,null,A,{isServer:!0}),ne=await Nt(fe.middleware,Me);if(ne.redirect){let De=ne.redirect.path,ye=ne.redirect.options.redirectCode||302,pt=new Headers(ne.responseHeaders);return pt.set("Location",De),new Response(null,{status:ye,headers:pt})}if(ne.abort){let{statusCode:De,message:ye}=ne.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${ye}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ne.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ne.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=f(H.content,De,"")}}let F=H.content;if(E&&va(A)&&Ye(F,b?.router?.container||"main")){let Ie=ot(F),Me=ke(F),ne=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ne?en(ne[1].trim()):"";if(Object.keys(G.params).length>0)F=Et(F,G.params);F=await x(F,m);let ye=b?.router?.container||"main";return F=Pe(F,ye,!0),new Response(F,{status:te,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ie.layout,"X-STX-Layout-Group":Ie.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[hc]:ps(),...z(),"Cache-Control":wt}})}if(E)F=Qr(E,F);if(Object.keys(G.params).length>0)F=Et(F,G.params);if(F=await x(F,m),o)F=We(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Ie,streamToResponse:Me}=await import("./chunk-razx95wk.js");return Me(Ie(F,H.boundaries,{timeoutMs:30000}),{status:te,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:te,headers:{"Content-Type":"text/html",...z(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(P.length>0){let H=P.map((te)=>te.route),ie=wr(B.pathname,H);if(ie){let te=D.get(ie.route.pattern);if(!te||ie.route.isDynamic){let ae=await I(ie.route,ie.params);if(ae){if(te=ae,!ie.route.isDynamic)D.set(ie.route.pattern,ae)}}if(te){let ae=te.content;if(E)ae=Qr(E,ae);if(Object.keys(ie.params).length>0)ae=Et(ae,ie.params);if(ae=await x(ae,m),o)ae=We(ae,u);return new Response(ae,{status:te.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:te}of O)if(te!=="/"&&B.pathname.startsWith(te)){let ae=D.get(te)||D.get(te+"/");if(!ae){let fe=P.find(({route:F})=>F.pattern===te||F.pattern===`${te}/`);if(fe){let F=await I(fe.route);if(F)ae=F,D.set(fe.route.pattern,F)}}if(ae){let fe=ae.content;if(E)fe=Qr(E,fe);if(fe=await x(fe,m),o)fe=We(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if($t(B.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=de.get("/");if(Ve){let H=Ve.content;if(H=await x(H,m),o)H=We(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let le=await se(404);if(le){let H=le;if(H=await x(H,m),o)H=We(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let B=await se(500);if(B)return new Response(B,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
|
|
1438
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(S.url.toString(),()=>{if(p)Xe.watch(d,{recursive:!0}).close();S.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let k=Xe.watch(d,{recursive:!0},async(v,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),tt.clear(),be(),await y()});process.on("SIGINT",()=>{k.close(),S.stop(),process.exit(0)})}return!0}function dn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ur}=globalThis.Bun;import me from"fs";import oe from"path";async function un(t){try{return vn(await Bun.file(t).text())}catch{return}}function Vt(t){let n=Bun.file(t),r=oe.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},d=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":p[r]||"application/octet-stream",...d}})}async function Xr(t=".",n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=oe.resolve(t),{loadStxConfig:y}=await import("./chunk-bx29jsqg.js"),b=await y(m),{createServerApi:w,isServerApiSource:S}=await import("./chunk-4yhd0mg6.js"),T=n.stxOptions?.serverApi??b.serverApi,R=await w(m,T),k=b.root&&b.root!=="."?oe.join(m,b.root):m,v=n.pagesDir||b.pagesDir||"pages",C=oe.join(k,v);if(!me.existsSync(C)&&!b._layerPageDirs?.some((A)=>me.existsSync(A)))return console.error(`${e.red}Error: No '${v}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${v}/index.stx for the homepage.${e.reset}`),!1;let L=Z(k,{pagesDir:v,pagesDirs:b._layerPageDirs?[C,...b._layerPageDirs.slice(1)]:void 0});if(L.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${L.length}${e.blue} routes${e.reset}`);let O=b?._pluginPageDirs||[],P=[];for(let{dir:A,prefix:B}of O)if(me.existsSync(A)){let W=Z(oe.dirname(A),{pagesDir:oe.basename(A)});for(let ee of W){let X=B==="/"?ee.pattern:`${B}${ee.pattern==="/"?"":ee.pattern}`;P.push({route:{...ee,pattern:X},prefix:B})}if(W.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${W.length}${e.blue} routes at ${e.cyan}${B}${e.reset}`)}let D=new Map,E=null,_=null;if(n.stxOptions?.shell!==!1){if(_=await wa(m,n.stxOptions?.shell),_){if(E=await So(_,n.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Rt(),await Pt(m);let j=At();if(j.length>0)console.log(`${e.blue}Loaded ${e.bright}${j.length}${e.blue} middleware: ${e.dim}${j.join(", ")}${e.reset}`);let K={},Q=null;try{let{loadStxConfig:A}=await import("./chunk-bx29jsqg.js"),B=await A(m);if(B?.apiRouter)Q=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){K=B.apiRoutes;let W=Object.keys(K).length;if(W>0)console.log(`${e.blue}Loaded ${e.bright}${W} API route${W>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:W,loadChannels:ee}=await import("./chunk-rqa92xm4.js"),X=B.broadcasting;await W(X);let Ee=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ee}/ws${e.reset}`);let we=oe.join(process.cwd(),"channels.ts");if(me.existsSync(we))try{let V=await ee(we);console.log(`${e.blue}Loaded ${e.bright}${V} broadcast channel${V!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(V){console.warn(`${e.yellow}Failed to load channels.ts: ${V.message}${e.reset}`)}}catch(W){console.warn(`${e.yellow}Broadcasting failed to start: ${W.message}${e.reset}`)}}catch{}let ve=l(m,"output");me.mkdirSync(ve,{recursive:!0});let de=new Map,Re=new Set,se=async(A)=>{let B=Ds(C,A);if(!B)return null;try{let W=await Bun.build({entrypoints:[B],outdir:ve,plugins:[st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!W.success)return null;let ee=W.outputs.find((X)=>X.path.endsWith(".html"));if(!ee)return null;return await Bun.file(ee.path).text()}catch{return null}},N=new Map,I=async(A,B)=>{try{let{processDirectives:W,extractVariables:ee,defaultConfig:X,loadStxConfig:Ee,injectRouterScript:we}=await import("./chunk-bx29jsqg.js"),{checkCache:V,cacheTemplate:J,readFileCached:q,templateCache:ue}=await import("./chunk-2v0jdfhg.js"),G=await Ee(m),Ve=(ce)=>{if(!ce)return ce;if(oe.isAbsolute(ce))return ce;return oe.resolve(m,ce)},le={...X,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)le.debug=!0;le.partialsDir=Ve(le.partialsDir),le.componentsDir=Ve(le.componentsDir),le.layoutsDir=Ve(le.layoutsDir),le.storesDir=Ve(le.storesDir||"stores"),le.cachePath=Ve(le.cachePath)??l(m,"cache");let H=!B&&!n.profile,ie=le.cache!==!1;if(ie&&H){let ce=ue.get(A.filePath);if(ce)try{if((await me.promises.stat(A.filePath)).mtime.getTime()<=ce.mtime){let He=!0;for(let Se of ce.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ce.mtime){He=!1;break}}if(He){let Se=ce.output;if(E)Se=Je(Se,{preserveHead:!0});let at=N.get(A.filePath);return{route:A,content:Se,status:at?.status??await un(A.filePath),headers:at?.headers}}}}catch{}let je=await V(A.filePath,le);if(je){let Be=je;if(E)Be=Je(Be,{preserveHead:!0});let He=N.get(A.filePath);return{route:A,content:Be,status:He?.status??await un(A.filePath),headers:He?.headers}}}let te=ie?await q(A.filePath):await Bun.file(A.filePath).text(),ae=vn(te),{classifyAllScripts:fe}=await import("./chunk-bx29jsqg.js"),F=fe(te),Ie=F.server.map((ce)=>ce.content),Me=te;for(let ce of F.server)Me=Me.replace(ce.fullTag,"");let ne={__filename:A.filePath,__dirname:oe.dirname(A.filePath),__stx_options:le,params:B??{},__stx_runtime_head:{}};for(let ce of Ie)try{await ee(ce,ne,A.filePath)}catch(je){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,je?.message||je)}let De=new Set,ye;if(n.profile){let ce=performance.now();ye=await W(Me,ne,A.filePath,le,De);let je=performance.now()-ce,Be=oe.relative(m,A.filePath)||A.filePath;console.log(`[stx:profile] ${Be} \u2192 ${je.toFixed(2)}ms`)}else ye=await W(Me,ne,A.filePath,le,De);if(!E)ye=await we(ye,{router:le.router});{let{interpolateScriptExpressions:ce}=await import("./chunk-v2712w9b.js");ye=ye.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(je,Be,He)=>{if(!/function\s+__stx_setup_/.test(He))return je;return`<script${Be}>${ce(He,ne)}</script>`})}if(E)ye=Je(ye,{preserveHead:!0});if(ie&&H)await J(A.filePath,ye,De,le);let{extractStreamBoundaries:pt}=await import("./chunk-cwdvmvc6.js"),Ze=pt(ne),it=ne.__streamTemplates;if(it&&typeof it==="object"&&Object.keys(it).length>0){let ce=ne.streamBoundaries||{},je={...le,autoShell:!1},Be=Object.keys(it).map((Se)=>({id:Se,render:async()=>{let at=typeof ce[Se]==="function"?await ce[Se]():void 0;return W(it[Se],{...ne,$boundary:at},A.filePath,je,new Set)}})),He=new Set(Be.map((Se)=>Se.id));Ze=[...(Ze||[]).filter((Se)=>!He.has(Se.id)),...Be]}if(Ze&&Ze.length>0)Re.add(A.pattern);else Ze=void 0;let Xt=Bt(ne),Gt=Ft(ne);if(H)N.set(A.filePath,{status:Xt,headers:Gt});return{route:A,content:ye,status:Xt??ae,headers:Gt,boundaries:Ze}}catch(W){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,W),null}},ze=8,Ue=async()=>{let A=new Set(de.keys()),B=new Set(D.keys());de.clear(),D.clear();let W=n.prebuild===!1?L.filter((X)=>A.has(X.pattern)):L,ee=n.prebuild===!1?P.filter(({route:X})=>B.has(X.pattern)):P;for(let X=0;X<W.length;X+=ze){let Ee=W.slice(X,X+ze),we=await Promise.all(Ee.map((V)=>I(V)));for(let V of we)if(V)de.set(V.route.pattern,V)}for(let X=0;X<ee.length;X+=ze){let Ee=ee.slice(X,X+ze),we=await Promise.all(Ee.map(({route:V})=>I(V)));for(let V of we)if(V)D.set(V.route.pattern,V)}return de.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?L.length+P.length>0:await Ue()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await mn(m);let Ge=r;try{if(Ge=await qe(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||Ge+1;d=St({wsPort:A,verbose:!1}),u=d.start(A)}let Et=(A,B)=>{let ee=`<script data-stx-route-params>(function(){var p=${JSON.stringify(B).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(A.includes("</head>"))return f(A,ee,"");if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${ee}`);return ee+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Ur({port:Ge,hostname:n.hostname,async fetch(A){let B=new URL(A.url),W=n.stxOptions?.offline??b.offline;if(B.pathname===zo&&W?.enabled){if(!["GET","HEAD"].includes(A.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(A.method==="HEAD"?null:Ho(W,ps()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let ee=b?.publicDir||"public",X=oe.join(m,ee,B.pathname),Ee=oe.join(m,B.pathname),we=oe.join(ve,B.pathname);if([X,Ee,we].some((H)=>S(H,m,T)))return new Response("Not Found",{status:404});let[V,J,q]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Ee).catch(()=>null),me.promises.stat(we).catch(()=>null)]);if(V?.isFile()&&!S(X,m,T))return Vt(X);if(J?.isFile()&&!S(Ee,m,T))return Vt(Ee);if(q?.isFile()&&!S(we,m,T))return Vt(we);if(B.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(B.pathname.slice(16));if(H)try{let ie=`<${H} />`,te={...buildConfig,autoShell:!1},ae=await processDirectives(ie,{},oe.join(m,"components",`${H}.stx`),te,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(ie){return new Response(`<div class="stx-async-error">${ie.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(B.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-z1rs6b4x.js"),ie=await H(A,{publicDir:oe.join(m,ee),cacheDir:l(m,"cache","img")});if(ie)return ie}if(Q)try{let H=await Q.handleRequest(A);if(H.status!==404)return H}catch{}if(K[B.pathname])try{return await K[B.pathname](A)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await R(A);if(ue)return ue;let G=wr(B.pathname,L);if(G){let H=de.get(G.route.pattern),ie=Re.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||ie){let te=await I(G.route,G.params);if(te){if(H=te,!G.route.isDynamic&&!ie)de.set(G.route.pattern,te)}}if(H){let te=H.status??200,ae=H.headers??{},fe=(G.route.filePath?kt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Me=await se(404);if(Me){let ne=Me;if(ne=await x(ne,m),o)ne=We(ne,u);return new Response(ne,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Ie=It(B.pathname,G.params,fe,B.search),Me=Ot(Ie,null,A,{isServer:!0}),ne=await Nt(fe.middleware,Me);if(ne.redirect){let De=ne.redirect.path,ye=ne.redirect.options.redirectCode||302,pt=new Headers(ne.responseHeaders);return pt.set("Location",De),new Response(null,{status:ye,headers:pt})}if(ne.abort){let{statusCode:De,message:ye}=ne.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${ye}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ne.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ne.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=f(H.content,De,"")}}let F=H.content;if(E&&va(A)&&Ye(F,b?.router?.container||"main")){let Ie=ot(F),Me=ke(F),ne=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ne?en(ne[1].trim()):"";if(Object.keys(G.params).length>0)F=Et(F,G.params);F=await x(F,m);let ye=b?.router?.container||"main";return F=Pe(F,ye,!0),new Response(F,{status:te,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ie.layout,"X-STX-Layout-Group":Ie.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[hc]:ps(),...z(),"Cache-Control":wt}})}if(E)F=Qr(E,F);if(Object.keys(G.params).length>0)F=Et(F,G.params);if(F=await x(F,m),o)F=We(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Ie,streamToResponse:Me}=await import("./chunk-cwdvmvc6.js");return Me(Ie(F,H.boundaries,{timeoutMs:30000}),{status:te,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:te,headers:{"Content-Type":"text/html",...z(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(P.length>0){let H=P.map((te)=>te.route),ie=wr(B.pathname,H);if(ie){let te=D.get(ie.route.pattern);if(!te||ie.route.isDynamic){let ae=await I(ie.route,ie.params);if(ae){if(te=ae,!ie.route.isDynamic)D.set(ie.route.pattern,ae)}}if(te){let ae=te.content;if(E)ae=Qr(E,ae);if(Object.keys(ie.params).length>0)ae=Et(ae,ie.params);if(ae=await x(ae,m),o)ae=We(ae,u);return new Response(ae,{status:te.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:te}of O)if(te!=="/"&&B.pathname.startsWith(te)){let ae=D.get(te)||D.get(te+"/");if(!ae){let fe=P.find(({route:F})=>F.pattern===te||F.pattern===`${te}/`);if(fe){let F=await I(fe.route);if(F)ae=F,D.set(fe.route.pattern,F)}}if(ae){let fe=ae.content;if(E)fe=Qr(E,fe);if(fe=await x(fe,m),o)fe=We(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if($t(B.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=de.get("/");if(Ve){let H=Ve.content;if(H=await x(H,m),o)H=We(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let le=await se(404);if(le){let H=le;if(H=await x(H,m),o)H=We(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let B=await se(500);if(B)return new Response(B,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
|
|
1439
1439
|
${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1440
1440
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1441
1441
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Ge}/${e.reset}`),o)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1442
1442
|
${e.yellow}Routes:${e.reset}`);let Mt=[...Ms(L,m)];for(let{route:A}of P)Mt.push(`${A.pattern}`);if(Mt.forEach((A,B)=>{let ee=B===Mt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${ee}${e.reset}${A}`)}),console.log(`
|
|
1443
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(Dt.url.toString(),()=>{if(d)ct();Dt.stop()}),n.native){let A,B=oe.join(C,"index.stx");if(me.existsSync(B)){let ee=await Bun.file(B).text();A=yt(ee)}let W=b?.app?.window??{};await et(Ge,{title:b?.app?.head?.title||oe.basename(m)||"stx App",width:W.width,height:W.height,darkMode:W.darkMode,hotReload:W.hotReload,titlebarHidden:W.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(V)=>V.startsWith("public/")||V.startsWith("public\\"),B=(V)=>{let J=V.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},W=new Map,ee=()=>{let V=new Set([m,...b._layerGraph?.layers.map((J)=>J.root)??[],...b._layerGraph?.configDependencies.map((J)=>oe.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of b._layerGraph?.layers??[])for(let q of Object.values(J.resources)){if(!me.existsSync(q))continue;let ue=me.realpathSync(q);if(![...V].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))V.add(ue)}for(let[J,q]of W)if(!V.has(J))q.close(),W.delete(J);for(let J of V)if(!W.has(J)&&me.existsSync(J))W.set(J,me.watch(J,{recursive:!0},(q,ue)=>{Ee(J,q,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Ee=(V,J,q)=>(X=X.catch(()=>{}).then(()=>we(V,J,q)),X),we=async(V,J,q)=>{if(!q||vt(q))return;if(xt(q)){if(b._layerGraph){let ue=await y(m);Object.assign(b,ue),L.splice(0,L.length,...Z(k,{pagesDir:v,pagesDirs:ue._layerPageDirs?[C,...ue._layerPageDirs.slice(1)]:void 0})),ee()}if(A(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),o&&d)d.reload(q)}else if(B(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-
|
|
1443
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(Dt.url.toString(),()=>{if(d)ct();Dt.stop()}),n.native){let A,B=oe.join(C,"index.stx");if(me.existsSync(B)){let ee=await Bun.file(B).text();A=yt(ee)}let W=b?.app?.window??{};await et(Ge,{title:b?.app?.head?.title||oe.basename(m)||"stx App",width:W.width,height:W.height,darkMode:W.darkMode,hotReload:W.hotReload,titlebarHidden:W.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(V)=>V.startsWith("public/")||V.startsWith("public\\"),B=(V)=>{let J=V.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},W=new Map,ee=()=>{let V=new Set([m,...b._layerGraph?.layers.map((J)=>J.root)??[],...b._layerGraph?.configDependencies.map((J)=>oe.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of b._layerGraph?.layers??[])for(let q of Object.values(J.resources)){if(!me.existsSync(q))continue;let ue=me.realpathSync(q);if(![...V].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))V.add(ue)}for(let[J,q]of W)if(!V.has(J))q.close(),W.delete(J);for(let J of V)if(!W.has(J)&&me.existsSync(J))W.set(J,me.watch(J,{recursive:!0},(q,ue)=>{Ee(J,q,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Ee=(V,J,q)=>(X=X.catch(()=>{}).then(()=>we(V,J,q)),X),we=async(V,J,q)=>{if(!q||vt(q))return;if(xt(q)){if(b._layerGraph){let ue=await y(m);Object.assign(b,ue),L.splice(0,L.length,...Z(k,{pagesDir:v,pagesDirs:ue._layerPageDirs?[C,...ue._layerPageDirs.slice(1)]:void 0})),ee()}if(A(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),o&&d)d.reload(q)}else if(B(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-2v0jdfhg.js");ue(oe.resolve(V,q)),G.delete(oe.resolve(V,q))}catch{}if(_&&q){if(oe.resolve(V,q)===_||oe.basename(_)===q){let G=await So(_,n.stxOptions||{});if(G)E=G}}if(await Ue(),await dr(m),o&&d)d.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-2v0jdfhg.js");ue(oe.resolve(V,q)),G.delete(oe.resolve(V,q))}catch{}if(await Ue(),o&&d)d.reload(q)}}else if(bt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),o&&d)d.updateCss(q)}};ee(),process.on("SIGINT",()=>{for(let V of W.values())V.close();if(d)ct();Dt.stop(),process.exit(0)})}return!0}import qt from"fs";import lt from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let p=r[1],o=[],d=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=d.exec(p))!==null){let m=u[1],y=u[2]||u[3]||u[4];if(!y)continue;let b={name:y},w=m.match(/@type\s+\{([^}]+)\}/i);if(w)b.type=w[1].trim();if(m.match(/@required/i))b.required=!0;let T=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(T)b.default=T[1].trim();let R=m.split(`
|
|
1444
1444
|
`).map((k)=>k.trim().replace(/^\*\s*/,"")).filter((k)=>!k.startsWith("@")&&k.length>0);b.description=R.join(" ").trim(),o.push(b)}if(o.length===0){let m=p.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(m){let b=m[1].split(",").map((w)=>w.trim()).filter(Boolean);for(let w of b){let[S]=w.split(":").map((T)=>T.trim());if(S)o.push({name:S})}}}return o}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function Vr(t){try{let n=await Bun.file(t).text(),r=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(r)return r[1].split(`
|
|
1445
1445
|
`).map((p)=>p.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function qr(t,n=!1,r){let p=lt.basename(t,".stx"),o=await Wr(t),d=await Vr(t),u="";if(n&&r)u=`<${r}></${r}>`;else{let m=o.map((y)=>{if(y.type==="boolean")return`:${y.name}="true"`;return`${y.name}="value"`}).join(`
|
|
1446
1446
|
`);u=`<${p}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Vt,pe,E,d,m,O,t,re,J,u,$e,Ni,U,Rn,Di,qt,Mi,bl,Dr,wl,pt,vl,Mr,xl,An,Li,Sl,Lr,Br,Re,ji}from"./chunk-g0xn80gz.js";import{hi,Hc,o,T,je,Lt,bn,Be,ye,Q,Er,wn,qs,Zc,Qc,xn,Pr,Gs,Xs,el,ki,tl,nl,rl,sl,ze,He,Js,We,s,_n,y,g,G,ne,Te,R,Ai}from"./chunk-
|
|
2
|
+
import{Vt,pe,E,d,m,O,t,re,J,u,$e,Ni,U,Rn,Di,qt,Mi,bl,Dr,wl,pt,vl,Mr,xl,An,Li,Sl,Lr,Br,Re,ji}from"./chunk-g0xn80gz.js";import{hi,Hc,o,T,je,Lt,bn,Be,ye,Q,Er,wn,qs,Zc,Qc,xn,Pr,Gs,Xs,el,ki,tl,nl,rl,sl,ze,He,Js,We,s,_n,y,g,G,ne,Te,R,Ai}from"./chunk-fpya25cc.js";import{Ht}from"./chunk-k32q90b2.js";import{Tn}from"./chunk-pqjmse0r.js";import{x}from"./chunk-73c3awyw.js";import{xr,Ls}from"./chunk-kh6njq2r.js";import{Cc,Ec,br,st,Tc,M}from"./chunk-rnvw07ca.js";import{ii,ai,ci,li}from"./chunk-83tvkw4y.js";import{vc,bs}from"./chunk-h1hcjx7e.js";import{gs,ms,hs}from"./chunk-tzey0xq2.js";import{xs,Zo,Qo,Ss,ks,ei}from"./chunk-c6rcrh48.js";import{ws,Ko}from"./chunk-q13dgfe1.js";import{Vo}from"./chunk-q1wxgw5s.js";import{le,Go,Xo,Jo}from"./chunk-jbgj2hph.js";import{gr,ke,Sc,mr,kc}from"./chunk-cr0msawk.js";import{H,nt}from"./chunk-8s6s6nd0.js";import{Rc,Ac}from"./chunk-t5jfh1bs.js";import{A,Pn,Bi}from"./chunk-bwdbj60y.js";import{D,c,f}from"./chunk-fd1bpv35.js";import Jn from"fs";import ae from"path";function mt(n){let e=Lt(n),l=e.find((S)=>S.closing&&S.name.toLowerCase()==="head");if(!l)return n;let a=new Set(["template","svg","noscript","math","textarea","title","xmp","iframe","noembed","noframes","plaintext"]),h=0,r=[];for(let S=0;S<e.length;S++){let v=e[S];if(v.start<l.end)continue;let k=v.name.toLowerCase();if(a.has(k)){h=Math.max(0,h+(v.closing?-1:v.selfClosing?0:1));continue}if(k!=="style"||v.closing||h>0)continue;let C=e[S+1];if(C?.name.toLowerCase()==="style"&&C.closing){if(/@scope\s*\{/.test(n.slice(v.end,C.start)))continue;r.push({start:v.start,end:C.end}),S++}}if(!r.length)return n;let p=r.map((S)=>n.slice(S.start,S.end)).join(`
|
|
3
3
|
`),w=[n.slice(0,l.start),p,`
|
|
4
4
|
`],b=l.start;for(let S of r)w.push(n.slice(b,S.start)),b=S.end;return w.push(n.slice(b)),w.join("")}function ht(){return`
|
|
5
5
|
// STX Lifecycle Runtime
|
|
@@ -1295,7 +1295,7 @@ ${L}
|
|
|
1295
1295
|
</style>`;a=a.replace(S,j),w.lastIndex=0}catch(L){}}}return a}import lt from"path";var Kn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,Gn=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function Zn(n,e){if(!e||!n.includes("/"))return n;let l=lt.dirname(e);return n.replace(Kn,(a,h,r,p)=>{let w=lt.resolve(l,p);return`${h}${r}${w.split(lt.sep).join("/")}${r}`})}function fr(n,e){if(!e||!n.includes("<script"))return n;return n.replace(Gn,(l,a,h,r)=>`${a}${Zn(h,e)}${r}`)}var Me="<!--PARENT_CONTENT_PLACEHOLDER-->";function hr(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Cr(n,e){let l=n.length,a=e,h=!0,r=[],p=(w)=>w+9<=l&&n[w]==="<"&&n[w+1]==="/"&&(n[w+2]==="s"||n[w+2]==="S")&&(n[w+3]==="c"||n[w+3]==="C")&&(n[w+4]==="r"||n[w+4]==="R")&&(n[w+5]==="i"||n[w+5]==="I")&&(n[w+6]==="p"||n[w+6]==="P")&&(n[w+7]==="t"||n[w+7]==="T")&&(n[w+8]===">"||/\s/.test(n[w+8]));while(a<l){let w=n[a];if(p(a))return a;if(w==="/"&&n[a+1]==="/"){if(a=n.indexOf(`
|
|
1296
1296
|
`,a+2),a===-1)return-1;a+=1,h=!0;continue}if(w==="/"&&n[a+1]==="*"){let b=n.indexOf("*/",a+2);if(b===-1)return-1;a=b+2,h=!0;continue}if(w==="/"&&h){let b=a+1,S=!1;while(b<l){let v=n[b];if(v==="\\"){b+=2;continue}if(v==="[")S=!0;else if(v==="]")S=!1;else if(v==="/"&&!S){b++;break}else if(v===`
|
|
1297
1297
|
`){b=-1;break}b++}if(b===-1){a++,h=!1;continue}while(b<l&&/[a-z]/.test(n[b]))b++;a=b,h=!1;continue}if(w==="'"||w==='"'){let b=w;a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]===b){a++;break}if(n[a]===`
|
|
1298
|
-
`)break;a++}h=!1;continue}if(w==="`"){a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}if(r.length===0)h=!1;continue}if(w==="}"&&r.length>0){r.pop(),a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,h=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}continue}if(/\s/.test(w));else if(/[)\].\w$]/.test(w))h=!1;else h=!0;a++}return-1}function _r(n,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let h=a.index+a[0].length,r=n.indexOf("</script>",h);if(r===-1)return null;let p=n.indexOf(">",r);if(p===-1)return null;return{start:a.index,end:p+1}}var Qn=4096;async function ut(n,e,l){if(l.buildMode!=="serve"||e.length<Qn)return null;let{registerServeModuleBundle:a}=await import("./chunk-
|
|
1298
|
+
`)break;a++}h=!1;continue}if(w==="`"){a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}if(r.length===0)h=!1;continue}if(w==="}"&&r.length>0){r.pop(),a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,h=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}continue}if(/\s/.test(w));else if(/[)\].\w$]/.test(w))h=!1;else h=!0;a++}return-1}function _r(n,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let h=a.index+a[0].length,r=n.indexOf("</script>",h);if(r===-1)return null;let p=n.indexOf(">",r);if(p===-1)return null;return{start:a.index,end:p+1}}var Qn=4096;async function ut(n,e,l){if(l.buildMode!=="serve"||e.length<Qn)return null;let{registerServeModuleBundle:a}=await import("./chunk-2v0jdfhg.js");return`<script ${n} src="${a(e)}"></script>`}async function cr(n,e,l,a){try{let{registeredModuleIdsIn:h,buildModuleRegistryScript:r}=await o("stx/client-module-registry",()=>import("./chunk-w6k6nkvq.js")),p=[],w=await r(h(...n),{minify:Bi(e.buildMode,e.minifyClient),collectInputs:p});for(let b of p)l?.add(b);if(a)a.inputs=p,a.code=w??void 0;if(!w)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:b}=await import("./chunk-2v0jdfhg.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${b(w)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${w.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function Yn(n,e,l,a){let h={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:C}=await o("stx/framework-composables",()=>import("./chunk-a76dtc8w.js"));h.frameworkScript=await C(n)}catch{}let r=null;try{r=await o("stx/store-loader",()=>import("./chunk-xzb0w6mf.js"))}catch{}let p=e.storesDir,w=!!a.__stx_native_screen||(r?.pageStoresAll()??!0),b=w?"":n.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),S=[],v=[],k=null;for(let C=0;C<8;C++){let _=null,P="",I=!1;try{if(r){let q=w?await r.getStoreScript(p).then((W)=>W?{code:W,stores:["*"],functions:null}:null):await r.getStoreScriptFor(p,[b],{reads:r.storesReadInFiles([...S,...v]),runOnce:!0});if(q)_=q.code,P=q.stores.join(","),I=!!q.functions&&!w}}catch{}if(k!==null&&P===k)break;k=P;let L=I?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",j=_?`<script ${L}>${_}</script>`:null;h.storeCode=_,h.storeTag=_?await ut(L,_,e)??j:null;let F={};h.modulesTag=await cr([n,j],e,l,F),h.modulesCode=F.code??null,S=F.inputs??[],h.composableTag=null,h.composableCode=null,v=[];try{let{getComposableScript:q}=await o("stx/composable-loader",()=>import("./chunk-apkna83n.js")),W=e.composablesDir,N=[h.modulesCode??h.modulesTag,j,h.frameworkScript].filter((V)=>V!==null),B=await q(e._layerComposableDirs??W,n,N,v);if(B)h.composableCode=B,h.composableTag=await ut('data-stx-scoped data-stx-run="always" data-stx-composables',B,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${B}</script>`}catch{}if(w||!r)break}return h}async function es(n,e,l,a={}){let{withModuleSubstitutes:h,moduleSubstitutionKey:r}=await import("./chunk-7fg2sj1z.js"),p=await import("./chunk-m9cperj4.js"),{messages:w,webModules:b}=e,S=null,v=null,k=r()===""&&!a.__stx_native_screen;if(w&&p.pageMessagesEnabled(e)&&k)try{S=await p.loadPageMessages(process.cwd(),w)}catch(L){ts(L)}if(b&&Object.keys(b).length&&k)try{v=await(await import("./chunk-8hhhmscy.js")).loadWebModules(process.cwd(),b)}catch(L){rs(L)}let C=new Map([...v??[],...S?.stubs??[]]),_=()=>Yn(n,e,l,a),P=C.size?await h(C,_):await _(),I=null;if(S){let L=p.messageAreasIn(P.modulesCode,P.storeCode,P.composableCode),j=p.pageMessagesScript(S,p.pageLanguages(n,S),L);if(j)I=await ut('data-stx-scoped data-stx-run="always" data-stx-messages',j,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${j.replace(/<\/script/gi,"<\\/script")}</script>`}return[I,P.modulesTag,P.storeTag,P.composableTag,P.frameworkScript].filter((L)=>L!==null)}var yr=!1;function ts(n){if(yr)return;yr=!0,console.warn(`[stx] messages: ${n instanceof Error?n.message:String(n)}; pages ship every language`)}var wr=!1;function rs(n){if(wr)return;wr=!0,console.warn(`[stx] ${n instanceof Error?n.message:String(n)}; pages bundle the real modules`)}function ns(n,e=""){let l=_r(n,"data-stx-runtime");if(!l)return n;let a=gr(n);if(a===-1||a===l.start){if(!e)return n;return n.slice(0,l.end)+e+n.slice(l.end)}if(a<l.start)return n.slice(0,a)+n.slice(l.start,l.end)+e+`
|
|
1299
1299
|
`+n.slice(a,l.start)+n.slice(l.end);let h=n.slice(l.start,l.end),r=n.slice(0,l.start)+n.slice(l.end),p=gr(r);if(p===-1)return h+e+`
|
|
1300
1300
|
`+r;return r.slice(0,p)+h+e+`
|
|
1301
1301
|
`+r.slice(p)}function ss(n){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return n.replace(e,(l,a,h)=>{let r=n.slice(0,h);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(n,e,l,a,h){if(await E(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return n;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Te(n,l);let r=!e.__stxProcessingDepth;xn(e);for(let p of a._layerGraph?.configDependencies??[])h.add(p);if(r&&a.runtimeConfig)await Tn(e,l,a.runtimeConfig);if(r)rl(e),e.__stx_scope_seq??={n:0,key:Js(String(e.__filename??l))},e.__stx_head_injections=Mi(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!A()&&!Pn())&&l&&l.endsWith(".stx"))Vo(n,l);try{return await pe.timeAsync("template-processing",async()=>{let p=await is(n,e,l,a,h);if(r)p=ki(p);if(r&&a.autoShell&&a.buildMode!=="compile"){let w=Re(a.app?.head,{known:Br,source:"app.head"}),S=(e.__stx_runtime_head||null)??ji(),v=(e.__stx_head_raw||"").trim(),k,C=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(C)k=C[1].trim(),v=v.replace(C[0],"").trim();let _=e.__sections?.title,P=_?R(_,e,l):void 0,I=S.title||k||P,L=!S.title&&(!!k||!!P),j=S.meta||[],F=new Set(j.map((K)=>pt(K)).filter(Boolean)),q={...w,...I&&{title:I},meta:[...(w.meta||[]).filter((K)=>!F.has(pt(K))),...j],link:[...w.link||[],...S.link||[]],script:[...w.script||[],...S.script||[]],headRaw:[w.headRaw,v].filter(Boolean).join(`
|
|
@@ -1310,7 +1310,7 @@ ${b.trim()}
|
|
|
1310
1310
|
@endsection`}}if(j&&b.includes("<script")){let N=Q(b),B=N.scripts.map((V)=>vr(V,l)??V);b=Er(N.output,B)}if(b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(N,B,V)=>(L[B]=V,"")),b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(N,B,V)=>{if(/^(['"]).*\1$/.test(V.trim()))return N;try{let K=d(V.trim(),e);if(K===void 0)return N;let Z=(e.__stx_inline_section_values??=[]).push(K)-1;return L[B]=`{{ __stx_inline_section_values[${Z}] }}`,""}catch{return N}}),b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(N,B,V)=>{if(V.includes("@parent"))L[B]=V.replace("@parent",Me);else L[B]=V.trim();return""}),e.__sections=L,b=b.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(N,B,V)=>L[B]||V||""),!("slot"in e)||e.slot===void 0)b=b.replace(/\{\{\s*slot\s*\}\}/g,()=>L.content||"");if(b=hs(b,I),j){let N=[],B=Q(b),V=ye(B.output,bn,(K,ue)=>`\x00STX_ORPHAN_STYLE_${ue}\x00`);if(b=V.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(K,ue,Z)=>{let de=ue==="SCRIPT"?vr(B.scripts[Number(Z)],l):V.tokens[Number(Z)];if(de)N.push(de);return""}),N.length>0){let K=N.join(`
|
|
1311
1311
|
`);L.content=L.content?`${L.content}
|
|
1312
1312
|
${K}`:K,e.__sections=L}}if(j)try{let N;if(ae.isAbsolute(j))N=j,h.add(j);else N=await $e(()=>_n(j,l,p,h),null,()=>{throw new re(`Failed to resolve layout path: ${j}`,l,void 0,void 0,`Layout referenced from ${l}`)});if(!N){let ce=(Y)=>{if(!Y)return[];try{let ve=ae.isAbsolute(Y)?Y:ae.resolve(process.cwd(),Y);return Jn.readdirSync(ve).filter((Ee)=>Ee.endsWith(".stx")).map((Ee)=>Ee.replace(/\.stx$/,""))}catch{return[]}},se=[...ce(p.layoutsDir),...ce(p.fallbackLayoutsDir)].filter((Y,ve,Ee)=>Ee.indexOf(Y)===ve).sort(),we=[p.layoutsDir,p.fallbackLayoutsDir].filter((Y)=>typeof Y==="string"&&Y.length>0),ge=we.length>0?` Searched: ${we.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",ie=`Layout not found: ${j} (referenced from ${l})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:p.layoutsDir?`. No .stx layouts found in ${p.layoutsDir}`:"")+ge;if(U.log(Error(ie),{layoutPath:j,filePath:l,available:se},"error"),console.error(`[stx] ${ie}`),p.debug)throw new re(ie,l);return b}let B=await $e(()=>Bun.file(N).text(),"",()=>{throw new re(`Failed to read layout file: ${N}`,l,void 0,void 0,"Layout content could not be loaded")});B=fr(B,N),B=B.replace(/\{\{--[\s\S]*?--\}\}/g,"");let V=Array.isArray(e.__layoutChain)?e.__layoutChain:[];if(V.includes(N)){let ce=[...V.slice(V.indexOf(N)),N];throw new re(ce.length===2?`Circular layout: ${N} extends itself`:`Circular layout: ${ce.join(" -> ")}`,l,void 0,void 0,"Remove the @extends or @layout line that points back at a layout already in use")}let K=B.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(K){if(p.debug)console.log(`Found nested layout: ${K[1]} in ${N}`);let ce={},se=B.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ie,Y,ve)=>(ce[Y]=ve.trim(),""));for(let[ie,Y]of Object.entries(ce))if(L[ie]&&L[ie].includes(Me)){let ve=L[ie].indexOf(Me);L[ie]=L[ie].slice(0,ve)+Y+L[ie].slice(ve+Me.length)}else if(!L[ie])L[ie]=Y;let we={...e,__sections:L,__layoutChain:[...V,N]},ge=`@layout('${K[1]}')${se}`;return await i(ge,we,N,p,h)}let ue=B.replace(/\{\{--[\s\S]*?--\}\}/g,""),Z=ms(ue,I),de={};return Z=Z.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ce,se,we)=>(de[se]=we.trim(),`@slot('${se}')`)),Z=Z.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ce,se,we)=>{if(L[se]){let ge=L[se];if(ge.includes(Me)){let ie=de[se]||"",Y=ge.indexOf(Me);ge=ge.slice(0,Y)+ie+ge.slice(Y+Me.length)}return ge}return we||""}),Z=os(Z,L),Z=Z.replace(/\{\{\s*slot\s*\}\}/g,()=>L.content||""),Z=hs(Z,I),e.__originalFilePath=l,b=await $r(Z,e,N,p,h),b=`<!-- stx-layout: ${j} -->
|
|
1313
|
-
${b}`,k(b)}catch(N){if(N instanceof J)throw N;throw new re(`Error processing layout ${j}: ${N instanceof Error?N.message:String(N)}`,l)}return k(await $r(b,e,l,p,h))}function os(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,h)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return h||""})}function as(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[h,r]of Object.entries(process.env))if(h.startsWith(l)&&r!==void 0)a[h]=r;n.$env=a}async function cs(n,e){await $e(()=>Yt(n,e),void 0,(l)=>{U.log(l,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${l.message}`)})}var dt="data-stx-source";function vr(n,e){if(!n)return n;let l=/^<script\b([^>]*)>/i.exec(n);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(dt))return n;return`<script ${dt}="${encodeURIComponent(e)}"${n.slice(7)}`}function ls(n){let e=new RegExp(`${dt}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function kr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Sr(n,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${kr(n)}</span><span style="display:block;margin-top:4px">${kr(l)}</span></div>`}async function us(n,e,l,a){let{scanScriptTags:h}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1313
|
+
${b}`,k(b)}catch(N){if(N instanceof J)throw N;throw new re(`Error processing layout ${j}: ${N instanceof Error?N.message:String(N)}`,l)}return k(await $r(b,e,l,p,h))}function os(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,h)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return h||""})}function as(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[h,r]of Object.entries(process.env))if(h.startsWith(l)&&r!==void 0)a[h]=r;n.$env=a}async function cs(n,e){await $e(()=>Yt(n,e),void 0,(l)=>{U.log(l,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${l.message}`)})}var dt="data-stx-source";function vr(n,e){if(!n)return n;let l=/^<script\b([^>]*)>/i.exec(n);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(dt))return n;return`<script ${dt}="${encodeURIComponent(e)}"${n.slice(7)}`}function ls(n){let e=new RegExp(`${dt}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function kr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Sr(n,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${kr(n)}</span><span style="display:block;margin-top:4px">${kr(l)}</span></div>`}async function us(n,e,l,a){let{scanScriptTags:h}=await o("stx/signal-processing",()=>import("./chunk-xfvedjvb.js")),r=[],p=!A()&&!Pn();for(let b of h(n)){let S=b.attrs;if(!/\bserver\b/.test(S))continue;let v=b.start+b.fullMatch.indexOf(">")+1,k=Cr(n,v);if(k===-1)continue;let C=n.slice(v,k);if(!C.trim())continue;let _=ls(S)??l,P={index:b.start,length:k+9-b.start};try{let{extractVariables:I}=await o("stx/variable-extractor",()=>import("./chunk-1vwgddct.js"));await I(C,e,_,{preserveExisting:!0,onFailure:(L)=>{if(L.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:_,kind:L.kind,message:L.message}),!p)return;r.push({...P,markup:Sr(_,L.kind,L.message)})}})}catch(I){let L=I instanceof Error?I:Error(String(I));if(U.log(L,{filePath:_,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${_}: ${L.message}`),p)r.push({...P,markup:Sr(_,"unknown",L.message)})}}if(r.length===0)return n;let w=n;for(let b of r.sort((S,v)=>v.index-S.index))w=w.slice(0,b.index)+b.markup+w.slice(b.index+b.length);return w}async function ds(n,e,l){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-v2712w9b.js"));return a(n,e,{skipServer:!0})}catch(a){let h=a instanceof Error?a:Error(String(a));return U.log(h,{filePath:l,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${l}: ${h.message}`),n}}async function $r(n,e,l,a,h){let r=n;await E();let p=a;if(r=await us(r,e,l,a),r=await Wt(r,e,l),r=await Xt(r,e,l),r=await ds(r,e,l),await E(),r=await Dt(r,e,l,p),Te(r))r=Zo(r,e),r=ks(r,e),r=Ss(r,e);r=Qo(r),await E();let{processStreamDirectives:w}=await o("stx/streaming",()=>import("./chunk-cwdvmvc6.js"));r=w(r,e),r=await Ko(r,e,l,p,!0),await E(),r=await ir(r,e,l,p,h),r=await bs(r,e,l,p,h),await E(),r=Cc(r,e,l,p);let{processDeferDirectives:b}=await o("stx/defer",()=>import("./chunk-6pczzq5f.js"));r=b(r,e,l);let{processTeleportDirectives:S}=await o("stx/teleport",()=>import("./chunk-ba91r7q9.js"));r=S(r,e,l);let{processTransitionDirectives:v,processTransitionAttributes:k}=await o("stx/transitions",()=>import("./chunk-7wqevtks.js"));r=v(r,e,l),r=k(r);let{processErrorBoundaryDirectives:C,stripRenderFailedMarkers:_}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));r=C(r,e,l),r=_(r);let{processSuspenseDirectives:P}=await o("stx/suspense",()=>import("./chunk-j4zrq17p.js"));r=P(r,e,l);let{processAsyncDirectives:I}=await o("stx/async-components",()=>import("./chunk-f52b9hjv.js"));r=I(r,e,l);let{processKeepAliveDirectives:L}=await o("stx/keep-alive",()=>import("./chunk-meqsd5bt.js"));r=L(r,e,l);let{processVirtualListDirectives:j,processVirtualGridDirectives:F,processInfiniteListDirectives:q}=await o("stx/virtual-scrolling",()=>import("./chunk-2asyyky3.js"));r=j(r,e,l),r=F(r,e,l),r=q(r,e,l),await E();let{processPartialHydrationDirectives:W,processStaticDirectives:N}=await o("stx/partial-hydration",()=>import("./chunk-3ryp43f3.js"));r=W(r,e,l),r=N(r);let{processComputedDirectives:B,processWatchDirectives:V}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));r=B(r,e,l),r=V(r,e,l);let{processFormValidationDirectives:K}=await o("stx/forms-validation",()=>import("./chunk-vkb353c3.js"));r=K(r,e,l);let{processHeadDirective:ue,processTitleDirective:Z,processMetaDirective:de,resetHead:ce}=await o("stx/head",()=>import("./chunk-cjy9cdm0.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ce();let se=ue(r);if(r=se.content,se.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${se.headContent}
|
|
1314
1314
|
`;if(r=Z(r,e),r=de(r,e,l),r=Qt(r),r=Go(r,e),r=Mt(r),r=Kt(r),r=await gs(r,e,l,p,h),r=await bs(r,e,l,p,h),await E(),r=r.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),r=ki(r),r=le(r,e,l),r=ws(r),await E(),e.__stxProcessingDepth===1)r=sl(r,e);if(r=Zc(r,e,{filePath:l,buildMode:p.buildMode}),r=Xo(r,e),r=Jo(r,e),r=Ze(r,e),r=Ft(r,e),r=Ut(r,e),r=await St(r,e,l,p),r=await Tc(r,e,l),r=await Rc(r,e,l,p),await E(),r=Ac(r,e,l,p),r=ii(r,e,l,p),r=ai(r,e,l),r=ci(r,e,l,p),r=At(r,e,l,p),r=Gs(r,e),r=Xs(r),r=el(r),!p.skipEventDirectives)r=Hc(r,e,l);if(r=Qc(r,e,l,a.skipSignalsRuntime===!0&&Number(e.__stxProcessingDepth)>0),await E(),p.debug){let X=/\bx-data\s*=/.test(r),z=xs(n);if(X&&z)console.warn(`[stx] ${l}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1315
1315
|
Both work on the same page, but they manage separate scopes.
|
|
1316
1316
|
Prefer signals (state/derived/effect) for new components.`)}r=vc(r,e),r=await Ai(r,e,l),await E(),r=tl(r),r=nl(r),r=wt(r);let{processXElementDirectives:we}=await o("stx/x-element",()=>import("./chunk-b666d8m6.js"));r=we(r);let ge=e.__originalFilePath||l,ie=ze(e);if(r=await ei(r,p,ge,ie),await E(),r=jt(r,e),r=await Jt(r,e,l,p),await E(),p.media?.image?.autoSiblings){let X=p.publicDir||"public",{rewriteImagesWithSiblings:z}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-ytzzth34.js"));r=await z(r,{publicDir:X})}if(p.seo?.enabled)r=li(r,e,p);let Y=(X,z,ee=!0)=>{if(!z)return X;let be=z.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),oe=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(X),me=oe?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(oe[0]):null;if(be&&oe&&me){if(ee){let De=oe.index+me.index;X=X.slice(0,De)+be[0]+X.slice(De+me[0].length)}if(z=z.replace(be[0],"").trim(),!z)return X}if(/<\/head>/i.test(X))return f(X,z);if(/<head\b[^>]*>/i.test(X))return X.replace(/(<head\b[^>]*>)/i,`$1
|
|
@@ -1322,6 +1322,6 @@ ${ht()}
|
|
|
1322
1322
|
</script>`;if(r.includes("</head>")){let ee=D(r),oe=r.slice(0,ee).indexOf("<script");if(oe!==-1){let me=r.slice(0,oe),De=r.slice(oe);r=me+z+`
|
|
1323
1323
|
`+De}else r=f(r,z)}else if(r.includes("<body"))r=r.replace(/<body([^>]*)>/,`<body$1>
|
|
1324
1324
|
${z}`);else r=z+`
|
|
1325
|
-
`+r}{let{scanScriptTags:X}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1325
|
+
`+r}{let{scanScriptTags:X}=await o("stx/signal-processing",()=>import("./chunk-xfvedjvb.js")),z=[];for(let ee of X(r)){if(!/\bserver\b/i.test(ee.attrs))continue;let be=ee.start+ee.fullMatch.indexOf(">")+1,oe=Cr(r,be);if(oe===-1)continue;let me=oe+9;while(me<r.length&&/\s/.test(r[me]))me++;z.push({start:ee.start,end:me})}if(z.length>0){let ee=Array(z.length+1),be=0;for(let oe=0;oe<z.length;oe++){let{start:me,end:De}=z[oe];ee[oe]=r.slice(be,me),be=De}ee[z.length]=r.slice(be),r=ee.join("")}}let ft=qs(r,l);if(ft.hasScoped)r=ft.html;let Ir=e.__stx_event_bindings||[],Qe=!1,gt=[],Or=/\s:[a-z][\w.-]*\s*=/.test(r),{scanScriptTags:jr}=await o("stx/signal-processing",()=>import("./chunk-xfvedjvb.js"));for(let X of jr(r,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))gt.push({match:X.fullMatch,attrs:X.attrs,content:X.body});for(let{match:X,attrs:z,content:ee}of gt){Qe=!0;let be=ee;je(ee,l,a.strict,e.__originalFilePath);let oe=await He(ee,{eventBindings:Ir,attrs:z,hasColonDirectives:Or,templateContent:n,filePath:l,projectRoot:process.cwd(),production:Bi(a.buildMode,a.minifyClient),serverData:ie});r=r.replace(X,()=>oe)}if(Qe)e.__stx_event_bindings=[];if(!Qe&&e.__stxProcessingDepth===1){let X=e.__stx_event_bindings||[];if(X.length>0){let z=hi(X);if(z){let ee=c(r);r=ee===-1?r+z:r.slice(0,ee)+z+`
|
|
1326
1326
|
`+r.slice(ee)}e.__stx_event_bindings=[]}}if(!p.skipSignalsRuntime&&!ke(r)&&Sc(r))r=await mr(r,p);if(r=kc(r),p.csp?.enabled&&p.csp.useNonce&&typeof e.cspNonce==="string")r=Tt(r,e.cspNonce);return r}
|
|
1327
1327
|
export{kt,Ne,hc,ps,zo,Ho,cr,i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R}from"./chunk-
|
|
2
|
+
import{R}from"./chunk-fpya25cc.js";import{ge}from"./chunk-67dgp45w.js";function g(e,t){let r={};for(let n of e)r[n]=ge(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=ge(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Ra(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=ge(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var vu=Ra;class Kn{rules=[];defaultValue="";addRule(e){let t=new Kn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Kn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Kn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Xm=new Kn;function xu(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>R(c,{...t,message:l},r)).join(`
|
|
3
3
|
`)}catch{return""}})}function Su(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>R(c,{...t,message:l},r)).join(`
|
|
4
4
|
`)}catch{return""}})}function ku(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function Jm(e,t,r){let n=e;return n=xu(n,t,r),n=Su(n,t,r),n=ku(n,t,r),n}export{Ra,vu,Kn,Xm,xu,Su,ku,Jm};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-g0xn80gz.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-
|
|
2
|
+
import"./chunk-g0xn80gz.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-fpya25cc.js";import"./chunk-k32q90b2.js";import"./chunk-pqjmse0r.js";import"./chunk-tnp2ta5q.js";import"./chunk-t5jfh1bs.js";import{l}from"./chunk-46pxmpeb.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|