@stacksjs/stx 0.2.626 → 0.2.629

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.
Files changed (64) hide show
  1. package/dist/{chunk-vddfv082.js → chunk-0fcxfd5f.js} +1 -1
  2. package/dist/{chunk-tc62pvzg.js → chunk-317xf7hx.js} +1 -1
  3. package/dist/{chunk-3h2rpaps.js → chunk-3ap1vsh3.js} +1 -1
  4. package/dist/{chunk-rg4zqdbj.js → chunk-4kyrzkvg.js} +1 -1
  5. package/dist/{chunk-hmpzdq4p.js → chunk-4tyj5vpw.js} +1 -1
  6. package/dist/{chunk-x7v3m9nk.js → chunk-5q7gcr0f.js} +1 -1
  7. package/dist/{chunk-g8f1dqx1.js → chunk-5s91drvs.js} +1 -1
  8. package/dist/{chunk-8xns82s5.js → chunk-6377p5ry.js} +1 -1
  9. package/dist/{chunk-3tp481j5.js → chunk-6j4f8dwx.js} +2 -2
  10. package/dist/{chunk-5wa3ydkf.js → chunk-6kd84jx3.js} +1 -1
  11. package/dist/{chunk-e030grrq.js → chunk-8jgrakqd.js} +17 -17
  12. package/dist/{chunk-9eejvpqc.js → chunk-8zqgb3q9.js} +2 -2
  13. package/dist/{chunk-3dd57j7e.js → chunk-9j2tpg46.js} +1 -1
  14. package/dist/{chunk-j8vd52sg.js → chunk-aktzv0x2.js} +1 -1
  15. package/dist/{chunk-pwsg9w5g.js → chunk-b7fgatb5.js} +1 -1
  16. package/dist/{chunk-wk95x5ym.js → chunk-crws777p.js} +5 -5
  17. package/dist/{chunk-kaz5smvw.js → chunk-dn050jj1.js} +1 -1
  18. package/dist/chunk-dyp3vncz.js +2 -0
  19. package/dist/chunk-fhxfh4nf.js +12 -0
  20. package/dist/{chunk-fqwyfx6c.js → chunk-g9sv00hm.js} +1 -1
  21. package/dist/{chunk-rmc8cg2n.js → chunk-hsmaakds.js} +1 -1
  22. package/dist/{chunk-fvk33v69.js → chunk-jm478rek.js} +1 -1
  23. package/dist/{chunk-a39kvc2p.js → chunk-ksn8mf12.js} +1 -1
  24. package/dist/{chunk-m64w624a.js → chunk-nhmqd1g9.js} +1 -1
  25. package/dist/{chunk-39qcn4gt.js → chunk-pbk2kwec.js} +1 -1
  26. package/dist/{chunk-6jjrvb9v.js → chunk-ppaj0hef.js} +1 -1
  27. package/dist/chunk-q9dh9dte.js +2 -0
  28. package/dist/{chunk-fmdezmt4.js → chunk-qnjhh828.js} +1 -1
  29. package/dist/{chunk-qbh3jk5z.js → chunk-qx2ra6fk.js} +1 -1
  30. package/dist/{chunk-nv0f778q.js → chunk-qxtgxcm8.js} +3 -3
  31. package/dist/{chunk-zvg2h3wd.js → chunk-qz7fyxwp.js} +1 -1
  32. package/dist/{chunk-9pz3jh7w.js → chunk-rdm35qqn.js} +1 -1
  33. package/dist/{chunk-m0zmexz1.js → chunk-s63fkwzc.js} +1 -1
  34. package/dist/{chunk-40fepd2t.js → chunk-sgn1h15s.js} +1 -1
  35. package/dist/{chunk-81h6xyna.js → chunk-snd65r8z.js} +1 -1
  36. package/dist/{chunk-jwqz8w58.js → chunk-sp94c1vv.js} +1 -1
  37. package/dist/{chunk-y3n2cgev.js → chunk-tchpwc6h.js} +1 -1
  38. package/dist/{chunk-qk4zkvzh.js → chunk-vhak3tvx.js} +1 -1
  39. package/dist/{chunk-tftnx4vj.js → chunk-wda1fsbk.js} +1 -1
  40. package/dist/{chunk-18104nfg.js → chunk-wq97shs3.js} +1 -1
  41. package/dist/{chunk-g6mv9vkp.js → chunk-xg1jtz8h.js} +1 -1
  42. package/dist/{chunk-29cbmfrc.js → chunk-xheh68kv.js} +2 -2
  43. package/dist/{chunk-f53x5d7h.js → chunk-xppat53n.js} +1 -1
  44. package/dist/{chunk-w28sn5g5.js → chunk-xxv8rfxs.js} +1 -1
  45. package/dist/{chunk-kep8q407.js → chunk-y17jdnrm.js} +1 -1
  46. package/dist/chunk-yceb9scc.js +2 -0
  47. package/dist/{chunk-rj8fsjx9.js → chunk-z4xqznsb.js} +1 -1
  48. package/dist/{chunk-erk7afjv.js → chunk-zedvwcta.js} +1 -1
  49. package/dist/cli.js +7 -7
  50. package/dist/composables/index.d.ts +1 -0
  51. package/dist/composables/index.js +1 -0
  52. package/dist/composables/use-animation-frame.d.ts +15 -0
  53. package/dist/composables/use-animation-frame.js +62 -0
  54. package/dist/craft-entry.js +1 -1
  55. package/dist/craft.js +1 -1
  56. package/dist/native/runtime/native-host.js +0 -8
  57. package/dist/pwa.js +1 -1
  58. package/dist/ssg.js +2 -2
  59. package/dist/unresolved-identifiers.js +1 -0
  60. package/package.json +5 -5
  61. package/dist/chunk-0r2g00m7.js +0 -2
  62. package/dist/chunk-3rmby39r.js +0 -12
  63. package/dist/chunk-jh2kve7q.js +0 -2
  64. package/dist/chunk-x5cscz50.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ht}from"./chunk-x6pz1h3x.js";import{fi,vs,V,Ge,te,Dt,x,Je,Ye,pr,u}from"./chunk-e030grrq.js";import{D}from"./chunk-szjgbjw1.js";var H=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(H.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function To(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Ge(t,s);if(a>s){i=a;continue}let o=V(t,s);if(o>s){let c=t.slice(s,o),f=q.exec(c);if(f){let l=B(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function W(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function O(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!W(o,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let S=m[1]==="/";if(!S&&(m[2]||"").trimEnd().endsWith("/"))continue;if(g+=S?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:m.index,tagName:a}}return null}return null}var Be="private, no-store";function $o(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ae(t){return t.headers.get("X-STX-Router")==="true"}function X(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function T(t){return{Vary:X(t,"X-STX-Router")}}import E from"path";var J="stx-page-head:",K=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Y(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-k1vjhhd4.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function Ro(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Ur(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=To(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)o.push(f[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:S,defaultConfig:b,loadStxConfig:w}=await import("./chunk-x5cscz50.js"),y=await w(),p={__filename:t,__dirname:E.dirname(t)};for(let d of a){let C=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!d.includes("client")&&!d.includes('type="module"'))await S(C[1],p,t)}let R=await m(l,p,t,{...b,...y,...n},new Set),h=R.indexOf(g);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:R.substring(0,h),afterSlot:R.substring(h+g.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Xn(t,n,e){let r,i="",s=n.match(K);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Y(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{Ht}from"./chunk-x6pz1h3x.js";import{fi,vs,V,Ge,te,Dt,x,Je,Ye,pr,u}from"./chunk-8jgrakqd.js";import{D}from"./chunk-szjgbjw1.js";var H=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(H.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function To(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Ge(t,s);if(a>s){i=a;continue}let o=V(t,s);if(o>s){let c=t.slice(s,o),f=q.exec(c);if(f){let l=B(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function W(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function O(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!W(o,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let S=m[1]==="/";if(!S&&(m[2]||"").trimEnd().endsWith("/"))continue;if(g+=S?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:m.index,tagName:a}}return null}return null}var Be="private, no-store";function $o(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ae(t){return t.headers.get("X-STX-Router")==="true"}function X(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function T(t){return{Vary:X(t,"X-STX-Router")}}import E from"path";var J="stx-page-head:",K=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Y(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-k1vjhhd4.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function Ro(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Ur(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=To(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)o.push(f[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:S,defaultConfig:b,loadStxConfig:w}=await import("./chunk-yceb9scc.js"),y=await w(),p={__filename:t,__dirname:E.dirname(t)};for(let d of a){let C=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!d.includes("client")&&!d.includes('type="module"'))await S(C[1],p,t)}let R=await m(l,p,t,{...b,...y,...n},new Set),h=R.indexOf(g);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:R.substring(0,h),afterSlot:R.substring(h+g.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Xn(t,n,e){let r,i="",s=n.match(K);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Y(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -27,5 +27,5 @@ ${o}
27
27
  `));if(i.length>0)y.push(i.filter((p)=>!c.has(p)).join(`
28
28
  `));if(S.length>0)y.push(S.filter((p)=>!c.has(p)).join(`
29
29
  `));return y.push(m),y.join(`
30
- `)}import k from"fs";import I from"path";function Po(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Io(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function Oo(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function Q(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Wr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function F(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Wr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await Q(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=tt(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function tt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(_(e,i.value,i))}}return n}function No(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function Kt(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await et(t,n),a=Je(r),o=Ye(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-qk4zkvzh.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-3dd57j7e.js"),{defaultConfig:m}=await import("./chunk-6jjrvb9v.js"),S=r.streamBoundaries||{},b={...m,autoShell:!1},w=Object.keys(l).map((p)=>({id:p,render:async()=>{let R=typeof S[p]==="function"?await S[p]():void 0;return g(l[p],{...r,$boundary:R},t.sourceFile,b,new Set)}})),y=new Set(w.map((p)=>p.id));f=[...(f||[]).filter((p)=>!y.has(p.id)),...w]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:o}}async function et(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!vs(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await F(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=pr(e);if(!c)return o;let f=o.indexOf("</head>");return f<0?c+o:o.slice(0,f)+c+o.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!vs(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=x(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?Dt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(fi(t.html,s)),context:e,cookies:r.cookies}}
30
+ `)}import k from"fs";import I from"path";function Po(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Io(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function Oo(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function Q(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Wr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function F(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Wr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await Q(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=tt(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function tt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(_(e,i.value,i))}}return n}function No(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function Kt(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await et(t,n),a=Je(r),o=Ye(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-vhak3tvx.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-9j2tpg46.js"),{defaultConfig:m}=await import("./chunk-ppaj0hef.js"),S=r.streamBoundaries||{},b={...m,autoShell:!1},w=Object.keys(l).map((p)=>({id:p,render:async()=>{let R=typeof S[p]==="function"?await S[p]():void 0;return g(l[p],{...r,$boundary:R},t.sourceFile,b,new Set)}})),y=new Set(w.map((p)=>p.id));f=[...(f||[]).filter((p)=>!y.has(p.id)),...w]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:o}}async function et(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!vs(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await F(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=pr(e);if(!c)return o;let f=o.indexOf("</head>");return f<0?c+o:o.slice(0,f)+c+o.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!vs(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=x(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?Dt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(fi(t.html,s)),context:e,cookies:r.cookies}}
31
31
  export{To,Be,$o,ae,T,Ro,Ur,Xn,xe,Ao,ce,Po,Io,Oo,Wr,No,Kt};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ze,Z,js,Bs,n}from"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Z as injectRouterScript,n as processDirectives,js as processJsonDirective,Bs as processOnceDirective,Ze as validateClientScript};
2
+ import{Ze,Z,js,Bs,n}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Z as injectRouterScript,n as processDirectives,js as processJsonDirective,Bs as processOnceDirective,Ze as validateClientScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{zt,C}from"./chunk-gc1dzxee.js";import m from"fs";import e from"path";async function $n(r,o,i){if(r.__stx_runtime_config)return;let n=zt();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-6jjrvb9v.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Us(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
2
+ import{zt,C}from"./chunk-gc1dzxee.js";import m from"fs";import e from"path";async function $n(r,o,i){if(r.__stx_runtime_config)return;let n=zt();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-ppaj0hef.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Us(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
3
3
  declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
4
4
  `),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
5
5
  declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{M,me}from"./chunk-e030grrq.js";import{ye,C,ot}from"./chunk-gc1dzxee.js";import{ut,Q,Ie}from"./chunk-sxpnpvt5.js";import{Be,ae,T,ce,Oo,Wr,No,Kt}from"./chunk-9eejvpqc.js";import{gs}from"./chunk-erk7afjv.js";import{Xt}from"./chunk-m735gtc4.js";import K from"fs";import A from"path";var{serve:le}=globalThis.Bun;import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),ne=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],re=["text/event-stream","multipart/x-mixed-replace"],se=1024;function oe(t){if(!t)return!1;let e=t.toLowerCase();if(re.some((o)=>e.startsWith(o)))return!1;return ne.some((o)=>e.startsWith(o))}function ie(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function pe(t){if(!t)return null;let e=ie(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ue(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function qt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!oe(e.headers.get("content-type")))return e;let r=pe(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??se))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),ue(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",T(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ae(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(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")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let L=await s.clone().arrayBuffer();if(L.byteLength>1048576)return null;s.headers.set("Vary",T(s.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let B=await v;return B?l(B):a()}}var fe={".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 wl(t={}){let e=A.resolve(t.outputDir||".output"),o=t.port??3000,r=Oo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Xt(r.routeRules),f=new G,h=gs(e,r.apiRoutes??[]),g=Bun.file(A.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,B=new Map;for(let n of r.routes)try{let y=A.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=ot(i.html,m);b.set(n.pattern,i),v.set(n.pattern,Ie(i.html)),B.set(n.pattern,me(i.html));let _=A.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let E=await Bun.file(_).text();k.set(n.pattern,m?ot(E,m):E)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=Q(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let L=le({port:o,async fetch(n){return qt(n,await ye(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=A.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=A.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${A.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=A.extname(u).toLowerCase(),j=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let E=ae(n),w=null,q={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,j)=>{q[R]=c[j+1]});break}}if(!w){let p=ut(i)?null:s.get("/404")||null;if(p){let d=b.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=a(i),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(E&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...B.has(w.pattern)?{"X-STX-Runtime":B.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...T(),...O.cache?{}:{"Cache-Control":Be}}})}}let d=Wr(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.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",...T(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:j,cookies:N,status:I,headers:D}=await Kt(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(j)return No(j,N,D);if(R&&R.length>0){let{renderStreamingPage:P,streamToResponse:z}=await import("./chunk-qk4zkvzh.js"),X=new Headers({...T(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(E&&!d){let V=Ie(c);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",me(c)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return z(P(E&&!d?ce(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let x=new Headers({"Content-Type":"text/html",...T(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of N??[])x.append("Set-Cookie",P);for(let[P,z]of Object.entries(D??{}))x.set(P,z);if(x.set("Vary",T(x.get("Vary")).Vary),E&&!d){let P=Ie(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",me(c)?"true":"false"),x.set("X-STX-Layout",P.layout),x.set("X-STX-Layout-Group",P.group),new Response(ce(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{f.invalidate(),L.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{M,me}from"./chunk-8jgrakqd.js";import{ye,C,ot}from"./chunk-gc1dzxee.js";import{ut,Q,Ie}from"./chunk-sxpnpvt5.js";import{Be,ae,T,ce,Oo,Wr,No,Kt}from"./chunk-8zqgb3q9.js";import{gs}from"./chunk-zedvwcta.js";import{Xt}from"./chunk-m735gtc4.js";import K from"fs";import A from"path";var{serve:le}=globalThis.Bun;import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),ne=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],re=["text/event-stream","multipart/x-mixed-replace"],se=1024;function oe(t){if(!t)return!1;let e=t.toLowerCase();if(re.some((o)=>e.startsWith(o)))return!1;return ne.some((o)=>e.startsWith(o))}function ie(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function pe(t){if(!t)return null;let e=ie(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ue(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function qt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!oe(e.headers.get("content-type")))return e;let r=pe(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??se))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),ue(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",T(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ae(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(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")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let L=await s.clone().arrayBuffer();if(L.byteLength>1048576)return null;s.headers.set("Vary",T(s.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let B=await v;return B?l(B):a()}}var fe={".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 wl(t={}){let e=A.resolve(t.outputDir||".output"),o=t.port??3000,r=Oo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Xt(r.routeRules),f=new G,h=gs(e,r.apiRoutes??[]),g=Bun.file(A.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,B=new Map;for(let n of r.routes)try{let y=A.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=ot(i.html,m);b.set(n.pattern,i),v.set(n.pattern,Ie(i.html)),B.set(n.pattern,me(i.html));let _=A.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let E=await Bun.file(_).text();k.set(n.pattern,m?ot(E,m):E)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=Q(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let L=le({port:o,async fetch(n){return qt(n,await ye(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=A.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=A.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${A.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=A.extname(u).toLowerCase(),j=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let E=ae(n),w=null,q={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,j)=>{q[R]=c[j+1]});break}}if(!w){let p=ut(i)?null:s.get("/404")||null;if(p){let d=b.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=a(i),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(E&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...B.has(w.pattern)?{"X-STX-Runtime":B.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...T(),...O.cache?{}:{"Cache-Control":Be}}})}}let d=Wr(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.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",...T(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:j,cookies:N,status:I,headers:D}=await Kt(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(j)return No(j,N,D);if(R&&R.length>0){let{renderStreamingPage:P,streamToResponse:z}=await import("./chunk-vhak3tvx.js"),X=new Headers({...T(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(E&&!d){let V=Ie(c);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",me(c)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return z(P(E&&!d?ce(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let x=new Headers({"Content-Type":"text/html",...T(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of N??[])x.append("Set-Cookie",P);for(let[P,z]of Object.entries(D??{}))x.set(P,z);if(x.set("Vary",T(x.get("Vary")).Vary),E&&!d){let P=Ie(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",me(c)?"true":"false"),x.set("X-STX-Layout",P.layout),x.set("X-STX-Layout-Group",P.group),new Response(ce(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{f.invalidate(),L.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{qt,wl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{X,b,vn,wn,e,Lt,kn,f,Xe,jt,Je,Ye,se,L,me,Z,u,Te,Oi,Ls,n,r,oe,mr,o,P,he}from"./chunk-e030grrq.js";import{U,Dn,ie,O,Vt}from"./chunk-1gtrs8va.js";import{ut,Fn,Rr,Ar,Pr,dt,pt,ft,gt,mt,ht,Ie}from"./chunk-sxpnpvt5.js";import{Be,$o,ae,T,Ro,Ur,Xn,xe,Ao,ce}from"./chunk-9eejvpqc.js";import{qt}from"./chunk-pwsg9w5g.js";import{pe}from"./chunk-5rtatjwq.js";import{a}from"./chunk-q4a2j4qr.js";import{D}from"./chunk-szjgbjw1.js";async function Gn(t){try{let s=await Bun.file(t).text(),i=Jn(s),d=Yn(s,t),c=Qn(s,i),l=Zn(s,i);return{file:t,metrics:i,issues:d,suggestions:c,performance:l}}catch(s){throw Error(`Failed to analyze template ${t}: ${s instanceof Error?s.message:String(s)}`)}}function Jn(t){let s=t.split(`
2
+ import{X,b,vn,wn,e,Lt,kn,f,Xe,jt,Je,Ye,se,L,me,Z,u,Te,Oi,Ls,n,r,oe,mr,o,P,he}from"./chunk-8jgrakqd.js";import{U,Dn,ie,O,Vt}from"./chunk-1gtrs8va.js";import{ut,Fn,Rr,Ar,Pr,dt,pt,ft,gt,mt,ht,Ie}from"./chunk-sxpnpvt5.js";import{Be,$o,ae,T,Ro,Ur,Xn,xe,Ao,ce}from"./chunk-8zqgb3q9.js";import{qt}from"./chunk-b7fgatb5.js";import{pe}from"./chunk-5rtatjwq.js";import{a}from"./chunk-q4a2j4qr.js";import{D}from"./chunk-szjgbjw1.js";async function Gn(t){try{let s=await Bun.file(t).text(),i=Jn(s),d=Yn(s,t),c=Qn(s,i),l=Zn(s,i);return{file:t,metrics:i,issues:d,suggestions:c,performance:l}}catch(s){throw Error(`Failed to analyze template ${t}: ${s instanceof Error?s.message:String(s)}`)}}function Jn(t){let s=t.split(`
3
3
  `),i=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),c=(i?i[1]:"").split(`
4
4
  `).length,l={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};l.total=l.conditionals+l.loops+l.includes+l.custom;let m=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,p=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,h=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,g=m+p+h,y=(t.match(/<[A-Z][^>]*>/g)||[]).length,w=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,R=0;for(let C of s)if(/@(?:if|unless|foreach|for|while|section)\b/.test(C)&&!/@end/.test(C)&&!/@else/.test(C))R++,S=Math.max(S,R);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(C))R--;let v=S>=4?3:0,x=Math.min(10,Math.ceil(l.total*0.5+g*0.1+y*0.3+(c>10?c*0.05:0)+v));return{lines:s.length,characters:t.length,directives:l,expressions:g,components:y,layouts:w,scriptLines:c,complexity:x}}function Yn(t,s){let i=[],d=Jt(t,"if","endif");if(d>0)i.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let c=Jt(t,"foreach","endforeach");if(c>0)i.push({type:"error",category:"syntax",message:`Found ${c} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let l=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(l&&l.length>0)i.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let m=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(m>0)i.push({type:"warning",category:"security",message:`Found ${m} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let p=t.match(/<img[^>]*>/g);if(p){let y=p.filter((w)=>!w.includes("alt="));if(y.length>0)i.push({type:"warning",category:"accessibility",message:`Found ${y.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let h=t.split(`
5
5
  `).filter((y)=>y.length>120);if(h.length>0)i.push({type:"info",category:"maintainability",message:`Found ${h.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let g=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(g>3)i.push({type:"info",category:"maintainability",message:`Found ${g} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return i}function Qn(t,s){let i=[];if(s.complexity>7)i.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(s.complexity>5&&s.directives.total>8)i.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(s.lines>100&&s.components===0)i.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(s.expressions>20)i.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)i.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(s.directives.total===0&&s.expressions<5)i.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(s.scriptLines>50)i.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return i}function Zn(t,s){let i=1;if(i+=s.directives.conditionals*0.1,i+=s.directives.loops*0.5,i+=s.directives.includes*2,i+=s.expressions*0.05,i+=s.components*1,s.scriptLines>10)i+=s.scriptLines*0.1;let d;if(s.expressions===0&&s.directives.total===0)d="high";else if(s.expressions<5&&s.directives.total<3)d="medium";else d="low";let c=[];if(i>10)c.push("Consider optimizing template complexity");if(d==="low"&&s.directives.total>5)c.push("Reduce dynamic content for better caching");if(s.components===0&&s.lines>40)c.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(i*100)/100,complexityScore:s.complexity,cacheability:d,recommendations:c}}function Jt(t,s,i){let d=t.replace(/<!--[\s\S]*?-->/g,""),c=(d.match(new RegExp(`@${s}\\b`,"g"))||[]).length,l=(d.match(new RegExp(`@${i}\\b`,"g"))||[]).length;return Math.abs(c-l)}async function mo(t=["**/*.stx"],s){let i=[],d=[];for(let l of t){let m=await Array.fromAsync(new Bun.Glob(l).scan({cwd:s||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...m.filter((p)=>p.endsWith(".stx")))}for(let l of d)try{let m=await Gn(l);i.push(m)}catch(m){console.warn(`Failed to analyze ${l}:`,m)}let c=er(i);return{results:i,summary:c}}function er(t){let s=t.length,i=t.reduce((g,y)=>g+y.metrics.lines,0),d=s>0?t.reduce((g,y)=>g+y.metrics.complexity,0)/s:0,c=t.reduce((g,y)=>g+y.issues.length,0),l={};t.forEach((g)=>{g.issues.forEach((y)=>{l[y.category]=(l[y.category]||0)+1})});let m=s>0?t.reduce((g,y)=>g+y.performance.estimatedRenderTime,0)/s:0,p=Math.max(1,Math.min(10,Math.round(10-m/2-d/2))),h=[];if(d>6)h.push("Project has high average complexity. Consider refactoring complex templates.");if(c>s*2)h.push("High number of issues detected. Run detailed analysis on individual files.");if(l.security>0)h.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:s,totalLines:i,avgComplexity:Math.round(d*100)/100,totalIssues:c,issuesByCategory:l,performanceScore:p,recommendations:h}}import{mkdir as tr,readFile as nr,readdir as rr,stat as Yt,writeFile as or}from"fs/promises";import Ee from"path";function rn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var on=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function sr(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join("")}function Ht(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function ir(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function ar(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function cr(t){let s=[];async function i(d){let c=await rr(d,{withFileTypes:!0});c.sort((l,m)=>l.name.localeCompare(m.name));for(let l of c){let m=Ee.join(d,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await i(m)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))s.push(m)}}return await i(t),s}function lr(t,s){let i=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!i)return{};let d=i[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(c){throw Error(`${s}: <script component> must contain JSON metadata (${c.message})`)}}function dr(t,s){let i={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let c of d){if(!/\bclient\b/i.test(c[1])||/\bcomponent\b|\bstx:component\b/i.test(c[1]))continue;let l;try{l=new Bun.Transpiler({loader:"ts"}).transformSync(c[2])}catch(h){throw Error(`${s}: failed to transpile <script client> (${h.message})`)}let m=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,p;while(p=m.exec(l)){let h=p[1];if(on.has(h))throw Error(`${s}: client ${rn(h)}`);let g=m.lastIndex,y=1,w="",S=!1,R=g;for(;R<l.length&&y>0;R++){let x=l[R];if(S){S=!1;continue}if(w){if(x==="\\")S=!0;else if(x===w)w="";continue}if(x==='"'||x==="'"||x==="`")w=x;else if(x==="{")y++;else if(x==="}")y--}if(y!==0)throw Error(`${s}: unterminated client function "${h}"`);let v=p[0].includes("async")?"async ":"";i[h]=`${v}${h}(${p[2]}) {${l.slice(g,R-1)}}`,m.lastIndex=R}}return i}function pr(t){let s=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(s?s[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Qt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((s)=>s[1].trim()).filter(Boolean).join(`
@@ -876,7 +876,7 @@ else {
876
876
  };
877
877
  })();
878
878
  </script>
879
- `}function Ve(t,s,i={}){let d=Xr(s,i),c=t.lastIndexOf("</body>");if(c!==-1)return t.slice(0,c)+d+t.slice(c);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function $t(t){let s=t.toLowerCase();return s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".sass")||s.endsWith(".less")}function Ct(t){let s=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>s.endsWith(d))}function Rt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((i)=>i.test(t))}var st=null;function Et(t){if(!st)st=new an(t);return st}function lt(){if(st)st.stop(),st=null}import Pt from"path";var it={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Pt.relative(Pt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await mr(i,d);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let p=new Set;if(i.cache&&i.cachePath){let x=await vn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ie(()=>Bun.file(m).text(),"",(x)=>{throw new Dn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new Dn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=X.time("script-extraction",()=>{let x=h,C=se(h);if(C)x=C.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",_=[];for(let E of k){let I=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=E.match(/<script\b([^>]*)>/i),K=F?F[1]:"";if(/\bserver\b/i.test(K))B=I;else _.push(E)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:_}}),S={__filename:m,__dirname:Pt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ie(()=>u(g,S,m),void 0,(x)=>{let C=new U(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(O.log(C,{filePath:m,scriptContent:g}),i.debug)throw C});let v=await X.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-rmc8cg2n.js"),C=x(w.join(`
879
+ `}function Ve(t,s,i={}){let d=Xr(s,i),c=t.lastIndexOf("</body>");if(c!==-1)return t.slice(0,c)+d+t.slice(c);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function $t(t){let s=t.toLowerCase();return s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".sass")||s.endsWith(".less")}function Ct(t){let s=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>s.endsWith(d))}function Rt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((i)=>i.test(t))}var st=null;function Et(t){if(!st)st=new an(t);return st}function lt(){if(st)st.stop(),st=null}import Pt from"path";var it={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Pt.relative(Pt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await mr(i,d);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let p=new Set;if(i.cache&&i.cachePath){let x=await vn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ie(()=>Bun.file(m).text(),"",(x)=>{throw new Dn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new Dn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=X.time("script-extraction",()=>{let x=h,C=se(h);if(C)x=C.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",_=[];for(let E of k){let I=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=E.match(/<script\b([^>]*)>/i),K=F?F[1]:"";if(/\bserver\b/i.test(K))B=I;else _.push(E)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:_}}),S={__filename:m,__dirname:Pt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ie(()=>u(g,S,m),void 0,(x)=>{let C=new U(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(O.log(C,{filePath:m,scriptContent:g}),i.debug)throw C});let v=await X.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-hsmaakds.js"),C=x(w.join(`
880
880
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+C+`
881
881
  `+v.slice(k);else v+=`
882
882
  ${C}`}if(v=await Z(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await wn(m,v,p,i),i.debug)console.log(`Cached template ${m} with ${p.size} dependencies`)}return{contents:v,loader:"html"}}catch(p){let h=p instanceof Error?p:new U(`Plugin processing failed: ${String(p)}`,m);if(O.log(h,{filePath:m,buildConfig:t.config}),Vt.logDetailedError(h,{filePath:m,plugin:"bun-plugin-stx"}),i.debug)console.error("stx Plugin Error:",h);let g=h,y=g.line||null,w=g.context||null;return{contents:i.debug||D()?`<!DOCTYPE html>
@@ -939,7 +939,7 @@ ${C}`}if(v=await Z(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await wn
939
939
  <h1>Something went wrong</h1>
940
940
  <p>An internal error occurred. Please try again later.</p>
941
941
  </body>
942
- </html>`,loader:"html"}}})}};async function Vn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=we.resolve(t);if(!He.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return zt(p,s);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");He.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ge)=>({path:ge.path,external:!0}))}},F=await Bun.build({entrypoints:[p],outdir:h,plugins:[I,it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let K=F.outputs.find(($e)=>$e.path.endsWith(".html"));if(!K)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(K.path).text(),!0}catch(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await y())return!1;let S=we.dirname(p);await Lt(S);let R=i;try{if(R=await Ge(i),R!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=s.hmrPort||R+1;l=Et({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,C;try{let{loadStxConfig:I}=await import("./chunk-x5cscz50.js"),F=await I();if(C=s.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.apiRoutes;let K=Object.keys(v).length;if(K>0)console.log(`${e.blue}Loaded ${e.bright}${K} API route${K>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:K,loadChannels:Q}=await import("./chunk-08jyyegp.js"),$e=F.broadcasting;await K($e);let ge=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ge}/ws${e.reset}`);let Oe=we.join(process.cwd(),"channels.ts");if(He.existsSync(Oe))try{let ne=await Q(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(K){console.warn(`${e.yellow}Broadcasting failed to start: ${K.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-g8f1dqx1.js"),_=await k(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=Gr({port:R,async fetch(I){return qt(I,await(async()=>{let F=new URL(I.url);if([h,we.dirname(p),we.join(process.cwd(),"public")].some((ne)=>B(we.join(ne,F.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(x)try{let ne=await x.handleRequest(I);if(ne.status!==404)return ne}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let K=await _(I);if(K)return K;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Ve(W,m);if(s.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(s.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Q=we.join(h,F.pathname);if(He.existsSync(Q)&&He.statSync(Q).isFile()){let ne=Bun.file(Q),W=we.extname(Q).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}let $e=we.dirname(p),ge=we.join($e,F.pathname);if(He.existsSync(ge)&&He.statSync(ge).isFile()){let ne=Bun.file(ge),W=we.extname(ge).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}let Oe=we.join(process.cwd(),"public",F.pathname);if(He.existsSync(Oe)&&He.statSync(Oe).isFile()){let ne=Bun.file(Oe),W=we.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
942
+ </html>`,loader:"html"}}})}};async function Vn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=we.resolve(t);if(!He.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return zt(p,s);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");He.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ge)=>({path:ge.path,external:!0}))}},F=await Bun.build({entrypoints:[p],outdir:h,plugins:[I,it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let K=F.outputs.find(($e)=>$e.path.endsWith(".html"));if(!K)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(K.path).text(),!0}catch(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await y())return!1;let S=we.dirname(p);await Lt(S);let R=i;try{if(R=await Ge(i),R!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=s.hmrPort||R+1;l=Et({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,C;try{let{loadStxConfig:I}=await import("./chunk-yceb9scc.js"),F=await I();if(C=s.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.apiRoutes;let K=Object.keys(v).length;if(K>0)console.log(`${e.blue}Loaded ${e.bright}${K} API route${K>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:K,loadChannels:Q}=await import("./chunk-08jyyegp.js"),$e=F.broadcasting;await K($e);let ge=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ge}/ws${e.reset}`);let Oe=we.join(process.cwd(),"channels.ts");if(He.existsSync(Oe))try{let ne=await Q(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(K){console.warn(`${e.yellow}Broadcasting failed to start: ${K.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-5s91drvs.js"),_=await k(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=Gr({port:R,async fetch(I){return qt(I,await(async()=>{let F=new URL(I.url);if([h,we.dirname(p),we.join(process.cwd(),"public")].some((ne)=>B(we.join(ne,F.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(x)try{let ne=await x.handleRequest(I);if(ne.status!==404)return ne}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let K=await _(I);if(K)return K;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Ve(W,m);if(s.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(s.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Q=we.join(h,F.pathname);if(He.existsSync(Q)&&He.statSync(Q).isFile()){let ne=Bun.file(Q),W=we.extname(Q).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}let $e=we.dirname(p),ge=we.join($e,F.pathname);if(He.existsSync(ge)&&He.statSync(ge).isFile()){let ne=Bun.file(ge),W=we.extname(ge).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}let Oe=we.join(process.cwd(),"public",F.pathname);if(He.existsSync(Oe)&&He.statSync(Oe).isFile()){let ne=Bun.file(Oe),W=we.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Fe=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),Ue=await ne.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
943
943
  ${I.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
944
944
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
945
945
  ${e.bright}\u2192 ${e.cyan}http://localhost:${R}/${e.reset}`),console.log(`
@@ -1426,12 +1426,12 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1426
1426
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1427
1427
  ${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
1428
1428
  ${e.yellow}Routes:${e.reset}`);let S=new Set(p.map((v)=>v.routeTemplate)),R=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Pe.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of p){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");R.push({route:x,filePath:Pe.relative(process.cwd(),v.filePath),fileType:"stx"})}if(R.sort((v,x)=>v.route.localeCompare(x.route)),R.forEach((v,x)=>{let k=x===R.length-1?"\u2514\u2500 ":"\u251C\u2500 ",B=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${B}`)}),console.log(`
1429
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(d)Ze.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),Te.clear(),oe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function ln(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Yr}=globalThis.Bun;import be from"fs";import te from"path";async function pn(t){try{return jt(await Bun.file(t).text())}catch{return}}function Nt(t){let s=Bun.file(t),i=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":d[i]||"application/octet-stream",...l}})}async function Wn(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=te.resolve(t),{loadStxConfig:h}=await import("./chunk-x5cscz50.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-g8f1dqx1.js"),S=s.stxOptions?.serverApi??g.serverApi,R=await y(p,S),v=g.root&&g.root!=="."?te.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",C=te.join(v,x);if(!be.existsSync(C)&&!g._layerPageDirs?.some((A)=>be.existsSync(A)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=L(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[C,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],_=[];for(let{dir:A,prefix:z}of B)if(be.existsSync(A)){let N=L(te.dirname(A),{pagesDir:te.basename(A)});for(let V of N){let ve=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;_.push({route:{...V,pattern:ve},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,E=null,I=null;if(s.stxOptions?.shell!==!1){if(I=await Ro(p,s.stxOptions?.shell),I){if(E=await Ur(I,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(p,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}dt(),await ft(p);let F=pt();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let K={},Q=null;try{let{loadStxConfig:A}=await import("./chunk-x5cscz50.js"),z=await A(p);if(z?.apiRouter)Q=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){K=z.apiRoutes;let N=Object.keys(K).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-08jyyegp.js"),ve=z.broadcasting;await N(ve);let ze=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ze}/ws${e.reset}`);let qe=te.join(process.cwd(),"channels.ts");if(be.existsSync(qe))try{let ee=await V(qe);console.log(`${e.blue}Loaded ${e.bright}${ee} broadcast channel${ee!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ee){console.warn(`${e.yellow}Failed to load channels.ts: ${ee.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(p,"output");be.mkdirSync($e,{recursive:!0});let ge=new Map,Oe=new Set,ne=async(A)=>{let z=Ar(C,A);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!N.success)return null;let V=N.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(A,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:ve,loadStxConfig:ze,injectRouterScript:qe}=await import("./chunk-x5cscz50.js"),{checkCache:ee,cacheTemplate:Y,readFileCached:q,templateCache:G}=await import("./chunk-8xns82s5.js"),Se=await ze(p),Ke=(re)=>{if(!re)return re;if(te.isAbsolute(re))return re;return te.resolve(p,re)},M={...ve,...Se,...s.stxOptions,autoShell:!0};if(s.debugDirectives)M.debug=!0;M.partialsDir=Ke(M.partialsDir),M.componentsDir=Ke(M.componentsDir),M.layoutsDir=Ke(M.layoutsDir),M.storesDir=Ke(M.storesDir||"stores"),M.cachePath=Ke(M.cachePath)??a(p,"cache");let ye=!z&&!s.profile,le=M.cache!==!1;if(le&&ye){let re=G.get(A.filePath);if(re)try{if((await be.promises.stat(A.filePath)).mtime.getTime()<=re.mtime){let je=!0;for(let Re of re.dependencies){if(!be.existsSync(Re)){je=!1;break}if((await be.promises.stat(Re)).mtime.getTime()>re.mtime){je=!1;break}}if(je){let Re=re.output;if(E)Re=xe(Re,{preserveHead:!0});let ct=W.get(A.filePath);return{route:A,content:Re,status:ct?.status??await pn(A.filePath),headers:ct?.headers}}}}catch{}let _e=await ee(A.filePath,M);if(_e){let Le=_e;if(E)Le=xe(Le,{preserveHead:!0});let je=W.get(A.filePath);return{route:A,content:Le,status:je?.status??await pn(A.filePath),headers:je?.headers}}}let fe=le?await q(A.filePath):await Bun.file(A.filePath).text(),Ce=jt(fe),{classifyAllScripts:J}=await import("./chunk-x5cscz50.js"),Me=J(fe),Ne=Me.server.map((re)=>re.content),de=fe;for(let re of Me.server)de=de.replace(re.fullTag,"");let ue={__filename:A.filePath,__dirname:te.dirname(A.filePath),__stx_options:M,params:z??{},__stx_runtime_head:{}};for(let re of Ne)try{await V(re,ue,A.filePath)}catch(_e){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,_e?.message||_e)}let We=new Set,Ae;if(s.profile){let re=performance.now();Ae=await N(de,ue,A.filePath,M,We);let _e=performance.now()-re,Le=te.relative(p,A.filePath)||A.filePath;console.log(`[stx:profile] ${Le} \u2192 ${_e.toFixed(2)}ms`)}else Ae=await N(de,ue,A.filePath,M,We);if(!E)Ae=await qe(Ae,{router:M.router});{let{interpolateScriptExpressions:re}=await import("./chunk-rmc8cg2n.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_e,Le,je)=>{if(!/function\s+__stx_setup_/.test(je))return _e;return`<script${Le}>${re(je,ue)}</script>`})}if(E)Ae=xe(Ae,{preserveHead:!0});if(le&&ye)await Y(A.filePath,Ae,We,M);let{extractStreamBoundaries:qn}=await import("./chunk-qk4zkvzh.js"),nt=qn(ue),at=ue.__streamTemplates;if(at&&typeof at==="object"&&Object.keys(at).length>0){let re=ue.streamBoundaries||{},_e={...M,autoShell:!1},Le=Object.keys(at).map((Re)=>({id:Re,render:async()=>{let ct=typeof re[Re]==="function"?await re[Re]():void 0;return N(at[Re],{...ue,$boundary:ct},A.filePath,_e,new Set)}})),je=new Set(Le.map((Re)=>Re.id));nt=[...(nt||[]).filter((Re)=>!je.has(Re.id)),...Le]}if(nt&&nt.length>0)Oe.add(A.pattern);else nt=void 0;let Kt=Je(ue),Xt=Ye(ue);if(ye)W.set(A.filePath,{status:Kt,headers:Xt});return{route:A,content:Ae,status:Kt??Ce,headers:Xt,boundaries:nt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,N),null}},Fe=8,Ue=async()=>{ge.clear(),j.clear();for(let A=0;A<k.length;A+=Fe){let z=k.slice(A,A+Fe),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)ge.set(V.route.pattern,V)}for(let A=0;A<_.length;A+=Fe){let z=_.slice(A,A+Fe),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return ge.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Ue())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Lt(p);let et=i;try{if(et=await Ge(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let A=s.hmrPort||et+1;l=Et({wsPort:A,verbose:!1}),m=l.start(A)}let At=(A,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(A.includes("</head>"))return A.replace("</head>",`${V}</head>`);if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Yr({port:et,async fetch(A){let z=new URL(A.url),N=g?.publicDir||"public",V=te.join(p,N,z.pathname),ve=te.join(p,z.pathname),ze=te.join($e,z.pathname);if([V,ve,ze].some((M)=>w(M,p,S)))return new Response("Not Found",{status:404});let[qe,ee,Y]=await Promise.all([be.promises.stat(V).catch(()=>null),be.promises.stat(ve).catch(()=>null),be.promises.stat(ze).catch(()=>null)]);if(qe?.isFile()&&!w(V,p,S))return Nt(V);if(ee?.isFile()&&!w(ve,p,S))return Nt(ve);if(Y?.isFile()&&!w(ze,p,S))return Nt(ze);if(z.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(z.pathname.slice(16));if(M)try{let ye=`<${M} />`,le={...buildConfig,autoShell:!1},fe=await processDirectives(ye,{},te.join(p,"components",`${M}.stx`),le,new Set);return new Response(fe,{headers:{"Content-Type":"text/html"}})}catch(ye){return new Response(`<div class="stx-async-error">${ye.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-wfettff6.js"),ye=await M(A,{publicDir:te.join(p,N),cacheDir:a(p,"cache","img")});if(ye)return ye}if(Q)try{let M=await Q.handleRequest(A);if(M.status!==404)return M}catch{}if(K[z.pathname])try{return await K[z.pathname](A)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await R(A);if(q)return q;let G=Fn(z.pathname,k);if(G){let M=ge.get(G.route.pattern),ye=Oe.has(G.route.pattern);if(G.route.isDynamic&&Object.keys(G.params).length>0||ye){let le=await H(G.route,G.params);if(le)M=le}if(M){let le=M.status??200,fe=M.headers??{},Ce=(G.route.filePath?Xe(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:G.params})){let Ne=await ne(404);if(Ne){let de=Ne;if(de=await f(de,p),c)de=Ve(de,m);return new Response(de,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Me=gt(z.pathname,G.params,Ce,z.search),Ne=mt(Me,null,A,{isServer:!0}),de=await ht(Ce.middleware,Ne);if(de.redirect){let ue=de.redirect.path,We=de.redirect.options.redirectCode||302,Ae=new Headers(de.responseHeaders);return Ae.set("Location",ue),new Response(null,{status:We,headers:Ae})}if(de.abort){let{statusCode:ue,message:We}=de.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${ue}</title></head><body><h1>Error ${ue}</h1><p>${We}</p></body></html>`,{status:ue,headers:{"Content-Type":"text/html"}})}if(Object.keys(de.state).length>0){let ue=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(de.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=M.content.replace("</head>",`${ue}</head>`)}}let J=M.content;if(E&&Ao(A)){let Me=Ie(J),Ne=me(J),de=J.match(/<title[^>]*>([\s\S]*?)<\/title>/i),ue=de?$o(de[1].trim()):"";if(Object.keys(G.params).length>0)J=At(J,G.params);J=await f(J,p);let We=g?.router?.container||"main";return J=ce(J,We),new Response(J,{status:le,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Me.layout,"X-STX-Layout-Group":Me.group,"X-STX-Runtime":Ne?"true":"false",...ue&&{"X-STX-Title":encodeURIComponent(ue)},[Oi]:Ls(),...T(),"Cache-Control":Be}})}if(E)J=Xn(E,J);if(Object.keys(G.params).length>0)J=At(J,G.params);if(J=await f(J,p),c)J=Ve(J,m);if(s.native)if(J.includes("<head>"))J=J.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else J="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+J;if(s.titlebarHidden)if(J.includes("<head>"))J=J.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else J=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${J}`;if(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Me,streamToResponse:Ne}=await import("./chunk-qk4zkvzh.js");return Ne(Me(J,M.boundaries,{timeoutMs:30000}),{status:le,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(J,{status:le,headers:{"Content-Type":"text/html",...T(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...fe}})}}if(_.length>0){let M=_.map((le)=>le.route),ye=Fn(z.pathname,M);if(ye){let le=j.get(ye.route.pattern);if(le){let fe=le.content;if(E)fe=Xn(E,fe);if(Object.keys(ye.params).length>0)fe=At(fe,ye.params);if(fe=await f(fe,p),c)fe=Ve(fe,m);return new Response(fe,{status:le.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:le}of B)if(le!=="/"&&z.pathname.startsWith(le)){let fe=j.get(le)||j.get(le+"/");if(fe){let Ce=fe.content;if(E)Ce=Xn(E,Ce);if(Ce=await f(Ce,p),c)Ce=Ve(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(ut(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Se=ge.get("/");if(Se){let M=Se.content;if(M=await f(M,p),c)M=Ve(M,m);if(s.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Ke=await ne(404);if(Ke){let M=Ke;if(M=await f(M,p),c)M=Ve(M,m);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let z=await ne(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
1429
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(d)Ze.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),Te.clear(),oe(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function ln(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Yr}=globalThis.Bun;import be from"fs";import te from"path";async function pn(t){try{return jt(await Bun.file(t).text())}catch{return}}function Nt(t){let s=Bun.file(t),i=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":d[i]||"application/octet-stream",...l}})}async function Wn(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=te.resolve(t),{loadStxConfig:h}=await import("./chunk-yceb9scc.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-5s91drvs.js"),S=s.stxOptions?.serverApi??g.serverApi,R=await y(p,S),v=g.root&&g.root!=="."?te.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",C=te.join(v,x);if(!be.existsSync(C)&&!g._layerPageDirs?.some((A)=>be.existsSync(A)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=L(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[C,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],_=[];for(let{dir:A,prefix:z}of B)if(be.existsSync(A)){let N=L(te.dirname(A),{pagesDir:te.basename(A)});for(let V of N){let ve=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;_.push({route:{...V,pattern:ve},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,E=null,I=null;if(s.stxOptions?.shell!==!1){if(I=await Ro(p,s.stxOptions?.shell),I){if(E=await Ur(I,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(p,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}dt(),await ft(p);let F=pt();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let K={},Q=null;try{let{loadStxConfig:A}=await import("./chunk-yceb9scc.js"),z=await A(p);if(z?.apiRouter)Q=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){K=z.apiRoutes;let N=Object.keys(K).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-08jyyegp.js"),ve=z.broadcasting;await N(ve);let ze=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ze}/ws${e.reset}`);let qe=te.join(process.cwd(),"channels.ts");if(be.existsSync(qe))try{let ee=await V(qe);console.log(`${e.blue}Loaded ${e.bright}${ee} broadcast channel${ee!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ee){console.warn(`${e.yellow}Failed to load channels.ts: ${ee.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(p,"output");be.mkdirSync($e,{recursive:!0});let ge=new Map,Oe=new Set,ne=async(A)=>{let z=Ar(C,A);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!N.success)return null;let V=N.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(A,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:ve,loadStxConfig:ze,injectRouterScript:qe}=await import("./chunk-yceb9scc.js"),{checkCache:ee,cacheTemplate:Y,readFileCached:q,templateCache:G}=await import("./chunk-6377p5ry.js"),Se=await ze(p),Ke=(re)=>{if(!re)return re;if(te.isAbsolute(re))return re;return te.resolve(p,re)},M={...ve,...Se,...s.stxOptions,autoShell:!0};if(s.debugDirectives)M.debug=!0;M.partialsDir=Ke(M.partialsDir),M.componentsDir=Ke(M.componentsDir),M.layoutsDir=Ke(M.layoutsDir),M.storesDir=Ke(M.storesDir||"stores"),M.cachePath=Ke(M.cachePath)??a(p,"cache");let ye=!z&&!s.profile,le=M.cache!==!1;if(le&&ye){let re=G.get(A.filePath);if(re)try{if((await be.promises.stat(A.filePath)).mtime.getTime()<=re.mtime){let je=!0;for(let Re of re.dependencies){if(!be.existsSync(Re)){je=!1;break}if((await be.promises.stat(Re)).mtime.getTime()>re.mtime){je=!1;break}}if(je){let Re=re.output;if(E)Re=xe(Re,{preserveHead:!0});let ct=W.get(A.filePath);return{route:A,content:Re,status:ct?.status??await pn(A.filePath),headers:ct?.headers}}}}catch{}let _e=await ee(A.filePath,M);if(_e){let Le=_e;if(E)Le=xe(Le,{preserveHead:!0});let je=W.get(A.filePath);return{route:A,content:Le,status:je?.status??await pn(A.filePath),headers:je?.headers}}}let fe=le?await q(A.filePath):await Bun.file(A.filePath).text(),Ce=jt(fe),{classifyAllScripts:J}=await import("./chunk-yceb9scc.js"),Me=J(fe),Ne=Me.server.map((re)=>re.content),de=fe;for(let re of Me.server)de=de.replace(re.fullTag,"");let ue={__filename:A.filePath,__dirname:te.dirname(A.filePath),__stx_options:M,params:z??{},__stx_runtime_head:{}};for(let re of Ne)try{await V(re,ue,A.filePath)}catch(_e){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,_e?.message||_e)}let We=new Set,Ae;if(s.profile){let re=performance.now();Ae=await N(de,ue,A.filePath,M,We);let _e=performance.now()-re,Le=te.relative(p,A.filePath)||A.filePath;console.log(`[stx:profile] ${Le} \u2192 ${_e.toFixed(2)}ms`)}else Ae=await N(de,ue,A.filePath,M,We);if(!E)Ae=await qe(Ae,{router:M.router});{let{interpolateScriptExpressions:re}=await import("./chunk-hsmaakds.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(_e,Le,je)=>{if(!/function\s+__stx_setup_/.test(je))return _e;return`<script${Le}>${re(je,ue)}</script>`})}if(E)Ae=xe(Ae,{preserveHead:!0});if(le&&ye)await Y(A.filePath,Ae,We,M);let{extractStreamBoundaries:qn}=await import("./chunk-vhak3tvx.js"),nt=qn(ue),at=ue.__streamTemplates;if(at&&typeof at==="object"&&Object.keys(at).length>0){let re=ue.streamBoundaries||{},_e={...M,autoShell:!1},Le=Object.keys(at).map((Re)=>({id:Re,render:async()=>{let ct=typeof re[Re]==="function"?await re[Re]():void 0;return N(at[Re],{...ue,$boundary:ct},A.filePath,_e,new Set)}})),je=new Set(Le.map((Re)=>Re.id));nt=[...(nt||[]).filter((Re)=>!je.has(Re.id)),...Le]}if(nt&&nt.length>0)Oe.add(A.pattern);else nt=void 0;let Kt=Je(ue),Xt=Ye(ue);if(ye)W.set(A.filePath,{status:Kt,headers:Xt});return{route:A,content:Ae,status:Kt??Ce,headers:Xt,boundaries:nt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,N),null}},Fe=8,Ue=async()=>{ge.clear(),j.clear();for(let A=0;A<k.length;A+=Fe){let z=k.slice(A,A+Fe),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)ge.set(V.route.pattern,V)}for(let A=0;A<_.length;A+=Fe){let z=_.slice(A,A+Fe),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return ge.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Ue())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Lt(p);let et=i;try{if(et=await Ge(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let A=s.hmrPort||et+1;l=Et({wsPort:A,verbose:!1}),m=l.start(A)}let At=(A,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(A.includes("</head>"))return A.replace("</head>",`${V}</head>`);if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Yr({port:et,async fetch(A){let z=new URL(A.url),N=g?.publicDir||"public",V=te.join(p,N,z.pathname),ve=te.join(p,z.pathname),ze=te.join($e,z.pathname);if([V,ve,ze].some((M)=>w(M,p,S)))return new Response("Not Found",{status:404});let[qe,ee,Y]=await Promise.all([be.promises.stat(V).catch(()=>null),be.promises.stat(ve).catch(()=>null),be.promises.stat(ze).catch(()=>null)]);if(qe?.isFile()&&!w(V,p,S))return Nt(V);if(ee?.isFile()&&!w(ve,p,S))return Nt(ve);if(Y?.isFile()&&!w(ze,p,S))return Nt(ze);if(z.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(z.pathname.slice(16));if(M)try{let ye=`<${M} />`,le={...buildConfig,autoShell:!1},fe=await processDirectives(ye,{},te.join(p,"components",`${M}.stx`),le,new Set);return new Response(fe,{headers:{"Content-Type":"text/html"}})}catch(ye){return new Response(`<div class="stx-async-error">${ye.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-wfettff6.js"),ye=await M(A,{publicDir:te.join(p,N),cacheDir:a(p,"cache","img")});if(ye)return ye}if(Q)try{let M=await Q.handleRequest(A);if(M.status!==404)return M}catch{}if(K[z.pathname])try{return await K[z.pathname](A)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await R(A);if(q)return q;let G=Fn(z.pathname,k);if(G){let M=ge.get(G.route.pattern),ye=Oe.has(G.route.pattern);if(G.route.isDynamic&&Object.keys(G.params).length>0||ye){let le=await H(G.route,G.params);if(le)M=le}if(M){let le=M.status??200,fe=M.headers??{},Ce=(G.route.filePath?Xe(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:G.params})){let Ne=await ne(404);if(Ne){let de=Ne;if(de=await f(de,p),c)de=Ve(de,m);return new Response(de,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Me=gt(z.pathname,G.params,Ce,z.search),Ne=mt(Me,null,A,{isServer:!0}),de=await ht(Ce.middleware,Ne);if(de.redirect){let ue=de.redirect.path,We=de.redirect.options.redirectCode||302,Ae=new Headers(de.responseHeaders);return Ae.set("Location",ue),new Response(null,{status:We,headers:Ae})}if(de.abort){let{statusCode:ue,message:We}=de.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${ue}</title></head><body><h1>Error ${ue}</h1><p>${We}</p></body></html>`,{status:ue,headers:{"Content-Type":"text/html"}})}if(Object.keys(de.state).length>0){let ue=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(de.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=M.content.replace("</head>",`${ue}</head>`)}}let J=M.content;if(E&&Ao(A)){let Me=Ie(J),Ne=me(J),de=J.match(/<title[^>]*>([\s\S]*?)<\/title>/i),ue=de?$o(de[1].trim()):"";if(Object.keys(G.params).length>0)J=At(J,G.params);J=await f(J,p);let We=g?.router?.container||"main";return J=ce(J,We),new Response(J,{status:le,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Me.layout,"X-STX-Layout-Group":Me.group,"X-STX-Runtime":Ne?"true":"false",...ue&&{"X-STX-Title":encodeURIComponent(ue)},[Oi]:Ls(),...T(),"Cache-Control":Be}})}if(E)J=Xn(E,J);if(Object.keys(G.params).length>0)J=At(J,G.params);if(J=await f(J,p),c)J=Ve(J,m);if(s.native)if(J.includes("<head>"))J=J.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else J="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+J;if(s.titlebarHidden)if(J.includes("<head>"))J=J.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else J=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${J}`;if(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Me,streamToResponse:Ne}=await import("./chunk-vhak3tvx.js");return Ne(Me(J,M.boundaries,{timeoutMs:30000}),{status:le,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(J,{status:le,headers:{"Content-Type":"text/html",...T(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...fe}})}}if(_.length>0){let M=_.map((le)=>le.route),ye=Fn(z.pathname,M);if(ye){let le=j.get(ye.route.pattern);if(le){let fe=le.content;if(E)fe=Xn(E,fe);if(Object.keys(ye.params).length>0)fe=At(fe,ye.params);if(fe=await f(fe,p),c)fe=Ve(fe,m);return new Response(fe,{status:le.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:le}of B)if(le!=="/"&&z.pathname.startsWith(le)){let fe=j.get(le)||j.get(le+"/");if(fe){let Ce=fe.content;if(E)Ce=Xn(E,Ce);if(Ce=await f(Ce,p),c)Ce=Ve(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(ut(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Se=ge.get("/");if(Se){let M=Se.content;if(M=await f(M,p),c)M=Ve(M,m);if(s.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Ke=await ne(404);if(Ke){let M=Ke;if(M=await f(M,p),c)M=Ve(M,m);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let z=await ne(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
1430
1430
  ${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1431
1431
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1432
1432
  ${e.bright}\u2192 ${e.cyan}http://localhost:${et}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
1433
1433
  ${e.yellow}Routes:${e.reset}`);let Mt=[...Pr(k,p)];for(let{route:A}of _)Mt.push(`${A.pattern}`);if(Mt.forEach((A,z)=>{let V=z===Mt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${A}`)}),console.log(`
1434
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(Dt.url.toString(),()=>{if(l)lt();Dt.stop()}),s.native){let A,z=te.join(C,"index.stx");if(be.existsSync(z)){let V=await Bun.file(z).text();A=Tt(V)}let N=g?.app?.window??{};await rt(et,{title:g?.app?.head?.title||te.basename(p)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(ee)=>ee.startsWith("public/")||ee.startsWith("public\\"),z=(ee)=>{let Y=ee.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},N=new Map,V=()=>{let ee=new Set([p,...g._layerGraph?.layers.map((Y)=>Y.root)??[],...g._layerGraph?.configDependencies.map((Y)=>te.dirname(Y))??[]].filter((Y)=>be.existsSync(Y)).map((Y)=>be.realpathSync(Y)));for(let Y of g._layerGraph?.layers??[])for(let q of Object.values(Y.resources)){if(!be.existsSync(q))continue;let G=be.realpathSync(q);if(![...ee].some((Se)=>G===Se||G.startsWith(`${Se}${te.sep}`)))ee.add(G)}for(let[Y,q]of N)if(!ee.has(Y))q.close(),N.delete(Y);for(let Y of ee)if(!N.has(Y)&&be.existsSync(Y))N.set(Y,be.watch(Y,{recursive:!0},(q,G)=>{ze(Y,q,G).catch((Se)=>console.error("[stx] Layer rebuild failed:",Se))}))},ve=Promise.resolve(),ze=(ee,Y,q)=>(ve=ve.catch(()=>{}).then(()=>qe(ee,Y,q)),ve),qe=async(ee,Y,q)=>{if(!q||Rt(q))return;if(Ct(q)){if(g._layerGraph){let G=await h(p);Object.assign(g,G),k.splice(0,k.length,...L(v,{pagesDir:x,pagesDirs:G._layerPageDirs?[C,...G._layerPageDirs.slice(1)]:void 0})),V()}if(A(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(z(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),Te.clear(),oe();try{let{invalidateFileCache:G,templateCache:Se}=await import("./chunk-8xns82s5.js");G(te.resolve(ee,q)),Se.delete(te.resolve(ee,q))}catch{}if(I&&q){if(te.resolve(ee,q)===I||te.basename(I)===q){let Se=await Ur(I,s.stxOptions||{});if(Se)E=Se}}if(await Ue(),await kn(p),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),Te.clear(),oe();try{let{invalidateFileCache:G,templateCache:Se}=await import("./chunk-8xns82s5.js");G(te.resolve(ee,q)),Se.delete(te.resolve(ee,q))}catch{}if(await Ue(),c&&l)l.reload(q)}}else if($t(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let ee of N.values())ee.close();if(l)lt();Dt.stop(),process.exit(0)})}return!0}import Ut from"fs";import yt from"path";async function Qr(t){try{let i=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!i)return[];let d=i[1],c=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,m;while((m=l.exec(d))!==null){let p=m[1],h=m[2]||m[3]||m[4];if(!h)continue;let g={name:h},y=p.match(/@type\s+\{([^}]+)\}/i);if(y)g.type=y[1].trim();if(p.match(/@required/i))g.required=!0;let S=p.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let R=p.split(`
1434
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(Dt.url.toString(),()=>{if(l)lt();Dt.stop()}),s.native){let A,z=te.join(C,"index.stx");if(be.existsSync(z)){let V=await Bun.file(z).text();A=Tt(V)}let N=g?.app?.window??{};await rt(et,{title:g?.app?.head?.title||te.basename(p)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(ee)=>ee.startsWith("public/")||ee.startsWith("public\\"),z=(ee)=>{let Y=ee.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},N=new Map,V=()=>{let ee=new Set([p,...g._layerGraph?.layers.map((Y)=>Y.root)??[],...g._layerGraph?.configDependencies.map((Y)=>te.dirname(Y))??[]].filter((Y)=>be.existsSync(Y)).map((Y)=>be.realpathSync(Y)));for(let Y of g._layerGraph?.layers??[])for(let q of Object.values(Y.resources)){if(!be.existsSync(q))continue;let G=be.realpathSync(q);if(![...ee].some((Se)=>G===Se||G.startsWith(`${Se}${te.sep}`)))ee.add(G)}for(let[Y,q]of N)if(!ee.has(Y))q.close(),N.delete(Y);for(let Y of ee)if(!N.has(Y)&&be.existsSync(Y))N.set(Y,be.watch(Y,{recursive:!0},(q,G)=>{ze(Y,q,G).catch((Se)=>console.error("[stx] Layer rebuild failed:",Se))}))},ve=Promise.resolve(),ze=(ee,Y,q)=>(ve=ve.catch(()=>{}).then(()=>qe(ee,Y,q)),ve),qe=async(ee,Y,q)=>{if(!q||Rt(q))return;if(Ct(q)){if(g._layerGraph){let G=await h(p);Object.assign(g,G),k.splice(0,k.length,...L(v,{pagesDir:x,pagesDirs:G._layerPageDirs?[C,...G._layerPageDirs.slice(1)]:void 0})),V()}if(A(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(z(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),Te.clear(),oe();try{let{invalidateFileCache:G,templateCache:Se}=await import("./chunk-6377p5ry.js");G(te.resolve(ee,q)),Se.delete(te.resolve(ee,q))}catch{}if(I&&q){if(te.resolve(ee,q)===I||te.basename(I)===q){let Se=await Ur(I,s.stxOptions||{});if(Se)E=Se}}if(await Ue(),await kn(p),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),Te.clear(),oe();try{let{invalidateFileCache:G,templateCache:Se}=await import("./chunk-6377p5ry.js");G(te.resolve(ee,q)),Se.delete(te.resolve(ee,q))}catch{}if(await Ue(),c&&l)l.reload(q)}}else if($t(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let ee of N.values())ee.close();if(l)lt();Dt.stop(),process.exit(0)})}return!0}import Ut from"fs";import yt from"path";async function Qr(t){try{let i=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!i)return[];let d=i[1],c=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,m;while((m=l.exec(d))!==null){let p=m[1],h=m[2]||m[3]||m[4];if(!h)continue;let g={name:h},y=p.match(/@type\s+\{([^}]+)\}/i);if(y)g.type=y[1].trim();if(p.match(/@required/i))g.required=!0;let S=p.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let R=p.split(`
1435
1435
  `).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);g.description=R.join(" ").trim(),c.push(g)}if(c.length===0){let p=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(p){let g=p[1].split(",").map((y)=>y.trim()).filter(Boolean);for(let y of g){let[w]=y.split(":").map((S)=>S.trim());if(w)c.push({name:w})}}}return c}catch(s){return console.error(`Error extracting props from ${t}:`,s),[]}}async function Zr(t){try{let s=await Bun.file(t).text(),i=s.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||s.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(i)return i[1].split(`
1436
1436
  `).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function eo(t,s=!1,i){let d=yt.basename(t,".stx"),c=await Qr(t),l=await Zr(t),m="";if(s&&i)m=`<${i}></${i}>`;else{let p=c.map((h)=>{if(h.type==="boolean")return`:${h.name}="true"`;return`${h.name}="value"`}).join(`
1437
1437
  `);m=`<${d}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Bt,Fc,zc,Hc,Vc,Uc,u,Wc,Is,qc,Ri,Ai}from"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Bt as STX_ENGINE_BINDING_NAMES,Is as convertToCommonJS,Ri as extractScriptFromTemplate,u as extractVariables,Ai as hasVariables,Wc as isCompleteImport,Uc as isMissingBindingFailure,Hc as isModuleResolutionFailure,Vc as isSyntaxFailure,qc as splitDeclaration,Fc as stripTypeScript,zc as withoutStxReferrer};
2
+ import{Bt,Fc,zc,Hc,Vc,Uc,u,Wc,Is,qc,Ri,Ai}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Bt as STX_ENGINE_BINDING_NAMES,Is as convertToCommonJS,Ri as extractScriptFromTemplate,u as extractVariables,Ai as hasVariables,Wc as isCompleteImport,Uc as isMissingBindingFailure,Hc as isModuleResolutionFailure,Vc as isSyntaxFailure,qc as splitDeclaration,Fc as stripTypeScript,zc as withoutStxReferrer};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rs,nu,ru}from"./chunk-ksn8mf12.js";import"./chunk-g9sv00hm.js";import"./chunk-zedvwcta.js";import"./chunk-5rtatjwq.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{ru as clearComposableCache,nu as getComposableScript,rs as listComposableModules};
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ import"./chunk-dvbgbd06.js";import"./chunk-66e4ga0z.js";import{m,h,w,j}from"./chunk-8jgrakqd.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.js";import"./chunk-sxpnpvt5.js";import"./chunk-x6pz1h3x.js";import"./chunk-khzyc41k.js";import"./chunk-z4te6223.js";import"./chunk-gc1dzxee.js";import"./chunk-aktzv0x2.js";import"./chunk-jp6yn9mj.js";import"./chunk-n5xbv1a9.js";import f from"path";var S=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(S);var l=new Map,x=m(64),y=new Set,O=0,R=new Set(S);function A(){l.clear(),x.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=h(n,O),r=x.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(y.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),x.set(o,t),t.slice()}async function W(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=j({loader:"ts",target:"browser",define:w()}),C=new Set(r),d=[],g=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let b=[];try{b=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!b.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),d.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
+ ${u.transformSync(e).trim()}`);for(let c of b)g.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!g.has(s)&&!I(n,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(d.length===0)return l.set(t,""),null;let E=[...g].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
+ `),k=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
5
+ ;(function(){
6
+ var __s = window.stx = window.stx || {};
7
+ ${d.join(`
8
+
9
+ `)}
10
+ ${E}
11
+ })();
12
+ </script>`;return l.set(t,k),k}function U(n){y.clear();for(let o of n)y.add(o);O++}export{U as __setRuntimeOwnedForTest,A as clearFrameworkComposableCache,W as getFrameworkComposableScript,M as referencedFrameworkComposables,P as selectComposableFiles};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{hn,pe}from"./chunk-5rtatjwq.js";import{m,yn,sr,w,qe,o,P}from"./chunk-e030grrq.js";import{ms}from"./chunk-erk7afjv.js";import{s,$e}from"./chunk-6qvskcwp.js";import{a}from"./chunk-q4a2j4qr.js";import d from"path";import S from"fs";import{AsyncLocalStorage as ft}from"async_hooks";var mt=10;function W(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||ms(t,e,n)}var rt=2;function gc(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):a(t,"bundle-cache")}function et(t,e){let n=d.resolve(e);return n===d.sep?t:t.split(n).join("\x00root")}function gt(t,e){try{let n=S.statSync(t),c=d.resolve(e),u=t.startsWith(`${c}${d.sep}`);return{path:u?d.relative(c,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(S.readFileSync(t)).toString(36)}}catch{return null}}function it(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function ht(t,e){for(let n of t){let c=it(n,e);try{let u=S.statSync(c);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(S.readFileSync(c)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ot=new Map,J=600,xt=100,V=new Map;async function yt(t){let e=V.get(t)??0;if(e>0&&e<xt){V.set(t,e+1);return}V.set(t,1);try{let n=(await S.promises.readdir(t)).filter((p)=>p.endsWith(".js"));if(n.length<=J)return;let u=(await Promise.all(n.map(async(p)=>{try{return{name:p,at:(await S.promises.stat(d.join(t,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,l)=>l.at-p.at);for(let p of u.slice(J)){let l=p.name.slice(0,-3);await S.promises.rm(d.join(t,`${l}.js`),{force:!0}),await S.promises.rm(d.join(t,`${l}.deps.json`),{force:!0})}D("pruned bundle cache to",J,"entries")}catch{}}function de(t){return ot.get(t)??[]}function G(t,e){if(t)ot.set(t,e)}function mc(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function D(...t){if(mc())console.log("[stx:bundler]",...t)}var Z=[];function ai(t,e,n){Z.push({filePath:t||"<inline>",message:e,details:n})}function Et(){return Z.slice()}function Tt(){Z.length=0}var H;function Xu(t){H=t}function ci(){if(H)return H;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function $t(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!q.some((l)=>l.test(u)))return D("detected user import:",u),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=c.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!q.some((l)=>l.test(u)))return D("detected side-effect import:",u),!0}return!1}var mn="stx-module:",bt=/\.(?:[cm]?[jt]sx?|json)$/i;function hc(t,e){return d.relative(t,e).split(d.sep).join("/")}function yc(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,c,u,p)=>{let l=e.get(p);return l&&!p.startsWith(mn)?`${c}${u}${l}${u}`:n})}function bc(t,e){let n=0,c=(p)=>{let l=`__stxMod${n++}`,E=JSON.stringify(p);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${E}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(E)} + " is not registered on this page (#1957)");`),l},u=(p,l)=>{for(let E of p.split(",")){let R=E.trim();if(!R)continue;let j=R.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let f=j[1].startsWith('"')?JSON.parse(j[1]):j[1],r=j[2]??f;e.push(`var ${r} = ${l}[${JSON.stringify(f)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l,E)=>{let R=E.slice(mn.length),j=c(R),f=l.trim(),r=f.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!f.startsWith("{")&&!f.startsWith("*"))e.push(`var ${r[1]} = ${j}.default;`),f=f.slice(r[0].length).trim();let i=f.match(/^\*\s*as\s+([\w$]+)$/);if(i)e.push(`var ${i[1]} = ${j};`);else if(f.startsWith("{"))u(f.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l)=>(c(l.slice(mn.length)),"")),t}function nt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(S.existsSync(n)&&S.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var Y=new ft;function us(t,e){let n=new Bun.CryptoHasher("md5");for(let[c,u]of[...t].sort(([p],[l])=>p<l?-1:p>l?1:0))n.update(`${c}\x00${u}\x00`);return Y.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Rt(){return Y.getStore()?.key??""}function wt(t,e,n,c,u,p=new Map,l,E){let R=(f,r,i)=>{if(W(r,t,l))return null;if(!u||f!==n||!bt.test(r))return null;try{if(!S.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let x=`${mn}${hc(process.cwd(),r)}`;return p.set(i,x),{path:x,external:!0}},j=(f,r)=>{let i=f===n?e:d.dirname(f),x=d.resolve(i,r);return nt(x)??x};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^\//},(r)=>{let i=nt(r.path);if(i){let x=R(r.importer,i,r.path);if(x)return x;if(i!==n)c.add(i);return{path:i}}return{path:r.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(r)=>{let i=j(r.importer,r.path),x=R(r.importer,i,r.path);if(x)return x;return c.add(i),{path:i}}),f.onResolve({filter:/^[@~]\//},(r)=>{let i=d.resolve(t,r.path.slice(2)),x=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,d.join(i,"index.ts"),d.join(i,"index.tsx"),d.join(i,"index.js"),d.join(i,"index.mjs")];for(let _ of x)if(S.existsSync(_)&&S.statSync(_,{throwIfNoEntry:!1})?.isFile()){let B=R(r.importer,_,r.path);if(B)return B;return D(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",_),c.add(_),{path:_}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:i}}),u)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let i=`${mn}npm:${r.path}`;return p.set(r.path,i),{path:i,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(W(r.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let i=d.extname(r.path).toLowerCase(),x=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(r.path!==n)c.add(r.path);let _=E?.get(r.path);if(_!==void 0)return{contents:_,loader:"js"};return{contents:S.readFileSync(r.path,"utf8"),loader:x}})}}}var X=new Map,U=m(64),st=Symbol.for("stx.client-bundle-build-queue");function vc(t){let e=globalThis,c=(e[st]??Promise.resolve()).then(t,t);return e[st]=c.then(()=>{return},()=>{return}),c}async function At(t,e,n={}){let c=n.projectRoot||process.cwd(),u=(await o(c)).serverApi,p=n.minify??!1,l=n.externalizeUserModules??!0,E=n.expose?.length?[...new Set(n.expose)].sort():void 0,R=n.cacheDir||gc(c),j=Y.getStore(),f=new Bun.CryptoHasher("md5");f.update(`${mt}\x00${qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${E?E.join(","):"*"}\x00${p?"minified":"readable"}\x00${j?.key??""}\x00${et(t,c)}\x00${et(e,c)}`);let r=f.digest("hex").slice(0,12),i=d.join(R,`${r}.js`),x=U.get(i);if(x){if(sr(x.files)&&x.files.every((M)=>!W(M.path,c,u))){D("memo hit:",r);let M=x.files.map((N)=>N.path);return G(e,M),n.collectInputs?.push(...M),x.code}U.delete(i),D("memo invalidated by dep change:",r)}let _=d.join(R,`${r}.deps.json`),B=Bun.file(i);if(await B.exists()){let M=Bun.file(_),N=!1,C=null;if(await M.exists())try{let F=JSON.parse(await M.text());if(F.metadataVersion===rt&&Array.isArray(F.files)&&ht(F.files,c))C=yn(F.files.map((g)=>it(g,c))),N=C.length===F.files.length&&!C.some((g)=>W(g.path,c,u))}catch{N=!1}if(N){if(D("cache hit:",r),C)G(e,C.map((g)=>g.path)),n.collectInputs?.push(...C.map((g)=>g.path));let F=await B.text();if(C)U.set(i,{code:F,files:C});return F}D("cache invalidated by dep change:",r)}let k=X.get(r);if(k){let M=await k;if(n.collectInputs)n.collectInputs.push(...(U.get(i)?.files??[]).map((N)=>N.path));return M}let L=vc(()=>vt(t,e,{projectRoot:c,minify:p,cacheDir:R,hash:r,cachePath:i,depsPath:_,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:E,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));X.set(r,L);try{return await L}finally{X.delete(r)}}var St=0;function wc(t){return`${t}-${process.pid}-${++St}`}async function vt(t,e,n){let{projectRoot:c,minify:u,cacheDir:p,hash:l,cachePath:E,depsPath:R,externalizeUserModules:j}=n,f=a(c,"bundle-tmp"),r=wc(l),i=d.join(f,`${r}.ts`),x=d.join(f,"out",r);S.mkdirSync(f,{recursive:!0}),S.mkdirSync(x,{recursive:!0});let _=d.dirname(e),B=new Set,k=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(t),{depths:N,balanced:C}=$e(M),F=(v)=>!C||N[v]===0,g;while((g=k.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;if(g[2])g[2].split(",").forEach((v)=>{let h=jt(v);if(h)B.add(h)});else if(g[3])B.add(g[3])}while((g=L.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;B.add(g[2])}let at=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=at.exec(M))!==null){if(!F(g.index))continue;let v=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(v&&q.some((h)=>h.test(v)))continue;if(g[1])B.add(g[1]);if(g[2])B.add(g[2]);for(let h of(g[3]??"").split(",")){let b=h.trim();if(!b||/^type\s/.test(b))continue;let O=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(O)B.add(O)}}for(let v of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let h of v[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(h)?.[1]??/^\s*(\w+)\s*$/.exec(h)?.[1];if(b)B.delete(b)}let ct=B.size>0?`
2
+ import{hn,pe}from"./chunk-5rtatjwq.js";import{m,yn,sr,w,qe,o,P}from"./chunk-8jgrakqd.js";import{ms}from"./chunk-zedvwcta.js";import{s,$e}from"./chunk-6qvskcwp.js";import{a}from"./chunk-q4a2j4qr.js";import d from"path";import S from"fs";import{AsyncLocalStorage as ft}from"async_hooks";var mt=10;function W(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||ms(t,e,n)}var rt=2;function gc(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):a(t,"bundle-cache")}function et(t,e){let n=d.resolve(e);return n===d.sep?t:t.split(n).join("\x00root")}function gt(t,e){try{let n=S.statSync(t),c=d.resolve(e),u=t.startsWith(`${c}${d.sep}`);return{path:u?d.relative(c,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(S.readFileSync(t)).toString(36)}}catch{return null}}function it(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function ht(t,e){for(let n of t){let c=it(n,e);try{let u=S.statSync(c);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(S.readFileSync(c)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ot=new Map,J=600,xt=100,V=new Map;async function yt(t){let e=V.get(t)??0;if(e>0&&e<xt){V.set(t,e+1);return}V.set(t,1);try{let n=(await S.promises.readdir(t)).filter((p)=>p.endsWith(".js"));if(n.length<=J)return;let u=(await Promise.all(n.map(async(p)=>{try{return{name:p,at:(await S.promises.stat(d.join(t,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,l)=>l.at-p.at);for(let p of u.slice(J)){let l=p.name.slice(0,-3);await S.promises.rm(d.join(t,`${l}.js`),{force:!0}),await S.promises.rm(d.join(t,`${l}.deps.json`),{force:!0})}D("pruned bundle cache to",J,"entries")}catch{}}function de(t){return ot.get(t)??[]}function G(t,e){if(t)ot.set(t,e)}function mc(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function D(...t){if(mc())console.log("[stx:bundler]",...t)}var Z=[];function ai(t,e,n){Z.push({filePath:t||"<inline>",message:e,details:n})}function Et(){return Z.slice()}function Tt(){Z.length=0}var H;function Xu(t){H=t}function ci(){if(H)return H;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function $t(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!q.some((l)=>l.test(u)))return D("detected user import:",u),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=c.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!q.some((l)=>l.test(u)))return D("detected side-effect import:",u),!0}return!1}var mn="stx-module:",bt=/\.(?:[cm]?[jt]sx?|json)$/i;function hc(t,e){return d.relative(t,e).split(d.sep).join("/")}function yc(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,c,u,p)=>{let l=e.get(p);return l&&!p.startsWith(mn)?`${c}${u}${l}${u}`:n})}function bc(t,e){let n=0,c=(p)=>{let l=`__stxMod${n++}`,E=JSON.stringify(p);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${E}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(E)} + " is not registered on this page (#1957)");`),l},u=(p,l)=>{for(let E of p.split(",")){let R=E.trim();if(!R)continue;let j=R.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let f=j[1].startsWith('"')?JSON.parse(j[1]):j[1],r=j[2]??f;e.push(`var ${r} = ${l}[${JSON.stringify(f)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l,E)=>{let R=E.slice(mn.length),j=c(R),f=l.trim(),r=f.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!f.startsWith("{")&&!f.startsWith("*"))e.push(`var ${r[1]} = ${j}.default;`),f=f.slice(r[0].length).trim();let i=f.match(/^\*\s*as\s+([\w$]+)$/);if(i)e.push(`var ${i[1]} = ${j};`);else if(f.startsWith("{"))u(f.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l)=>(c(l.slice(mn.length)),"")),t}function nt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(S.existsSync(n)&&S.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var Y=new ft;function us(t,e){let n=new Bun.CryptoHasher("md5");for(let[c,u]of[...t].sort(([p],[l])=>p<l?-1:p>l?1:0))n.update(`${c}\x00${u}\x00`);return Y.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Rt(){return Y.getStore()?.key??""}function wt(t,e,n,c,u,p=new Map,l,E){let R=(f,r,i)=>{if(W(r,t,l))return null;if(!u||f!==n||!bt.test(r))return null;try{if(!S.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let x=`${mn}${hc(process.cwd(),r)}`;return p.set(i,x),{path:x,external:!0}},j=(f,r)=>{let i=f===n?e:d.dirname(f),x=d.resolve(i,r);return nt(x)??x};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^\//},(r)=>{let i=nt(r.path);if(i){let x=R(r.importer,i,r.path);if(x)return x;if(i!==n)c.add(i);return{path:i}}return{path:r.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(r)=>{let i=j(r.importer,r.path),x=R(r.importer,i,r.path);if(x)return x;return c.add(i),{path:i}}),f.onResolve({filter:/^[@~]\//},(r)=>{let i=d.resolve(t,r.path.slice(2)),x=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,d.join(i,"index.ts"),d.join(i,"index.tsx"),d.join(i,"index.js"),d.join(i,"index.mjs")];for(let _ of x)if(S.existsSync(_)&&S.statSync(_,{throwIfNoEntry:!1})?.isFile()){let B=R(r.importer,_,r.path);if(B)return B;return D(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",_),c.add(_),{path:_}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:i}}),u)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let i=`${mn}npm:${r.path}`;return p.set(r.path,i),{path:i,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(W(r.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let i=d.extname(r.path).toLowerCase(),x=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(r.path!==n)c.add(r.path);let _=E?.get(r.path);if(_!==void 0)return{contents:_,loader:"js"};return{contents:S.readFileSync(r.path,"utf8"),loader:x}})}}}var X=new Map,U=m(64),st=Symbol.for("stx.client-bundle-build-queue");function vc(t){let e=globalThis,c=(e[st]??Promise.resolve()).then(t,t);return e[st]=c.then(()=>{return},()=>{return}),c}async function At(t,e,n={}){let c=n.projectRoot||process.cwd(),u=(await o(c)).serverApi,p=n.minify??!1,l=n.externalizeUserModules??!0,E=n.expose?.length?[...new Set(n.expose)].sort():void 0,R=n.cacheDir||gc(c),j=Y.getStore(),f=new Bun.CryptoHasher("md5");f.update(`${mt}\x00${qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${E?E.join(","):"*"}\x00${p?"minified":"readable"}\x00${j?.key??""}\x00${et(t,c)}\x00${et(e,c)}`);let r=f.digest("hex").slice(0,12),i=d.join(R,`${r}.js`),x=U.get(i);if(x){if(sr(x.files)&&x.files.every((M)=>!W(M.path,c,u))){D("memo hit:",r);let M=x.files.map((N)=>N.path);return G(e,M),n.collectInputs?.push(...M),x.code}U.delete(i),D("memo invalidated by dep change:",r)}let _=d.join(R,`${r}.deps.json`),B=Bun.file(i);if(await B.exists()){let M=Bun.file(_),N=!1,C=null;if(await M.exists())try{let F=JSON.parse(await M.text());if(F.metadataVersion===rt&&Array.isArray(F.files)&&ht(F.files,c))C=yn(F.files.map((g)=>it(g,c))),N=C.length===F.files.length&&!C.some((g)=>W(g.path,c,u))}catch{N=!1}if(N){if(D("cache hit:",r),C)G(e,C.map((g)=>g.path)),n.collectInputs?.push(...C.map((g)=>g.path));let F=await B.text();if(C)U.set(i,{code:F,files:C});return F}D("cache invalidated by dep change:",r)}let k=X.get(r);if(k){let M=await k;if(n.collectInputs)n.collectInputs.push(...(U.get(i)?.files??[]).map((N)=>N.path));return M}let L=vc(()=>vt(t,e,{projectRoot:c,minify:p,cacheDir:R,hash:r,cachePath:i,depsPath:_,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:E,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));X.set(r,L);try{return await L}finally{X.delete(r)}}var St=0;function wc(t){return`${t}-${process.pid}-${++St}`}async function vt(t,e,n){let{projectRoot:c,minify:u,cacheDir:p,hash:l,cachePath:E,depsPath:R,externalizeUserModules:j}=n,f=a(c,"bundle-tmp"),r=wc(l),i=d.join(f,`${r}.ts`),x=d.join(f,"out",r);S.mkdirSync(f,{recursive:!0}),S.mkdirSync(x,{recursive:!0});let _=d.dirname(e),B=new Set,k=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(t),{depths:N,balanced:C}=$e(M),F=(v)=>!C||N[v]===0,g;while((g=k.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;if(g[2])g[2].split(",").forEach((v)=>{let h=jt(v);if(h)B.add(h)});else if(g[3])B.add(g[3])}while((g=L.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;B.add(g[2])}let at=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=at.exec(M))!==null){if(!F(g.index))continue;let v=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(v&&q.some((h)=>h.test(v)))continue;if(g[1])B.add(g[1]);if(g[2])B.add(g[2]);for(let h of(g[3]??"").split(",")){let b=h.trim();if(!b||/^type\s/.test(b))continue;let O=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(O)B.add(O)}}for(let v of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let h of v[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(h)?.[1]??/^\s*(\w+)\s*$/.exec(h)?.[1];if(b)B.delete(b)}let ct=B.size>0?`
3
3
  export { ${[...B].join(", ")} }`:"";await Bun.write(i,t+ct),D("bundling:",l,"from:",d.basename(e));let Q=new Set,K=new Map;try{let v=await Bun.build({entrypoints:[i],outdir:x,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[wt(c,_,i,Q,j,K,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...w()},root:c});if(!v.success){let I=v.logs.filter((A)=>A.level==="error").map((A)=>A.message).join(", ")||`Unable to bundle ${d.basename(e)}`,T=hn(v.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",I),ai(e||"",I,T),n.throwOnFailure||ci()==="error")throw Error(I);return t}let h="";for(let y of v.outputs){h=await y.text();break}let b=[];for(let y of h.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of y[1].split(",")){let T=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(T){b.push([T[2],T[1]]);continue}let A=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(A))b.push([A,A])}if(n.expose){let y=new Set(n.expose);for(let I=b.length-1;I>=0;I--)if(!y.has(b[I][0]))b.splice(I,1)}let O=[];h=bc(yc(h,K),O);let lt=h.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(h=h.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&h)try{h=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(h)}catch{}let tt=`__stxBundle_${l}`,ut=b.map(([y,I])=>`${JSON.stringify(y)}: ${I}`).join(", "),dt=b.map(([y])=>`var ${y} = undefined;`).join(`
4
4
  `),pt=b.map(([y])=>`${y} = ${tt}[${JSON.stringify(y)}];`).join(`
5
5
  `);if(h=`${lt.join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{or,Sc,Zu,kc,Qu,Cc,ir,b,Dt,Ce,_c,ws,Ec,ed,Y,Tc,td,x,nd}from"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Tc as applyFilters,Qu as clearCustomFilters,_c as clientLoopScopes,or as defaultFilters,b as escapeHtml,Dt as escapeHtmlValue,x as evaluateExpression,Cc as findMustacheEnd,kc as getAllFilters,Ec as interpolateScriptAttributes,ws as interpolateScriptExpressions,ed as interpolateScriptsInTemplate,Y as processExpressions,Sc as registerFilter,Zu as registerFilters,ir as replaceInterpolations,td as resetRejectedExpressionWarnings,nd as unescapeHtml,Ce as usesSignalsInScript};
2
+ import{or,Sc,Zu,kc,Qu,Cc,ir,b,Dt,Ce,_c,ws,Ec,ed,Y,Tc,td,x,nd}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Tc as applyFilters,Qu as clearCustomFilters,_c as clientLoopScopes,or as defaultFilters,b as escapeHtml,Dt as escapeHtmlValue,x as evaluateExpression,Cc as findMustacheEnd,kc as getAllFilters,Ec as interpolateScriptAttributes,ws as interpolateScriptExpressions,ed as interpolateScriptsInTemplate,Y as processExpressions,Sc as registerFilter,Zu as registerFilters,ir as replaceInterpolations,td as resetRejectedExpressionWarnings,nd as unescapeHtml,Ce as usesSignalsInScript};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-vddfv082.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-0fgp13q4.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-jwqz8w58.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-ekfmad19.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-0fcxfd5f.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-0fgp13q4.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-sp94c1vv.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-ekfmad19.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
4
4
  `)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-dvbgbd06.js";import{I,Ut}from"./chunk-66e4ga0z.js";import{It,m,h,w,et,j,o}from"./chunk-e030grrq.js";import{de,$t,Rt,At}from"./chunk-fqwyfx6c.js";import{ze,an,kt,q}from"./chunk-swv69q75.js";import{E,jn}from"./chunk-szjgbjw1.js";import S from"path";var C=new Map,D=new Map,k=m(64),A=new Map,Z=["composables","functions"];function G(t){let n=S.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Q(t){if(t)return S.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await V();if(e!==null)A.set(n,e);return e}async function V(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return S.resolve(n,a);for(let e of Z){let s=S.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!G(c))return s}catch{}}return null}async function J(t){let n=Array.isArray(t)?t:t?[S.resolve(t)]:(await o())._layerComposableDirs??[await Q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=S.relative(e,d);if(!G(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function rs(t){let{files:n}=await J(t),a=j({loader:"ts",target:"browser",define:w()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((p)=>p!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Y(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):Y(t,s))e.add(s);return e}var z=m(64);function ee(t,n){let a=h(t,n.size),e=z.get(a);if(e)return e;let s;try{s=It(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let p of c[1].split(",")){let g=p.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(g&&n.has(g))s.add(g)}return z.set(a,s),s}function te(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of ee(u,d))l.push(e.get(f));return l},p=new Set,g=a.flatMap((u,l)=>l===0?s(u):c(u));while(g.length>0){let u=[];for(let l of g){if(p.has(l))continue;p.add(l);for(let f of c(n.get(l)??""))if(!p.has(f))u.push(f)}g=u}return p}async function nu(t,n,a){let{key:e,files:s}=await J(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>de(r))])],c=ze(d());if(s.length===0)return q(C,e,c,""),null;s.sort();let p=j({loader:"ts",target:"browser",define:w()}),g=kt(D,e,c);if(!g){let r=new Map,i=[];for(let _ of s)try{let x=await Bun.file(_).text();r.set(_,x);let b=p.scan(x).exports.filter((X)=>X!=="default");if(b.length>0)i.push({file:_,names:b})}catch{r.set(_,"")}g=q(D,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=g,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=h(r.join("\x00"),e,r.length,c),_=k.get(i);if(f=_??te(l,u,r),!_)k.set(i,f)}if(f.size===0)return null;let F=s.filter((r)=>f.has(r)),B=`${e}\x00${F.join("\x00")}\x00${Rt()}`,R=kt(C,B,c);if(R!==void 0)return R||null;let M=[],v=new Set,P=new Set;for(let r of F)try{let i=u.get(r)??await Bun.file(r).text(),_=S.basename(r,".ts");for(let b of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(b[1])P.add(b[1]);let x=[];try{for(let b of p.scan(i).exports)if(b!=="default")v.add(b),x.push(b)}catch{}if(i=I(i),$t(i))i=await At(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),i=et(i);i=Ut(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=p.transformSync(i),M.push(`// Composable: ${_}
2
+ import{y}from"./chunk-dvbgbd06.js";import{I,Ut}from"./chunk-66e4ga0z.js";import{It,m,h,w,et,j,o}from"./chunk-8jgrakqd.js";import{de,$t,Rt,At}from"./chunk-g9sv00hm.js";import{ze,an,kt,q}from"./chunk-swv69q75.js";import{E,jn}from"./chunk-szjgbjw1.js";import S from"path";var C=new Map,D=new Map,k=m(64),A=new Map,Z=["composables","functions"];function G(t){let n=S.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function Q(t){if(t)return S.resolve(t);let n=`<default>:${process.cwd()}`,a=A.get(n);if(a!==void 0)return a;let e=await V();if(e!==null)A.set(n,e);return e}async function V(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return S.resolve(n,a);for(let e of Z){let s=S.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!G(c))return s}catch{}}return null}async function J(t){let n=Array.isArray(t)?t:t?[S.resolve(t)]:(await o())._layerComposableDirs??[await Q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=S.relative(e,d);if(!G(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function rs(t){let{files:n}=await J(t),a=j({loader:"ts",target:"browser",define:w()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((p)=>p!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function Y(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function L(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):Y(t,s))e.add(s);return e}var z=m(64);function ee(t,n){let a=h(t,n.size),e=z.get(a);if(e)return e;let s;try{s=It(t,n)}catch{s=L(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let p of c[1].split(",")){let g=p.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(g&&n.has(g))s.add(g)}return z.set(a,s),s}function te(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of L(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of ee(u,d))l.push(e.get(f));return l},p=new Set,g=a.flatMap((u,l)=>l===0?s(u):c(u));while(g.length>0){let u=[];for(let l of g){if(p.has(l))continue;p.add(l);for(let f of c(n.get(l)??""))if(!p.has(f))u.push(f)}g=u}return p}async function nu(t,n,a){let{key:e,files:s}=await J(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>de(r))])],c=ze(d());if(s.length===0)return q(C,e,c,""),null;s.sort();let p=j({loader:"ts",target:"browser",define:w()}),g=kt(D,e,c);if(!g){let r=new Map,i=[];for(let _ of s)try{let x=await Bun.file(_).text();r.set(_,x);let b=p.scan(x).exports.filter((X)=>X!=="default");if(b.length>0)i.push({file:_,names:b})}catch{r.set(_,"")}g=q(D,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=g,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=h(r.join("\x00"),e,r.length,c),_=k.get(i);if(f=_??te(l,u,r),!_)k.set(i,f)}if(f.size===0)return null;let F=s.filter((r)=>f.has(r)),B=`${e}\x00${F.join("\x00")}\x00${Rt()}`,R=kt(C,B,c);if(R!==void 0)return R||null;let M=[],v=new Set,P=new Set;for(let r of F)try{let i=u.get(r)??await Bun.file(r).text(),_=S.basename(r,".ts");for(let b of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(b[1])P.add(b[1]);let x=[];try{for(let b of p.scan(i).exports)if(b!=="default")v.add(b),x.push(b)}catch{}if(i=I(i),$t(i))i=await At(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:x}),i=et(i);i=Ut(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=p.transformSync(i),M.push(`// Composable: ${_}
3
3
  ${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(M.length===0||v.size===0)return q(C,B,c,""),null;let H=[...v].map((r)=>` try { if (!(${JSON.stringify(r)} in __c)) __c[${JSON.stringify(r)}] = ${r}; } catch (e) {}`).join(`
4
4
  `),K=JSON.stringify([...v]),N=M.join(`
5
5
 
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{o}from"./chunk-e030grrq.js";import{qr}from"./chunk-m735gtc4.js";import p from"path";async function Fl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(qr(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-x7v3m9nk.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
2
+ import{o}from"./chunk-8jgrakqd.js";import{qr}from"./chunk-m735gtc4.js";import p from"path";async function Fl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(qr(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-5q7gcr0f.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
3
  export{Fl};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Go,Ko,Xo,Gu}from"./chunk-3h2rpaps.js";import"./chunk-3tp481j5.js";import"./chunk-jsw5yby0.js";import"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Go as buildNative,Gu as default,Xo as getAvailableFormats,Ko as getAvailableTargets};
2
+ import{Go,Ko,Xo,Gu}from"./chunk-3ap1vsh3.js";import"./chunk-6j4f8dwx.js";import"./chunk-jsw5yby0.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Go as buildNative,Gu as default,Xo as getAvailableFormats,Ko as getAvailableTargets};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{A,rl,zs,o,P,wd,xd}from"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{P as config,A as defaultConfig,wd as defineStxConfig,zs as discoverConfig,o as loadStxConfig,rl as resolveStxDirectories,xd as validateConfig};
2
+ import{A,rl,zs,o,P,wd,xd}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{P as config,A as defaultConfig,wd as defineStxConfig,zs as discoverConfig,o as loadStxConfig,rl as resolveStxDirectories,xd as validateConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ku,Cu}from"./chunk-4tyj5vpw.js";import"./chunk-g9sv00hm.js";import"./chunk-zedvwcta.js";import"./chunk-5rtatjwq.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Cu as clearStoreCache,ku as getStoreScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{wl}from"./chunk-pwsg9w5g.js";import"./chunk-9eejvpqc.js";import"./chunk-erk7afjv.js";import"./chunk-e030grrq.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-j8vd52sg.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{wl as startProductionServer};
2
+ import{wl}from"./chunk-b7fgatb5.js";import"./chunk-8zqgb3q9.js";import"./chunk-zedvwcta.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{wl as startProductionServer};