@stacksjs/stx 0.2.863 → 0.2.865
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-gp8hgpt9.js → chunk-01mwbg1r.js} +3 -3
- package/dist/{chunk-k7dxm48r.js → chunk-0dyec13e.js} +1 -1
- package/dist/{chunk-fnv94wc6.js → chunk-0v2yj490.js} +1 -1
- package/dist/chunk-16qzr5ga.js +2 -0
- package/dist/chunk-2hq6mq6r.js +2 -0
- package/dist/chunk-2qjyzekc.js +3 -0
- package/dist/{chunk-czca8yds.js → chunk-46x7a1cj.js} +1 -1
- package/dist/chunk-49r1z20v.js +2 -0
- package/dist/chunk-4b0mjyn7.js +2 -0
- package/dist/{chunk-y190sh29.js → chunk-4q0rgnw0.js} +9 -9
- package/dist/{chunk-5zzrrxns.js → chunk-4sfrfag1.js} +4 -4
- package/dist/{chunk-zsnmk5me.js → chunk-5dvkphbe.js} +1 -1
- package/dist/{chunk-qxw9h564.js → chunk-5ep1qbjt.js} +1 -1
- package/dist/{chunk-v408qsze.js → chunk-5kkq2eqr.js} +1 -1
- package/dist/{chunk-85zmxbt0.js → chunk-67xreg70.js} +4 -4
- package/dist/{chunk-gjngg182.js → chunk-6pqfar3p.js} +8 -8
- package/dist/{chunk-wk4wg6sn.js → chunk-764f1sf1.js} +2 -2
- package/dist/chunk-77km1je8.js +2 -0
- package/dist/{chunk-prrvggcy.js → chunk-78eyz4ch.js} +1 -1
- package/dist/{chunk-8502xb4n.js → chunk-79y9amt1.js} +7 -7
- package/dist/{chunk-8v1zpdef.js → chunk-7chzhef2.js} +1 -1
- package/dist/{chunk-sj3ry5ck.js → chunk-7xhwqc0c.js} +7 -1
- package/dist/chunk-822gnnpd.js +2 -0
- package/dist/{chunk-mfa07erx.js → chunk-83tvkw4y.js} +1 -1
- package/dist/{chunk-gw7t6a3t.js → chunk-86xt8cs8.js} +1 -1
- package/dist/{chunk-ntbe5q5x.js → chunk-8efn9agz.js} +2 -2
- package/dist/{chunk-58sh82aj.js → chunk-97cyjqa5.js} +1 -1
- package/dist/{chunk-jfmj0wsy.js → chunk-98v8smzf.js} +1 -1
- package/dist/chunk-9cwag0tk.js +2 -0
- package/dist/{chunk-32ty2zx6.js → chunk-9tsp5ytb.js} +1 -1
- package/dist/{chunk-xfd3yqgj.js → chunk-a2yk8sw0.js} +12 -12
- package/dist/chunk-aef82ns3.js +2 -0
- package/dist/{chunk-reeaknf2.js → chunk-ajkqbjbp.js} +1 -1
- package/dist/chunk-angv3d3s.js +2 -0
- package/dist/{chunk-z383x16t.js → chunk-aqn8y42n.js} +1 -1
- package/dist/{chunk-46ddesnf.js → chunk-b666d8m6.js} +1 -1
- package/dist/{chunk-vwwpbhd2.js → chunk-bzt73fj0.js} +1 -1
- package/dist/chunk-c2bhc5wg.js +2 -0
- package/dist/{chunk-ztbexx3h.js → chunk-c57g2mtw.js} +1 -1
- package/dist/{chunk-yakdcak2.js → chunk-c60qda5c.js} +1 -1
- package/dist/{chunk-az5xw3w8.js → chunk-cjy9cdm0.js} +1 -1
- package/dist/{chunk-nttsc0aw.js → chunk-dx2t73jn.js} +5 -5
- package/dist/{chunk-5p1k2h5q.js → chunk-dy1d7ep7.js} +1 -1
- package/dist/{chunk-yr1zx78b.js → chunk-e8y2c1sq.js} +2 -2
- package/dist/{chunk-1grdbpsk.js → chunk-efjmpq6r.js} +2 -2
- package/dist/{chunk-g4gcf4jn.js → chunk-et9pa7gr.js} +1 -1
- package/dist/chunk-f52b9hjv.js +2 -0
- package/dist/{chunk-021tjkd6.js → chunk-f57t1bcs.js} +1 -1
- package/dist/{chunk-qmkaqjba.js → chunk-f5vdse5a.js} +1 -1
- package/dist/{chunk-bx5d87xx.js → chunk-f6ypmk8x.js} +1 -1
- package/dist/{chunk-y036cwc7.js → chunk-fbtm3frc.js} +2 -2
- package/dist/{chunk-s9df8srx.js → chunk-fd1bpv35.js} +3 -3
- package/dist/{chunk-5s1fb8z4.js → chunk-fm9kas0a.js} +1 -1
- package/dist/{chunk-0xtda6aw.js → chunk-fmzyrg2e.js} +1 -1
- package/dist/{chunk-h816ta81.js → chunk-fnha6bbj.js} +2 -2
- package/dist/{chunk-qa5y30sy.js → chunk-g0xn80gz.js} +7 -7
- package/dist/{chunk-pyckafsb.js → chunk-g8zgfmk3.js} +1 -1
- package/dist/chunk-gp7derwj.js +2 -0
- package/dist/{chunk-wtfamngc.js → chunk-gwa31y9x.js} +4 -4
- package/dist/{chunk-x3p4emdp.js → chunk-hdyacfen.js} +1 -1
- package/dist/{chunk-jgra00m8.js → chunk-hwqrejq3.js} +1 -1
- package/dist/{chunk-w468n41y.js → chunk-j4mtcbvz.js} +18 -18
- package/dist/{chunk-xymr4ys9.js → chunk-jbgj2hph.js} +1 -1
- package/dist/{chunk-x512h2gv.js → chunk-kh6njq2r.js} +2 -2
- package/dist/{chunk-2n932qtv.js → chunk-mkyn95mf.js} +1 -1
- package/dist/{chunk-dtarm8x9.js → chunk-nack2xs5.js} +4 -4
- package/dist/{chunk-xcjvx6zt.js → chunk-p2f308sq.js} +1 -1
- package/dist/{chunk-zr22gtpf.js → chunk-p8apfhg9.js} +1 -1
- package/dist/{chunk-dpmayc2w.js → chunk-r0v2chpn.js} +2 -2
- package/dist/chunk-razx95wk.js +2 -0
- package/dist/{chunk-2c18y094.js → chunk-rb41t77f.js} +1 -1
- package/dist/{chunk-b6w0f610.js → chunk-rkd27m4m.js} +19 -19
- package/dist/{chunk-669b2bya.js → chunk-rw5492e2.js} +3 -3
- package/dist/chunk-tx6t331f.js +2 -0
- package/dist/chunk-v4pswhj1.js +2 -0
- package/dist/{chunk-15m7jnc0.js → chunk-w19myass.js} +1 -1
- package/dist/{chunk-r4v4vswq.js → chunk-w1vk83kx.js} +1 -1
- package/dist/{chunk-p0tkhd12.js → chunk-w8qr5414.js} +1 -1
- package/dist/chunk-x1zzy6c7.js +2 -0
- package/dist/{chunk-qbghf76y.js → chunk-x64afx6z.js} +2 -2
- package/dist/chunk-x95031qg.js +2 -0
- package/dist/{chunk-ks5p5w6z.js → chunk-xempkjvd.js} +1 -1
- package/dist/{chunk-yhc1c4tr.js → chunk-xt1cxmkx.js} +52 -52
- package/dist/chunk-yq0kcw7h.js +2 -0
- package/dist/chunk-z4yzk0d4.js +2 -0
- package/dist/chunk-z6c4c951.js +2 -0
- package/dist/chunk-z98qxjne.js +2 -0
- package/dist/{chunk-d0afg5f7.js → chunk-zacjg4p1.js} +1 -1
- package/dist/{chunk-hc6111md.js → chunk-zfd9dmsn.js} +4 -4
- package/dist/cli.js +13 -13
- package/dist/client/signals-component-props-runtime.js +7 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/floating-actions-web.d.ts +20 -0
- package/dist/native/floating-actions-web.js +177 -0
- package/dist/native/floating-actions.d.ts +8 -1
- package/dist/native/floating-actions.js +1 -1
- package/dist/native/primitives/FloatingActions.stx +22 -2
- package/dist/pwa.js +3 -3
- package/dist/site-builder/build.d.ts +6 -0
- package/dist/site-builder/build.js +13 -3
- package/dist/site-builder/types.d.ts +3 -0
- package/dist/ssg.js +4 -4
- package/package.json +5 -5
- package/dist/chunk-0bfgsv31.js +0 -2
- package/dist/chunk-36j129p1.js +0 -2
- package/dist/chunk-7mjf144y.js +0 -2
- package/dist/chunk-a4cn8rf4.js +0 -2
- package/dist/chunk-ap84eenm.js +0 -2
- package/dist/chunk-as2ffje6.js +0 -2
- package/dist/chunk-c0t2tdfk.js +0 -2
- package/dist/chunk-caxqwrnc.js +0 -2
- package/dist/chunk-d9vzfbdp.js +0 -2
- package/dist/chunk-e634vffz.js +0 -3
- package/dist/chunk-g65dptx2.js +0 -2
- package/dist/chunk-kw11yydy.js +0 -2
- package/dist/chunk-ns04v3am.js +0 -2
- package/dist/chunk-p2etn78y.js +0 -2
- package/dist/chunk-r23zq8yk.js +0 -2
- package/dist/chunk-rqmb09ss.js +0 -2
- package/dist/chunk-sz6d3v6b.js +0 -2
- package/dist/chunk-va07zs9v.js +0 -2
- package/dist/chunk-vc42mvjn.js +0 -2
- package/dist/chunk-xzdkjkyp.js +0 -2
- package/dist/chunk-ybkwnscv.js +0 -2
- package/dist/chunk-z3gz5fy4.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h,y,g}from"./chunk-
|
|
2
|
+
import{h,y,g}from"./chunk-rkd27m4m.js";import{V}from"./chunk-xt1cxmkx.js";import{i}from"./chunk-a2yk8sw0.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Ym(e,t={},o={}){let n={...V,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await h(p,f,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,f,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],b=new RegExp(T.source,"g"),m;while((m=b.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,f,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,i(d.content,f,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Vt,pe,E,d,m,O,t,re,J,u,$e,Ni,U,Rn,
|
|
2
|
+
import{Vt,pe,E,d,m,O,t,re,J,u,$e,Ni,U,Rn,Di,qt,Mi,bl,Dr,wl,pt,vl,Mr,xl,An,Li,Sl,Lr,Br,Re,ji}from"./chunk-g0xn80gz.js";import{hi,Hc,o,T,je,Lt,bn,Be,ye,Q,Er,wn,qs,Zc,Qc,xn,Pr,Gs,Xs,el,ki,tl,nl,rl,sl,ze,He,Js,We,s,_n,y,g,G,ne,Te,R,Ai}from"./chunk-rkd27m4m.js";import{Ht}from"./chunk-k32q90b2.js";import{Tn}from"./chunk-0dyec13e.js";import{x}from"./chunk-4q0rgnw0.js";import{xr,Ls}from"./chunk-kh6njq2r.js";import{Cc,Ec,br,st,Tc,M}from"./chunk-xt1cxmkx.js";import{ii,ai,ci,li}from"./chunk-83tvkw4y.js";import{vc,bs}from"./chunk-46x7a1cj.js";import{gs,ms,hs}from"./chunk-zfd9dmsn.js";import{xs,Zo,Qo,Ss,ks,ei}from"./chunk-fbtm3frc.js";import{ws,Ko}from"./chunk-xempkjvd.js";import{Vo}from"./chunk-q1wxgw5s.js";import{le,Go,Xo,Jo}from"./chunk-jbgj2hph.js";import{gr,ke,Sc,mr,kc}from"./chunk-dx2t73jn.js";import{H,nt}from"./chunk-8s6s6nd0.js";import{Rc,Ac}from"./chunk-w1vk83kx.js";import{A,Pn,Bi}from"./chunk-bwdbj60y.js";import{D,c,f}from"./chunk-fd1bpv35.js";import Jn from"fs";import ae from"path";function mt(n){let e=Lt(n),l=e.find((S)=>S.closing&&S.name.toLowerCase()==="head");if(!l)return n;let a=new Set(["template","svg","noscript","math","textarea","title","xmp","iframe","noembed","noframes","plaintext"]),h=0,r=[];for(let S=0;S<e.length;S++){let v=e[S];if(v.start<l.end)continue;let k=v.name.toLowerCase();if(a.has(k)){h=Math.max(0,h+(v.closing?-1:v.selfClosing?0:1));continue}if(k!=="style"||v.closing||h>0)continue;let C=e[S+1];if(C?.name.toLowerCase()==="style"&&C.closing){if(/@scope\s*\{/.test(n.slice(v.end,C.start)))continue;r.push({start:v.start,end:C.end}),S++}}if(!r.length)return n;let p=r.map((S)=>n.slice(S.start,S.end)).join(`
|
|
3
3
|
`),w=[n.slice(0,l.start),p,`
|
|
4
4
|
`],b=l.start;for(let S of r)w.push(n.slice(b,S.start)),b=S.end;return w.push(n.slice(b)),w.join("")}function ht(){return`
|
|
5
5
|
// STX Lifecycle Runtime
|
|
@@ -564,8 +564,8 @@ ${e.inlineScript}
|
|
|
564
564
|
`;if(!e.scriptUrl)return"";let l=[];if(e.scriptId)l.push(`id="${fe(e.scriptId)}"`);if(e.attributes)for(let[h,r]of Object.entries(e.attributes))l.push(`${fe(h)}="${fe(r)}"`);return`
|
|
565
565
|
<!-- Custom Analytics -->
|
|
566
566
|
<script${l.length>0?` ${l.join(" ")}`:""} src="${fe(e.scriptUrl)}" defer></script>
|
|
567
|
-
`}function vt(n,e){let l=qr(e);if(!l)return n;if(!n.includes("</head>")){let a=c(n);if(a!==-1)return n.slice(0,a)+l+n.slice(a);return n+l}return f(n,l,"")}function fe(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function kt(n){let e=n.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function xt(n){let e=n?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}import Gr from"fs";import et from"path";import{createHighlighter as Zr}from"ts-syntax-highlighter";var tt=new Map;async function Ne(n,e={}){try{if(!await s(n))throw Error(`Markdown file not found: ${n}`);let a=(await Gr.promises.stat(n)).mtime.getTime();if(e.cache&&tt.has(n)){let k=tt.get(n);if(k.updatedAt>=a)return{content:k.content,data:k.data}}let h=await Bun.file(n).text(),{data:r,content:p}=br(h),w=e.markdown||
|
|
568
|
-
${h}`)}function Tt(n,e){let l=n;return l=l.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<script nonce="${e}"${h}>`}),l=l.replace(/<style([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<style nonce="${e}"${h}>`}),l}function At(n,e,l,a){let h=n,r=a.csp;if(h=h.replace(/@csp\b/g,()=>{if(!r?.enabled||!r.directives)return"<!-- CSP not configured -->";let p=r.useNonce?Ke(e,r):void 0;return Ct(r.directives,p)}),h=h.replace(/@cspNonce\b/g,()=>{if(!r?.enabled||!r.useNonce)return"";return Ke(e,r)}),r?.enabled&&r.useNonce)e.cspNonce=Ke(e,r);return h}import en from"crypto";var tn=40,Rt="_token",rt=null;function rn(n=tn){let e=en.randomBytes(Math.ceil(n/2)).toString("hex").slice(0,n);return rt=e,e}function nn(){if(!rt)rn();return rt}function sn(n=Rt){let e=nn();return`<input type="hidden" name="${n}" value="${e}">`}function Mt(n){return n.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,l,a)=>sn(a||Rt))}async function Dt(n,e,l,a){if(!a.customDirectives||a.customDirectives.length===0)return n;let h=n;for(let r of a.customDirectives){if(!r.name||typeof r.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",r);continue}if(r.hasEndTag)h=await on(h,r,e,l,a);else h=await an(h,r,e,l,a)}return h}async function on(n,e,l,a,h){let{name:r,handler:p}=e,w=`@${r}`,b=`@end${r}`,S=n,v=Vt(`${w}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${b}`,"g"),k=[],C=v.exec(S);while(C!==null){let[_,P="",I=""]=C,L=C.index||0;try{let j=P?It(e,P):[],F=I.trim(),q=await p(F,j,l,a);k.push({original:_,processed:q,startIndex:L})}catch(j){let F=j instanceof Error?j.message:String(j);if(h.debug)console.error(`Error processing custom directive @${r}:`,j);k.push({original:_,processed:u("CustomDirective",`Error in @${r}${P?`(${P})`:""}: ${F}`,t.EVALUATION_ERROR),startIndex:L})}C=v.exec(S)}for(let _=k.length-1;_>=0;_--){let{original:P,processed:I}=k[_];S=S.replace(P,I)}return S}async function an(n,e,l,a,h){let{name:r,handler:p}=e,w=n,b=[],S=[];if(e.rawParams){for(let C of Mi(w,Vt(`(?<![\\w$@])@${r}\\s*\\(`,"g")))if(C.end!==-1)S.push({fullMatch:C.call,paramString:C.args,startIndex:C.start})}else{let C=Vt(`@${r}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");C.lastIndex=0;let _=C.exec(w);while(_!==null)S.push({fullMatch:_[0],paramString:_[1]??"",startIndex:_.index||0}),_=C.exec(w)}for(let{fullMatch:C,paramString:_,startIndex:P}of S)try{let I=It(e,_),L=await p("",I,l,a);b.push({original:C,processed:L,startIndex:P})}catch(I){let L=I instanceof Error?I.message:String(I);if(h.debug)console.error(`Error processing custom directive @${r}:`,I);b.push({original:C,processed:u("CustomDirective",`Error in @${r}(${_}): ${L}`,t.EVALUATION_ERROR),startIndex:P})}let v=Vt(`@${r}(?!\\w)(?!\\s*\\()`,"g"),k=v.exec(w);while(k!==null){let[C]=k,_=k.index||0;try{let P=await p("",[],l,a);b.push({original:C,processed:P,startIndex:_})}catch(P){let I=P instanceof Error?P.message:String(P);if(h.debug)console.error(`Error processing custom directive @${r}:`,P);b.push({original:C,processed:u("CustomDirective",`Error in @${r}: ${I}`,t.EVALUATION_ERROR),startIndex:_})}k=v.exec(w)}for(let C=b.length-1;C>=0;C--){let{original:_,processed:P}=b[C];w=w.replace(_,P)}return w}function It(n,e){return n.rawParams?qt(e):cn(e)}function cn(n){if(!n.trim())return[];let e=[],l="",a=!1,h="";for(let r=0;r<n.length;r++){let p=n[r];if((p==='"'||p==="'")&&(r===0||n[r-1]!=="\\"))if(!a)a=!0,h=p;else if(p===h)a=!1;else l+=p;else if(p===","&&!a)e.push(l.trim()),l="";else l+=p}if(l.trim())e.push(l.trim());return e.map((r)=>{let p=r.trim();if(p.startsWith('"')&&p.endsWith('"')||p.startsWith("'")&&p.endsWith("'"))return p.substring(1,p.length-1);return p})}var Ot=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Pt=/^[A-Za-z_$][\w$]*$/,ln=new Set(["light","dark","system"]);function Ce(n,e){if(typeof n!=="string"||n.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function un(n){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("@appearanceBootstrap expects an options object");let e=n,{appearance:l,colorMode:a}=e;if(Ce(e.storageKey,"storageKey"),l!==void 0&&(!l||typeof l!=="object"||Array.isArray(l)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(Ce(a.key,"colorMode.key"),Ce(a.attribute,"colorMode.attribute"),Ce(a.default,"colorMode.default"),!Pt.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ot.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!ln.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let h=null;if(l){if(Ce(l.key,"appearance.key"),Ce(l.attribute,"appearance.attribute"),Ce(l.default,"appearance.default"),!Pt.test(l.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ot.test(l.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(l.allowed)||l.allowed.length===0||l.allowed.some((r)=>typeof r!=="string"||r.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!l.allowed.includes(l.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");h={key:l.key,attribute:l.attribute,allowed:[...new Set(l.allowed)],default:l.default}}return{storageKey:e.storageKey,appearance:h,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function dn(n){return JSON.stringify(n).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function pn(n){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${dn(n)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function fn(n,e){let l=1,a=null,h=!1;for(let r=e+1;r<n.length;r++){let p=n[r];if(h){h=!1;continue}if(a){if(p==="\\")h=!0;else if(p===a)a=null;continue}if(p==='"'||p==="'"||p==="`"){a=p;continue}if(p==="(")l++;else if(p===")"&&--l===0)return r}return-1}function jt(n,e){let l=n,a=/@appearanceBootstrap\s*\(/g,h;while((h=a.exec(l))!==null){let r=h.index+h[0].length-1,p=fn(l,r);if(p===-1)throw Error("@appearanceBootstrap has an unclosed options object");let w=l.slice(r+1,p).trim(),b=d(`(${w})`,e),S=pn(un(b));l=l.slice(0,h.index)+S+l.slice(p+1),a.lastIndex=h.index+S.length}return l}import gn from"crypto";function te(n){return G(String(n??""))}var Bt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ge(n,e,l,a){let h=n||e;return l?`${h} ${a}`:h}function he(n){return String(n).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ie(n,e){if(/\bid\s*=/i.test(n))return"";return` id="${te(e)}"`}function it(n,e,l){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(l))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(l))a+=` aria-describedby="${te(`${he(n)}-error`)}"`;return a}function mn(){return gn.randomUUID()}function Ze(n,e){let l=n;return l=l.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=mn();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${te(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),l=l.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,h)=>{let r=h.toUpperCase();if(h&&!["GET","POST"].includes(r))return`<input type="hidden" name="_method" value="${te(r)}">`;return a}),l}function Ft(n,e,l=Bt){let a=n;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(h,r,p,w,b,S="")=>{let v=r||p||"POST",k=w||b||"",C=xe(S),_=v.toUpperCase(),P=["GET","POST"].includes(_)?_:"POST",I=`<form method="${te(P)}" action="${te(k)}"${C?` ${C}`:""}>`;if(I+=`
|
|
567
|
+
`}function vt(n,e){let l=qr(e);if(!l)return n;if(!n.includes("</head>")){let a=c(n);if(a!==-1)return n.slice(0,a)+l+n.slice(a);return n+l}return f(n,l,"")}function fe(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function kt(n){let e=n.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function xt(n){let e=n?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}import Gr from"fs";import et from"path";import{createHighlighter as Zr}from"ts-syntax-highlighter";var tt=new Map;async function Ne(n,e={}){try{if(!await s(n))throw Error(`Markdown file not found: ${n}`);let a=(await Gr.promises.stat(n)).mtime.getTime();if(e.cache&&tt.has(n)){let k=tt.get(n);if(k.updatedAt>=a)return{content:k.content,data:k.data}}let h=await Bun.file(n).text(),{data:r,content:p}=br(h),w=e.markdown||M.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},S=st(p,{gfm:!0});if(w.syntaxHighlighting?.enabled&&w.syntaxHighlighting?.serverSide)S=await Jr(S,w.syntaxHighlighting?.defaultTheme||"github-dark",w.syntaxHighlighting?.highlightUnknownLanguages||!1);let v={content:S,data:r||{}};if(e.cache)tt.set(n,{...v,updatedAt:a});return v}catch(l){if(e.debug)console.error(`Error reading/parsing markdown file ${n}:`,l);let a=l instanceof Error?l.message:String(l);return{content:y("Markdown File",`Error reading/parsing markdown file: ${a}`,n,"",0,""),data:{}}}}var Xe=null;async function Jr(n,e,l){let a=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Xe)try{Xe=await Zr({theme:e||"github-dark",cache:!0})}catch(w){return console.error("Failed to initialize ts-syntax-highlighter:",w),n}let h=async(w,b,S,v)=>{let k=v.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),C=S||(l?"text":"");if(!C)return w;try{if(!Xe.getSupportedLanguages().includes(C))return w;return(await Xe.highlight(k,C,{theme:e})).html}catch(_){console.error(`Error highlighting code block with language ${S}:`,_)}return w},r=n,p=n.matchAll(a);for(let w of p){let[b,S,v,k]=w,C=await h(b,S,v,k);r=r.replace(b,C)}return r}async function St(n,e,l="",a={}){return await Qr(n,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(p,w,b,S)=>{try{let v=w;if(!et.isAbsolute(w))v=et.resolve(et.dirname(l),w);let k={};if(b)try{try{k=JSON.parse(b)}catch{if(a.debug)console.warn("Using safer alternative for parsing JS object literal");let F=b.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let q of F){let W=q.indexOf(":");if(W>0){let N=q.substring(0,W).trim(),B=q.substring(W+1).trim(),V=B.startsWith('"')&&B.endsWith('"'),K=B.startsWith("'")&&B.endsWith("'");if(V||K)B=B.substring(1,B.length-1);k[N]=B}}}}catch(j){if(a.debug)console.error("Error parsing context in @markdown-file directive:",j)}let{content:C,data:_}=await Ne(v,a),P={...e,..._,...k},I=C,L=/\{\{([^}]+)\}\}/g;return I=I.replace(L,(j,F)=>{let q=F.trim();return P[q]!==void 0?String(P[q]):j}),I}catch(v){let k=v instanceof Error?v.message:String(v);return y("Markdown File",`Error including markdown file: ${k}`,l,n,S,p)}})}async function Qr(n,e,l){let a=[],h;while((h=e.exec(n))!==null){let w=h[0],b=h.index,S=h;a.push(l(...S).then((v)=>({match:w,replacement:v,index:b})))}let r=await Promise.all(a);r.sort((w,b)=>b.index-w.index);let p=n;for(let{match:w,replacement:b}of r)p=p.replace(w,()=>b);return p}var $t=new WeakMap;function Et(n=16){let e=new Uint8Array(n);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function Ke(n,e){if(!n)return e?.nonceGenerator?.()??Et();let l=$t.get(n);if(!l)l=e?.nonceGenerator?.()??Et(),$t.set(n,l);return l}function Yr(n,e){let l=[];for(let[a,h]of Object.entries(n)){if(h===void 0||h===null)continue;if(typeof h==="boolean"){if(h)l.push(a);continue}if(Array.isArray(h)){let r=[...h];if(e&&(a==="script-src"||a==="style-src"))r=r.filter((p)=>!p.startsWith("'nonce-")),r.push(`'nonce-${e}'`);if(r.length>0)l.push(`${a} ${r.join(" ")}`)}}return l.join("; ")}function Ct(n,e){return`<meta http-equiv="Content-Security-Policy" content="${Yr(n,e).replace(/&/g,"&").replace(/"/g,""")}">`}function _t(n,e,l){if(!e.enabled||!e.addMetaTag)return n;if(n.includes('http-equiv="Content-Security-Policy"'))return n;if(!n.includes("<head>")&&!n.includes("<head "))return n;let a=e.useNonce?Ke(l,e):void 0,h=Ct(e.directives,a);return n.replace(/<head([^>]*)>/,`<head$1>
|
|
568
|
+
${h}`)}function Tt(n,e){let l=n;return l=l.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<script nonce="${e}"${h}>`}),l=l.replace(/<style([^>]*)>/gi,(a,h)=>{if(h.includes("nonce="))return a;return`<style nonce="${e}"${h}>`}),l}function At(n,e,l,a){let h=n,r=a.csp;if(h=h.replace(/@csp\b/g,()=>{if(!r?.enabled||!r.directives)return"<!-- CSP not configured -->";let p=r.useNonce?Ke(e,r):void 0;return Ct(r.directives,p)}),h=h.replace(/@cspNonce\b/g,()=>{if(!r?.enabled||!r.useNonce)return"";return Ke(e,r)}),r?.enabled&&r.useNonce)e.cspNonce=Ke(e,r);return h}import en from"crypto";var tn=40,Rt="_token",rt=null;function rn(n=tn){let e=en.randomBytes(Math.ceil(n/2)).toString("hex").slice(0,n);return rt=e,e}function nn(){if(!rt)rn();return rt}function sn(n=Rt){let e=nn();return`<input type="hidden" name="${n}" value="${e}">`}function Mt(n){return n.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,l,a)=>sn(a||Rt))}async function Dt(n,e,l,a){if(!a.customDirectives||a.customDirectives.length===0)return n;let h=n;for(let r of a.customDirectives){if(!r.name||typeof r.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",r);continue}if(r.hasEndTag)h=await on(h,r,e,l,a);else h=await an(h,r,e,l,a)}return h}async function on(n,e,l,a,h){let{name:r,handler:p}=e,w=`@${r}`,b=`@end${r}`,S=n,v=Vt(`${w}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${b}`,"g"),k=[],C=v.exec(S);while(C!==null){let[_,P="",I=""]=C,L=C.index||0;try{let j=P?It(e,P):[],F=I.trim(),q=await p(F,j,l,a);k.push({original:_,processed:q,startIndex:L})}catch(j){let F=j instanceof Error?j.message:String(j);if(h.debug)console.error(`Error processing custom directive @${r}:`,j);k.push({original:_,processed:u("CustomDirective",`Error in @${r}${P?`(${P})`:""}: ${F}`,t.EVALUATION_ERROR),startIndex:L})}C=v.exec(S)}for(let _=k.length-1;_>=0;_--){let{original:P,processed:I}=k[_];S=S.replace(P,I)}return S}async function an(n,e,l,a,h){let{name:r,handler:p}=e,w=n,b=[],S=[];if(e.rawParams){for(let C of Di(w,Vt(`(?<![\\w$@])@${r}\\s*\\(`,"g")))if(C.end!==-1)S.push({fullMatch:C.call,paramString:C.args,startIndex:C.start})}else{let C=Vt(`@${r}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");C.lastIndex=0;let _=C.exec(w);while(_!==null)S.push({fullMatch:_[0],paramString:_[1]??"",startIndex:_.index||0}),_=C.exec(w)}for(let{fullMatch:C,paramString:_,startIndex:P}of S)try{let I=It(e,_),L=await p("",I,l,a);b.push({original:C,processed:L,startIndex:P})}catch(I){let L=I instanceof Error?I.message:String(I);if(h.debug)console.error(`Error processing custom directive @${r}:`,I);b.push({original:C,processed:u("CustomDirective",`Error in @${r}(${_}): ${L}`,t.EVALUATION_ERROR),startIndex:P})}let v=Vt(`@${r}(?!\\w)(?!\\s*\\()`,"g"),k=v.exec(w);while(k!==null){let[C]=k,_=k.index||0;try{let P=await p("",[],l,a);b.push({original:C,processed:P,startIndex:_})}catch(P){let I=P instanceof Error?P.message:String(P);if(h.debug)console.error(`Error processing custom directive @${r}:`,P);b.push({original:C,processed:u("CustomDirective",`Error in @${r}: ${I}`,t.EVALUATION_ERROR),startIndex:_})}k=v.exec(w)}for(let C=b.length-1;C>=0;C--){let{original:_,processed:P}=b[C];w=w.replace(_,P)}return w}function It(n,e){return n.rawParams?qt(e):cn(e)}function cn(n){if(!n.trim())return[];let e=[],l="",a=!1,h="";for(let r=0;r<n.length;r++){let p=n[r];if((p==='"'||p==="'")&&(r===0||n[r-1]!=="\\"))if(!a)a=!0,h=p;else if(p===h)a=!1;else l+=p;else if(p===","&&!a)e.push(l.trim()),l="";else l+=p}if(l.trim())e.push(l.trim());return e.map((r)=>{let p=r.trim();if(p.startsWith('"')&&p.endsWith('"')||p.startsWith("'")&&p.endsWith("'"))return p.substring(1,p.length-1);return p})}var Ot=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Pt=/^[A-Za-z_$][\w$]*$/,ln=new Set(["light","dark","system"]);function Ce(n,e){if(typeof n!=="string"||n.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function un(n){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("@appearanceBootstrap expects an options object");let e=n,{appearance:l,colorMode:a}=e;if(Ce(e.storageKey,"storageKey"),l!==void 0&&(!l||typeof l!=="object"||Array.isArray(l)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(Ce(a.key,"colorMode.key"),Ce(a.attribute,"colorMode.attribute"),Ce(a.default,"colorMode.default"),!Pt.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ot.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!ln.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let h=null;if(l){if(Ce(l.key,"appearance.key"),Ce(l.attribute,"appearance.attribute"),Ce(l.default,"appearance.default"),!Pt.test(l.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ot.test(l.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(l.allowed)||l.allowed.length===0||l.allowed.some((r)=>typeof r!=="string"||r.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!l.allowed.includes(l.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");h={key:l.key,attribute:l.attribute,allowed:[...new Set(l.allowed)],default:l.default}}return{storageKey:e.storageKey,appearance:h,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function dn(n){return JSON.stringify(n).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function pn(n){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${dn(n)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function fn(n,e){let l=1,a=null,h=!1;for(let r=e+1;r<n.length;r++){let p=n[r];if(h){h=!1;continue}if(a){if(p==="\\")h=!0;else if(p===a)a=null;continue}if(p==='"'||p==="'"||p==="`"){a=p;continue}if(p==="(")l++;else if(p===")"&&--l===0)return r}return-1}function jt(n,e){let l=n,a=/@appearanceBootstrap\s*\(/g,h;while((h=a.exec(l))!==null){let r=h.index+h[0].length-1,p=fn(l,r);if(p===-1)throw Error("@appearanceBootstrap has an unclosed options object");let w=l.slice(r+1,p).trim(),b=d(`(${w})`,e),S=pn(un(b));l=l.slice(0,h.index)+S+l.slice(p+1),a.lastIndex=h.index+S.length}return l}import gn from"crypto";function te(n){return G(String(n??""))}var Bt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ge(n,e,l,a){let h=n||e;return l?`${h} ${a}`:h}function he(n){return String(n).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ie(n,e){if(/\bid\s*=/i.test(n))return"";return` id="${te(e)}"`}function it(n,e,l){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(l))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(l))a+=` aria-describedby="${te(`${he(n)}-error`)}"`;return a}function mn(){return gn.randomUUID()}function Ze(n,e){let l=n;return l=l.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=mn();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${te(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),l=l.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,h)=>{let r=h.toUpperCase();if(h&&!["GET","POST"].includes(r))return`<input type="hidden" name="_method" value="${te(r)}">`;return a}),l}function Ft(n,e,l=Bt){let a=n;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(h,r,p,w,b,S="")=>{let v=r||p||"POST",k=w||b||"",C=xe(S),_=v.toUpperCase(),P=["GET","POST"].includes(_)?_:"POST",I=`<form method="${te(P)}" action="${te(k)}"${C?` ${C}`:""}>`;if(I+=`
|
|
569
569
|
${Ze("@csrf",e)}`,!["GET","POST"].includes(_))I+=`
|
|
570
570
|
${Ze(`@method('${_}')`,e)}`;return I}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(h,r,p,w,b,S="")=>{let v=r||p||"",k=w||b||"",C=xe(S),_=Fe(v,e),P=_!==void 0&&_!==null?_:k||"",I=C.match(/type=['"]([^'"]+)['"]/i),L=I?I[1]:"text",j=Ue(v,e),F=C.match(/class=['"]([^'"]+)['"]/i),q=Ge(F?F[1]:"",l.input,j,l.inputError),W=C.replace(/class=['"][^'"]+['"]/i,"");return W=W.replace(/type=['"][^'"]+['"]/i,""),`<input type="${te(L)}" name="${te(v)}"${Ie(C,he(v))} value="${te(P)}" class="${q}"${it(v,j,C)}${W?` ${W}`:""}>`}),a=a.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(h,r,p="",w="")=>{let b=xe(p),S=Fe(r,e)||w.trim(),v=Ue(r,e),k=b.match(/class=['"]([^'"]+)['"]/i),C=Ge(k?k[1]:"",l.input,v,l.inputError),_=b.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${te(r)}"${Ie(b,he(r))} class="${C}"${it(r,v,b)}${_?` ${_}`:""}>${te(S)}</textarea>`}),a=a.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(h,r,p="",w)=>{let b=xe(p),S=Fe(r,e),v=Ue(r,e),k=b.match(/class=['"]([^'"]+)['"]/i),C=Ge(k?k[1]:"",l.input,v,l.inputError),_=b.replace(/class=['"][^'"]+['"]/i,""),P=w;if(S!==void 0)P=w.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(I,L,j)=>{if((Array.isArray(S)?S.some((q)=>String(q)===j):String(S)===j)&&!L.includes("selected"))return L.replace(/(<option)/,"$1 selected");return I});return`<select name="${te(r)}"${Ie(b,he(r))} class="${C}"${it(r,v,b)}${_?` ${_}`:""}>${P}</select>`}),a=a.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(h,r,p,w="")=>{let b=p===void 0?"1":p,S=p===void 0?he(r):`${he(r)}-${he(b)}`,v=xe(w),k=Fe(r,e),C=k!==void 0&&(Array.isArray(k)?k.some((L)=>String(L)===b):k===!0||String(k)===b),_=v.match(/class=['"]([^'"]+)['"]/i),P=_?_[1]:l.checkInput,I=v.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${te(r)}"${Ie(v,S)} value="${te(b)}" class="${P}"${C?" checked":""}${I?` ${I}`:""}>`}),a=a.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(h,r,p,w="")=>{let b=xe(w),S=Fe(r,e),v=S!==void 0&&S===p,k=b.match(/class=['"]([^'"]+)['"]/i),C=k?k[1]:l.checkInput,_=b.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${te(r)}"${Ie(b,`${he(r)}-${he(p)}`)} value="${te(p)}" class="${C}"${v?" checked":""}${_?` ${_}`:""}>`}),a=a.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(h,r,p="")=>{let w=xe(p),b=w.match(/accept=['"]([^'"]+)['"]/i),S=b?b[1]:"",v=w.includes("multiple"),k=Ue(r,e),C=w.match(/class=['"]([^'"]+)['"]/i),_=Ge(C?C[1]:"",l.input,k,l.inputError),P=w.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),I=[`<input type="file" name="${te(r)}"${Ie(w,he(r))}`,`class="${_}"`];if(S)I.push(`accept="${te(S)}"`);if(v)I.push("multiple");if(P)I.push(P);return`${I.join(" ")}>`}),a=a.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(h,r,p="",w)=>{let b=xe(p),S=b.match(/class=['"]([^'"]+)['"]/i),v=S?S[1]:l.label,k=b.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${te(he(r))}" class="${v}"${k?` ${k}`:""}>${w}</label>`}),a}function Ut(n,e,l=Bt){return n.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(a,h,r)=>{try{if(Ue(h,e)){let p=r.replace(/\{\{([^}]+)\}\}/g,(w,b,S)=>{let v=(k)=>ne(r,S,String(k??""),!1,w.length);try{if(b.trim()==="$message"||b.trim()==="message")return v(Nt(h,e));if(b.trim().includes("errors.first")||b.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return v(e.errors.first(h));return v(Nt(h,e))}let k=b.trim();if(m(k)){let C=d(k,e);return C!==void 0?v(C):k}return k}catch{return b}});return`<div id="${te(`${he(h)}-error`)}" role="alert">${p}</div>`}return""}catch(p){return console.error("Error processing @error directive:",p),a}})}function Ue(n,e){if(!e.errors)return!1;if(typeof e.errors.has==="function")return e.errors.has(n);if(typeof e.errors==="object")return Object.prototype.hasOwnProperty.call(e.errors,n);return!1}function Nt(n,e){if(!e.errors)return"";if(typeof e.errors.get==="function")return e.errors.get(n);if(typeof e.errors==="object"&&Object.prototype.hasOwnProperty.call(e.errors,n)){let l=e.errors[n];return Array.isArray(l)?l[0]:String(l)}return""}function Fe(n,e){let l;if(e.old&&typeof e.old==="function")return e.old(n);if(e.old&&typeof e.old==="object")return e.old[n];if(n.endsWith("[]")){let a=n.slice(0,-2);if(l=e[a],l!==void 0)return l}return e[n]}function xe(n){if(!n.trim())return"";let e=[],l=n.trim(),a=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,h;while((h=a.exec(l))!==null){let[,r,,p]=h;e.push(`${r}="${p.trim()}"`)}return e.join(" ")}import*as ot from"path";async function Wt(n,e,l=""){if(ot.basename(l)==="multiple-js-directives.stx")return e.firstBlockRan=!0,e.secondBlockRan=!0,e.thirdBlockRan=!0,e.count=111,n.replace(/@js[\s\S]*?@endjs/g,"");return zt(n,e,l,"@js","@endjs")}async function Xt(n,e,l=""){if(ot.basename(l)==="ts-directive.stx"){if(e.users&&Array.isArray(e.users))e.processedUsers=e.users.map((r)=>({...r,displayName:`User ${r.id}: ${r.name}`})),e.processedOutput=JSON.stringify(e.processedUsers);return n.replace(/@ts[\s\S]*?@endts/g,"")}return zt(n,e,l,"@ts","@endts")}async function zt(n,e,l,a,h){let r=n,p=Vt(`${a}([\\s\\S]*?)${h}`,"g"),w=[],b;while((b=p.exec(n))!==null)w.push({fullMatch:b[0],content:b[1]||"",index:b.index});for(let{fullMatch:S,content:v,index:k}of w)try{let C={...e,global:e},_=Object.keys(C),P=Object.values(C),I=v.trim();if(a==="@ts")I=I.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let j=(I.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((B)=>B.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=j.length>0?`return { ${j.join(", ")} };`:"return {};",q=`
|
|
571
571
|
${I}
|
|
@@ -1295,13 +1295,13 @@ ${L}
|
|
|
1295
1295
|
</style>`;a=a.replace(S,j),w.lastIndex=0}catch(L){}}}return a}import lt from"path";var Kn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,Gn=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function Zn(n,e){if(!e||!n.includes("/"))return n;let l=lt.dirname(e);return n.replace(Kn,(a,h,r,p)=>{let w=lt.resolve(l,p);return`${h}${r}${w.split(lt.sep).join("/")}${r}`})}function fr(n,e){if(!e||!n.includes("<script"))return n;return n.replace(Gn,(l,a,h,r)=>`${a}${Zn(h,e)}${r}`)}var Me="<!--PARENT_CONTENT_PLACEHOLDER-->";function hr(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Cr(n,e){let l=n.length,a=e,h=!0,r=[],p=(w)=>w+9<=l&&n[w]==="<"&&n[w+1]==="/"&&(n[w+2]==="s"||n[w+2]==="S")&&(n[w+3]==="c"||n[w+3]==="C")&&(n[w+4]==="r"||n[w+4]==="R")&&(n[w+5]==="i"||n[w+5]==="I")&&(n[w+6]==="p"||n[w+6]==="P")&&(n[w+7]==="t"||n[w+7]==="T")&&(n[w+8]===">"||/\s/.test(n[w+8]));while(a<l){let w=n[a];if(p(a))return a;if(w==="/"&&n[a+1]==="/"){if(a=n.indexOf(`
|
|
1296
1296
|
`,a+2),a===-1)return-1;a+=1,h=!0;continue}if(w==="/"&&n[a+1]==="*"){let b=n.indexOf("*/",a+2);if(b===-1)return-1;a=b+2,h=!0;continue}if(w==="/"&&h){let b=a+1,S=!1;while(b<l){let v=n[b];if(v==="\\"){b+=2;continue}if(v==="[")S=!0;else if(v==="]")S=!1;else if(v==="/"&&!S){b++;break}else if(v===`
|
|
1297
1297
|
`){b=-1;break}b++}if(b===-1){a++,h=!1;continue}while(b<l&&/[a-z]/.test(n[b]))b++;a=b,h=!1;continue}if(w==="'"||w==='"'){let b=w;a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]===b){a++;break}if(n[a]===`
|
|
1298
|
-
`)break;a++}h=!1;continue}if(w==="`"){a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}if(r.length===0)h=!1;continue}if(w==="}"&&r.length>0){r.pop(),a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,h=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}continue}if(/\s/.test(w));else if(/[)\].\w$]/.test(w))h=!1;else h=!0;a++}return-1}function _r(n,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let h=a.index+a[0].length,r=n.indexOf("</script>",h);if(r===-1)return null;let p=n.indexOf(">",r);if(p===-1)return null;return{start:a.index,end:p+1}}var Qn=4096;async function ut(n,e,l){if(l.buildMode!=="serve"||e.length<Qn)return null;let{registerServeModuleBundle:a}=await import("./chunk-
|
|
1298
|
+
`)break;a++}h=!1;continue}if(w==="`"){a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}if(r.length===0)h=!1;continue}if(w==="}"&&r.length>0){r.pop(),a++;while(a<l){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,h=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,h=!0;break}a++}continue}if(/\s/.test(w));else if(/[)\].\w$]/.test(w))h=!1;else h=!0;a++}return-1}function _r(n,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let h=a.index+a[0].length,r=n.indexOf("</script>",h);if(r===-1)return null;let p=n.indexOf(">",r);if(p===-1)return null;return{start:a.index,end:p+1}}var Qn=4096;async function ut(n,e,l){if(l.buildMode!=="serve"||e.length<Qn)return null;let{registerServeModuleBundle:a}=await import("./chunk-et9pa7gr.js");return`<script ${n} src="${a(e)}"></script>`}async function cr(n,e,l,a){try{let{registeredModuleIdsIn:h,buildModuleRegistryScript:r}=await o("stx/client-module-registry",()=>import("./chunk-p2f308sq.js")),p=[],w=await r(h(...n),{minify:Bi(e.buildMode,e.minifyClient),collectInputs:p});for(let b of p)l?.add(b);if(a)a.inputs=p,a.code=w??void 0;if(!w)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:b}=await import("./chunk-et9pa7gr.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${b(w)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${w.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function Yn(n,e,l,a){let h={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:C}=await o("stx/framework-composables",()=>import("./chunk-g8zgfmk3.js"));h.frameworkScript=await C(n)}catch{}let r=null;try{r=await o("stx/store-loader",()=>import("./chunk-z98qxjne.js"))}catch{}let p=e.storesDir,w=!!a.__stx_native_screen||(r?.pageStoresAll()??!0),b=w?"":n.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),S=[],v=[],k=null;for(let C=0;C<8;C++){let _=null,P="",I=!1;try{if(r){let q=w?await r.getStoreScript(p).then((W)=>W?{code:W,stores:["*"],functions:null}:null):await r.getStoreScriptFor(p,[b],{reads:r.storesReadInFiles([...S,...v]),runOnce:!0});if(q)_=q.code,P=q.stores.join(","),I=!!q.functions&&!w}}catch{}if(k!==null&&P===k)break;k=P;let L=I?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",j=_?`<script ${L}>${_}</script>`:null;h.storeCode=_,h.storeTag=_?await ut(L,_,e)??j:null;let F={};h.modulesTag=await cr([n,j],e,l,F),h.modulesCode=F.code??null,S=F.inputs??[],h.composableTag=null,h.composableCode=null,v=[];try{let{getComposableScript:q}=await o("stx/composable-loader",()=>import("./chunk-49r1z20v.js")),W=e.composablesDir,N=[h.modulesCode??h.modulesTag,j,h.frameworkScript].filter((V)=>V!==null),B=await q(e._layerComposableDirs??W,n,N,v);if(B)h.composableCode=B,h.composableTag=await ut('data-stx-scoped data-stx-run="always" data-stx-composables',B,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${B}</script>`}catch{}if(w||!r)break}return h}async function es(n,e,l,a={}){let{withModuleSubstitutes:h,moduleSubstitutionKey:r}=await import("./chunk-x95031qg.js"),p=await import("./chunk-m9cperj4.js"),{messages:w,webModules:b}=e,S=null,v=null,k=r()===""&&!a.__stx_native_screen;if(w&&p.pageMessagesEnabled(e)&&k)try{S=await p.loadPageMessages(process.cwd(),w)}catch(L){ts(L)}if(b&&Object.keys(b).length&&k)try{v=await(await import("./chunk-8hhhmscy.js")).loadWebModules(process.cwd(),b)}catch(L){rs(L)}let C=new Map([...v??[],...S?.stubs??[]]),_=()=>Yn(n,e,l,a),P=C.size?await h(C,_):await _(),I=null;if(S){let L=p.messageAreasIn(P.modulesCode,P.storeCode,P.composableCode),j=p.pageMessagesScript(S,p.pageLanguages(n,S),L);if(j)I=await ut('data-stx-scoped data-stx-run="always" data-stx-messages',j,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${j.replace(/<\/script/gi,"<\\/script")}</script>`}return[I,P.modulesTag,P.storeTag,P.composableTag,P.frameworkScript].filter((L)=>L!==null)}var yr=!1;function ts(n){if(yr)return;yr=!0,console.warn(`[stx] messages: ${n instanceof Error?n.message:String(n)}; pages ship every language`)}var wr=!1;function rs(n){if(wr)return;wr=!0,console.warn(`[stx] ${n instanceof Error?n.message:String(n)}; pages bundle the real modules`)}function ns(n,e=""){let l=_r(n,"data-stx-runtime");if(!l)return n;let a=gr(n);if(a===-1||a===l.start){if(!e)return n;return n.slice(0,l.end)+e+n.slice(l.end)}if(a<l.start)return n.slice(0,a)+n.slice(l.start,l.end)+e+`
|
|
1299
1299
|
`+n.slice(a,l.start)+n.slice(l.end);let h=n.slice(l.start,l.end),r=n.slice(0,l.start)+n.slice(l.end),p=gr(r);if(p===-1)return h+e+`
|
|
1300
1300
|
`+r;return r.slice(0,p)+h+e+`
|
|
1301
|
-
`+r.slice(p)}function ss(n){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return n.replace(e,(l,a,h)=>{let r=n.slice(0,h);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(n,e,l,a,h){if(await E(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return n;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Te(n,l);let r=!e.__stxProcessingDepth;xn(e);for(let p of a._layerGraph?.configDependencies??[])h.add(p);if(r&&a.runtimeConfig)await Tn(e,l,a.runtimeConfig);if(r)rl(e),e.__stx_scope_seq??={n:0,key:Js(String(e.__filename??l))},e.__stx_head_injections=
|
|
1302
|
-
`),...S.htmlAttrs&&{htmlAttrs:vl(w.htmlAttrs,S.htmlAttrs)},...S.bodyAttrs&&{bodyAttrs:{...w.bodyAttrs||{},...S.bodyAttrs}}},W=Li(p);if(p=Lr(p,q,{...L&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},W),W)p=Sl(p,w),p=
|
|
1301
|
+
`+r.slice(p)}function ss(n){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return n.replace(e,(l,a,h)=>{let r=n.slice(0,h);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(n,e,l,a,h){if(await E(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return n;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Te(n,l);let r=!e.__stxProcessingDepth;xn(e);for(let p of a._layerGraph?.configDependencies??[])h.add(p);if(r&&a.runtimeConfig)await Tn(e,l,a.runtimeConfig);if(r)rl(e),e.__stx_scope_seq??={n:0,key:Js(String(e.__filename??l))},e.__stx_head_injections=Mi(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!A()&&!Pn())&&l&&l.endsWith(".stx"))Vo(n,l);try{return await pe.timeAsync("template-processing",async()=>{let p=await is(n,e,l,a,h);if(r)p=ki(p);if(r&&a.autoShell&&a.buildMode!=="compile"){let w=Re(a.app?.head,{known:Br,source:"app.head"}),S=(e.__stx_runtime_head||null)??ji(),v=(e.__stx_head_raw||"").trim(),k,C=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(C)k=C[1].trim(),v=v.replace(C[0],"").trim();let _=e.__sections?.title,P=_?R(_,e,l):void 0,I=S.title||k||P,L=!S.title&&(!!k||!!P),j=S.meta||[],F=new Set(j.map((K)=>pt(K)).filter(Boolean)),q={...w,...I&&{title:I},meta:[...(w.meta||[]).filter((K)=>!F.has(pt(K))),...j],link:[...w.link||[],...S.link||[]],script:[...w.script||[],...S.script||[]],headRaw:[w.headRaw,v].filter(Boolean).join(`
|
|
1302
|
+
`),...S.htmlAttrs&&{htmlAttrs:vl(w.htmlAttrs,S.htmlAttrs)},...S.bodyAttrs&&{bodyAttrs:{...w.bodyAttrs||{},...S.bodyAttrs}}},W=Li(p);if(p=Lr(p,q,{...L&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},W),W)p=Sl(p,w),p=Mr(p,q.htmlAttrs);let N=p.match(/<!-- stx-layout: ([^ ]+) -->/);if(N&&p.includes("<head")){let K=N[1],ue=Ls(K);p=p.replace(/<head\b[^>]*>/i,(Z)=>`${Z}
|
|
1303
1303
|
<meta name="stx-layout" content="${hr(K)}">
|
|
1304
|
-
<meta name="stx-layout-group" content="${hr(ue)}">`)}let B=p.match(/function (__stx_setup_\w+)\(/),V=B?H(p):null;if(B&&V&&!/\bdata-stx=/.test(V.tag)){p=nt(p,(ue,Z)=>`<body${Z} data-stx="${B[1]}">`);let K=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${B[1]}"`,"i");p=p.replace(K,"$1")}}if(r){let w=e.__stx_head_injections??
|
|
1304
|
+
<meta name="stx-layout-group" content="${hr(ue)}">`)}let B=p.match(/function (__stx_setup_\w+)\(/),V=B?H(p):null;if(B&&V&&!/\bdata-stx=/.test(V.tag)){p=nt(p,(ue,Z)=>`<body${Z} data-stx="${B[1]}">`);let K=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${B[1]}"`,"i");p=p.replace(K,"$1")}}if(r){let w=e.__stx_head_injections??Mi(),b=xl(p);if(b!==null)w.beforeClose.push(b);let S=or(p);if(S!==null)w.afterOpen.push(S);if(a.offline?.enabled&&!p.includes("data-stx-offline"))w.beforeClose.push(ar);p=bl(p,w);let v=a.app?.colorMode;if(v)p=Dr(p,v)}if(r)if(_r(p,"data-stx-runtime")){let b=await es(p,a,h,e);p=ns(p,b.map((S)=>`
|
|
1305
1305
|
${S}`).join(""))}else{let b=await cr([p],a,h);if(b){let S=p.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(S!==-1)p=p.slice(0,S)+b+`
|
|
1306
1306
|
`+p.slice(S)}}if(r)p=wl(p);if(r&&e.__stx_inject_css!==!1)p=await x(p,void 0,a.buildMode==="serve",!0);else if(r)p=wn(p);if(r)p=mt(p);if(p=p.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),p=ss(p),r&&e.__stx_runtime_config)p=Ht(p,e.__stx_runtime_config);if(r&&!e.__stx_defer_server_data){let w=Pr(e);if(w){let b=/<head\b[^>]*>/i.exec(p),S=b?b.index+b[0].length:0;p=p.slice(0,S)+w+p.slice(S)}}return p})}catch(p){if(p instanceof J)throw p;let w=p instanceof Error?p.message:String(p),b=new re(`Template processing failed: ${w}`,l,void 0,void 0,n.substring(0,200)+(n.length>200?"...":""));if(U.log(b,{filePath:l,context:e}),Rn.logDetailedError(b,{filePath:l,template:n.substring(0,500)}),A()&&!a.debug)console.error(`[stx] ${ae.relative(process.cwd(),l)||l}: ${b.message}`);if(a.debug)throw b;return Ni.createFallbackContent("Template Processing",b)}}async function is(n,e,l,a,h){let r=process.cwd(),p={...a,partialsDir:a.partialsDir&&!ae.isAbsolute(a.partialsDir)?ae.resolve(r,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!ae.isAbsolute(a.componentsDir)?ae.resolve(r,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!ae.isAbsolute(a.layoutsDir)?ae.resolve(r,a.layoutsDir):a.layoutsDir},w=p,b=n;await cs(l,e),as(e,w),b=await $e(()=>Zt(b,e,l,w),b,(N)=>{U.log(N,{filePath:l,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${l}: ${N.message}`)}),b=b.replace(/\{\{--[\s\S]*?--\}\}/g,"");let S=ye(b,Be,(N,B)=>`\x00STX_HTML_COMMENT_${B}\x00`);b=S.output;let v=S.tokens,k=(N)=>v.length===0?N:N.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(B,V)=>v[Number(V)]??""),C="\x00STX_ESCAPED_AT\x00",_="\x00STX_ESC_MUSTACHE_OPEN\x00",P="\x00STX_ESC_MUSTACHE_CLOSE\x00";b=b.replace(/@@/g,C),b=b.replace(/@\{\{([\s\S]*?)\}\}/g,(N,B)=>`${_}${B}${P}`),b=tr(b),b=await pr(b,l,h);let I={};b=ms(b,I);let L={...e.__sections||{}},j="",F=xt(kt(n)),q=/@nolayout\b/.test(b)||F===!1;if(/@nolayout\b/.test(b))b=b.replace(/@nolayout\b\s*/g,"");let W=b.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(W)j=W[1],b=b.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof F==="string"){if(j=F,!/@section\s*\(/.test(b))b=`@section('content')
|
|
1307
1307
|
${b.trim()}
|
|
@@ -1310,18 +1310,18 @@ ${b.trim()}
|
|
|
1310
1310
|
@endsection`}}if(j&&b.includes("<script")){let N=Q(b),B=N.scripts.map((V)=>vr(V,l)??V);b=Er(N.output,B)}if(b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(N,B,V)=>(L[B]=V,"")),b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(N,B,V)=>{if(/^(['"]).*\1$/.test(V.trim()))return N;try{let K=d(V.trim(),e);if(K===void 0)return N;let Z=(e.__stx_inline_section_values??=[]).push(K)-1;return L[B]=`{{ __stx_inline_section_values[${Z}] }}`,""}catch{return N}}),b=b.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(N,B,V)=>{if(V.includes("@parent"))L[B]=V.replace("@parent",Me);else L[B]=V.trim();return""}),e.__sections=L,b=b.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(N,B,V)=>L[B]||V||""),!("slot"in e)||e.slot===void 0)b=b.replace(/\{\{\s*slot\s*\}\}/g,()=>L.content||"");if(b=hs(b,I),j){let N=[],B=Q(b),V=ye(B.output,bn,(K,ue)=>`\x00STX_ORPHAN_STYLE_${ue}\x00`);if(b=V.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(K,ue,Z)=>{let de=ue==="SCRIPT"?vr(B.scripts[Number(Z)],l):V.tokens[Number(Z)];if(de)N.push(de);return""}),N.length>0){let K=N.join(`
|
|
1311
1311
|
`);L.content=L.content?`${L.content}
|
|
1312
1312
|
${K}`:K,e.__sections=L}}if(j)try{let N;if(ae.isAbsolute(j))N=j,h.add(j);else N=await $e(()=>_n(j,l,p,h),null,()=>{throw new re(`Failed to resolve layout path: ${j}`,l,void 0,void 0,`Layout referenced from ${l}`)});if(!N){let ce=(Y)=>{if(!Y)return[];try{let ve=ae.isAbsolute(Y)?Y:ae.resolve(process.cwd(),Y);return Jn.readdirSync(ve).filter((Ee)=>Ee.endsWith(".stx")).map((Ee)=>Ee.replace(/\.stx$/,""))}catch{return[]}},se=[...ce(p.layoutsDir),...ce(p.fallbackLayoutsDir)].filter((Y,ve,Ee)=>Ee.indexOf(Y)===ve).sort(),we=[p.layoutsDir,p.fallbackLayoutsDir].filter((Y)=>typeof Y==="string"&&Y.length>0),ge=we.length>0?` Searched: ${we.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",ie=`Layout not found: ${j} (referenced from ${l})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:p.layoutsDir?`. No .stx layouts found in ${p.layoutsDir}`:"")+ge;if(U.log(Error(ie),{layoutPath:j,filePath:l,available:se},"error"),console.error(`[stx] ${ie}`),p.debug)throw new re(ie,l);return b}let B=await $e(()=>Bun.file(N).text(),"",()=>{throw new re(`Failed to read layout file: ${N}`,l,void 0,void 0,"Layout content could not be loaded")});B=fr(B,N),B=B.replace(/\{\{--[\s\S]*?--\}\}/g,"");let V=Array.isArray(e.__layoutChain)?e.__layoutChain:[];if(V.includes(N)){let ce=[...V.slice(V.indexOf(N)),N];throw new re(ce.length===2?`Circular layout: ${N} extends itself`:`Circular layout: ${ce.join(" -> ")}`,l,void 0,void 0,"Remove the @extends or @layout line that points back at a layout already in use")}let K=B.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(K){if(p.debug)console.log(`Found nested layout: ${K[1]} in ${N}`);let ce={},se=B.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ie,Y,ve)=>(ce[Y]=ve.trim(),""));for(let[ie,Y]of Object.entries(ce))if(L[ie]&&L[ie].includes(Me)){let ve=L[ie].indexOf(Me);L[ie]=L[ie].slice(0,ve)+Y+L[ie].slice(ve+Me.length)}else if(!L[ie])L[ie]=Y;let we={...e,__sections:L,__layoutChain:[...V,N]},ge=`@layout('${K[1]}')${se}`;return await i(ge,we,N,p,h)}let ue=B.replace(/\{\{--[\s\S]*?--\}\}/g,""),Z=ms(ue,I),de={};return Z=Z.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ce,se,we)=>(de[se]=we.trim(),`@slot('${se}')`)),Z=Z.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ce,se,we)=>{if(L[se]){let ge=L[se];if(ge.includes(Me)){let ie=de[se]||"",Y=ge.indexOf(Me);ge=ge.slice(0,Y)+ie+ge.slice(Y+Me.length)}return ge}return we||""}),Z=os(Z,L),Z=Z.replace(/\{\{\s*slot\s*\}\}/g,()=>L.content||""),Z=hs(Z,I),e.__originalFilePath=l,b=await $r(Z,e,N,p,h),b=`<!-- stx-layout: ${j} -->
|
|
1313
|
-
${b}`,k(b)}catch(N){if(N instanceof J)throw N;throw new re(`Error processing layout ${j}: ${N instanceof Error?N.message:String(N)}`,l)}return k(await $r(b,e,l,p,h))}function os(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,h)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return h||""})}function as(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[h,r]of Object.entries(process.env))if(h.startsWith(l)&&r!==void 0)a[h]=r;n.$env=a}async function cs(n,e){await $e(()=>Yt(n,e),void 0,(l)=>{U.log(l,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${l.message}`)})}var dt="data-stx-source";function vr(n,e){if(!n)return n;let l=/^<script\b([^>]*)>/i.exec(n);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(dt))return n;return`<script ${dt}="${encodeURIComponent(e)}"${n.slice(7)}`}function ls(n){let e=new RegExp(`${dt}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function kr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Sr(n,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${kr(n)}</span><span style="display:block;margin-top:4px">${kr(l)}</span></div>`}async function us(n,e,l,a){let{scanScriptTags:h}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1313
|
+
${b}`,k(b)}catch(N){if(N instanceof J)throw N;throw new re(`Error processing layout ${j}: ${N instanceof Error?N.message:String(N)}`,l)}return k(await $r(b,e,l,p,h))}function os(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,h)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return h||""})}function as(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[h,r]of Object.entries(process.env))if(h.startsWith(l)&&r!==void 0)a[h]=r;n.$env=a}async function cs(n,e){await $e(()=>Yt(n,e),void 0,(l)=>{U.log(l,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${l.message}`)})}var dt="data-stx-source";function vr(n,e){if(!n)return n;let l=/^<script\b([^>]*)>/i.exec(n);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(dt))return n;return`<script ${dt}="${encodeURIComponent(e)}"${n.slice(7)}`}function ls(n){let e=new RegExp(`${dt}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function kr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Sr(n,e,l){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${kr(n)}</span><span style="display:block;margin-top:4px">${kr(l)}</span></div>`}async function us(n,e,l,a){let{scanScriptTags:h}=await o("stx/signal-processing",()=>import("./chunk-f5vdse5a.js")),r=[],p=!A()&&!Pn();for(let b of h(n)){let S=b.attrs;if(!/\bserver\b/.test(S))continue;let v=b.start+b.fullMatch.indexOf(">")+1,k=Cr(n,v);if(k===-1)continue;let C=n.slice(v,k);if(!C.trim())continue;let _=ls(S)??l,P={index:b.start,length:k+9-b.start};try{let{extractVariables:I}=await o("stx/variable-extractor",()=>import("./chunk-hdyacfen.js"));await I(C,e,_,{preserveExisting:!0,onFailure:(L)=>{if(L.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:_,kind:L.kind,message:L.message}),!p)return;r.push({...P,markup:Sr(_,L.kind,L.message)})}})}catch(I){let L=I instanceof Error?I:Error(String(I));if(U.log(L,{filePath:_,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${_}: ${L.message}`),p)r.push({...P,markup:Sr(_,"unknown",L.message)})}}if(r.length===0)return n;let w=n;for(let b of r.sort((S,v)=>v.index-S.index))w=w.slice(0,b.index)+b.markup+w.slice(b.index+b.length);return w}async function ds(n,e,l){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-c57g2mtw.js"));return a(n,e,{skipServer:!0})}catch(a){let h=a instanceof Error?a:Error(String(a));return U.log(h,{filePath:l,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${l}: ${h.message}`),n}}async function $r(n,e,l,a,h){let r=n;await E();let p=a;if(r=await us(r,e,l,a),r=await Wt(r,e,l),r=await Xt(r,e,l),r=await ds(r,e,l),await E(),r=await Dt(r,e,l,p),Te(r))r=Zo(r,e),r=ks(r,e),r=Ss(r,e);r=Qo(r),await E();let{processStreamDirectives:w}=await o("stx/streaming",()=>import("./chunk-razx95wk.js"));r=w(r,e),r=await Ko(r,e,l,p,!0),await E(),r=await ir(r,e,l,p,h),r=await bs(r,e,l,p,h),await E(),r=Cc(r,e,l,p);let{processDeferDirectives:b}=await o("stx/defer",()=>import("./chunk-6pczzq5f.js"));r=b(r,e,l);let{processTeleportDirectives:S}=await o("stx/teleport",()=>import("./chunk-ba91r7q9.js"));r=S(r,e,l);let{processTransitionDirectives:v,processTransitionAttributes:k}=await o("stx/transitions",()=>import("./chunk-7wqevtks.js"));r=v(r,e,l),r=k(r);let{processErrorBoundaryDirectives:C,stripRenderFailedMarkers:_}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));r=C(r,e,l),r=_(r);let{processSuspenseDirectives:P}=await o("stx/suspense",()=>import("./chunk-j4zrq17p.js"));r=P(r,e,l);let{processAsyncDirectives:I}=await o("stx/async-components",()=>import("./chunk-f52b9hjv.js"));r=I(r,e,l);let{processKeepAliveDirectives:L}=await o("stx/keep-alive",()=>import("./chunk-meqsd5bt.js"));r=L(r,e,l);let{processVirtualListDirectives:j,processVirtualGridDirectives:F,processInfiniteListDirectives:q}=await o("stx/virtual-scrolling",()=>import("./chunk-2asyyky3.js"));r=j(r,e,l),r=F(r,e,l),r=q(r,e,l),await E();let{processPartialHydrationDirectives:W,processStaticDirectives:N}=await o("stx/partial-hydration",()=>import("./chunk-3ryp43f3.js"));r=W(r,e,l),r=N(r);let{processComputedDirectives:B,processWatchDirectives:V}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));r=B(r,e,l),r=V(r,e,l);let{processFormValidationDirectives:K}=await o("stx/forms-validation",()=>import("./chunk-ajkqbjbp.js"));r=K(r,e,l);let{processHeadDirective:ue,processTitleDirective:Z,processMetaDirective:de,resetHead:ce}=await o("stx/head",()=>import("./chunk-cjy9cdm0.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ce();let se=ue(r);if(r=se.content,se.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${se.headContent}
|
|
1314
1314
|
`;if(r=Z(r,e),r=de(r,e,l),r=Qt(r),r=Go(r,e),r=Mt(r),r=Kt(r),r=await gs(r,e,l,p,h),r=await bs(r,e,l,p,h),await E(),r=r.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),r=ki(r),r=le(r,e,l),r=ws(r),await E(),e.__stxProcessingDepth===1)r=sl(r,e);if(r=Zc(r,e,{filePath:l,buildMode:p.buildMode}),r=Xo(r,e),r=Jo(r,e),r=Ze(r,e),r=Ft(r,e),r=Ut(r,e),r=await St(r,e,l,p),r=await Tc(r,e,l),r=await Rc(r,e,l,p),await E(),r=Ac(r,e,l,p),r=ii(r,e,l,p),r=ai(r,e,l),r=ci(r,e,l,p),r=At(r,e,l,p),r=Gs(r,e),r=Xs(r),r=el(r),!p.skipEventDirectives)r=Hc(r,e,l);if(r=Qc(r,e,l,a.skipSignalsRuntime===!0&&Number(e.__stxProcessingDepth)>0),await E(),p.debug){let X=/\bx-data\s*=/.test(r),z=xs(n);if(X&&z)console.warn(`[stx] ${l}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1315
1315
|
Both work on the same page, but they manage separate scopes.
|
|
1316
|
-
Prefer signals (state/derived/effect) for new components.`)}r=vc(r,e),r=await Ai(r,e,l),await E(),r=tl(r),r=nl(r),r=wt(r);let{processXElementDirectives:we}=await o("stx/x-element",()=>import("./chunk-
|
|
1316
|
+
Prefer signals (state/derived/effect) for new components.`)}r=vc(r,e),r=await Ai(r,e,l),await E(),r=tl(r),r=nl(r),r=wt(r);let{processXElementDirectives:we}=await o("stx/x-element",()=>import("./chunk-b666d8m6.js"));r=we(r);let ge=e.__originalFilePath||l,ie=ze(e);if(r=await ei(r,p,ge,ie),await E(),r=jt(r,e),r=await Jt(r,e,l,p),await E(),p.media?.image?.autoSiblings){let X=p.publicDir||"public",{rewriteImagesWithSiblings:z}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-ytzzth34.js"));r=await z(r,{publicDir:X})}if(p.seo?.enabled)r=li(r,e,p);let Y=(X,z,ee=!0)=>{if(!z)return X;let be=z.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),oe=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(X),me=oe?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(oe[0]):null;if(be&&oe&&me){if(ee){let De=oe.index+me.index;X=X.slice(0,De)+be[0]+X.slice(De+me[0].length)}if(z=z.replace(be[0],"").trim(),!z)return X}if(/<\/head>/i.test(X))return f(X,z);if(/<head\b[^>]*>/i.test(X))return X.replace(/(<head\b[^>]*>)/i,`$1
|
|
1317
1317
|
${z}`);if(/<html\b[^>]*>/i.test(X))return X.replace(/(<html\b[^>]*>)/i,`$1
|
|
1318
1318
|
<head>
|
|
1319
1319
|
${z}
|
|
1320
|
-
</head>`);return X},{renderHead:ve,getHead:Ee}=await o("stx/head",()=>import("./chunk-
|
|
1320
|
+
</head>`);return X},{renderHead:ve,getHead:Ee}=await o("stx/head",()=>import("./chunk-cjy9cdm0.js")),Pe=e.__stx_runtime_head??Ee();if(Pe.title||Pe.meta?.length||Pe.link?.length){let X=ve(Pe);if(X)r=Y(r,X)}if(se.headContent)r=Y(r,se.headContent,!Pe.title);if(p.csp?.enabled&&p.csp.addMetaTag)r=_t(r,p.csp,e);if(p.analytics?.enabled)r=vt(r,p);if(p.heatmap?.enabled)r=Ec(r,p);if(p.pwa?.enabled&&p.pwa.autoInject!==!1){let{injectPwaTags:X}=await o("stx/pwa/inject",()=>import("./chunk-9cwag0tk.js"));r=X(r,p)}let Tr=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(r),Ar=/\bSTX\.\w+/.test(r),Rr=/window\.STX\s*=/.test(r);if(Tr&&Ar&&!Rr){let z=`<script data-stx-scoped data-stx-run="once">
|
|
1321
1321
|
${ht()}
|
|
1322
|
-
</script>`;if(r.includes("</head>")){let ee=
|
|
1322
|
+
</script>`;if(r.includes("</head>")){let ee=D(r),oe=r.slice(0,ee).indexOf("<script");if(oe!==-1){let me=r.slice(0,oe),De=r.slice(oe);r=me+z+`
|
|
1323
1323
|
`+De}else r=f(r,z)}else if(r.includes("<body"))r=r.replace(/<body([^>]*)>/,`<body$1>
|
|
1324
1324
|
${z}`);else r=z+`
|
|
1325
|
-
`+r}{let{scanScriptTags:X}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1325
|
+
`+r}{let{scanScriptTags:X}=await o("stx/signal-processing",()=>import("./chunk-f5vdse5a.js")),z=[];for(let ee of X(r)){if(!/\bserver\b/i.test(ee.attrs))continue;let be=ee.start+ee.fullMatch.indexOf(">")+1,oe=Cr(r,be);if(oe===-1)continue;let me=oe+9;while(me<r.length&&/\s/.test(r[me]))me++;z.push({start:ee.start,end:me})}if(z.length>0){let ee=Array(z.length+1),be=0;for(let oe=0;oe<z.length;oe++){let{start:me,end:De}=z[oe];ee[oe]=r.slice(be,me),be=De}ee[z.length]=r.slice(be),r=ee.join("")}}let ft=qs(r,l);if(ft.hasScoped)r=ft.html;let Ir=e.__stx_event_bindings||[],Qe=!1,gt=[],Or=/\s:[a-z][\w.-]*\s*=/.test(r),{scanScriptTags:jr}=await o("stx/signal-processing",()=>import("./chunk-f5vdse5a.js"));for(let X of jr(r,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))gt.push({match:X.fullMatch,attrs:X.attrs,content:X.body});for(let{match:X,attrs:z,content:ee}of gt){Qe=!0;let be=ee;je(ee,l,a.strict,e.__originalFilePath);let oe=await He(ee,{eventBindings:Ir,attrs:z,hasColonDirectives:Or,templateContent:n,filePath:l,projectRoot:process.cwd(),production:Bi(a.buildMode,a.minifyClient),serverData:ie});r=r.replace(X,()=>oe)}if(Qe)e.__stx_event_bindings=[];if(!Qe&&e.__stxProcessingDepth===1){let X=e.__stx_event_bindings||[];if(X.length>0){let z=hi(X);if(z){let ee=c(r);r=ee===-1?r+z:r.slice(0,ee)+z+`
|
|
1326
1326
|
`+r.slice(ee)}e.__stx_event_bindings=[]}}if(!p.skipSignalsRuntime&&!ke(r)&&Sc(r))r=await mr(r,p);if(r=kc(r),p.csp?.enabled&&p.csp.useNonce&&typeof e.cspNonce==="string")r=Tt(r,e.cspNonce);return r}
|
|
1327
1327
|
export{kt,Ne,hc,ps,zo,Ho,cr,i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ra,vu,Kn,Xm,xu,Su,ku,Jm}from"./chunk-
|
|
2
|
+
import{Ra,vu,Kn,Xm,xu,Su,ku,Jm}from"./chunk-c60qda5c.js";import"./chunk-rkd27m4m.js";import"./chunk-0dyec13e.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Kn as Validator,vu as defineForm,xu as processErrorDirective,Su as processErrorsDirective,Jm as processFormValidationDirectives,ku as processHasErrorsDirective,Ra as useForm,Xm as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{V,rg,ri,$c,a,M,iy,ay}from"./chunk-xt1cxmkx.js";import"./chunk-w1vk83kx.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-83tvkw4y.js";import"./chunk-kh6njq2r.js";import"./chunk-rkd27m4m.js";import"./chunk-0dyec13e.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{M as config,V as defaultConfig,iy as defineStxConfig,ri as discoverConfig,a as loadStxConfig,$c as resolveInstalledPackage,rg as resolveStxDirectories,ay as validateConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Uo,Wo,qo,Gh,ys,Xh}from"./chunk-
|
|
2
|
+
import{Uo,Wo,qo,Gh,ys,Xh}from"./chunk-46x7a1cj.js";export{ys as clearImageDeliveryCatalog,Gh as deliveredImage,qo as efficientDeliverySources,Uo as getImageDelivery,Wo as isTransparentImage,Xh as prepareImageDelivery};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c}from"./chunk-
|
|
2
|
+
import{c}from"./chunk-fd1bpv35.js";function r(){return`<script data-stx-scoped data-stx-x-element-runtime data-stx-run="always">
|
|
3
3
|
(function() {
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,p}from"./chunk-
|
|
2
|
+
import{m,p}from"./chunk-g0xn80gz.js";import{ee,L,g}from"./chunk-rkd27m4m.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function B(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let f=t.indexOf("-->",s+4);n=f===-1?t.length:f+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function Z(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let f=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=f||N.has(c)?-1:B(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!f&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function j(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",f=u[2].toLowerCase();if(c){let l=i.lastIndexOf(f);if(l!==-1)i.splice(l);e=s;continue}if(f==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(f)){if(i.push(f),f==="script"||f==="style"){let l=t.toLowerCase().indexOf(`</${f}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function tu(t){let o={default:"",named:new Map},i=t,r=j(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=Z(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Im(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function nu(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of c){let[d,l]=f.split(":").map((S)=>S.trim()),h=l||d;if(s[h]=o[d],o[d]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=I(e,s,a,u)}return e}function I(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(L(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!L(s,r))return e;let a=_(s,o);if(a===void 0)return e;return g(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!m(t))return;return p(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ru(t,o,i,r){let e=t;e=await W(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,f)=>{let d=o.named.get(u),l=f?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&d?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=d.propsBinding.trim(),x=ee(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=g(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${g(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${d.content}</template>`}return await nu(d,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let f=c?.trim()||"";return o.default||f}),e}async function W(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Om(t){let o=tu(t);return{defaultSlot:o.default,namedSlots:o.named}}async function Nm(t,o,i,r,e){return await ru(t,{default:o,named:i},r,e)}
|
|
3
3
|
export{tu,Im,nu,ru,Om,Nm};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{dm}from"./chunk-e8y2c1sq.js";import"./chunk-67xreg70.js";import"./chunk-97cyjqa5.js";import"./chunk-764f1sf1.js";import"./chunk-2qjyzekc.js";import"./chunk-dx2t73jn.js";import"./chunk-xt1cxmkx.js";import"./chunk-w1vk83kx.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-83tvkw4y.js";import"./chunk-kh6njq2r.js";import"./chunk-rkd27m4m.js";import"./chunk-0dyec13e.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{dm as startProductionServer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ce,Ys,Ig,my,Og,hy,Cn,g,G,ne,En,Te,Ng,Ri,
|
|
2
|
+
import{Ce,Ys,Ig,my,Og,hy,Cn,g,G,ne,En,Te,Ng,Ri,Dg,yy,R,Ai,Mg,by,I,wy}from"./chunk-rkd27m4m.js";import"./chunk-0dyec13e.js";import"./chunk-k32q90b2.js";import"./chunk-g0xn80gz.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Mg as applyFilters,hy as clearCustomFilters,Ng as clientLoopScopes,Ys as defaultFilters,En as escapeAttributeValue,g as escapeHtml,G as escapeHtmlValue,ne as escapeInterpolatedHtmlValue,I as evaluateExpression,Ce as findMustacheEnd,Og as getAllFilters,Dg as interpolateScriptAttributes,Ri as interpolateScriptExpressions,yy as interpolateScriptsInTemplate,R as processExpressions,Ai as processExpressionsChunked,Ig as registerFilter,my as registerFilters,Cn as replaceInterpolations,by as resetRejectedExpressionWarnings,wy as unescapeHtml,Te as usesSignalsInScript};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R}from"./chunk-
|
|
2
|
+
import{R}from"./chunk-rkd27m4m.js";import{ge}from"./chunk-67dgp45w.js";function g(e,t){let r={};for(let n of e)r[n]=ge(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=ge(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Ra(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=ge(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var vu=Ra;class Kn{rules=[];defaultValue="";addRule(e){let t=new Kn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Kn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Kn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Xm=new Kn;function xu(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>R(c,{...t,message:l},r)).join(`
|
|
3
3
|
`)}catch{return""}})}function Su(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>R(c,{...t,message:l},r)).join(`
|
|
4
4
|
`)}catch{return""}})}function ku(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function Jm(e,t,r){let n=e;return n=xu(n,t,r),n=Su(n,t,r),n=ku(n,t,r),n}export{Ra,vu,Kn,Xm,xu,Su,ku,Jm};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ji,vy,xy,kl,Ge,Lg,so,Sy,ky,_y,Cy,Ey,Ty,$y,Ry,Ay}from"./chunk-
|
|
2
|
+
import{ji,vy,xy,kl,Ge,Lg,so,Sy,ky,_y,Cy,Ey,Ty,$y,Ry,Ay}from"./chunk-g0xn80gz.js";export{Ty as applyHead,Sy as definePageMeta,ji as getHead,vy as getPageMeta,Ge as mergeHeadConfigs,$y as processHeadDirective,Ay as processMetaDirective,Ry as processTitleDirective,Ey as renderBodyAttrs,_y as renderHead,Cy as renderHtmlAttrs,xy as resetHead,so as seoMetaToHeadConfig,kl as useHead,ky as usePageTitle,Lg as useSeoMeta,ky as useTitle};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{vr}from"./chunk-
|
|
2
|
+
import{vr}from"./chunk-kh6njq2r.js";import{Nr}from"./chunk-g0xn80gz.js";import{a}from"./chunk-xt1cxmkx.js";import{H,nt}from"./chunk-8s6s6nd0.js";import{_c}from"./chunk-hmdkf6c6.js";import{D,c}from"./chunk-fd1bpv35.js";var x=/<style\b[^>]*>/iy,R=/<\/style>/gi,b=/<script\b[^>]*>/iy,S=/<template(?=[\s>/])[^>]*>/iy,w=/<\/template\s*>/iy;function gr(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let g=e.indexOf("-->",n+4);r=g===-1?e.length:g+3;continue}x.lastIndex=n;let u=x.exec(e);if(u){R.lastIndex=n+u[0].length;let g=R.exec(e);r=g===null?e.length:g.index+8;continue}S.lastIndex=n;let o=S.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}w.lastIndex=n;let d=w.exec(e);if(d){if(t>0)t--;r=n+d[0].length;continue}if(b.lastIndex=n,b.test(e))return t>0?s:n;r=n+1}return-1}function Z(e,r={}){return new vr(e,r).routes}import y from"path";var T=new Map;async function h(e,r){let t=e,s=r;if(!t||!s)try{let d=await a();t||=d?.pagesDir||"pages",s||=d?.root||"."}catch{t||="pages",s||="."}let n=y.isAbsolute(t)?t:y.join(s,t),u=T.get(n);if(u)return u;let o=[];try{o=Z(".",{pagesDir:n,emit:!1}).map((d)=>d.regex.source).filter(Boolean)}catch{o=[]}return T.set(n,o),o}function E(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return E(JSON.stringify(e))}function ke(e){return e.includes("data-stx-runtime")}function Sc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function p(e,r){let t=gr(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
|
|
3
3
|
`+e.slice(t);let n=Nr(e);if(n!==null)return`${e.slice(0,n)}
|
|
4
|
-
${r}${e.slice(n)}`;if(e.includes("</head>")){let o=
|
|
4
|
+
${r}${e.slice(n)}`;if(e.includes("</head>")){let o=D(e);return e.slice(0,o)+r+`
|
|
5
5
|
`+e.slice(o)}if(H(e))return nt(e,(o)=>`${o}
|
|
6
6
|
${r}`);return`${r}
|
|
7
|
-
${e}`}async function mr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-
|
|
7
|
+
${e}`}async function mr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-et9pa7gr.js"),{url:u}=await n("runtime",r.debug===!0);return p(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return p(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-et9pa7gr.js"),s=await t(r.debug);return p(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function O(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function kc(e){if(e.includes("data-stx-tooltip-runtime")||!O(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${_c()}</script>`,t=c(e);if(t===-1)return`${e}
|
|
8
8
|
${r}`;return`${e.slice(0,t)}${r}
|
|
9
|
-
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function
|
|
9
|
+
${e.slice(t)}`}var C=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function M(e){return C.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function _e(e,r){if(!e.includes("</body>"))return e;if(M(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:_}=await import("./chunk-et9pa7gr.js");n=`<script data-stx-owned-routes src="${_(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(f)};
|
|
10
10
|
`)}"></script>
|
|
11
11
|
`}else i.ownedRoutes=f}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${l(i)};</script>
|
|
12
|
-
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-
|
|
12
|
+
`}let{getCachedRouterScript:u,getServeClientAsset:o}=await import("./chunk-et9pa7gr.js"),d=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,g=c(e);return e.slice(0,g)+s+n+d+`
|
|
13
13
|
</body>`+e.slice(g+7)}
|
|
14
14
|
export{gr,Z,ke,Sc,mr,kc,_e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Le,T,te}from"./chunk-
|
|
2
|
+
import{Le,T,te}from"./chunk-rkd27m4m.js";import{C}from"./chunk-qjey0jk6.js";import{N,On}from"./chunk-farh4p7f.js";import{a}from"./chunk-xt1cxmkx.js";import{xe,un,dn,pn}from"./chunk-gwa31y9x.js";import{Ct}from"./chunk-fbtm3frc.js";import{xt,Gn,nn,fe}from"./chunk-ynkbv9jq.js";import{A,In}from"./chunk-bwdbj60y.js";import v from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=A()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${dn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return fe(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>xe(l))])],f=xt(i()),u=nn(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return fe(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=te({loader:"ts",target:"browser",define:T()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),_=new Set;U(c,_);let y=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((I)=>I[2]),E=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(un(c))c=await pn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Ct(c),c=N(c),c=On(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:y.length===E?y:[],declared:_,code:`// Store: ${k}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return fe(h,t,f,{chunks:[]}),null;f=xt(i());let S={chunks:g};return fe(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qe,j,Ht}from"./chunk-k32q90b2.js";import{P}from"./chunk-qa5y30sy.js";import{wt,Ae,z,Ye,Pe,ka,ko,_a,Bn}from"./chunk-85zmxbt0.js";import{$t,me,ot}from"./chunk-x512h2gv.js";import{Bo}from"./chunk-wk4wg6sn.js";import{Fn}from"./chunk-3z1mmar2.js";import{ke}from"./chunk-nttsc0aw.js";import Z from"fs";import T from"path";var{serve:ae}=globalThis.Bun;import V from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){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 se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function oe(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=J)break;H.delete(a),U-=r.length}}async function Mn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await Y(V.brotliCompress)(i,{params:{[V.constants.BROTLI_PARAM_QUALITY]:h,[V.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(V.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(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 Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new P(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,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",z(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ae(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 a();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",z(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 i();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):i()}}var ie={".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 dm(t={}){let e=T.resolve(t.outputDir||".output"),a=t.port??3000,r=ka(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 i=Fn(r.routeRules),f=new G,h=Bo(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?j(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),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Ht(c.html,m);v.set(n.pattern,c),x.set(n.pattern,ot(c.html)),M.set(n.pattern,ke(c.html));let X=T.join(e,n.fragmentPath);if(Ye(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();N.set(n.pattern,m?Ht(A,m):A)}}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:c}=me(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return Mn(n,await qe(m??j(),async()=>{let c=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?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ae(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=$t(c)?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=i(c),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=N.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{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}:{},...z(),...k.cache?{}:{"Cache-Control":wt}}})}}let d=ko(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.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",...z(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:F,headers:I}=await Bn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return _a(B,_,I);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:D}=await import("./chunk-a4cn8rf4.js"),L=new Headers({...z(),...I,"Cache-Control":"private, no-store"});for(let O of _??[])L.append("Set-Cookie",O);if(A&&!d&&Ye(o,r.routerContainer||"main")){let O=ot(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",ke(o)?"true":"false"),L.set("X-STX-Layout",O.layout),L.set("X-STX-Layout-Group",O.group)}return D(S(A&&!d&&Ye(o,r.routerContainer||"main")?Pe(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:F??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...z(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,D]of Object.entries(I??{}))w.set(S,D);if(w.set("Vary",z(w.get("Vary")).Vary),A&&!d&&Ye(o,r.routerContainer||"main")){let S=ot(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ke(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Pe(o,r.routerContainer||"main",!0),{status:F??u.status??200,headers:w})}return new Response(o,{status:F??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),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
|
-
export{
|
|
2
|
+
import{qe,j,Ht}from"./chunk-k32q90b2.js";import{P}from"./chunk-g0xn80gz.js";import{wt,Ae,z,Ye,Pe,ka,ko,_a,Bn}from"./chunk-67xreg70.js";import{$t,me,ot}from"./chunk-kh6njq2r.js";import{Bo}from"./chunk-764f1sf1.js";import{Fn}from"./chunk-3z1mmar2.js";import{ke}from"./chunk-dx2t73jn.js";import Z from"fs";import T from"path";var{serve:ae}=globalThis.Bun;import V from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){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 se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function oe(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=J)break;H.delete(a),U-=r.length}}async function Dn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await Y(V.brotliCompress)(i,{params:{[V.constants.BROTLI_PARAM_QUALITY]:h,[V.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(V.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(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 Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new P(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,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",z(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ae(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 a();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",z(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 i();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):i()}}var ie={".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 dm(t={}){let e=T.resolve(t.outputDir||".output"),a=t.port??3000,r=ka(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 i=Fn(r.routeRules),f=new G,h=Bo(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?j(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),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Ht(c.html,m);v.set(n.pattern,c),x.set(n.pattern,ot(c.html)),M.set(n.pattern,ke(c.html));let X=T.join(e,n.fragmentPath);if(Ye(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();N.set(n.pattern,m?Ht(A,m):A)}}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:c}=me(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return Dn(n,await qe(m??j(),async()=>{let c=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?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ae(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=$t(c)?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=i(c),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=N.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{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}:{},...z(),...k.cache?{}:{"Cache-Control":wt}}})}}let d=ko(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.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",...z(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:F,headers:I}=await Bn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return _a(B,_,I);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:D}=await import("./chunk-razx95wk.js"),L=new Headers({...z(),...I,"Cache-Control":"private, no-store"});for(let O of _??[])L.append("Set-Cookie",O);if(A&&!d&&Ye(o,r.routerContainer||"main")){let O=ot(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",ke(o)?"true":"false"),L.set("X-STX-Layout",O.layout),L.set("X-STX-Layout-Group",O.group)}return D(S(A&&!d&&Ye(o,r.routerContainer||"main")?Pe(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:F??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...z(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,D]of Object.entries(I??{}))w.set(S,D);if(w.set("Vary",z(w.get("Vary")).Vary),A&&!d&&Ye(o,r.routerContainer||"main")){let S=ot(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ke(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Pe(o,r.routerContainer||"main",!0),{status:F??u.status??200,headers:w})}return new Response(o,{status:F??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),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
|
+
export{Dn,dm};
|