@stacksjs/stx 0.2.825 → 0.2.826
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-19gk9k01.js +2 -0
- package/dist/{chunk-jb2rvsf4.js → chunk-1d67wtj4.js} +1 -1
- package/dist/{chunk-yr3ped5m.js → chunk-21syn2j5.js} +1 -1
- package/dist/{chunk-rrkn40eq.js → chunk-2c5bwrnh.js} +1 -1
- package/dist/{chunk-d30p1zvd.js → chunk-2fwssv2z.js} +1 -1
- package/dist/chunk-2v3r330m.js +3 -0
- package/dist/{chunk-3bny2583.js → chunk-2vk7dtvs.js} +1 -1
- package/dist/{chunk-40rzr6qj.js → chunk-4amybnpc.js} +1 -1
- package/dist/{chunk-3dz29mpg.js → chunk-4qhz8q0d.js} +1 -1
- package/dist/{chunk-6tfhx4zw.js → chunk-4zjxj8ex.js} +1 -1
- package/dist/chunk-58e92xts.js +2 -0
- package/dist/{chunk-1qwb0pyb.js → chunk-82v1egn6.js} +1 -1
- package/dist/{chunk-zqsygwa0.js → chunk-897gqcby.js} +1 -1
- package/dist/{chunk-gp37b8vw.js → chunk-8p86mpfv.js} +1 -1
- package/dist/{chunk-djpmrctd.js → chunk-8qy616yt.js} +1 -1
- package/dist/{chunk-0wgjhyb8.js → chunk-8ycrmsba.js} +1 -1
- package/dist/{chunk-a1htb5r5.js → chunk-928y0wer.js} +6 -6
- package/dist/{chunk-z5hmwq1z.js → chunk-9kj5p5jq.js} +1 -1
- package/dist/{chunk-sfr0767s.js → chunk-9z9c025j.js} +1 -1
- package/dist/{chunk-cnh6tcdj.js → chunk-b64y3yh0.js} +1 -1
- package/dist/{chunk-xmdcjyyx.js → chunk-bq7cfqk3.js} +1 -1
- package/dist/{chunk-faxbznng.js → chunk-bwsz6sv4.js} +1 -1
- package/dist/{chunk-en390342.js → chunk-cgtpbr01.js} +5 -5
- package/dist/{chunk-9fm8khcc.js → chunk-cmf6ar8v.js} +2 -2
- package/dist/chunk-d0jcw9h6.js +2 -0
- package/dist/{chunk-e99szqws.js → chunk-d9yjpdyn.js} +4 -4
- package/dist/{chunk-axwa3s1m.js → chunk-e648sx8w.js} +1 -1
- package/dist/chunk-erf2g5b2.js +2 -0
- package/dist/{chunk-030tgwve.js → chunk-exke928x.js} +1 -1
- package/dist/{chunk-vyj9xddw.js → chunk-eycaj8mk.js} +1 -1
- package/dist/{chunk-0kbzs147.js → chunk-f05tmz4z.js} +2 -2
- package/dist/{chunk-9w9vr35m.js → chunk-fwk0gjbq.js} +1 -1
- package/dist/{chunk-ge0k6c49.js → chunk-g25rz48g.js} +1 -1
- package/dist/{chunk-hras294c.js → chunk-gnt36wgk.js} +1 -1
- package/dist/{chunk-rzt51r2b.js → chunk-h864en4b.js} +1 -1
- package/dist/{chunk-pbpr3bdy.js → chunk-he5njpsd.js} +1 -1
- package/dist/{chunk-716qmx26.js → chunk-hhats9b3.js} +1 -1
- package/dist/{chunk-dfy5g8cb.js → chunk-htdbm0sd.js} +1 -1
- package/dist/chunk-jzc3rw49.js +2 -0
- package/dist/{chunk-kg9gnar1.js → chunk-kep17bvj.js} +1 -1
- package/dist/{chunk-y3trpdp9.js → chunk-kfn7g24h.js} +1 -1
- package/dist/chunk-ksxtrmy2.js +2 -0
- package/dist/{chunk-3e7t4qzd.js → chunk-mfc5d181.js} +1 -1
- package/dist/{chunk-3fwhb1q4.js → chunk-mfy2ayv0.js} +1 -1
- package/dist/{chunk-ap2t6fdt.js → chunk-p1sfwzmb.js} +1 -1
- package/dist/chunk-p9dma8k0.js +2 -0
- package/dist/{chunk-7mw1yc6j.js → chunk-pby6dxnc.js} +1 -1
- package/dist/chunk-q2ynwst2.js +2 -0
- package/dist/{chunk-06y0da27.js → chunk-q45xwvf6.js} +1 -1
- package/dist/{chunk-px6336z8.js → chunk-qp7dajd2.js} +1 -1
- package/dist/{chunk-zen28e3p.js → chunk-rptnx3s6.js} +2 -2
- package/dist/{chunk-an1cc36z.js → chunk-s8b6re34.js} +1 -1
- package/dist/{chunk-3wjh3aw8.js → chunk-sk0tmtd3.js} +4 -4
- package/dist/{chunk-kvgxmb0s.js → chunk-t9vwggkw.js} +3 -3
- package/dist/{chunk-vfy3b7gm.js → chunk-tgk2hcxv.js} +2 -2
- package/dist/{chunk-g0zxp9qh.js → chunk-tjhcrj3z.js} +4 -4
- package/dist/chunk-v2ps4gnx.js +2 -0
- package/dist/{chunk-24d3yy27.js → chunk-vwtejkb5.js} +27 -27
- package/dist/{chunk-dsfdgqmd.js → chunk-w45njn1r.js} +1 -1
- package/dist/chunk-x5r1cty7.js +2 -0
- package/dist/{chunk-xegj9wqj.js → chunk-x5vxkypk.js} +1 -1
- package/dist/{chunk-b1n2tq8f.js → chunk-x6863pzd.js} +2 -2
- package/dist/{chunk-ac2vz9c3.js → chunk-y2bf32vg.js} +2 -2
- package/dist/{chunk-5ea3zebc.js → chunk-zd3dsp6p.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/process.js +8 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-4sev2jfs.js +0 -2
- package/dist/chunk-5e5jschg.js +0 -3
- package/dist/chunk-7bjxmzre.js +0 -2
- package/dist/chunk-7vfq8t4x.js +0 -2
- package/dist/chunk-e38gkp8q.js +0 -2
- package/dist/chunk-fm8hq9y2.js +0 -2
- package/dist/chunk-pgpkrf6g.js +0 -2
- package/dist/chunk-rqdnzbq0.js +0 -2
- package/dist/chunk-sx8j2e58.js +0 -2
- package/dist/chunk-t2tv5ezg.js +0 -2
- package/dist/chunk-vvjp9xp0.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Lt,ie,u,f,A,t,ae,q,l,ke,_i,F,Sn,Ci,Ft,Ei,ol,$r,il,it,al,Rr,cl,kn,Ti,ll,Ar,Ir,_e,$i}from"./chunk-8ttmzcxb.js";import{ai,Rc,o,C,Oe,pn,Ne,pe,G,vr,fn,Bs,Bc,Fc,mn,_r,zs,Hs,zc,gi,Hc,Vc,Uc,Wc,De,Le,Vs,Fe,s,bn,h,p,U,Z,Se,_}from"./chunk-
|
|
2
|
+
import{Lt,ie,u,f,A,t,ae,q,l,ke,_i,F,Sn,Ci,Ft,Ei,ol,$r,il,it,al,Rr,cl,kn,Ti,ll,Ar,Ir,_e,$i}from"./chunk-8ttmzcxb.js";import{ai,Rc,o,C,Oe,pn,Ne,pe,G,vr,fn,Bs,Bc,Fc,mn,_r,zs,Hs,zc,gi,Hc,Vc,Uc,Wc,De,Le,Vs,Fe,s,bn,h,p,U,Z,Se,_}from"./chunk-928y0wer.js";import{Dt}from"./chunk-2vqpz4qv.js";import{vn}from"./chunk-e648sx8w.js";import{b}from"./chunk-y2bf32vg.js";import{gr,As}from"./chunk-qj4r08jb.js";import{fc,gc,dr,Qe,mc,I}from"./chunk-rptnx3s6.js";import{Zo,Qo,ei,ti}from"./chunk-xpy9yjyx.js";import{cc,us}from"./chunk-8qy616yt.js";import{is,as,cs}from"./chunk-tjhcrj3z.js";import{gs,Uo,Wo,ms,hs,qo}from"./chunk-f05tmz4z.js";import{ds,or}from"./chunk-gnt36wgk.js";import{Do}from"./chunk-c84pxd2k.js";import{se,Fo,zo,Ho}from"./chunk-wceg59n0.js";import{ar,be,uc,cr,dc}from"./chunk-d9yjpdyn.js";import{j,Ye}from"./chunk-cmnze7at.js";import{hc,yc}from"./chunk-1d67wtj4.js";import{E,_n,Ri}from"./chunk-wpendr22.js";import zn from"fs";import oe from"path";function ut(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -347,7 +347,7 @@ else {
|
|
|
347
347
|
|
|
348
348
|
console.log('[stx] Lifecycle runtime initialized');
|
|
349
349
|
})();
|
|
350
|
-
`}function Ke(n){return Symbol(n)}var
|
|
350
|
+
`}function Ke(n){return Symbol(n)}var ws=Ke("theme"),vs=Ke("router"),xs=Ke("i18n");import*as pt from"crypto";function dt(n){let e=/\$(\w+)\./g,c=[],a;while((a=e.exec(n))!==null)if(!c.includes(a[1]))c.push(a[1]);return c}function Lr(){return`stx-${pt.randomBytes(4).toString("hex")}`}function Pr(n){return/\$\w+\./.test(n)}function Nr(n){if(!/\{\{[^}]*\$\w/.test(n)||!/\$\w+\./.test(n))return{html:n,bindings:[],stores:new Set};let e=[],c=new Set,a=/<(\w+)([^>]*?)(\s*\/?>)/g,g=n;return g=g.replace(a,(r,d,y,m)=>{if(["script","style","template"].includes(d.toLowerCase()))return r;if(!y.includes("{{"))return r;let x=[],w=!1,v=y,k=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,S=[...y.matchAll(k)];for(let R of S){let D=R[0],P=R[1],N=R[2];if(Pr(N)){w=!0;let B=N.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(B){let O=B[1];if(x.push({attr:P,expr:O,fullMatch:D,originalAttr:P}),dt(O).forEach((H)=>c.add(H)),P==="text")v=v.replace(D,"");else if(P==="class")v=v.replace(D,'class=""');else if(P==="disabled"||P==="hidden")v=v.replace(D,"");else v=v.replace(D,`${P}=""`)}}}if(!w)return r;let M=v.match(/\bid\s*=\s*"([^"]+)"/),T;if(M)T=M[1];else T=Lr(),v=` id="${T}"${v}`;for(let R of x)e.push({elementId:T,attribute:R.attr,expression:R.expr,stores:dt(R.expr)});return`<${d}${v}${m}`}),{html:g,bindings:e,stores:c}}function jr(n,e){if(n.length===0)return"";let c=Array.from(e),a=`
|
|
351
351
|
<script>
|
|
352
352
|
(function() {
|
|
353
353
|
'use strict';
|
|
@@ -505,10 +505,10 @@ else {
|
|
|
505
505
|
}
|
|
506
506
|
})();
|
|
507
507
|
</script>
|
|
508
|
-
`,a}function ft(n){let{html:e,bindings:c,stores:a}=
|
|
508
|
+
`,a}function ft(n){let{html:e,bindings:c,stores:a}=Nr(n);if(c.length===0)return n;let g=jr(c,a),r=e.lastIndexOf("</body>");if(r!==-1)return e.slice(0,r)+g+e.slice(r);return e+g}function Hr(n){let e=n.analytics;if(!e?.enabled)return"";switch(e.driver){case"fathom":return Br(e);case"google-analytics":return Fr(e);case"plausible":return Ur(e);case"self-hosted":return qr(e);case"custom":return Vr(e);default:return""}}function Br(n){let e=n.fathom;if(!e?.siteId)return"";let c=e.scriptUrl||"https://cdn.usefathom.com/script.js",a=e.defer!==!1?" defer":"",g=[`data-site="${le(e.siteId)}"`];if(e.honorDnt)g.push('data-honor-dnt="true"');if(e.spa)g.push('data-spa="auto"');if(e.canonical)g.push(`data-canonical="${le(e.canonical)}"`);if(e.auto===!1)g.push('data-auto="false"');return`
|
|
509
509
|
<!-- Fathom Analytics -->
|
|
510
510
|
<script src="${le(c)}" ${g.join(" ")}${a}></script>
|
|
511
|
-
`}function
|
|
511
|
+
`}function Fr(n){let e=n.googleAnalytics;if(!e?.measurementId)return"";let c=le(e.measurementId),a=e.debug?`gtag('config', '${c}', { 'debug_mode': true });`:"";return`
|
|
512
512
|
<!-- Google Analytics -->
|
|
513
513
|
<script async src="https://www.googletagmanager.com/gtag/js?id=${c}"></script>
|
|
514
514
|
<script>
|
|
@@ -518,10 +518,10 @@ else {
|
|
|
518
518
|
gtag('config', '${c}');
|
|
519
519
|
${a}
|
|
520
520
|
</script>
|
|
521
|
-
`}function
|
|
521
|
+
`}function Ur(n){let e=n.plausible;if(!e?.domain)return"";let c=e.scriptUrl||"https://plausible.io/js/script.js",a=[`data-domain="${le(e.domain)}"`],g=c,r=[];if(e.trackLocalhost)r.push("local");if(e.hashMode)r.push("hash");if(r.length>0&&c==="https://plausible.io/js/script.js")g=`https://plausible.io/js/script.${r.join(".")}.js`;return`
|
|
522
522
|
<!-- Plausible Analytics -->
|
|
523
523
|
<script defer data-domain="${le(e.domain)}" src="${le(g)}"></script>
|
|
524
|
-
`}function
|
|
524
|
+
`}function qr(n){let e=n.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let c=le(e.siteId),a=le(e.apiEndpoint),g=e.honorDnt?'if(n.doNotTrack==="1")return;':"",r=e.trackHashChanges?"w.addEventListener('hashchange',pv);":"",d=e.trackOutboundLinks?`
|
|
525
525
|
d.addEventListener('click',function(e){
|
|
526
526
|
var a=e.target.closest('a');
|
|
527
527
|
if(a&&a.hostname!==location.hostname){
|
|
@@ -554,7 +554,7 @@ else {
|
|
|
554
554
|
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
555
555
|
})();
|
|
556
556
|
</script>
|
|
557
|
-
`}function
|
|
557
|
+
`}function Vr(n){let e=n.custom;if(!e)return"";if(e.inlineScript)return`
|
|
558
558
|
<!-- Custom Analytics -->
|
|
559
559
|
<script>
|
|
560
560
|
${e.inlineScript}
|
|
@@ -562,24 +562,24 @@ ${e.inlineScript}
|
|
|
562
562
|
`;if(!e.scriptUrl)return"";let c=[];if(e.scriptId)c.push(`id="${le(e.scriptId)}"`);if(e.attributes)for(let[g,r]of Object.entries(e.attributes))c.push(`${le(g)}="${le(r)}"`);return`
|
|
563
563
|
<!-- Custom Analytics -->
|
|
564
564
|
<script${c.length>0?` ${c.join(" ")}`:""} src="${le(e.scriptUrl)}" defer></script>
|
|
565
|
-
`}function gt(n,e){let c=
|
|
566
|
-
${g}`)}function kt(n,e){let c=n;return c=c.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<script nonce="${e}"${g}>`}),c=c.replace(/<style([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<style nonce="${e}"${g}>`}),c}function St(n,e,c,a){let g=n,r=a.csp;if(g=g.replace(/@csp\b/g,()=>{if(!r?.enabled||!r.directives)return"<!-- CSP not configured -->";let d=r.useNonce?qe(e,r):void 0;return vt(r.directives,d)}),g=g.replace(/@cspNonce\b/g,()=>{if(!r?.enabled||!r.useNonce)return"";return qe(e,r)}),r?.enabled&&r.useNonce)e.cspNonce=qe(e,r);return g}import Gr from"crypto";var Zr=40,$t="_token",Je=null;function Jr(n=Zr){let e=Gr.randomBytes(Math.ceil(n/2)).toString("hex").slice(0,n);return Je=e,e}function Qr(){if(!Je)Jr();return Je}function Yr(n=$t){let e=Qr();return`<input type="hidden" name="${n}" value="${e}">`}function Et(n){return n.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,c,a)=>Yr(a||$t))}async function Tt(n,e,c,a){if(!a.customDirectives||a.customDirectives.length===0)return n;let g=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)g=await en(g,r,e,c,a);else g=await tn(g,r,e,c,a)}return g}async function en(n,e,c,a,g){let{name:r,handler:d}=e,y=`@${r}`,m=`@end${r}`,x=n,w=Lt(`${y}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${m}`,"g"),v=[],k=w.exec(x);while(k!==null){let[S,M="",T=""]=k,R=k.index||0;try{let D=M?_t(e,M):[],P=T.trim(),N=await d(P,D,c,a);v.push({original:S,processed:N,startIndex:R})}catch(D){let P=D instanceof Error?D.message:String(D);if(g.debug)console.error(`Error processing custom directive @${r}:`,D);v.push({original:S,processed:l("CustomDirective",`Error in @${r}${M?`(${M})`:""}: ${P}`,t.EVALUATION_ERROR),startIndex:R})}k=w.exec(x)}for(let S=v.length-1;S>=0;S--){let{original:M,processed:T}=v[S];x=x.replace(M,T)}return x}async function tn(n,e,c,a,g){let{name:r,handler:d}=e,y=n,m=[],x=[];if(e.rawParams){for(let k of Ci(y,Lt(`(?<![\\w$@])@${r}\\s*\\(`,"g")))if(k.end!==-1)x.push({fullMatch:k.call,paramString:k.args,startIndex:k.start})}else{let k=Lt(`@${r}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");k.lastIndex=0;let S=k.exec(y);while(S!==null)x.push({fullMatch:S[0],paramString:S[1]??"",startIndex:S.index||0}),S=k.exec(y)}for(let{fullMatch:k,paramString:S,startIndex:M}of x)try{let T=_t(e,S),R=await d("",T,c,a);m.push({original:k,processed:R,startIndex:M})}catch(T){let R=T instanceof Error?T.message:String(T);if(g.debug)console.error(`Error processing custom directive @${r}:`,T);m.push({original:k,processed:l("CustomDirective",`Error in @${r}(${S}): ${R}`,t.EVALUATION_ERROR),startIndex:M})}let w=Lt(`@${r}(?!\\w)(?!\\s*\\()`,"g"),v=w.exec(y);while(v!==null){let[k]=v,S=v.index||0;try{let M=await d("",[],c,a);m.push({original:k,processed:M,startIndex:S})}catch(M){let T=M instanceof Error?M.message:String(M);if(g.debug)console.error(`Error processing custom directive @${r}:`,M);m.push({original:k,processed:l("CustomDirective",`Error in @${r}: ${T}`,t.EVALUATION_ERROR),startIndex:S})}v=w.exec(y)}for(let k=m.length-1;k>=0;k--){let{original:S,processed:M}=m[k];y=y.replace(S,M)}return y}function _t(n,e){return n.rawParams?Ft(e):rn(e)}function rn(n){if(!n.trim())return[];let e=[],c="",a=!1,g="";for(let r=0;r<n.length;r++){let d=n[r];if((d==='"'||d==="'")&&(r===0||n[r-1]!=="\\"))if(!a)a=!0,g=d;else if(d===g)a=!1;else c+=d;else if(d===","&&!a)e.push(c.trim()),c="";else c+=d}if(c.trim())e.push(c.trim());return e.map((r)=>{let d=r.trim();if(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))return d.substring(1,d.length-1);return d})}var Ct=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,At=/^[A-Za-z_$][\w$]*$/,nn=new Set(["light","dark","system"]);function ve(n,e){if(typeof n!=="string"||n.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function sn(n){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("@appearanceBootstrap expects an options object");let e=n,{appearance:c,colorMode:a}=e;if(ve(e.storageKey,"storageKey"),c!==void 0&&(!c||typeof c!=="object"||Array.isArray(c)))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(ve(a.key,"colorMode.key"),ve(a.attribute,"colorMode.attribute"),ve(a.default,"colorMode.default"),!At.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ct.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!nn.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let g=null;if(c){if(ve(c.key,"appearance.key"),ve(c.attribute,"appearance.attribute"),ve(c.default,"appearance.default"),!At.test(c.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ct.test(c.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(c.allowed)||c.allowed.length===0||c.allowed.some((r)=>typeof r!=="string"||r.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!c.allowed.includes(c.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");g={key:c.key,attribute:c.attribute,allowed:[...new Set(c.allowed)],default:c.default}}return{storageKey:e.storageKey,appearance:g,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function on(n){return JSON.stringify(n).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function an(n){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${on(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 cn(n,e){let c=1,a=null,g=!1;for(let r=e+1;r<n.length;r++){let d=n[r];if(g){g=!1;continue}if(a){if(d==="\\")g=!0;else if(d===a)a=null;continue}if(d==='"'||d==="'"||d==="`"){a=d;continue}if(d==="(")c++;else if(d===")"&&--c===0)return r}return-1}function Rt(n,e){let c=n,a=/@appearanceBootstrap\s*\(/g,g;while((g=a.exec(c))!==null){let r=g.index+g[0].length-1,d=cn(c,r);if(d===-1)throw Error("@appearanceBootstrap has an unclosed options object");let y=c.slice(r+1,d).trim(),m=u(`(${y})`,e),x=an(sn(m));c=c.slice(0,g.index)+x+c.slice(d+1),a.lastIndex=g.index+x.length}return c}import ln from"crypto";function Q(n){return U(String(n??""))}var It={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ve(n,e,c,a){let g=n||e;return c?`${g} ${a}`:g}function fe(n){return String(n).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ce(n,e){if(/\bid\s*=/i.test(n))return"";return` id="${Q(e)}"`}function et(n,e,c){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(c))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(c))a+=` aria-describedby="${Q(`${fe(n)}-error`)}"`;return a}function un(){return ln.randomUUID()}function We(n,e){let c=n;return c=c.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=un();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Q(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),c=c.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,g)=>{let r=g.toUpperCase();if(g&&!["GET","POST"].includes(r))return`<input type="hidden" name="_method" value="${Q(r)}">`;return a}),c}function Ot(n,e,c=It){let a=n;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(g,r,d,y,m,x="")=>{let w=r||d||"POST",v=y||m||"",k=he(x),S=w.toUpperCase(),M=["GET","POST"].includes(S)?S:"POST",T=`<form method="${Q(M)}" action="${Q(v)}"${k?` ${k}`:""}>`;if(T+=`
|
|
565
|
+
`}function gt(n,e){let c=Hr(e);if(!c)return n;if(!n.includes("</head>")){let a=n.lastIndexOf("</body>");if(a!==-1)return n.slice(0,a)+c+n.slice(a);return n+c}return n.replace("</head>",`${c}</head>`)}function le(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function yt(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 mt(n){let e=n?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}import Wr from"fs";import Ge from"path";import{createHighlighter as Xr}from"ts-syntax-highlighter";var Ze=new Map;async function Re(n,e={}){try{if(!await s(n))throw Error(`Markdown file not found: ${n}`);let a=(await Wr.promises.stat(n)).mtime.getTime();if(e.cache&&Ze.has(n)){let v=Ze.get(n);if(v.updatedAt>=a)return{content:v.content,data:v.data}}let g=await Bun.file(n).text(),{data:r,content:d}=dr(g),y=e.markdown||I.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},x=Qe(d,{gfm:!0});if(y.syntaxHighlighting?.enabled&&y.syntaxHighlighting?.serverSide)x=await zr(x,y.syntaxHighlighting?.defaultTheme||"github-dark",y.syntaxHighlighting?.highlightUnknownLanguages||!1);let w={content:x,data:r||{}};if(e.cache)Ze.set(n,{...w,updatedAt:a});return w}catch(c){if(e.debug)console.error(`Error reading/parsing markdown file ${n}:`,c);let a=c instanceof Error?c.message:String(c);return{content:h("Markdown File",`Error reading/parsing markdown file: ${a}`,n,"",0,""),data:{}}}}var Ue=null;async function zr(n,e,c){let a=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Ue)try{Ue=await Xr({theme:e||"github-dark",cache:!0})}catch(y){return console.error("Failed to initialize ts-syntax-highlighter:",y),n}let g=async(y,m,x,w)=>{let v=w.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),k=x||(c?"text":"");if(!k)return y;try{if(!Ue.getSupportedLanguages().includes(k))return y;return(await Ue.highlight(v,k,{theme:e})).html}catch(S){console.error(`Error highlighting code block with language ${x}:`,S)}return y},r=n,d=n.matchAll(a);for(let y of d){let[m,x,w,v]=y,k=await g(m,x,w,v);r=r.replace(m,k)}return r}async function ht(n,e,c="",a={}){return await Kr(n,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(d,y,m,x)=>{try{let w=y;if(!Ge.isAbsolute(y))w=Ge.resolve(Ge.dirname(c),y);let v={};if(m)try{try{v=JSON.parse(m)}catch{if(a.debug)console.warn("Using safer alternative for parsing JS object literal");let P=m.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let N of P){let B=N.indexOf(":");if(B>0){let O=N.substring(0,B).trim(),L=N.substring(B+1).trim(),H=L.startsWith('"')&&L.endsWith('"'),X=L.startsWith("'")&&L.endsWith("'");if(H||X)L=L.substring(1,L.length-1);v[O]=L}}}}catch(D){if(a.debug)console.error("Error parsing context in @markdown-file directive:",D)}let{content:k,data:S}=await Re(w,a),M={...e,...S,...v},T=k,R=/\{\{([^}]+)\}\}/g;return T=T.replace(R,(D,P)=>{let N=P.trim();return M[N]!==void 0?String(M[N]):D}),T}catch(w){let v=w instanceof Error?w.message:String(w);return h("Markdown File",`Error including markdown file: ${v}`,c,n,x,d)}})}async function Kr(n,e,c){let a=[],g;while((g=e.exec(n))!==null){let y=g[0],m=g.index,x=g;a.push(c(...x).then((w)=>({match:y,replacement:w,index:m})))}let r=await Promise.all(a);r.sort((y,m)=>m.index-y.index);let d=n;for(let{match:y,replacement:m}of r)d=d.replace(y,()=>m);return d}var bt=new WeakMap;function wt(n=16){let e=new Uint8Array(n);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function qe(n,e){if(!n)return e?.nonceGenerator?.()??wt();let c=bt.get(n);if(!c)c=e?.nonceGenerator?.()??wt(),bt.set(n,c);return c}function Gr(n,e){let c=[];for(let[a,g]of Object.entries(n)){if(g===void 0||g===null)continue;if(typeof g==="boolean"){if(g)c.push(a);continue}if(Array.isArray(g)){let r=[...g];if(e&&(a==="script-src"||a==="style-src"))r=r.filter((d)=>!d.startsWith("'nonce-")),r.push(`'nonce-${e}'`);if(r.length>0)c.push(`${a} ${r.join(" ")}`)}}return c.join("; ")}function vt(n,e){return`<meta http-equiv="Content-Security-Policy" content="${Gr(n,e).replace(/&/g,"&").replace(/"/g,""")}">`}function xt(n,e,c){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?qe(c,e):void 0,g=vt(e.directives,a);return n.replace(/<head([^>]*)>/,`<head$1>
|
|
566
|
+
${g}`)}function kt(n,e){let c=n;return c=c.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<script nonce="${e}"${g}>`}),c=c.replace(/<style([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<style nonce="${e}"${g}>`}),c}function St(n,e,c,a){let g=n,r=a.csp;if(g=g.replace(/@csp\b/g,()=>{if(!r?.enabled||!r.directives)return"<!-- CSP not configured -->";let d=r.useNonce?qe(e,r):void 0;return vt(r.directives,d)}),g=g.replace(/@cspNonce\b/g,()=>{if(!r?.enabled||!r.useNonce)return"";return qe(e,r)}),r?.enabled&&r.useNonce)e.cspNonce=qe(e,r);return g}import Zr from"crypto";var Jr=40,$t="_token",Je=null;function Qr(n=Jr){let e=Zr.randomBytes(Math.ceil(n/2)).toString("hex").slice(0,n);return Je=e,e}function Yr(){if(!Je)Qr();return Je}function en(n=$t){let e=Yr();return`<input type="hidden" name="${n}" value="${e}">`}function Et(n){return n.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,c,a)=>en(a||$t))}async function Tt(n,e,c,a){if(!a.customDirectives||a.customDirectives.length===0)return n;let g=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)g=await tn(g,r,e,c,a);else g=await rn(g,r,e,c,a)}return g}async function tn(n,e,c,a,g){let{name:r,handler:d}=e,y=`@${r}`,m=`@end${r}`,x=n,w=Lt(`${y}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${m}`,"g"),v=[],k=w.exec(x);while(k!==null){let[S,M="",T=""]=k,R=k.index||0;try{let D=M?_t(e,M):[],P=T.trim(),N=await d(P,D,c,a);v.push({original:S,processed:N,startIndex:R})}catch(D){let P=D instanceof Error?D.message:String(D);if(g.debug)console.error(`Error processing custom directive @${r}:`,D);v.push({original:S,processed:l("CustomDirective",`Error in @${r}${M?`(${M})`:""}: ${P}`,t.EVALUATION_ERROR),startIndex:R})}k=w.exec(x)}for(let S=v.length-1;S>=0;S--){let{original:M,processed:T}=v[S];x=x.replace(M,T)}return x}async function rn(n,e,c,a,g){let{name:r,handler:d}=e,y=n,m=[],x=[];if(e.rawParams){for(let k of Ci(y,Lt(`(?<![\\w$@])@${r}\\s*\\(`,"g")))if(k.end!==-1)x.push({fullMatch:k.call,paramString:k.args,startIndex:k.start})}else{let k=Lt(`@${r}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");k.lastIndex=0;let S=k.exec(y);while(S!==null)x.push({fullMatch:S[0],paramString:S[1]??"",startIndex:S.index||0}),S=k.exec(y)}for(let{fullMatch:k,paramString:S,startIndex:M}of x)try{let T=_t(e,S),R=await d("",T,c,a);m.push({original:k,processed:R,startIndex:M})}catch(T){let R=T instanceof Error?T.message:String(T);if(g.debug)console.error(`Error processing custom directive @${r}:`,T);m.push({original:k,processed:l("CustomDirective",`Error in @${r}(${S}): ${R}`,t.EVALUATION_ERROR),startIndex:M})}let w=Lt(`@${r}(?!\\w)(?!\\s*\\()`,"g"),v=w.exec(y);while(v!==null){let[k]=v,S=v.index||0;try{let M=await d("",[],c,a);m.push({original:k,processed:M,startIndex:S})}catch(M){let T=M instanceof Error?M.message:String(M);if(g.debug)console.error(`Error processing custom directive @${r}:`,M);m.push({original:k,processed:l("CustomDirective",`Error in @${r}: ${T}`,t.EVALUATION_ERROR),startIndex:S})}v=w.exec(y)}for(let k=m.length-1;k>=0;k--){let{original:S,processed:M}=m[k];y=y.replace(S,M)}return y}function _t(n,e){return n.rawParams?Ft(e):nn(e)}function nn(n){if(!n.trim())return[];let e=[],c="",a=!1,g="";for(let r=0;r<n.length;r++){let d=n[r];if((d==='"'||d==="'")&&(r===0||n[r-1]!=="\\"))if(!a)a=!0,g=d;else if(d===g)a=!1;else c+=d;else if(d===","&&!a)e.push(c.trim()),c="";else c+=d}if(c.trim())e.push(c.trim());return e.map((r)=>{let d=r.trim();if(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))return d.substring(1,d.length-1);return d})}var Ct=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,At=/^[A-Za-z_$][\w$]*$/,sn=new Set(["light","dark","system"]);function ve(n,e){if(typeof n!=="string"||n.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function on(n){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("@appearanceBootstrap expects an options object");let e=n,{appearance:c,colorMode:a}=e;if(ve(e.storageKey,"storageKey"),c!==void 0&&(!c||typeof c!=="object"||Array.isArray(c)))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(ve(a.key,"colorMode.key"),ve(a.attribute,"colorMode.attribute"),ve(a.default,"colorMode.default"),!At.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ct.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!sn.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let g=null;if(c){if(ve(c.key,"appearance.key"),ve(c.attribute,"appearance.attribute"),ve(c.default,"appearance.default"),!At.test(c.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Ct.test(c.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(c.allowed)||c.allowed.length===0||c.allowed.some((r)=>typeof r!=="string"||r.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!c.allowed.includes(c.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");g={key:c.key,attribute:c.attribute,allowed:[...new Set(c.allowed)],default:c.default}}return{storageKey:e.storageKey,appearance:g,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function an(n){return JSON.stringify(n).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function cn(n){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${an(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 ln(n,e){let c=1,a=null,g=!1;for(let r=e+1;r<n.length;r++){let d=n[r];if(g){g=!1;continue}if(a){if(d==="\\")g=!0;else if(d===a)a=null;continue}if(d==='"'||d==="'"||d==="`"){a=d;continue}if(d==="(")c++;else if(d===")"&&--c===0)return r}return-1}function Rt(n,e){let c=n,a=/@appearanceBootstrap\s*\(/g,g;while((g=a.exec(c))!==null){let r=g.index+g[0].length-1,d=ln(c,r);if(d===-1)throw Error("@appearanceBootstrap has an unclosed options object");let y=c.slice(r+1,d).trim(),m=u(`(${y})`,e),x=cn(on(m));c=c.slice(0,g.index)+x+c.slice(d+1),a.lastIndex=g.index+x.length}return c}import un from"crypto";function Q(n){return U(String(n??""))}var It={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ve(n,e,c,a){let g=n||e;return c?`${g} ${a}`:g}function fe(n){return String(n).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ce(n,e){if(/\bid\s*=/i.test(n))return"";return` id="${Q(e)}"`}function et(n,e,c){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(c))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(c))a+=` aria-describedby="${Q(`${fe(n)}-error`)}"`;return a}function dn(){return un.randomUUID()}function We(n,e){let c=n;return c=c.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=dn();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Q(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),c=c.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,g)=>{let r=g.toUpperCase();if(g&&!["GET","POST"].includes(r))return`<input type="hidden" name="_method" value="${Q(r)}">`;return a}),c}function Ot(n,e,c=It){let a=n;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(g,r,d,y,m,x="")=>{let w=r||d||"POST",v=y||m||"",k=he(x),S=w.toUpperCase(),M=["GET","POST"].includes(S)?S:"POST",T=`<form method="${Q(M)}" action="${Q(v)}"${k?` ${k}`:""}>`;if(T+=`
|
|
567
567
|
${We("@csrf",e)}`,!["GET","POST"].includes(S))T+=`
|
|
568
568
|
${We(`@method('${S}')`,e)}`;return T}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(g,r,d,y,m,x="")=>{let w=r||d||"",v=y||m||"",k=he(x),S=Pe(w,e),M=S!==void 0&&S!==null?S:v||"",T=k.match(/type=['"]([^'"]+)['"]/i),R=T?T[1]:"text",D=je(w,e),P=k.match(/class=['"]([^'"]+)['"]/i),N=Ve(P?P[1]:"",c.input,D,c.inputError),B=k.replace(/class=['"][^'"]+['"]/i,"");return B=B.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Q(R)}" name="${Q(w)}"${Ce(k,fe(w))} value="${Q(M)}" class="${N}"${et(w,D,k)}${B?` ${B}`:""}>`}),a=a.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(g,r,d="",y="")=>{let m=he(d),x=Pe(r,e)||y.trim(),w=je(r,e),v=m.match(/class=['"]([^'"]+)['"]/i),k=Ve(v?v[1]:"",c.input,w,c.inputError),S=m.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Q(r)}"${Ce(m,fe(r))} class="${k}"${et(r,w,m)}${S?` ${S}`:""}>${Q(x)}</textarea>`}),a=a.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(g,r,d="",y)=>{let m=he(d),x=Pe(r,e),w=je(r,e),v=m.match(/class=['"]([^'"]+)['"]/i),k=Ve(v?v[1]:"",c.input,w,c.inputError),S=m.replace(/class=['"][^'"]+['"]/i,""),M=y;if(x!==void 0)M=y.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(T,R,D)=>{if((Array.isArray(x)?x.some((N)=>String(N)===D):String(x)===D)&&!R.includes("selected"))return R.replace(/(<option)/,"$1 selected");return T});return`<select name="${Q(r)}"${Ce(m,fe(r))} class="${k}"${et(r,w,m)}${S?` ${S}`:""}>${M}</select>`}),a=a.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(g,r,d,y="")=>{let m=d===void 0?"1":d,x=d===void 0?fe(r):`${fe(r)}-${fe(m)}`,w=he(y),v=Pe(r,e),k=v!==void 0&&(Array.isArray(v)?v.some((R)=>String(R)===m):v===!0||String(v)===m),S=w.match(/class=['"]([^'"]+)['"]/i),M=S?S[1]:c.checkInput,T=w.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Q(r)}"${Ce(w,x)} value="${Q(m)}" class="${M}"${k?" checked":""}${T?` ${T}`:""}>`}),a=a.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,r,d,y="")=>{let m=he(y),x=Pe(r,e),w=x!==void 0&&x===d,v=m.match(/class=['"]([^'"]+)['"]/i),k=v?v[1]:c.checkInput,S=m.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Q(r)}"${Ce(m,`${fe(r)}-${fe(d)}`)} value="${Q(d)}" class="${k}"${w?" checked":""}${S?` ${S}`:""}>`}),a=a.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,r,d="")=>{let y=he(d),m=y.match(/accept=['"]([^'"]+)['"]/i),x=m?m[1]:"",w=y.includes("multiple"),v=je(r,e),k=y.match(/class=['"]([^'"]+)['"]/i),S=Ve(k?k[1]:"",c.input,v,c.inputError),M=y.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),T=[`<input type="file" name="${Q(r)}"${Ce(y,fe(r))}`,`class="${S}"`];if(x)T.push(`accept="${Q(x)}"`);if(w)T.push("multiple");if(M)T.push(M);return`${T.join(" ")}>`}),a=a.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(g,r,d="",y)=>{let m=he(d),x=m.match(/class=['"]([^'"]+)['"]/i),w=x?x[1]:c.label,v=m.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Q(fe(r))}" class="${w}"${v?` ${v}`:""}>${y}</label>`}),a}function Pt(n,e,c=It){return n.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(a,g,r)=>{try{if(je(g,e)){let d=r.replace(/\{\{([^}]+)\}\}/g,(y,m,x)=>{let w=(v)=>Z(r,x,String(v??""),!1,y.length);try{if(m.trim()==="$message"||m.trim()==="message")return w(Mt(g,e));if(m.trim().includes("errors.first")||m.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return w(e.errors.first(g));return w(Mt(g,e))}let v=m.trim();if(f(v)){let k=u(v,e);return k!==void 0?w(k):v}return v}catch{return m}});return`<div id="${Q(`${fe(g)}-error`)}" role="alert">${d}</div>`}return""}catch(d){return console.error("Error processing @error directive:",d),a}})}function je(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 Mt(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 c=e.errors[n];return Array.isArray(c)?c[0]:String(c)}return""}function Pe(n,e){let c;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(c=e[a],c!==void 0)return c}return e[n]}function he(n){if(!n.trim())return"";let e=[],c=n.trim(),a=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,g;while((g=a.exec(c))!==null){let[,r,,d]=g;e.push(`${r}="${d.trim()}"`)}return e.join(" ")}import*as tt from"path";async function Nt(n,e,c=""){if(tt.basename(c)==="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 Ht(n,e,c,"@js","@endjs")}async function jt(n,e,c=""){if(tt.basename(c)==="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 Ht(n,e,c,"@ts","@endts")}async function Ht(n,e,c,a,g){let r=n,d=Lt(`${a}([\\s\\S]*?)${g}`,"g"),y=[],m;while((m=d.exec(n))!==null)y.push({fullMatch:m[0],content:m[1]||"",index:m.index});for(let{fullMatch:x,content:w,index:v}of y)try{let k={...e,global:e},S=Object.keys(k),M=Object.values(k),T=w.trim();if(a==="@ts")T=T.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 D=(T.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((L)=>L.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),P=D.length>0?`return { ${D.join(", ")} };`:"return {};",N=`
|
|
569
569
|
${T}
|
|
570
570
|
${P}
|
|
571
|
-
`,O=Function(...S,N)(...M);if(O&&typeof O==="object")Object.assign(e,O);r=r.replace(x,"")}catch(k){console.error(`Error executing ${a} code block in ${c}:`,k);let S=k instanceof Error?k.message:String(k),M=h(`${a} Directive`,`Error executing code: ${S}`,c,n,v,x);console.error(M),r=r.replace(x,"")}return r}function
|
|
571
|
+
`,O=Function(...S,N)(...M);if(O&&typeof O==="object")Object.assign(e,O);r=r.replace(x,"")}catch(k){console.error(`Error executing ${a} code block in ${c}:`,k);let S=k instanceof Error?k.message:String(k),M=h(`${a} Directive`,`Error executing code: ${S}`,c,n,v,x);console.error(M),r=r.replace(x,"")}return r}function gn(n,e="_method"){let c=n.toUpperCase();if(c==="GET"||c==="POST")return"";return`<input type="hidden" name="${e}" value="${c}">`}function Bt(n){return n.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(e,c,a,g,r)=>gn(a,r||"_method"))}async function Ut(n,e,c,a,g){if(!a.middleware||a.middleware.length===0)return n;let r=n,d=a.middleware.filter((y)=>y.timing===g);if(d.length===0)return r;for(let y of d){if(!y.name||typeof y.handler!=="function"){if(a.debug)console.warn("Invalid middleware:",y);continue}try{let m=await y.handler(r,e,c,a);if(typeof m==="string")r=m;else if(a.debug)console.warn(`Middleware ${y.name} did not return a string`)}catch(m){if(a.debug)console.error(`Error in middleware ${y.name}:`,m);if(a.debug){let x=h("Middleware",`Error in middleware '${y.name}': ${m instanceof Error?m.message:String(m)}`,c,n);r=r.replace(/<body[^>]*>/,`$&
|
|
572
572
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${p(x)}</div>
|
|
573
|
-
`)}}}return r}async function qt(n,e,c,a){return Ut(n,e,c,a,"before")}async function Vt(n,e,c,a){return Ut(n,e,c,a,"after")}function Wt(n){return n.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,c,a,g,r)=>{try{let d=g?A(g,{}):{};return gr(a,d,r==="true")}catch(d){return console.error(`Error processing @route directive: ${d}`),"#route-error"}})}var He={patterns:[],exact:{}};async function Xt(n,e){let c=n.split("/").pop()?.split(".")[0]||"";if(He.exact[n])for(let a of He.exact[n])await Promise.resolve(a(e,n));if(He.exact[c])for(let a of He.exact[c])await Promise.resolve(a(e,n));for(let{pattern:a,callback:g}of He.patterns)if(a.test(n)||a.test(c))await Promise.resolve(g(e,n))}var
|
|
573
|
+
`)}}}return r}async function qt(n,e,c,a){return Ut(n,e,c,a,"before")}async function Vt(n,e,c,a){return Ut(n,e,c,a,"after")}function Wt(n){return n.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,c,a,g,r)=>{try{let d=g?A(g,{}):{};return gr(a,d,r==="true")}catch(d){return console.error(`Error processing @route directive: ${d}`),"#route-error"}})}var He={patterns:[],exact:{}};async function Xt(n,e){let c=n.split("/").pop()?.split(".")[0]||"";if(He.exact[n])for(let a of He.exact[n])await Promise.resolve(a(e,n));if(He.exact[c])for(let a of He.exact[c])await Promise.resolve(a(e,n));for(let{pattern:a,callback:g}of He.patterns)if(a.test(n)||a.test(c))await Promise.resolve(g(e,n))}var hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),yn=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function $e(n,e){let c=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;c.lastIndex=e;let a=c.exec(n);if(!a)return null;let g=/\/\s*>$/.test(a[0])||a[1]===a[1].toLowerCase()&&hn.has(a[1]),r=g?a[2].replace(/\/\s*$/,""):a[2];return{full:a[0],tag:a[1],attrs:r,selfClosing:g,start:a.index,end:a.index+a[0].length}}function wn(n,e,c){let a=1,g=c,r=new RegExp(`<${e}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),d=new RegExp(`</${e}\\s*>`,"gi");while(a>0&&g<n.length){r.lastIndex=g,d.lastIndex=g;let y=r.exec(n),m=d.exec(n);if(!m)return-1;if(y&&y.index<m.index)a++,g=y.index+y[0].length;else{if(a--,a===0)return m.index+m[0].length;g=m.index+m[0].length}}return-1}function xe(n,e){if(e.selfClosing)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};let c=wn(n,e.tag,e.end);if(c===-1)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};return{outerStart:e.start,outerEnd:c,innerHTML:n.slice(e.end,c-`</${e.tag}>`.length)}}function zt(n,e){return new RegExp(`(?:^|\\s)${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(n)||n.includes(` ${e}=`)||n.includes(` ${e} `)||n.trimEnd().endsWith(` ${e}`)}function Be(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=n.match(new RegExp(`${c}="([^"]*)"`,"s"))||n.match(new RegExp(`${c}='([^']*)'`,"s"));return a?a[1]:null}function ye(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`\\s*${c}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${c}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${c}(?=\\s|$|>|/)`,"g"),"")}function Ae(n,e,c){let a=e.selfClosing?" /":"",g=`<${e.tag}${c}${a}>`;return n.slice(0,e.start)+g+n.slice(e.end)}function xn(n){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(n)}function $n(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Be(a.attrs,"v-for");if(g===null){c=a.end;continue}let r=g.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!r){c=a.end;continue}let d=r[1].trim(),y=r[2].trim(),m;if(d.includes(",")){let R=d.split(",").map((N)=>N.trim()),D=R[0],P=R[1];m=`${y} as ${P} => ${D}`}else m=`${y} as ${d}`;let x=ye(a.attrs,"v-for"),w=ye(x,":key").replace(/\s*v-bind:key="[^"]*"/g,""),v=xe(e,a),k=e.slice(v.outerStart,v.outerEnd),S=Ae(k,{...a,start:0,end:a.end-a.start},w),M=`@foreach(${m})
|
|
574
574
|
`,T=`${M}${S}
|
|
575
|
-
@endforeach`;e=e.slice(0,v.outerStart)+T+e.slice(v.outerEnd),c=v.outerStart+M.length}return e}function
|
|
575
|
+
@endforeach`;e=e.slice(0,v.outerStart)+T+e.slice(v.outerEnd),c=v.outerStart+M.length}return e}function En(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Be(a.attrs,"v-if");if(g===null){c=a.end;continue}let r=[],d=xe(e,a),y=ye(a.attrs,"v-if"),m=Ae(e.slice(d.outerStart,d.outerEnd),{...a,start:0,end:a.end-a.start},y);r.push({type:"if",expr:g,outerStart:d.outerStart,outerEnd:d.outerEnd,element:m,parsedTag:a});let x=d.outerEnd,w=!0;while(w){let T=e.slice(x).match(/^\s*/),R=T?T[0].length:0,D=$e(e,x+R);if(!D){w=!1;break}let P=Be(D.attrs,"v-else-if"),N=zt(D.attrs,"v-else");if(P!==null){let B=xe(e,D),O=ye(D.attrs,"v-else-if"),L=Ae(e.slice(B.outerStart,B.outerEnd),{...D,start:0,end:D.end-D.start},O);r.push({type:"else-if",expr:P,outerStart:x,outerEnd:B.outerEnd,element:L,parsedTag:D}),x=B.outerEnd}else if(N){let B=xe(e,D),O=ye(D.attrs,"v-else"),L=Ae(e.slice(B.outerStart,B.outerEnd),{...D,start:0,end:D.end-D.start},O);r.push({type:"else",outerStart:x,outerEnd:B.outerEnd,element:L,parsedTag:D}),w=!1}else w=!1}let v=[];for(let T of r)if(T.type==="if")v.push(`@if(${T.expr})
|
|
576
576
|
${T.element}`);else if(T.type==="else-if")v.push(`@elseif(${T.expr})
|
|
577
577
|
${T.element}`);else v.push(`@else
|
|
578
578
|
${T.element}`);v.push("@endif");let k=v.join(`
|
|
579
|
-
`),S=r[0].outerStart,M=r[r.length-1].outerEnd;e=e.slice(0,S)+k+e.slice(M),c=S+k.length}return e}function
|
|
579
|
+
`),S=r[0].outerStart,M=r[r.length-1].outerEnd;e=e.slice(0,S)+k+e.slice(M),c=S+k.length}return e}function Tn(n){return n.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Cn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=yn.has(a.tag),r=a.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(y,m,x)=>{let w=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(m);if(!w||!x||!/^["']/.test(x))return y;let v=w[1]||"modelValue",k=w[2];if(g&&!w[1])return`@model${k}=${x}`;let S=x[0],M=x.slice(1,-1),T=`:${v}=${x} @update:${v}=${S}${M} = $event${S}`;if(k){let R=w[1]?`${v}Modifiers`:"modelModifiers",D=k.slice(1).split(".").map((P)=>`${P}: true`).join(", ");T+=` :${R}="{ ${D} }"`}return T});if(r===a.attrs){c=a.end;continue}let d=Ae(a.full,{...a,start:0,end:a.full.length},r);e=e.slice(0,a.start)+d+e.slice(a.end),c=a.start+d.length}return e}function An(n){return n.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Rn(n){return n.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Mn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Be(a.attrs,"v-html");if(g===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let r=xe(e,a),d=ye(a.attrs,"v-html"),y=a.selfClosing?" /":"",m=`<${a.tag}${d}${y}>{!! ${g} !!}</${a.tag}>`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function Dn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Be(a.attrs,"v-text");if(g===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let r=xe(e,a),d=ye(a.attrs,"v-text"),y=a.selfClosing?" /":"",m=`<${a.tag}${d}${y}>{{ ${g} }}</${a.tag}>`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function In(n){return n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function On(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;if(!zt(a.attrs,"v-once")){c=a.end;continue}let g=ye(a.attrs,"v-once"),r=xe(e,a),d=e.slice(r.outerStart,r.outerEnd),m=`@once
|
|
580
580
|
${Ae(d,{...a,start:0,end:a.end-a.start},g)}
|
|
581
|
-
@endonce`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function
|
|
582
|
-
<meta name="stx-build" content="${e}">`}var No="/_stx/sw.js";function
|
|
581
|
+
@endonce`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function Ln(n){return n.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function Pn(n){return n.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Kt(n){if(!xn(n))return n;let e=n;return e=$n(e),e=En(e),e=On(e),e=An(e),e=Rn(e),e=Cn(e),e=Tn(e),e=Pn(e),e=Mn(e),e=Dn(e),e=In(e),e=Ln(e),e}function Xe(n){return n.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var rt=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),Nn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Gt(n,e){let c=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(n),a=c?c[1]:n,g=u(a,e);if(g&&typeof g==="string")return g;let r=a.trim();return rt.has(r)?r:null}function Zt(n){let e=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(n);return e?e[1]:n}function Jt(n,e,c){let a=e.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),g=a?`<${n} ${a}>`:`<${n}>`;if(Nn.has(n))return a?`<${n} ${a}>`:`<${n}>`;return`${g}${c}</${n}>`}async function Qt(n,e,c,a,g){let r=n,d=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,y=[],m;while((m=d.exec(r))!==null)y.push({full:m[0],expr:m[1],attrs:m[2],slotContent:m[3],index:m.index});for(let x=y.length-1;x>=0;x--){let w=y[x];try{let v=Gt(w.expr,e);if(!v||typeof v!=="string"){let P=`<!-- dynamic component: could not resolve "${Xe(Zt(w.expr))}" -->`;r=r.slice(0,w.index)+P+r.slice(w.index+w.full.length);continue}if(rt.has(v)){let P=Jt(v,w.attrs,w.slotContent);r=r.slice(0,w.index)+P+r.slice(w.index+w.full.length);continue}let k=w.attrs.trim(),S={},M=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,T;while((T=M.exec(k))!==null){let P=T[1]||T[2],N=T[3];if(T[1])try{S[P]=u(N,e)}catch{S[P]=N}else S[P]=N}let R=a.componentsDir||"components",D=await Fe(v,S,w.slotContent,R,e,c,a,new Set,g??new Set);r=r.slice(0,w.index)+D+r.slice(w.index+w.full.length)}catch(v){let k=v instanceof Error?v.message:String(v),S=`<!-- dynamic component error: ${Xe(k)} -->`;r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}}return r=await jn(r,e,c,a,g),r}async function jn(n,e,c,a,g){let r=n,d=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,y=[],m;while((m=d.exec(r))!==null)y.push({full:m[0],expr:m[1],attrs:m[2],index:m.index});for(let x=y.length-1;x>=0;x--){let w=y[x];try{let v=Gt(w.expr,e);if(!v||typeof v!=="string"){let M=`<!-- dynamic component: could not resolve "${Xe(Zt(w.expr))}" -->`;r=r.slice(0,w.index)+M+r.slice(w.index+w.full.length);continue}if(rt.has(v)){let M=Jt(v,w.attrs,"");r=r.slice(0,w.index)+M+r.slice(w.index+w.full.length);continue}let k=a.componentsDir||"components",S=await Fe(v,{},"",k,e,c,a,new Set,g??new Set);r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}catch(v){let k=v instanceof Error?v.message:String(v),S=`<!-- dynamic component error: ${Xe(k)} -->`;r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}}return r}var sc="X-STX-Build",nt=Symbol.for("stx.buildId");function os(){let n=globalThis;if(!n[nt])n[nt]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return n[nt]}function Yt(n,e=os()){if(n.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(n))return null;return`
|
|
582
|
+
<meta name="stx-build" content="${e}">`}var No="/_stx/sw.js";function Hn(n){if(typeof n!=="string"||!n.startsWith("/"))return null;let e=[],c=[],a=n.replace(/\/+$/,"").split("/").slice(1).map((g)=>{let r=/^:(\w+)$/.exec(g)||/^\[(\w+)\]$/.exec(g);if(r)return e.push(r[1]),c.push("0"),"([^/]+)";return c.push(g),g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(!e.length)return null;return{path:n,re:`^/${a.join("/")}/?$`,names:e,sample:`/${c.join("/")}`}}function Bn(n){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let e=navigator.serviceWorker,c=window;if(c.stxOffline)return;let a=null,g=!1,r=[],d={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>a,onUpdateReady(w){if(d.updateReady)try{w()}catch{}else r.push(w);return()=>{let v=r.indexOf(w);if(v!==-1)r.splice(v,1)}},applyUpdate(){let w=a&&a.waiting;if(!w)return!1;return g=!0,w.postMessage({type:"stx:activate-update",force:!0}),!0}};c.stxOffline=d;let y=(w)=>{if(!w.waiting||!e.controller||d.updateReady)return;d.updateReady=!0;let v=r.splice(0);for(let k of v)try{k()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};e.addEventListener("message",(w)=>{let v=w.data||{};if(v.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:v.url,kind:v.kind,fragment:!!v.fragment}}))}catch{}if(v.type==="stx:reachability"){if(c.stxOffline.reachable=v.reachable!==!1,Number(v.at)>0)c.stxOffline.reachedAt=Number(v.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:v.reachable!==!1,at:Number(v.at)||0}}))}catch{}}}),e.addEventListener("controllerchange",()=>{if(g)g=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&a&&a.waiting)a.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let m=()=>{e.register(n,{scope:"/"}).then((w)=>{a=w;try{e.controller?.postMessage({type:"stx:reachability?"})}catch{}if(w.waiting)y(w),w.waiting.postMessage({type:"stx:activate-update",reason:"load"});w.addEventListener("updatefound",()=>{let v=w.installing;if(!v)return;v.addEventListener("statechange",()=>{if(v.state==="installed")y(w)})})}).catch(()=>{})},x=()=>{let w=(v)=>{setTimeout(v,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>w(m));else w(m)};if(!e.controller)if(document.readyState==="complete")x();else addEventListener("load",x);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",x);else x()}function Fn(){let n=`(${Bn.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim().replace(/;$/,"")}catch{return n}}function Un(n,e){if(typeof e==="string"&&e.startsWith("/"))return e==="/"?"/":e.replace(/\/+$/,"");if(!n||!n.startsWith("/"))return null;let c=n.split(/[?#]/)[0].split("/").filter(Boolean)[0];return c?`/${c}`:"/"}var er=`<script data-stx-offline>${Fn()}</script>`;function Mo(n,e){let c=Number(n.precacheTimeoutMs),a={build:String(e||"dev"),pages:Array.from(new Set((n.pages||[]).filter((g)=>typeof g==="string"&&g.startsWith("/")))),staticPages:(n.staticPages||[]).filter((g)=>typeof g==="string"&&((n.pages||[]).includes(g)||(n.routes||[]).includes(g))),api:n.apiPrefix||"/api/",timeout:Math.max(500,Number(n.networkTimeoutMs)||1500),precacheTimeout:Number.isFinite(c)&&c>0?Math.min(2147483647,Math.max(1,Math.floor(c))):1e4,networkFirst:(n.networkFirst||[]).filter((g)=>typeof g==="string"&&g.startsWith("/")),updateOnColdStart:n.updateOnColdStart===!0,fallback:n.fallback||n.pages&&n.pages[0]||null,fallbackScope:Un(n.fallback||n.pages&&n.pages[0]||null,n.fallbackScope),routes:(n.routes||[]).map(Hn).filter(Boolean),exclude:["/_stx/hmr","/_stx/sw.js",...n.exclude||[]],mediaMax:Math.max(10485760,Number(n.mediaMaxBytes)||629145600),assetsMax:Math.max(50,Number(n.assetsMaxEntries)||500)};return`/* stx offline worker, build ${a.build} */
|
|
583
583
|
'use strict';
|
|
584
584
|
var S = ${JSON.stringify(a)};
|
|
585
585
|
var SHELL = 'stx-shell-' + S.build;
|
|
@@ -1283,32 +1283,32 @@ self.addEventListener('fetch', function (event) {
|
|
|
1283
1283
|
event.respondWith(pageResponse(request, event));
|
|
1284
1284
|
}
|
|
1285
1285
|
});
|
|
1286
|
-
`}import Me from"path";function rr(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("//")}async function nr(n,e,c){try{let a;if(n.startsWith("/")){let g=e;for(let r=0;r<5;r++){let d=Me.join(g,n);if(await Bun.file(d).exists())return d;g=Me.dirname(g)}a=Me.join(e,n)}else if(n.startsWith("./")||n.startsWith("../"))a=Me.resolve(e,n);else a=Me.resolve(e,n);if(await Bun.file(a).exists())return a;return null}catch{return null}}var sr=Symbol.for("stx.inline-assets.import-meta");function
|
|
1287
|
-
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw c[sr]=!0,c}async function ir(n,e,c){let a=n,g=Me.dirname(e),r=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,d;while((d=r.exec(a))!==null){let[x,w,v,k]=d;if(rr(v))continue;let S=await nr(v,g,e);if(S)try{let M=await Bun.file(S).text();if(c.add(S),v.endsWith(".ts")||v.endsWith(".tsx")){let R=await Bun.build({entrypoints:[S],target:"browser",minify:!0,define:C()});if(R.outputs.length>0)M=await R.outputs[0].text(),
|
|
1286
|
+
`}import Me from"path";function rr(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("//")}async function nr(n,e,c){try{let a;if(n.startsWith("/")){let g=e;for(let r=0;r<5;r++){let d=Me.join(g,n);if(await Bun.file(d).exists())return d;g=Me.dirname(g)}a=Me.join(e,n)}else if(n.startsWith("./")||n.startsWith("../"))a=Me.resolve(e,n);else a=Me.resolve(e,n);if(await Bun.file(a).exists())return a;return null}catch{return null}}var sr=Symbol.for("stx.inline-assets.import-meta");function qn(n,e){if(!n.includes("import.meta"))return;let c=Error(`[stx] ${e} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
|
|
1287
|
+
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw c[sr]=!0,c}async function ir(n,e,c){let a=n,g=Me.dirname(e),r=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,d;while((d=r.exec(a))!==null){let[x,w,v,k]=d;if(rr(v))continue;let S=await nr(v,g,e);if(S)try{let M=await Bun.file(S).text();if(c.add(S),v.endsWith(".ts")||v.endsWith(".tsx")){let R=await Bun.build({entrypoints:[S],target:"browser",minify:!0,define:C()});if(R.outputs.length>0)M=await R.outputs[0].text(),qn(M,v)}let T=`<script>
|
|
1288
1288
|
// Source: ${v}
|
|
1289
1289
|
${M}
|
|
1290
1290
|
</script>`;a=a.replace(x,T),r.lastIndex=0}catch(M){if(M?.[sr])throw M}}let y=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,m;while((m=y.exec(a))!==null){let[x,w,v,k]=m,S=w+k;if(rr(v))continue;if(/rel=["']stylesheet["']/.test(S)||v.endsWith(".css")){let T=await nr(v,g,e);if(T)try{let R=await Bun.file(T).text();c.add(T);let D=`<style>
|
|
1291
1291
|
/* Source: ${v} */
|
|
1292
1292
|
${R}
|
|
1293
|
-
</style>`;a=a.replace(x,D),y.lastIndex=0}catch(R){}}}return a}import st from"path";var
|
|
1293
|
+
</style>`;a=a.replace(x,D),y.lastIndex=0}catch(R){}}}return a}import st from"path";var Vn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,Wn=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function Xn(n,e){if(!e||!n.includes("/"))return n;let c=st.dirname(e);return n.replace(Vn,(a,g,r,d)=>{let y=st.resolve(c,d);return`${g}${r}${y.split(st.sep).join("/")}${r}`})}function lr(n,e){if(!e||!n.includes("<script"))return n;return n.replace(Wn,(c,a,g,r)=>`${a}${Xn(g,e)}${r}`)}var Ee="<!--PARENT_CONTENT_PLACEHOLDER-->";function ur(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function xr(n,e){let c=n.length,a=e,g=!0,r=[],d=(y)=>y+9<=c&&n[y]==="<"&&n[y+1]==="/"&&(n[y+2]==="s"||n[y+2]==="S")&&(n[y+3]==="c"||n[y+3]==="C")&&(n[y+4]==="r"||n[y+4]==="R")&&(n[y+5]==="i"||n[y+5]==="I")&&(n[y+6]==="p"||n[y+6]==="P")&&(n[y+7]==="t"||n[y+7]==="T")&&(n[y+8]===">"||/\s/.test(n[y+8]));while(a<c){let y=n[a];if(d(a))return a;if(y==="/"&&n[a+1]==="/"){if(a=n.indexOf(`
|
|
1294
1294
|
`,a+2),a===-1)return-1;a+=1,g=!0;continue}if(y==="/"&&n[a+1]==="*"){let m=n.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,g=!0;continue}if(y==="/"&&g){let m=a+1,x=!1;while(m<c){let w=n[m];if(w==="\\"){m+=2;continue}if(w==="[")x=!0;else if(w==="]")x=!1;else if(w==="/"&&!x){m++;break}else if(w===`
|
|
1295
1295
|
`){m=-1;break}m++}if(m===-1){a++,g=!1;continue}while(m<c&&/[a-z]/.test(n[m]))m++;a=m,g=!1;continue}if(y==="'"||y==='"'){let m=y;a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]===m){a++;break}if(n[a]===`
|
|
1296
|
-
`)break;a++}g=!1;continue}if(y==="`"){a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}if(r.length===0)g=!1;continue}if(y==="}"&&r.length>0){r.pop(),a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,g=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}continue}if(/\s/.test(y));else if(/[)\].\w$]/.test(y))g=!1;else g=!0;a++}return-1}function
|
|
1296
|
+
`)break;a++}g=!1;continue}if(y==="`"){a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}if(r.length===0)g=!1;continue}if(y==="}"&&r.length>0){r.pop(),a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,g=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}continue}if(/\s/.test(y));else if(/[)\].\w$]/.test(y))g=!1;else g=!0;a++}return-1}function kr(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${c}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let g=a.index+a[0].length,r=n.indexOf("</script>",g);if(r===-1)return null;let d=n.indexOf(">",r);if(d===-1)return null;return{start:a.index,end:d+1}}var Kn=4096;async function ot(n,e,c){if(c.buildMode!=="serve"||e.length<Kn)return null;let{registerServeModuleBundle:a}=await import("./chunk-4zjxj8ex.js");return`<script ${n} src="${a(e)}"></script>`}async function tr(n,e,c,a){try{let{registeredModuleIdsIn:g,buildModuleRegistryScript:r}=await o("stx/client-module-registry",()=>import("./chunk-2fwssv2z.js")),d=[],y=await r(g(...n),{minify:Ri(e.buildMode,e.minifyClient),collectInputs:d});for(let m of d)c?.add(m);if(a)a.inputs=d,a.code=y??void 0;if(!y)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-4zjxj8ex.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(y)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${y.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function Gn(n,e,c,a){let g={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:k}=await o("stx/framework-composables",()=>import("./chunk-p1sfwzmb.js"));g.frameworkScript=await k(n)}catch{}let r=null;try{r=await o("stx/store-loader",()=>import("./chunk-v2ps4gnx.js"))}catch{}let d=e.storesDir,y=!!a.__stx_native_screen||(r?.pageStoresAll()??!0),m=y?"":n.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],w=[],v=null;for(let k=0;k<8;k++){let S=null,M="",T=!1;try{if(r){let N=y?await r.getStoreScript(d).then((B)=>B?{code:B,stores:["*"],functions:null}:null):await r.getStoreScriptFor(d,[m],{reads:r.storesReadInFiles([...x,...w]),runOnce:!0});if(N)S=N.code,M=N.stores.join(","),T=!!N.functions&&!y}}catch{}if(v!==null&&M===v)break;v=M;let R=T?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",D=S?`<script ${R}>${S}</script>`:null;g.storeCode=S,g.storeTag=S?await ot(R,S,e)??D:null;let P={};g.modulesTag=await tr([n,D],e,c,P),g.modulesCode=P.code??null,x=P.inputs??[],g.composableTag=null,g.composableCode=null,w=[];try{let{getComposableScript:N}=await o("stx/composable-loader",()=>import("./chunk-erf2g5b2.js")),B=e.composablesDir,O=[g.modulesCode??g.modulesTag,D,g.frameworkScript].filter((H)=>H!==null),L=await N(e._layerComposableDirs??B,n,O,w);if(L)g.composableCode=L,g.composableTag=await ot('data-stx-scoped data-stx-run="always" data-stx-composables',L,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${L}</script>`}catch{}if(y||!r)break}return g}async function Zn(n,e,c,a={}){let{withModuleSubstitutes:g,moduleSubstitutionKey:r}=await import("./chunk-897gqcby.js"),d=await import("./chunk-tg18j1yf.js"),{messages:y,webModules:m}=e,x=null,w=null,v=r()===""&&!a.__stx_native_screen;if(y&&d.pageMessagesEnabled(e)&&v)try{x=await d.loadPageMessages(process.cwd(),y)}catch(R){Jn(R)}if(m&&Object.keys(m).length&&v)try{w=await(await import("./chunk-076fj387.js")).loadWebModules(process.cwd(),m)}catch(R){Qn(R)}let k=new Map([...w??[],...x?.stubs??[]]),S=()=>Gn(n,e,c,a),M=k.size?await g(k,S):await S(),T=null;if(x){let R=d.messageAreasIn(M.modulesCode,M.storeCode,M.composableCode),D=d.pageMessagesScript(x,d.pageLanguages(n,x),R);if(D)T=await ot('data-stx-scoped data-stx-run="always" data-stx-messages',D,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${D.replace(/<\/script/gi,"<\\/script")}</script>`}return[T,M.modulesTag,M.storeTag,M.composableTag,M.frameworkScript].filter((R)=>R!==null)}var pr=!1;function Jn(n){if(pr)return;pr=!0,console.warn(`[stx] messages: ${n instanceof Error?n.message:String(n)}; pages ship every language`)}var fr=!1;function Qn(n){if(fr)return;fr=!0,console.warn(`[stx] ${n instanceof Error?n.message:String(n)}; pages bundle the real modules`)}function Yn(n,e=""){let c=kr(n,"data-stx-runtime");if(!c)return n;let a=ar(n);if(a===-1||a===c.start){if(!e)return n;return n.slice(0,c.end)+e+n.slice(c.end)}if(a<c.start)return n.slice(0,a)+n.slice(c.start,c.end)+e+`
|
|
1297
1297
|
`+n.slice(a,c.start)+n.slice(c.end);let g=n.slice(c.start,c.end),r=n.slice(0,c.start)+n.slice(c.end),d=ar(r);if(d===-1)return g+e+`
|
|
1298
1298
|
`+r;return r.slice(0,d)+g+e+`
|
|
1299
|
-
`+r.slice(d)}function
|
|
1299
|
+
`+r.slice(d)}function es(n){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return n.replace(e,(c,a,g)=>{let r=n.slice(0,g);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}var mr=0;async function ts(){if(performance.now()-mr<16)return;await new Promise((n)=>setTimeout(n,0)),mr=performance.now()}async function i(n,e,c,a,g){if(await ts(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return n;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Se(n,c);let r=!e.__stxProcessingDepth;mn(e);for(let d of a._layerGraph?.configDependencies??[])g.add(d);if(r&&a.runtimeConfig)await vn(e,c,a.runtimeConfig);if(r)Uc(e),e.__stx_scope_seq??={n:0,key:Vs(String(e.__filename??c))},e.__stx_head_injections=Ei(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!E()&&!_n())&&c&&c.endsWith(".stx"))Do(n,c);try{return await ie.timeAsync("template-processing",async()=>{let d=await rs(n,e,c,a,g);if(r)d=gi(d);if(r&&a.autoShell&&a.buildMode!=="compile"){let y=_e(a.app?.head,{known:Ir,source:"app.head"}),x=(e.__stx_runtime_head||null)??$i(),w=(e.__stx_head_raw||"").trim(),v,k=w.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(k)v=k[1].trim(),w=w.replace(k[0],"").trim();let S=e.__sections?.title,M=S?_(S,e,c):void 0,T=x.title||v||M,R=!x.title&&(!!v||!!M),D=x.meta||[],P=new Set(D.map((X)=>it(X)).filter(Boolean)),N={...y,...T&&{title:T},meta:[...(y.meta||[]).filter((X)=>!P.has(it(X))),...D],link:[...y.link||[],...x.link||[]],script:[...y.script||[],...x.script||[]],headRaw:[y.headRaw,w].filter(Boolean).join(`
|
|
1300
1300
|
`),...x.htmlAttrs&&{htmlAttrs:al(y.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...y.bodyAttrs||{},...x.bodyAttrs}}},B=Ti(d);if(d=Ar(d,N,{...R&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},B),B)d=ll(d,y),d=Rr(d,N.htmlAttrs);let O=d.match(/<!-- stx-layout: ([^ ]+) -->/);if(O&&d.includes("<head")){let X=O[1],z=As(X);d=d.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
1301
1301
|
<meta name="stx-layout" content="${ur(X)}">
|
|
1302
|
-
<meta name="stx-layout-group" content="${ur(z)}">`)}let L=d.match(/function (__stx_setup_\w+)\(/),H=L?j(d):null;if(L&&H&&!/\bdata-stx=/.test(H.tag)){d=Ye(d,(z,Y)=>`<body${Y} data-stx="${L[1]}">`);let X=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${L[1]}"`,"i");d=d.replace(X,"$1")}}if(r){let y=e.__stx_head_injections??Ei(),m=cl(d);if(m!==null)y.beforeClose.push(m);let x=Yt(d);if(x!==null)y.afterOpen.push(x);if(a.offline?.enabled&&!d.includes("data-stx-offline"))y.beforeClose.push(er);d=ol(d,y);let w=a.app?.colorMode;if(w)d=$r(d,w)}if(r)if(
|
|
1302
|
+
<meta name="stx-layout-group" content="${ur(z)}">`)}let L=d.match(/function (__stx_setup_\w+)\(/),H=L?j(d):null;if(L&&H&&!/\bdata-stx=/.test(H.tag)){d=Ye(d,(z,Y)=>`<body${Y} data-stx="${L[1]}">`);let X=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${L[1]}"`,"i");d=d.replace(X,"$1")}}if(r){let y=e.__stx_head_injections??Ei(),m=cl(d);if(m!==null)y.beforeClose.push(m);let x=Yt(d);if(x!==null)y.afterOpen.push(x);if(a.offline?.enabled&&!d.includes("data-stx-offline"))y.beforeClose.push(er);d=ol(d,y);let w=a.app?.colorMode;if(w)d=$r(d,w)}if(r)if(kr(d,"data-stx-runtime")){let m=await Zn(d,a,g,e);d=Yn(d,m.map((x)=>`
|
|
1303
1303
|
${x}`).join(""))}else{let m=await tr([d],a,g);if(m){let x=d.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)d=d.slice(0,x)+m+`
|
|
1304
|
-
`+d.slice(x)}}if(r)d=il(d);if(r&&e.__stx_inject_css!==!1)d=await b(d,void 0,a.buildMode==="serve",!0);else if(r)d=fn(d);if(d=d.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),d=
|
|
1304
|
+
`+d.slice(x)}}if(r)d=il(d);if(r&&e.__stx_inject_css!==!1)d=await b(d,void 0,a.buildMode==="serve",!0);else if(r)d=fn(d);if(d=d.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),d=es(d),r&&e.__stx_runtime_config)d=Dt(d,e.__stx_runtime_config);if(r&&!e.__stx_defer_server_data){let y=_r(e);if(y){let m=/<head\b[^>]*>/i.exec(d),x=m?m.index+m[0].length:0;d=d.slice(0,x)+y+d.slice(x)}}return d})}catch(d){if(d instanceof q)throw d;let y=d instanceof Error?d.message:String(d),m=new ae(`Template processing failed: ${y}`,c,void 0,void 0,n.substring(0,200)+(n.length>200?"...":""));if(F.log(m,{filePath:c,context:e}),Sn.logDetailedError(m,{filePath:c,template:n.substring(0,500)}),E()&&!a.debug)console.error(`[stx] ${oe.relative(process.cwd(),c)||c}: ${m.message}`);if(a.debug)throw m;return _i.createFallbackContent("Template Processing",m)}}async function rs(n,e,c,a,g){let r=process.cwd(),d={...a,partialsDir:a.partialsDir&&!oe.isAbsolute(a.partialsDir)?oe.resolve(r,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!oe.isAbsolute(a.componentsDir)?oe.resolve(r,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!oe.isAbsolute(a.layoutsDir)?oe.resolve(r,a.layoutsDir):a.layoutsDir},y=d,m=n;await ls(c,e),ss(e,y),m=await ke(()=>qt(m,e,c,y),m,(O)=>{F.log(O,{filePath:c,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${c}: ${O.message}`)}),m=m.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=pe(m,Ne,(O,L)=>`\x00STX_HTML_COMMENT_${L}\x00`);m=x.output;let w=x.tokens,v=(O)=>w.length===0?O:O.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(L,H)=>w[Number(H)]??""),k="\x00STX_ESCAPED_AT\x00",S="\x00STX_ESC_MUSTACHE_OPEN\x00",M="\x00STX_ESC_MUSTACHE_CLOSE\x00";m=m.replace(/@@/g,k),m=m.replace(/@\{\{([\s\S]*?)\}\}/g,(O,L)=>`${S}${L}${M}`),m=Kt(m),m=await ir(m,c,g);let T={};m=as(m,T);let R={...e.__sections||{}},D="",P=mt(yt(n)),N=/@nolayout\b/.test(m)||P===!1;if(/@nolayout\b/.test(m))m=m.replace(/@nolayout\b\s*/g,"");let B=m.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(B)D=B[1],m=m.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof P==="string"){if(D=P,!/@section\s*\(/.test(m))m=`@section('content')
|
|
1305
1305
|
${m.trim()}
|
|
1306
1306
|
@endsection`}if(!D&&!N&&y.defaultLayout){let O=kn(m),L=/@section\s*\(/.test(m);if(!O||L){let H="",X=oe.dirname(c),z=y.layoutsDir?oe.dirname(y.layoutsDir):process.cwd();for(let Y=0;Y<20;Y++){let ee=oe.join(X,"_layout.stx");if(await s(ee)){H=ee;break}let te=oe.dirname(X);if(te===X||te.length<z.length)break;X=te}if(H)D=H;else if(y.layoutsDir){let Y=oe.isAbsolute(y.layoutsDir)?y.layoutsDir:oe.resolve(process.cwd(),y.layoutsDir),ee=oe.join(Y,`${y.defaultLayout}.stx`);if(await s(ee))D=ee}if(D&&!L)m=`@section('content')
|
|
1307
1307
|
${m.trim()}
|
|
1308
|
-
@endsection`}}if(D&&m.includes("<script")){let O=G(m),L=O.scripts.map((H)=>
|
|
1308
|
+
@endsection`}}if(D&&m.includes("<script")){let O=G(m),L=O.scripts.map((H)=>hr(H,c)??H);m=vr(O.output,L)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,L,H)=>(R[L]=H,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,L,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return O;try{let X=u(H.trim(),e);if(X===void 0)return O;let Y=(e.__stx_inline_section_values??=[]).push(X)-1;return R[L]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return O}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,L,H)=>{if(H.includes("@parent"))R[L]=H.replace("@parent",Ee);else R[L]=H.trim();return""}),e.__sections=R,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,L,H)=>R[L]||H||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>R.content||"");if(m=cs(m,T),D){let O=[],L=G(m),H=pe(L.output,pn,(X,z)=>`\x00STX_ORPHAN_STYLE_${z}\x00`);if(m=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(X,z,Y)=>{let ee=z==="SCRIPT"?hr(L.scripts[Number(Y)],c):H.tokens[Number(Y)];if(ee)O.push(ee);return""}),O.length>0){let X=O.join(`
|
|
1309
1309
|
`);R.content=R.content?`${R.content}
|
|
1310
|
-
${X}`:X,e.__sections=R}}if(D)try{let O;if(oe.isAbsolute(D))O=D,g.add(D);else O=await ke(()=>bn(D,c,d,g),null,()=>{throw new ae(`Failed to resolve layout path: ${D}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!O){let ee=(K)=>{if(!K)return[];try{let ge=oe.isAbsolute(K)?K:oe.resolve(process.cwd(),K);return
|
|
1311
|
-
${m}`,v(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${D}: ${O instanceof Error?O.message:String(O)}`,c)}return v(await
|
|
1310
|
+
${X}`:X,e.__sections=R}}if(D)try{let O;if(oe.isAbsolute(D))O=D,g.add(D);else O=await ke(()=>bn(D,c,d,g),null,()=>{throw new ae(`Failed to resolve layout path: ${D}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!O){let ee=(K)=>{if(!K)return[];try{let ge=oe.isAbsolute(K)?K:oe.resolve(process.cwd(),K);return zn.readdirSync(ge).filter((we)=>we.endsWith(".stx")).map((we)=>we.replace(/\.stx$/,""))}catch{return[]}},te=[...ee(d.layoutsDir),...ee(d.fallbackLayoutsDir)].filter((K,ge,we)=>we.indexOf(K)===ge).sort(),ce=[d.layoutsDir,d.fallbackLayoutsDir].filter((K)=>typeof K==="string"&&K.length>0),ue=ce.length>0?` Searched: ${ce.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",ne=`Layout not found: ${D} (referenced from ${c})`+(te.length>0?`. Available layouts: ${te.join(", ")}`:d.layoutsDir?`. No .stx layouts found in ${d.layoutsDir}`:"")+ue;if(F.log(Error(ne),{layoutPath:D,filePath:c,available:te},"error"),console.error(`[stx] ${ne}`),d.debug)throw new ae(ne,c);return m}let L=await ke(()=>Bun.file(O).text(),"",()=>{throw new ae(`Failed to read layout file: ${O}`,c,void 0,void 0,"Layout content could not be loaded")});L=lr(L,O);let H=L.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(d.debug)console.log(`Found nested layout: ${H[1]} in ${O}`);let ee={},te=L.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ne,K,ge)=>(ee[K]=ge.trim(),""));for(let[ne,K]of Object.entries(ee))if(R[ne]&&R[ne].includes(Ee)){let ge=R[ne].indexOf(Ee);R[ne]=R[ne].slice(0,ge)+K+R[ne].slice(ge+Ee.length)}else if(!R[ne])R[ne]=K;let ce={...e,__sections:R},ue=`@layout('${H[1]}')${te}`;return await i(ue,ce,O,d,g)}let X=L.replace(/\{\{--[\s\S]*?--\}\}/g,""),z=as(X,T),Y={};return z=z.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ee,te,ce)=>(Y[te]=ce.trim(),`@slot('${te}')`)),z=z.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ee,te,ce)=>{if(R[te]){let ue=R[te];if(ue.includes(Ee)){let ne=Y[te]||"",K=ue.indexOf(Ee);ue=ue.slice(0,K)+ne+ue.slice(K+Ee.length)}return ue}return ce||""}),z=ns(z,R),z=z.replace(/\{\{\s*slot\s*\}\}/g,()=>R.content||""),z=cs(z,T),e.__originalFilePath=c,m=await wr(z,e,O,d,g),m=`<!-- stx-layout: ${D} -->
|
|
1311
|
+
${m}`,v(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${D}: ${O instanceof Error?O.message:String(O)}`,c)}return v(await wr(m,e,c,d,g))}function ns(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,a,g)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return g||""})}function ss(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let c=e.envPrefix||"STX_PUBLIC_",a={};for(let[g,r]of Object.entries(process.env))if(g.startsWith(c)&&r!==void 0)a[g]=r;n.$env=a}async function ls(n,e){await ke(()=>Xt(n,e),void 0,(c)=>{F.log(c,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${c.message}`)})}var at="data-stx-source";function hr(n,e){if(!n)return n;let c=/^<script\b([^>]*)>/i.exec(n);if(!c||!/\bserver\b/.test(c[1])||c[1].includes(at))return n;return`<script ${at}="${encodeURIComponent(e)}"${n.slice(7)}`}function ps(n){let e=new RegExp(`${at}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function yr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function br(n,e,c){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">${yr(n)}</span><span style="display:block;margin-top:4px">${yr(c)}</span></div>`}async function fs(n,e,c,a){let{scanScriptTags:g}=await o("stx/signal-processing",()=>import("./chunk-htdbm0sd.js")),r=[],d=!E()&&!_n();for(let m of g(n)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let w=m.start+m.fullMatch.indexOf(">")+1,v=xr(n,w);if(v===-1)continue;let k=n.slice(w,v);if(!k.trim())continue;let S=ps(x)??c,M={index:m.start,length:v+9-m.start};try{let{extractVariables:T}=await o("stx/variable-extractor",()=>import("./chunk-exke928x.js"));await T(k,e,S,{preserveExisting:!0,onFailure:(R)=>{if(R.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:S,kind:R.kind,message:R.message}),!d)return;r.push({...M,markup:br(S,R.kind,R.message)})}})}catch(T){let R=T instanceof Error?T:Error(String(T));if(F.log(R,{filePath:S,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${S}: ${R.message}`),d)r.push({...M,markup:br(S,"unknown",R.message)})}}if(r.length===0)return n;let y=n;for(let m of r.sort((x,w)=>w.index-x.index))y=y.slice(0,m.index)+m.markup+y.slice(m.index+m.length);return y}async function ys(n,e,c){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-mfc5d181.js"));return a(n,e,{skipServer:!0})}catch(a){let g=a instanceof Error?a:Error(String(a));return F.log(g,{filePath:c,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${c}: ${g.message}`),n}}async function wr(n,e,c,a,g){let r=n,d=a;if(r=await fs(r,e,c,a),r=await Nt(r,e,c),r=await jt(r,e,c),r=await ys(r,e,c),r=await Tt(r,e,c,d),Se(r))r=Uo(r,e),r=hs(r,e),r=ms(r,e);r=Wo(r);let{processStreamDirectives:y}=await o("stx/streaming",()=>import("./chunk-9z9c025j.js"));r=y(r,e),r=or(r,e,c,d,!0),r=await Qt(r,e,c,d,g),r=await us(r,e,c,d,g),r=fc(r,e,c,d);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-mmeck545.js"));r=m(r,e,c);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-a8fy7jv8.js"));r=x(r,e,c);let{processTransitionDirectives:w,processTransitionAttributes:v}=await o("stx/transitions",()=>import("./chunk-tj7dh2dz.js"));r=w(r,e,c),r=v(r);let{processErrorBoundaryDirectives:k,stripRenderFailedMarkers:S}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));r=k(r,e,c),r=S(r);let{processSuspenseDirectives:M}=await o("stx/suspense",()=>import("./chunk-x30gh7vt.js"));r=M(r,e,c);let{processAsyncDirectives:T}=await o("stx/async-components",()=>import("./chunk-m934bzg2.js"));r=T(r,e,c);let{processKeepAliveDirectives:R}=await o("stx/keep-alive",()=>import("./chunk-k0xdvegc.js"));r=R(r,e,c);let{processVirtualListDirectives:D,processVirtualGridDirectives:P,processInfiniteListDirectives:N}=await o("stx/virtual-scrolling",()=>import("./chunk-q5bct2ks.js"));r=D(r,e,c),r=P(r,e,c),r=N(r,e,c);let{processPartialHydrationDirectives:B,processStaticDirectives:O}=await o("stx/partial-hydration",()=>import("./chunk-j0hrk24j.js"));r=B(r,e,c),r=O(r);let{processComputedDirectives:L,processWatchDirectives:H}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));r=L(r,e,c),r=H(r,e,c);let{processFormValidationDirectives:X}=await o("stx/forms-validation",()=>import("./chunk-qp7dajd2.js"));r=X(r,e,c);let{processHeadDirective:z,processTitleDirective:Y,processMetaDirective:ee,resetHead:te}=await o("stx/head",()=>import("./chunk-s2zsa16d.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)te();let ce=z(r);if(r=ce.content,ce.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${ce.headContent}
|
|
1312
1312
|
`;if(r=Y(r,e),r=ee(r,e,c),r=Wt(r),r=Fo(r,e),r=Et(r),r=Bt(r),r=await is(r,e,c,d,g),r=await us(r,e,c,d,g),r=r.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),r=gi(r),r=se(r,e,c),r=ds(r),e.__stxProcessingDepth===1)r=Wc(r,e);if(r=Bc(r,e,{filePath:c,buildMode:d.buildMode}),r=zo(r,e),r=Ho(r,e),r=We(r,e),r=Ot(r,e),r=Pt(r,e),r=await ht(r,e,c,d),r=await mc(r,e,c),r=await hc(r,e,c,d),r=yc(r,e,c,d),r=Zo(r,e,c,d),r=Qo(r,e,c),r=ei(r,e,c,d),r=St(r,e,c,d),r=zs(r,e),r=Hs(r),r=zc(r),!d.skipEventDirectives)r=Rc(r,e,c);if(r=Fc(r,e,c,a.skipSignalsRuntime===!0&&Number(e.__stxProcessingDepth)>0),d.debug){let V=/\bx-data\s*=/.test(r),W=gs(n);if(V&&W)console.warn(`[stx] ${c}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1313
1313
|
Both work on the same page, but they manage separate scopes.
|
|
1314
1314
|
Prefer signals (state/derived/effect) for new components.`)}r=cc(r,e),r=await _(r,e,c),r=Hc(r),r=Vc(r),r=ft(r);let{processXElementDirectives:ue}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));r=ue(r);let ne=e.__originalFilePath||c,K=De(e);if(r=await qo(r,d,ne,K),r=Rt(r,e),r=await Vt(r,e,c,d),d.media?.image?.autoSiblings){let V=d.publicDir||"public",{rewriteImagesWithSiblings:W}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-6h1qa3hw.js"));r=await W(r,{publicDir:V})}if(d.seo?.enabled)r=ti(r,e,d);let ge=(V,W,J=!0)=>{if(!W)return V;let me=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),re=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(V),de=re?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(re[0]):null;if(me&&re&&de){if(J){let Te=re.index+de.index;V=V.slice(0,Te)+me[0]+V.slice(Te+de[0].length)}if(W=W.replace(me[0],"").trim(),!W)return V}if(/<\/head>/i.test(V))return V.replace(/<\/head>/i,`${W}
|
|
@@ -1316,12 +1316,12 @@ ${m}`,v(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing lay
|
|
|
1316
1316
|
${W}`);if(/<html\b[^>]*>/i.test(V))return V.replace(/(<html\b[^>]*>)/i,`$1
|
|
1317
1317
|
<head>
|
|
1318
1318
|
${W}
|
|
1319
|
-
</head>`);return V},{renderHead:we,getHead:
|
|
1319
|
+
</head>`);return V},{renderHead:we,getHead:Sr}=await o("stx/head",()=>import("./chunk-s2zsa16d.js")),Ie=e.__stx_runtime_head??Sr();if(Ie.title||Ie.meta?.length||Ie.link?.length){let V=we(Ie);if(V)r=ge(r,V)}if(ce.headContent)r=ge(r,ce.headContent,!Ie.title);if(d.csp?.enabled&&d.csp.addMetaTag)r=xt(r,d.csp,e);if(d.analytics?.enabled)r=gt(r,d);if(d.heatmap?.enabled)r=gc(r,d);if(d.pwa?.enabled&&d.pwa.autoInject!==!1){let{injectPwaTags:V}=await o("stx/pwa/inject",()=>import("./chunk-jjbdtj4w.js"));r=V(r,d)}let Er=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(r),Tr=/\bSTX\.\w+/.test(r),Cr=/window\.STX\s*=/.test(r);if(Er&&Tr&&!Cr){let W=`<script data-stx-scoped data-stx-run="once">
|
|
1320
1320
|
${ut()}
|
|
1321
1321
|
</script>`;if(r.includes("</head>")){let J=r.indexOf("</head>"),re=r.slice(0,J).indexOf("<script");if(re!==-1){let de=r.slice(0,re),Te=r.slice(re);r=de+W+`
|
|
1322
1322
|
`+Te}else r=r.replace("</head>",`${W}
|
|
1323
1323
|
</head>`)}else if(r.includes("<body"))r=r.replace(/<body([^>]*)>/,`<body$1>
|
|
1324
1324
|
${W}`);else r=W+`
|
|
1325
|
-
`+r}{let{scanScriptTags:V}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1325
|
+
`+r}{let{scanScriptTags:V}=await o("stx/signal-processing",()=>import("./chunk-htdbm0sd.js")),W=[];for(let J of V(r)){if(!/\bserver\b/i.test(J.attrs))continue;let me=J.start+J.fullMatch.indexOf(">")+1,re=xr(r,me);if(re===-1)continue;let de=re+9;while(de<r.length&&/\s/.test(r[de]))de++;W.push({start:J.start,end:de})}if(W.length>0){let J=Array(W.length+1),me=0;for(let re=0;re<W.length;re++){let{start:de,end:Te}=W[re];J[re]=r.slice(me,de),me=Te}J[W.length]=r.slice(me),r=J.join("")}}let ct=Bs(r,c);if(ct.hasScoped)r=ct.html;let Mr=e.__stx_event_bindings||[],ze=!1,lt=[],Dr=/\s:[a-z][\w.-]*\s*=/.test(r),{scanScriptTags:Or}=await o("stx/signal-processing",()=>import("./chunk-htdbm0sd.js"));for(let V of Or(r,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))lt.push({match:V.fullMatch,attrs:V.attrs,content:V.body});for(let{match:V,attrs:W,content:J}of lt){ze=!0;let me=J;Oe(J,c,a.strict,e.__originalFilePath);let re=await Le(J,{eventBindings:Mr,attrs:W,hasColonDirectives:Dr,templateContent:n,filePath:c,projectRoot:process.cwd(),production:Ri(a.buildMode,a.minifyClient),serverData:K});r=r.replace(V,()=>re)}if(ze)e.__stx_event_bindings=[];if(!ze&&e.__stxProcessingDepth===1){let V=e.__stx_event_bindings||[];if(V.length>0){let W=ai(V);if(W){let J=r.lastIndexOf("</body>");r=J===-1?r+W:r.slice(0,J)+W+`
|
|
1326
1326
|
`+r.slice(J)}e.__stx_event_bindings=[]}}if(!d.skipSignalsRuntime&&!be(r)&&uc(r))r=await cr(r,d);if(r=dc(r),d.csp?.enabled&&d.csp.useNonce&&typeof e.cspNonce==="string")r=kt(r,e.cspNonce);return r}
|
|
1327
1327
|
export{yt,Re,sc,os,No,Mo,tr,i};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ze,N,Dt}from"./chunk-2vqpz4qv.js";import{T}from"./chunk-8ttmzcxb.js";import{ft,Ce,L,qe,Ee,pa,ho,fa,In}from"./chunk-kvgxmb0s.js";import{St,ue,et}from"./chunk-qj4r08jb.js";import{Io}from"./chunk-faxbznng.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-e99szqws.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(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 ae(t){if(!t)return null;let e=oe(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 Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))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 K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),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 T(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",L(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}|${Ce(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,k=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",L(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=k().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 pe={".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 Gg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=pa(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=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,v=new Map,k=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Dt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(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}=ue(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),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=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=pe[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=Ce(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=St(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 O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.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}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(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",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return fa(B,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-sfr0767s.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",L(w.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let S=et(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",be(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??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)}}
|
|
2
|
+
import{ze,N,Dt}from"./chunk-2vqpz4qv.js";import{T}from"./chunk-8ttmzcxb.js";import{ft,Ce,L,qe,Ee,pa,ho,fa,In}from"./chunk-t9vwggkw.js";import{St,ue,et}from"./chunk-qj4r08jb.js";import{Io}from"./chunk-bwsz6sv4.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-d9yjpdyn.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(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 ae(t){if(!t)return null;let e=oe(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 Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))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 K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),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 T(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",L(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}|${Ce(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,k=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",L(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=k().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 pe={".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 Gg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=pa(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=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,v=new Map,k=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Dt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(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}=ue(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),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=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=pe[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=Ce(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=St(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 O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.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}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(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",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return fa(B,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-9z9c025j.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",L(w.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let S=et(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",be(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:w})}return new Response(o,{status:I??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
3
|
export{$n,Gg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tr,i}from"./chunk-vwtejkb5.js";import"./chunk-y2bf32vg.js";import"./chunk-tjhcrj3z.js";import"./chunk-c84pxd2k.js";import"./chunk-8qy616yt.js";import"./chunk-2v3r330m.js";import"./chunk-gnt36wgk.js";import"./chunk-wceg59n0.js";import"./chunk-f05tmz4z.js";import{we}from"./chunk-d9yjpdyn.js";import"./chunk-2nj9aewf.js";import"./chunk-8p86mpfv.js";import"./chunk-rptnx3s6.js";import"./chunk-1d67wtj4.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import{Oe,zs,Hs}from"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{tr as buildModulesTag,we as injectRouterScript,i as processDirectives,zs as processJsonDirective,Hs as processOnceDirective,Oe as validateClientScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,h,p}from"./chunk-
|
|
2
|
+
import{m,h,p}from"./chunk-928y0wer.js";import{B}from"./chunk-rptnx3s6.js";import{i}from"./chunk-vwtejkb5.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 Mm(e,t={},o={}){let n={...B,...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),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,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,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[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,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,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(_,y,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,y,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,y,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|