@stacksjs/stx 0.2.668 → 0.2.670
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-9edksf8x.js → chunk-0dxkj53f.js} +1 -1
- package/dist/{chunk-41cvkdcm.js → chunk-0gxxknfy.js} +1 -1
- package/dist/{chunk-61n06wra.js → chunk-0zqzn3hr.js} +1 -1
- package/dist/{chunk-wesafj4a.js → chunk-1a7k07b8.js} +1 -1
- package/dist/{chunk-fpz59dhz.js → chunk-28qn219e.js} +4 -4
- package/dist/{chunk-w6x8m0tz.js → chunk-2f2q31yc.js} +1 -1
- package/dist/{chunk-dtjybwtz.js → chunk-2q8maj3k.js} +1 -1
- package/dist/{chunk-rcefnd1g.js → chunk-38th7z7d.js} +5 -5
- package/dist/{chunk-2hxwds8c.js → chunk-3cr5yths.js} +1 -1
- package/dist/{chunk-avph47dc.js → chunk-3m0cebvd.js} +1 -1
- package/dist/{chunk-cyq1jcg2.js → chunk-3ttr743b.js} +5 -5
- package/dist/chunk-4ef70h09.js +2 -0
- package/dist/{chunk-0hemydnd.js → chunk-4v1582qk.js} +1 -1
- package/dist/{chunk-cba7953e.js → chunk-54gq98a2.js} +1 -1
- package/dist/{chunk-hm9jt1p9.js → chunk-57vwx6nv.js} +1 -1
- package/dist/chunk-5r6jbxyk.js +2 -0
- package/dist/chunk-6vk1jvx5.js +130 -0
- package/dist/{chunk-fb93n9ts.js → chunk-77dewvn4.js} +1 -1
- package/dist/{chunk-zcz97ber.js → chunk-7hm5asnb.js} +1 -1
- package/dist/{chunk-6z2sdfac.js → chunk-7hzjnzex.js} +1 -1
- package/dist/{chunk-fmkcc7g1.js → chunk-82w7h48a.js} +1 -1
- package/dist/{chunk-s5w3t7xw.js → chunk-8p14rew3.js} +1 -1
- package/dist/{chunk-ca6vx6vg.js → chunk-8yry75vs.js} +1 -1
- package/dist/{chunk-65b6cy92.js → chunk-beccrqdy.js} +1 -1
- package/dist/chunk-ccwattyw.js +2 -0
- package/dist/{chunk-060298px.js → chunk-cxc3zdhn.js} +2 -2
- package/dist/{chunk-3641xvaw.js → chunk-cxmdbhwb.js} +1 -1
- package/dist/{chunk-heh151bn.js → chunk-dxc782vg.js} +1 -1
- package/dist/{chunk-6tngeb4b.js → chunk-e7avmdqn.js} +1 -1
- package/dist/{chunk-vg9bz5zs.js → chunk-egt49kgq.js} +1 -1
- package/dist/chunk-f87ycgnc.js +2 -0
- package/dist/chunk-ffd48ere.js +2 -0
- package/dist/{chunk-3n9vaxnt.js → chunk-h1gjww3q.js} +1 -1
- package/dist/{chunk-k5mez1vx.js → chunk-h1qz5xd6.js} +1 -1
- package/dist/{chunk-hkqhpckf.js → chunk-hjccqjt4.js} +1 -1
- package/dist/{chunk-9k2wz3k1.js → chunk-hvsv59f5.js} +2 -2
- package/dist/{chunk-t7jxkrbx.js → chunk-jy89bcma.js} +1 -1
- package/dist/{chunk-e8gcqp8w.js → chunk-kjhbchxn.js} +2 -2
- package/dist/{chunk-4m1hye28.js → chunk-m2znv53p.js} +1 -1
- package/dist/{chunk-02gn092e.js → chunk-mrs4sw7d.js} +1 -1
- package/dist/chunk-ng1mgtph.js +2 -0
- package/dist/{chunk-kpeep7gq.js → chunk-p450pdx3.js} +1 -1
- package/dist/{chunk-zdgsj39g.js → chunk-pgs6p767.js} +1 -1
- package/dist/{chunk-x986xz7h.js → chunk-pjdsvqzc.js} +1 -1
- package/dist/chunk-q19vdv8m.js +2 -0
- package/dist/chunk-qmtpvrz4.js +2 -0
- package/dist/{chunk-c4qebqmk.js → chunk-qqzmmnga.js} +1 -1
- package/dist/{chunk-sme31jbj.js → chunk-rmdc1bqn.js} +1 -1
- package/dist/{chunk-ynh1ppa6.js → chunk-rt2v4sy2.js} +1 -1
- package/dist/{chunk-vdjj4vrp.js → chunk-rwyexk13.js} +6 -6
- package/dist/{chunk-dy5j389v.js → chunk-sbvmcwqg.js} +2 -2
- package/dist/{chunk-8kskjg62.js → chunk-skwjbhfh.js} +1 -1
- package/dist/{chunk-4teqcbw0.js → chunk-tm6z49c5.js} +2 -2
- package/dist/{chunk-6by8f7n9.js → chunk-tnfbx8he.js} +4 -4
- package/dist/{chunk-t01c62y5.js → chunk-v2yjapag.js} +1 -1
- package/dist/{chunk-9vaz5f9j.js → chunk-wf7wxa9h.js} +1 -1
- package/dist/chunk-x4t3mjg0.js +2 -0
- package/dist/{chunk-c3dk9pkf.js → chunk-xsbacs9w.js} +1 -1
- package/dist/chunk-y4n984em.js +2 -0
- package/dist/{chunk-493x6e71.js → chunk-zgg6w9pt.js} +2 -2
- package/dist/{chunk-tq0bgaae.js → chunk-zrged04y.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/component-mapping.js +2 -0
- package/dist/native/compiler/html-to-ir.js +35 -2
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/compiler/layout-chrome.js +51 -4
- package/dist/native/components/primitives.d.ts +18 -0
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/primitives/NativeSegmentedControl.stx +5 -0
- package/dist/native/prop-names.js +8 -1
- package/dist/native/runtime/browser-renderer.js +23 -1
- package/dist/native/runtime/craft-bridge.js +2 -1
- package/dist/native/runtime/native-host.js +46 -3
- package/dist/native/runtime/web-storage.js +41 -8
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-2ecgyqam.js +0 -2
- package/dist/chunk-gkmpr64n.js +0 -2
- package/dist/chunk-hj0raner.js +0 -2
- package/dist/chunk-hx9cn2s4.js +0 -2
- package/dist/chunk-n7a33e3v.js +0 -2
- package/dist/chunk-r7cenpxp.js +0 -2
- package/dist/chunk-sz6xdz4h.js +0 -2
- package/dist/chunk-tw0wc95k.js +0 -2
- package/dist/chunk-v0091n1g.js +0 -2
- package/dist/chunk-vfba7nz5.js +0 -129
- package/dist/chunk-vryzt0p0.js +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st,cc}from"./chunk-pxdww4rb.js";import{T}from"./chunk-ce6zddpf.js";import{L,rs,r,sn,W,ce,$a,Pt,dn,De,Me}from"./chunk-
|
|
2
|
+
import{st,cc}from"./chunk-pxdww4rb.js";import{T}from"./chunk-ce6zddpf.js";import{L,rs,r,sn,W,ce,$a,Pt,dn,De,Me}from"./chunk-rwyexk13.js";import{Kn}from"./chunk-28qn219e.js";import{U}from"./chunk-bnn7pd62.js";import{tn}from"./chunk-p472crv1.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,K=65536,Y=4,O=new Map;function fp(){O.clear()}function q(e){let i=[];for(let s of ce(e,W)){let t=s.token.match(/^<script\b([^>]*)>/i),n=s.token.match(/<\/script\s*>$/i);if(!t||!n)continue;let a=t[0].length,l=s.token.length-n[0].length;i.push(Object.freeze({fullMatch:s.token,attrs:t[1],body:s.token.slice(a,l),start:s.start,end:s.end}))}return i}function _l(e,i={}){let s=e.length>=K,t=s?O.get(e):void 0;if(t===void 0){if(t=q(e),s)$a(O,Y),O.set(e,t)}let n=i.skipAttrs;if(!n)return t.slice();let a=[];for(let l of t)if(n.lastIndex=0,!n.test(l.attrs))a.push(l);return a}function oo(e){let i=e.trim(),s=i.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(s){let n=s[1].trim(),a=s[2].trim(),{itemVar:l,indexVar:o}=B(a);if(l)return{style:"as",iterable:n,itemVar:l,indexVar:o}}let t=i.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let n=t[1].trim(),a=t[2].trim(),{itemVar:l,indexVar:o}=B(n);if(l)return{style:"in",iterable:a,itemVar:l,indexVar:o}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function B(e){let i=e.trim(),s=i.match(/^(\w+)\s*=>\s*(\w+)$/);if(s)return{itemVar:s[2],indexVar:s[1]};let t=i.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let n=i.match(/^(\w+)\s*,\s*(\w+)$/);if(n)return{itemVar:n[1],indexVar:n[2]};let a=i.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Fr(e,i){return cc(e,i)}function ee(e){let i=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,s=0,t;while((t=i.exec(e))!==null){let n=t[1];if(n.startsWith("if"))s++;else if(n==="endif")s--;else if(s===0)return!0}return!1}function J(e){let i=new Set,s=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,n;while((n=s.exec(e))!==null){let a=n[1],l;while((l=t.exec(a))!==null)i.add(l[1])}return i}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let i=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),s=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=ce(e,(a,l)=>{i.lastIndex=l;let o=i.exec(a);if(!o||o.index!==l||!s.test(o[2]))return-1;return i.lastIndex}),n=[];for(let a of t){i.lastIndex=0;let l=i.exec(a.token);if(!l)continue;let o=l[2].match(s),p=oo(o?.[1]??o?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let u=l[1],g=/\/\s*>$/.test(a.token)||N.has(u.toLowerCase())?a.end:z(e,a.start,u,a.end);if(g!==-1)n.push({start:a.start,end:g,vars:new Set(h)})}return n}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 ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function F(e,i,s,t){if(!e)return!1;let n=ne(e),a=!1,l=!1,o=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(n))!==null){let d=h[1];if(n.slice(0,h.index).trimEnd().endsWith("."))continue;if(Z.has(d))continue;if(i.has(d)||t?.has(d))a=!0;else if(s&&d in s)l=!0}let u=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,c;while((c=u.exec(n))!==null){let d=c[1];if(n.slice(0,c.index).trimEnd().endsWith("."))continue;if(Z.has(d)||s&&d in s)continue;o=!0}return(a||o)&&!l}function M(e,i,s){let t=s===void 0?` ${i}`:` ${i}="${s.replace(/"/g,""")}"`,n=e.trim(),a=n.match(Q);if(a&&se(a[3],a[1])){let[,l,o,p]=a;return`<${l}${o}${t}>${p}</${l}>`}return`<template${t}>${n}</template>`}function se(e,i){let s=new RegExp(`<(/)?${i}(?=[\\s/>])`,"gi"),t=0,n;while((n=s.exec(e))!==null)if(n[1]){if(t--,t<0)return!1}else t++;return!0}function io(e,i){let s=J(e);function t(n){let a=n,l=te(n),o=(c)=>{let g=new Set;for(let d of l)if(c>d.start&&c<d.end)for(let f of d.vars)g.add(f);return g},p=/@if\s*\(/g,h,u=[];while((h=p.exec(a))!==null){let c=h.index,g=c+h[0].length,d=1,f=g;while(f<a.length&&d>0){if(a[f]==="(")d++;else if(a[f]===")")d--;f++}if(d!==0)continue;let b=a.substring(g,f-1).trim(),E=f,S=1,w=E,m=/@(if\s*\(|endif)/g;m.lastIndex=E;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))S++;else if(x[1]==="endif"){if(S--,S===0){w=x.index+x[0].length;break}}if(S!==0)continue;let C=a.substring(E,w-6).trim(),R;if(ee(C)){let _=tn(a.substring(c,w));if(_.length===0)continue;let v=_[0].branches.filter((A)=>A.type!=="else"),I=o(c);if(!(v.length>0&&v.every((A)=>F(A.condition,s,i,I))))continue;R=_[0].branches.map((A)=>{let V=t(A.content);if(A.type==="elseif")return M(V,"@else-if",A.condition??"");if(A.type==="else")return M(V,"@else");return M(V,"@if",A.condition??"")}).join(`
|
|
3
3
|
`)}else{if(!F(b,s,i,o(c)))continue;R=M(t(C),"@if",b)}u.push({start:c,end:w,replacement:R}),p.lastIndex=w}for(let c=u.length-1;c>=0;c--){let{start:g,end:d,replacement:f}=u[c];a=a.substring(0,g)+f+a.substring(d)}return a}return t(e)}function re(e){let i=e.trim();if(i==="")return;if(i==="true")return!0;if(i==="false")return!1;if(i==="null")return!1;if(i==="undefined")return!1;if(i==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(i)){let n=Number(i);return n!==0&&!Number.isNaN(n)}let s=i.match(/^'((?:\\.|[^'\\])*)'$/);if(s)return s[1].length>0;let t=i.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),G=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function z(e,i,s,t){if(N.has(s.toLowerCase()))return t;let n=s.toLowerCase(),a=e.length,l=1,o=t;while(o<a){let p=e.indexOf("<",o);if(p===-1)return-1;if(o=p,e.startsWith("<!--",o)){let g=e.indexOf("-->",o+4);if(g===-1)return-1;o=g+3;continue}G.lastIndex=o;let h=G.exec(e);if(h){let g=e.indexOf(">",o);if(g===-1)return-1;if(e[g-1]==="/"){o=g+1;continue}let d=h[1].toLowerCase()==="script"?ie:oe;d.lastIndex=o;let f=d.exec(e);if(f===null)return-1;let b=e.indexOf(">",f.index);if(b===-1)return-1;o=b+1;continue}if(e[o+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(o,o+64));if(!g){o++;continue}if(g[1].toLowerCase()===n){if(l--,o+=g[0].length,l===0)return o;continue}o+=g[0].length;continue}let u=/^<([a-z][\w-]*)\b/i.exec(e.slice(o,o+64));if(!u){o++;continue}let c=e.indexOf(">",o);if(c===-1)return-1;if(u[1].toLowerCase()===n){let g=e.slice(o,c+1);if(!(/\/\s*>$/.test(g)||N.has(n)))l++}o=c+1}return-1}var ae=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function le(e,i){let s=i,t=e.length;for(;;){while(s<t&&e[s]!=="<")s++;if(s>=t)return!1;if(e.startsWith("<!--",s)){let l=e.indexOf("-->",s+4);if(l===-1)return!1;s=l+3;continue}break}if(e[s+1]==="/")return!1;let n=e.indexOf(">",s);if(n===-1)return!1;let a=e.slice(s,n+1);return ae.test(a)}function ao(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let i=[],s=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,t;while((t=s.exec(e))!==null)i.push([t.index,t.index+t[0].length]);let n=(c)=>i.some(([g,d])=>c>=g&&c<d),a=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,l=[],o;while((o=a.exec(e))!==null){if(n(o.index))continue;let[c,g,d,f,b,E,S]=o,w=re(b);if(w===void 0)continue;let m=o.index,x=m+c.length,_=!!S||/\/\s*>$/.test(c)||N.has(g.toLowerCase())?x:z(e,m,g,x);if(_===-1)continue;if((f===":if"||f==="x-if"||f==="@if")&&le(e,_)){a.lastIndex=x;continue}if(w===!0){let I=`<${g}${d}${E}${S}>`;l.push({start:m,end:x,replacement:I});continue}l.push({start:m,end:_,replacement:""}),a.lastIndex=_}if(l.length===0)return e;l.sort((c,g)=>c.start-g.start);let p=[],h=-1;for(let c of l){if(c.start<h)continue;p.push(c),h=c.end}let u=e;for(let c=p.length-1;c>=0;c--){let{start:g,end:d,replacement:f}=p[c];u=u.substring(0,g)+f+u.substring(d)}return u}var X=[":for","@for","x-for"];function zr(e,i){if(!i||Object.keys(i).length===0)return e;if(!X.some((o)=>e.includes(`${o}=`)))return e;let s=J(e);if(Array.isArray(i.__stx_client_signal_names)){for(let o of i.__stx_client_signal_names)if(typeof o==="string")s.add(o)}let t=e,n=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,l;while((l=a.exec(t))!==null){let[o,p,h]=l,u=l.index,c=u+o.length,g=X.map((R)=>({attr:R,m:new RegExp(`\\s${R}="([^"]*)"`).exec(h)})).find((R)=>R.m!==null);if(!g||!g.m)continue;let d=oo(g.m[1]);if(!d.iterable||!d.itemVar)continue;let f=d.iterable.trim().split(/[.[(]/)[0].trim();if(!f||s.has(f)||!(f in i))continue;let b=z(t,u,p,c);if(b===-1)continue;let E=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),S=t.slice(c,b-`</${p}>`.length),w={...i,[d.itemVar]:void 0};if(d.indexVar)w[d.indexVar]=void 0;let m=zr(S,w),x=d.indexVar?`${d.iterable} as ${d.indexVar} => ${d.itemVar}`:`${d.iterable} as ${d.itemVar}`,C=p.toLowerCase()==="template"?m:`<${p}${E}>${m}</${p}>`;n.push({start:u,end:b,replacement:`@foreach(${x})${C}@endforeach`}),a.lastIndex=b}for(let o=n.length-1;o>=0;o--){let{start:p,end:h,replacement:u}=n[o];t=t.slice(0,p)+u+t.slice(h)}return t}function Hr(e,i){let s=e,t=/@(for|foreach)\s*\(/g,n,a=[],l=[];while((n=t.exec(s))!==null){let o=n[1],p=n.index,h=p+n[0].length,u=1,c=h;while(c<s.length&&u>0){if(s[c]==="(")u++;else if(s[c]===")")u--;c++}if(u!==0)continue;let g=s.substring(h,c-1).trim(),d=c,f=oo(g),b=o==="for"?"@endfor":"@endforeach",E=1,S=d,w=o==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${o}\\s*\\(|end${o})`,"g");w.lastIndex=d;let m;while((m=w.exec(s))!==null)if(m[1].startsWith(o))E++;else if(E--,E===0){S=m.index+m[0].length;break}if(E!==0)continue;let x=()=>{let y=[f.itemVar,f.indexVar].filter(Boolean);if(y.length)l.push({start:p,end:S,vars:y})};if(f.iterable){let y=f.iterable.trim();if(y.startsWith("[")||y.startsWith("{")||y.startsWith("'")||y.startsWith('"')||y.startsWith("`")||/^-?\d/.test(y)){x();continue}let k=y.split(/[.[(]/)[0].trim(),A=i?k in i:!1,V=l.some((P)=>p>P.start&&p<P.end&&P.vars.includes(k));if(k&&(A||V)){x();continue}}if(f.style==="as")g=f.indexVar?`(${f.itemVar}, ${f.indexVar}) in ${f.iterable}`:`${f.itemVar} in ${f.iterable}`;let C=s.substring(d,S-b.length).trim(),R=i?{...i}:{};if(f.itemVar)delete R[f.itemVar];if(f.indexVar)delete R[f.indexVar];let _=Hr(C,R),v=_.match(Q),I;if(v){let[,y,k,A]=v;I=`<${y}${k} @for="${g}">${A}</${y}>`}else I=`<template @for="${g}">${_}</template>`;a.push({start:p,end:S,replacement:I}),t.lastIndex=S}for(let o=a.length-1;o>=0;o--){let{start:p,end:h,replacement:u}=a[o];s=s.substring(0,p)+u+s.substring(h)}return s}function ue(e){let i=new Set,s=[],t=0,n=0,a=e.length,l=(u)=>{let c=t+1;while(c<a){let g=e[c];if(g==="\\"){c+=2;continue}if(g===u)return c+1;c++}return a},o=()=>{let u=t+2;while(u<a&&e[u]!==`
|
|
4
4
|
`)u++;return u},p=()=>{let u=t+2;while(u<a-1){if(e[u]==="*"&&e[u+1]==="/")return u+2;u++}return a},h=(u)=>{let c=u,g=0;while(c<a){let d=e[c];if(d==="/"&&e[c+1]==="/"){let f=c+2;while(f<a&&e[f]!==`
|
|
5
|
-
`)f++;c=f;continue}if(d==="/"&&e[c+1]==="*"){let f=c+2;while(f<a-1&&!(e[f]==="*"&&e[f+1]==="/"))f++;c=f+2;continue}if(d==='"'||d==="'"||d==="`"){let f=c+1;while(f<a){if(e[f]==="\\"){f+=2;continue}if(e[f]===d){f++;break}f++}c=f;continue}if(d==="("||d==="["||d==="{"){g++,c++;continue}if(d===")"||d==="]"||d==="}"){g--,c++;continue}if(d===";"&&g===0)return c+1;c++}return a};while(t<a){let u=e[t];if(u==="/"&&e[t+1]==="/"){let c=o();s.push(e.slice(t,c)),t=c;continue}if(u==="/"&&e[t+1]==="*"){let c=p();s.push(e.slice(t,c)),t=c;continue}if(u==='"'||u==="'"||u==="`"){let c=l(u);s.push(e.slice(t,c)),t=c;continue}if(u==="{"){n++,s.push(u),t++;continue}if(u==="}"){n--,s.push(u),t++;continue}if(n===0){let c=t>0?e[t-1]:"";if(c===""||/\s/.test(c)||c===";"||c==="}"||c==="{"){let d=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(d){let f=d[2],b=h(t+d[0].length);if(i.has(f)){s.push(`/* stx: deduped const ${f} */`),t=b;continue}i.add(f),s.push(e.slice(t,b)),t=b;continue}}}s.push(u),t++}return s.join("")}var fe=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,i,s){for(let t of s){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function de(e,i,s){let t=0;while(t<e.length){let n=e.indexOf(i,t);if(n===-1)return!1;if(!D(n,n+i.length,s))return!0;t=n+i.length}return!1}function ge(e,i){if(de(e,"<body",i)){let n=new RegExp(`<body(${j})>`,"g"),a;while((a=n.exec(e))!==null)if(!D(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let s=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=s.exec(e))!==null){if(D(t.index,t.index+t[0].length,i))continue;if(fe.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function pe(e,i,s,t){let n=[],a=` data-stx="${t}"`,l=0,o=!1,p=(h)=>{if(s!==null&&!o&&s>=l&&s<=h)n.push(e.slice(l,s),a,e.slice(s,h)),o=!0;else n.push(e.slice(l,h))};for(let h of i){if(h.start<l)continue;p(h.start),l=h.end}return p(e.length),n.join("")}async function Vr(e,i,s,t={}){let n=_l(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,l=[],{hasUserImports:o,bundleClientScript:p}=await r("stx/client-script-bundler",()=>import("./chunk-
|
|
5
|
+
`)f++;c=f;continue}if(d==="/"&&e[c+1]==="*"){let f=c+2;while(f<a-1&&!(e[f]==="*"&&e[f+1]==="/"))f++;c=f+2;continue}if(d==='"'||d==="'"||d==="`"){let f=c+1;while(f<a){if(e[f]==="\\"){f+=2;continue}if(e[f]===d){f++;break}f++}c=f;continue}if(d==="("||d==="["||d==="{"){g++,c++;continue}if(d===")"||d==="]"||d==="}"){g--,c++;continue}if(d===";"&&g===0)return c+1;c++}return a};while(t<a){let u=e[t];if(u==="/"&&e[t+1]==="/"){let c=o();s.push(e.slice(t,c)),t=c;continue}if(u==="/"&&e[t+1]==="*"){let c=p();s.push(e.slice(t,c)),t=c;continue}if(u==='"'||u==="'"||u==="`"){let c=l(u);s.push(e.slice(t,c)),t=c;continue}if(u==="{"){n++,s.push(u),t++;continue}if(u==="}"){n--,s.push(u),t++;continue}if(n===0){let c=t>0?e[t-1]:"";if(c===""||/\s/.test(c)||c===";"||c==="}"||c==="{"){let d=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(d){let f=d[2],b=h(t+d[0].length);if(i.has(f)){s.push(`/* stx: deduped const ${f} */`),t=b;continue}i.add(f),s.push(e.slice(t,b)),t=b;continue}}}s.push(u),t++}return s.join("")}var fe=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,i,s){for(let t of s){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function de(e,i,s){let t=0;while(t<e.length){let n=e.indexOf(i,t);if(n===-1)return!1;if(!D(n,n+i.length,s))return!0;t=n+i.length}return!1}function ge(e,i){if(de(e,"<body",i)){let n=new RegExp(`<body(${j})>`,"g"),a;while((a=n.exec(e))!==null)if(!D(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let s=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=s.exec(e))!==null){if(D(t.index,t.index+t[0].length,i))continue;if(fe.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function pe(e,i,s,t){let n=[],a=` data-stx="${t}"`,l=0,o=!1,p=(h)=>{if(s!==null&&!o&&s>=l&&s<=h)n.push(e.slice(l,s),a,e.slice(s,h)),o=!0;else n.push(e.slice(l,h))};for(let h of i){if(h.start<l)continue;p(h.start),l=h.end}return p(e.length),n.join("")}async function Vr(e,i,s,t={}){let n=_l(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,l=[],{hasUserImports:o,bundleClientScript:p}=await r("stx/client-script-bundler",()=>import("./chunk-rt2v4sy2.js"));for(let m of n){let x=m.body;if(De(m.attrs))x=Me(x);if(t.forceClientSetup||a.test(x)){l.push({content:x,start:m.start,end:m.end});continue}if(!o(x))continue;try{let C=await p(Pt(x).code,i||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(C))l.push({content:x,start:m.start,end:m.end})}catch{}}if(l.length===0)return{output:e,setupCode:null};let h=`${i??""}\x00${l.map((m)=>m.content).join("\x00")}`,u=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,c=[];for(let m=0;m<l.length;m++){let x=l[m].bundled??Pt(l[m].content).code;if(!l[m].bundled&&o(x))x=await p(x,i||"",{projectRoot:process.cwd()});x=ht(x);let C=T(x);c.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
|
|
6
6
|
${C}`)}let g=c.join(`
|
|
7
7
|
|
|
8
8
|
`);g=ue(g);let f=L(g).split(",").map((m)=>m.trim()).filter(Boolean),b=dn(g,s),E=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-pxdww4rb.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-pxdww4rb.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-rwyexk13.js";import{o}from"./chunk-hvsv59f5.js";import{zs}from"./chunk-beccrqdy.js";import{c}from"./chunk-zhf01af3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),xe=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Pc(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=$o(e)+Eo(Co(e.code)),l=e.kind==="client"||e.kind==="plain"?Pa(t,e.code):"";return ls(`${u+i}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{N,Rl,po,o,R,xp,Sp}from"./chunk-
|
|
2
|
+
import{N,Rl,po,o,R,xp,Sp}from"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{R as config,N as defaultConfig,xp as defineStxConfig,po as discoverConfig,o as loadStxConfig,Rl as resolveStxDirectories,Sp as validateConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qs,eo,to,dp,jr,pp}from"./chunk-
|
|
2
|
+
import{Qs,eo,to,dp,jr,pp}from"./chunk-57vwx6nv.js";export{jr as clearImageDeliveryCatalog,dp as deliveredImage,to as efficientDeliverySources,Qs as getImageDelivery,eo as isTransparentImage,pp as prepareImageDelivery};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-rwyexk13.js";import{s}from"./chunk-38th7z7d.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xc,Sc}from"./chunk-3ttr743b.js";import"./chunk-egt49kgq.js";import"./chunk-jy89bcma.js";import"./chunk-7met6yva.js";import"./chunk-7d4z944r.js";import"./chunk-cxmdbhwb.js";import"./chunk-zqtbtqbq.js";import"./chunk-3cr5yths.js";import{_i}from"./chunk-tm6z49c5.js";import"./chunk-jxda11cg.js";import"./chunk-89jbdtgw.js";import"./chunk-m2znv53p.js";import"./chunk-rcadtv3x.js";import"./chunk-0gxxknfy.js";import"./chunk-b823zxq6.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-h1qz5xd6.js";import"./chunk-tre98h62.js";import"./chunk-0zqzn3hr.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-v2yjapag.js";import"./chunk-beccrqdy.js";import"./chunk-3y41efsf.js";import"./chunk-zgg6w9pt.js";import"./chunk-yfvm7q6t.js";import"./chunk-6ajahb2x.js";import"./chunk-7hm5asnb.js";import"./chunk-rmdc1bqn.js";import"./chunk-md2jn67b.js";import{Te,s}from"./chunk-38th7z7d.js";import"./chunk-sbvmcwqg.js";import"./chunk-prf164ct.js";import"./chunk-2q8maj3k.js";import"./chunk-tnfbx8he.js";import"./chunk-57vwx6nv.js";import"./chunk-ka8befem.js";import"./chunk-cxc3zdhn.js";import{me}from"./chunk-28qn219e.js";import"./chunk-p472crv1.js";import{Xn,Jn}from"./chunk-7hzjnzex.js";import{qr,N,o}from"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{g,Ne}from"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,g as extractVariables,me as injectRouterScript,o as loadStxConfig,Ne as processClientScript,s as processDirectives,Te as readMarkdownFile};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Mu}from"./chunk-3cr5yths.js";import"./chunk-tm6z49c5.js";import"./chunk-3y41efsf.js";import"./chunk-rmdc1bqn.js";import"./chunk-38th7z7d.js";import"./chunk-sbvmcwqg.js";import"./chunk-prf164ct.js";import"./chunk-2q8maj3k.js";import"./chunk-tnfbx8he.js";import"./chunk-57vwx6nv.js";import"./chunk-ka8befem.js";import"./chunk-cxc3zdhn.js";import"./chunk-28qn219e.js";import"./chunk-p472crv1.js";import"./chunk-7hzjnzex.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Mu as buildForProduction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g,Po,Va,Ua,Xl,Jl,Yl,Zl,Ql,ms,eu,De,G,Me,tu,lr,nu,Ga,Do,Le,n,pn,Ka,m,de,Rp}from"./chunk-
|
|
2
|
+
import{g,Po,Va,Ua,Xl,Jl,Yl,Zl,Ql,ms,eu,De,G,Me,tu,lr,nu,Ga,Do,Le,n,pn,Ka,m,de,Rp}from"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{de as clearComponentCache,Do as componentClientSignalNames,Po as convertToCommonJS,m as createDetailedErrorMessage,Ql as extractDirectiveNames,Va as extractScriptFromTemplate,g as extractVariables,n as fileExists,Rp as getComponentCacheStats,Jl as getPositionInfo,G as getSharedTranspiler,Ka as getSourceLineInfo,Zl as hasDirectives,Ua as hasVariables,nu as isHydrateTrigger,eu as isJavaScriptScript,Le as renderComponentWithSlot,pn as resolveTemplatePath,tu as scopeOnRootElement,ms as scopeSequenceKey,De as shouldTranspileTypeScript,Ga as slotContentHasExpressions,Me as transpileTypeScript,lr as userComponentFileExists,Yl as validateDirective,Xl as validateTemplate};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-rwyexk13.js";import{oe}from"./chunk-wbzmr6a4.js";function g(e,t){let r={};for(let n of e)r[n]=oe(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=oe(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 Mi(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=oe(!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 tl=Mi;class Pn{rules=[];defaultValue="";addRule(e){let t=new Pn;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 Pn;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 Pn;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 td=new Pn;function nl(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)=>k(c,{...t,message:l},r)).join(`
|
|
3
3
|
`)}catch{return""}})}function rl(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)=>k(c,{...t,message:l},r)).join(`
|
|
4
4
|
`)}catch{return""}})}function sl(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 nd(e,t,r){let n=e;return n=nl(n,t,r),n=rl(n,t,r),n=sl(n,t,r),n}export{Mi,tl,Pn,td,nl,rl,sl,nd};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-
|
|
2
|
+
import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-h1qz5xd6.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-
|
|
2
|
+
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-rwyexk13.js";import{Ye}from"./chunk-365vg0eg.js";import{Xr,Jr}from"./chunk-fzqj1mjz.js";import{va,go,Gr,Kr}from"./chunk-04kg16qs.js";import{ha,ya}from"./chunk-0dxkj53f.js";import{bt}from"./chunk-3hxd5td3.js";import{nn,Ca,tr,nr}from"./chunk-zhf01af3.js";import{f}from"./chunk-b7e07ybq.js";import{Ts}from"./chunk-qv6axke4.js";import Q from"fs";import j from"path";import{loadConfigWithResult as Ht}from"bunfig";var B={duration:300,delay:0,ease:"ease",direction:"both"};function nt(e,r={}){let{duration:i,delay:l,ease:s,direction:c,custom:d}={...B,...r};if(e==="custom"&&d)return d;switch(e){case"fade":return`${c==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
3
3
|
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
4
4
|
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${c==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
5
5
|
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
@@ -1307,6 +1307,6 @@ ${y}
|
|
|
1307
1307
|
customElements.define('${r}', ${d});
|
|
1308
1308
|
`}async function Qe(e,r,i,l){if(r.length<1)return a("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let s=r[0].replace(/['"]/g,""),d=(i.__stx_options||{}).componentsDir||"components",p=q.isAbsolute(d)?[q.join(d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)]:[q.join(q.dirname(l),d,`${s}.stx`),q.join(process.cwd(),d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)],u=null;for(let h of p)if(await n(h)){u=await Bun.file(h).text();break}if(!u)return a("WebComponent",`Component file not found: ${s}.stx`,t.FILE_NOT_FOUND);let g=Ft(u,s);return`<script type="module">
|
|
1309
1309
|
${qt(g)}
|
|
1310
|
-
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-3n9vaxnt.js"),{partialsCache:p}=await import("./chunk-fb93n9ts.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-tq0bgaae.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1310
|
+
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-h1gjww3q.js"),{partialsCache:p}=await import("./chunk-77dewvn4.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-zrged04y.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1311
1311
|
`)}catch(k){console.warn(`[stx] Failed to load plugin ${S}:`,k.message)}}u._pluginComponentDirs=b,u._pluginPageDirs=x}return u})();if(Y.set(r,s),s.catch(()=>{if(Y.get(r)===s)Y.delete(r)}),!e)se=s,s.then((c)=>{K=c}).catch(()=>{});return s}var R=new Proxy(N,{get(e,r){if(K&&r in K)return K[r];if(!se)o().catch((i)=>{console.warn("[stx] Failed to load config file:",i?.message||i)});return e[r]}});function xp(e){return e}function Sp(e){let r=[],i=[];if(e.partialsDir!==void 0&&typeof e.partialsDir!=="string")r.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(e.componentsDir!==void 0&&typeof e.componentsDir!=="string")r.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(e.cache!==void 0&&typeof e.cache!=="boolean")r.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(e.debug!==void 0&&typeof e.debug!=="boolean")r.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(e.streaming){if(e.streaming.bufferSize!==void 0){if(typeof e.streaming.bufferSize!=="number"||e.streaming.bufferSize<=0)r.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(e.streaming.timeout!==void 0){if(typeof e.streaming.timeout!=="number"||e.streaming.timeout<=0)r.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(e.streaming.strategy!==void 0){let l=["auto","manual","sections"];if(!l.includes(e.streaming.strategy))r.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.i18n){if(e.i18n.format!==void 0){let l=["json","yaml","yml","js"];if(!l.includes(e.i18n.format))r.push({path:"i18n.format",message:`i18n.format must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.animation){if(e.animation.defaultDuration!==void 0){if(typeof e.animation.defaultDuration!=="number"||e.animation.defaultDuration<0)r.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(e.animation.staggerDelay!==void 0){if(typeof e.animation.staggerDelay!=="number"||e.animation.staggerDelay<0)r.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(e.a11y){if(e.a11y.level!==void 0){let l=["AA","AAA"];if(!l.includes(e.a11y.level))r.push({path:"a11y.level",message:`a11y.level must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.hydration){if(e.hydration.mode!==void 0){let l=["progressive","islands"];if(!l.includes(e.hydration.mode))r.push({path:"hydration.mode",message:`hydration.mode must be one of: ${l.join(", ")}`,severity:"error"})}if(e.hydration.preload!==void 0){let l=["none","eager","lazy"];if(!l.includes(e.hydration.preload))r.push({path:"hydration.preload",message:`hydration.preload must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.customDirectives)if(!Array.isArray(e.customDirectives))r.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else e.customDirectives.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`customDirectives[${s}].name`,message:"Custom directive must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`customDirectives[${s}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(e.middleware)if(!Array.isArray(e.middleware))r.push({path:"middleware",message:"middleware must be an array",severity:"error"});else e.middleware.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`middleware[${s}].name`,message:"Middleware must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`middleware[${s}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!l.timing||!["before","after"].includes(l.timing))r.push({path:`middleware[${s}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(e.debug===!0&&e.cache===!0)i.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(e.seo?.enabled===!0&&!e.seo?.defaultConfig?.title)i.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(e.pwa){if(e.pwa.enabled===!0&&!e.pwa.manifest?.name)r.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(e.pwa.manifest?.display!==void 0){let l=["fullscreen","standalone","minimal-ui","browser"];if(!l.includes(e.pwa.manifest.display))r.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.manifest?.orientation!==void 0){let l=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!l.includes(e.pwa.manifest.orientation))r.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.routes){let l=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];e.pwa.routes.forEach((s,c)=>{if(!s.pattern||typeof s.pattern!=="string")r.push({path:`pwa.routes[${c}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!l.includes(s.strategy))r.push({path:`pwa.routes[${c}].strategy`,message:`PWA route strategy must be one of: ${l.join(", ")}`,severity:"error"});if(s.maxAgeSeconds!==void 0&&(typeof s.maxAgeSeconds!=="number"||s.maxAgeSeconds<0))r.push({path:`pwa.routes[${c}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(s.maxEntries!==void 0&&(typeof s.maxEntries!=="number"||s.maxEntries<1))r.push({path:`pwa.routes[${c}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(e.pwa.icons?.sizes){if(!Array.isArray(e.pwa.icons.sizes))r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(e.pwa.icons.sizes.filter((s)=>typeof s!=="number"||s<16||s>1024).length>0)r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(e.pwa.icons?.purpose){let l=["any","maskable","monochrome"];if(e.pwa.icons.purpose.filter((c)=>!l.includes(c)).length>0)r.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.enabled===!0&&!e.pwa.icons?.src)i.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(e.pwa.enabled===!0&&!e.pwa.manifest?.themeColor)i.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:r.length===0,errors:r,warnings:i}}
|
|
1312
1312
|
export{ua,da,Yn,Xe,pa,qr,N,Rl,po,o,R,xp,Sp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B}from"./chunk-
|
|
2
|
+
import{B}from"./chunk-rwyexk13.js";import{je,A,Ot}from"./chunk-1sr6c0nk.js";import{ut,Se,O,ke,Ai,Bs,Pi,kn}from"./chunk-tm6z49c5.js";import{vt,ie,Je}from"./chunk-365vg0eg.js";import{Xs}from"./chunk-rmdc1bqn.js";import{_n}from"./chunk-vqc4h16r.js";import{ge}from"./chunk-28qn219e.js";import Z from"fs";import T from"path";var{serve:pe}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((o)=>e.startsWith(o)))return!1;return te.some((o)=>e.startsWith(o))}function oe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ce(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function xn(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??re))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await K(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await ee(a),ce(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new B(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",O(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Se(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,N=async()=>{let s=await o();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",O(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return a();x=N().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):a()}}var ue={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function $u(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=Ai(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=_n(r.routeRules),f=new G,h=Xs(e,r.apiRoutes??[]),g=Bun.file(T.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?A(l):void 0,v=new Map,N=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=T.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ot(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Je(i.html)),M.set(n.pattern,ge(i.html));let X=T.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let P=await Bun.file(X).text();N.set(n.pattern,m?Ot(P,m):P)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=ie(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let E=pe({port:o,async fetch(n){return xn(n,await je(m??A(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),L=ue[R]||"application/octet-stream",_=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=Se(n),C=null,q={};if(C=s.get(i)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let c=i.match(p);if(c){C=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!C){let p=vt(i)?null:s.get("/404")||null;if(p){let d=v.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=a(i),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=N.get(C.pattern);if(c){let R=x.get(C.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...O(),...k.cache?{}:{"Cache-Control":ut}}})}}let d=Bs(n.method),u=v.get(C.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=v.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...O(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:_,status:I,headers:D}=await kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return Pi(L,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-qmtpvrz4.js"),j=new Headers({...O(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(P&&!d){let V=Je(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ge(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(P&&!d?ke(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...O(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",O(w.get("Vary")).Vary),P&&!d){let S=Je(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ge(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(ke(c,r.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(c,{status:I??u.status??200,headers:w})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
3
|
export{xn,$u};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-
|
|
2
|
+
import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-rwyexk13.js";import"./chunk-2dp7hyv7.js";import"./chunk-1sr6c0nk.js";import"./chunk-p450pdx3.js";import{Bt,$s,Ft,ai,ot,ci,Rs,zt,ui,Ht}from"./chunk-pn1ehs6a.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ci("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-ng1mgtph.js"),p={},u=h(n);if(u)try{await g(u,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-ng1mgtph.js"),c={...r},n=h(e);if(n)try{await g(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await zt(t);at(t,r);let s=Ht(t.config,r);ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=ui(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);at(t,m);let f=Ht(t.config,m);if(ct(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{o}from"./chunk-
|
|
2
|
+
import{o}from"./chunk-hvsv59f5.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-ffd48ere.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
|
|
3
3
|
export{Ku};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-
|
|
2
|
+
import"./chunk-2dp7hyv7.js";import"./chunk-pxdww4rb.js";import"./chunk-ce6zddpf.js";import"./chunk-rwyexk13.js";import"./chunk-1sr6c0nk.js";import"./chunk-p450pdx3.js";import"./chunk-a3d0g4mr.js";import"./chunk-0dxkj53f.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l 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||c(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=l.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"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hn,s}from"./chunk-38th7z7d.js";import"./chunk-sbvmcwqg.js";import"./chunk-prf164ct.js";import"./chunk-2q8maj3k.js";import"./chunk-tnfbx8he.js";import"./chunk-57vwx6nv.js";import"./chunk-ka8befem.js";import"./chunk-cxc3zdhn.js";import{me}from"./chunk-28qn219e.js";import"./chunk-p472crv1.js";import"./chunk-7hzjnzex.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{Ae,ps,gs}from"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hn as buildModulesTag,me as injectRouterScript,s as processDirectives,ps as processJsonDirective,gs as processOnceDirective,Ae as validateClientScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mn,A}from"./chunk-1sr6c0nk.js";import m from"fs";import e from"path";async function gn(r,o,i){if(r.__stx_runtime_config)return;let n=mn();if(n||i){r.__stx_runtime_config=n??A(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-
|
|
2
|
+
import{mn,A}from"./chunk-1sr6c0nk.js";import m from"fs";import e from"path";async function gn(r,o,i){if(r.__stx_runtime_config)return;let n=mn();if(n||i){r.__stx_runtime_config=n??A(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-dxc782vg.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=A(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function jo(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fp,_l,oo,Fr,io,ao,zr,Hr,Vr,co,ia,Cl,ht}from"./chunk-
|
|
2
|
+
import{fp,_l,oo,Fr,io,ao,zr,Hr,Vr,co,ia,Cl,ht}from"./chunk-cxc3zdhn.js";import"./chunk-28qn219e.js";import"./chunk-p472crv1.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{L}from"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{fp as clearScriptScanCache,zr as convertServerLoopAttributesToDirectives,io as convertSignalDirectivesToAttributes,Hr as convertSignalLoopsToAttributes,L as extractExports,ia as findMarkupIndexOutsideScripts,Fr as hasSignalsSyntax,oo as parseLoopExpression,ao as preEvalLiteralReactiveIfs,Vr as processScriptSetup,co as processSignals,Cl as rewriteStxImportSpecifiers,_l as scanScriptTags,ht as stripStxRuntimeImports};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Zt,Gs,Ks,Xs,sp,Js}from"./chunk-
|
|
2
|
+
import{Zt,Gs,Ks,Xs,sp,Js}from"./chunk-rmdc1bqn.js";import"./chunk-04kg16qs.js";import"./chunk-365vg0eg.js";import"./chunk-1sr6c0nk.js";export{Ks as buildServerApi,sp as createServerApi,Zt as discoverServerApi,Gs as generateApiTypes,Js as isServerApiSource,Xs as productionApiDispatcher};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$u}from"./chunk-jy89bcma.js";import"./chunk-tm6z49c5.js";import"./chunk-rmdc1bqn.js";import"./chunk-28qn219e.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{$u as startProductionServer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rd,Li,il,sd,od,id,ad,cd,al,cl,ld,ud,dd,pd}from"./chunk-0zqzn3hr.js";import"./chunk-38th7z7d.js";import"./chunk-sbvmcwqg.js";import"./chunk-prf164ct.js";import"./chunk-2q8maj3k.js";import"./chunk-tnfbx8he.js";import"./chunk-57vwx6nv.js";import"./chunk-ka8befem.js";import"./chunk-cxc3zdhn.js";import"./chunk-28qn219e.js";import"./chunk-p472crv1.js";import"./chunk-7hzjnzex.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{il as SUSPENSE_RESOLVER_RUNTIME,Li as buildSuspenseResolveScript,cd as createStreamRenderer,id as extractStreamBoundaries,pd as generateHydrationRuntime,cl as islandDirective,ud as processSectionDirectives,od as processStreamDirectives,ld as registerStreamingDirectives,sd as renderStreamingPage,rd as streamTemplate,ad as streamTemplateSimple,dd as streamToResponse,al as streamingSuspenseDirective};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ye,Io,Oo,Kl,Pt,Wa,No,qa,$p,Oe,dn,Ne}from"./chunk-
|
|
2
|
+
import{ye,Io,Oo,Kl,Pt,Wa,No,qa,$p,Oe,dn,Ne}from"./chunk-rwyexk13.js";import{Za,i}from"./chunk-qjtpxsyx.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{ye as BROWSER_CORE_IMPORTS,Kl as STX_AUTO_IMPORTS,Io as extractAndStripCssImports,Oe as extractBridgeData,Za as findInterpolationEnd,qa as generateAutoImportDestructuring,$p as generateBrowserAutoImportDestructuring,dn as generateServerDataBridge,Pt as injectBrowserCoreAutoImports,Ne as processClientScript,No as referencesName,Oo as renderVendorStyleTags,i as stripCommentsAndLiterals,Wa as transformAutoImports};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ie}from"./chunk-365vg0eg.js";import{je,A}from"./chunk-1sr6c0nk.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ks(s,l,o={}){let i=Zt(s,o);await Gs(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-dxc782vg.js"),a=A((await e(s)).runtimeConfig);return await je(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Js(s,l,o){if(ba(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
6
|
export{Zt,Gs,Ks,Xs,sp,Js};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-
|
|
2
|
+
import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-7hm5asnb.js";import"./chunk-rmdc1bqn.js";import"./chunk-md2jn67b.js";import"./chunk-hvsv59f5.js";import"./chunk-0dxkj53f.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-rwyexk13.js";import"./chunk-p450pdx3.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Fn as MODULE_SPECIFIER_PREFIX,ll as bundleCacheDir,ul as bundleCacheEntryLimit,Yt as bundleClientScript,Kt as clearBundleFailures,Ce as clientBundleDependencies,Gt as getBundleFailures,Xt as hasUserImports,Jt as moduleSubstitutionKey,fl as normalizeRegistrySpecifiers,ml as queueClientBundleBuild,Qi as recordBundleFailure,pl as registryIdForPath,ea as resolveBundlerFallback,gl as rewriteRegistryImports,rp as setBundlerFallbackMode,dl as shouldLogBundlerDiagnostics,hl as tempBuildName,qs as withModuleSubstitutes};
|