@stacksjs/stx 0.2.465 → 0.2.466

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 (118) hide show
  1. package/dist/{chunk-nmk9en1n.js → chunk-01zwbzyw.js} +324 -164
  2. package/dist/{chunk-qc7zybaa.js → chunk-02e24cym.js} +1 -1
  3. package/dist/{chunk-ag1v2tkm.js → chunk-0adxpd3e.js} +2321 -2321
  4. package/dist/{chunk-sgbgwezf.js → chunk-0v5dpk7r.js} +1 -1
  5. package/dist/chunk-1rbabtw0.js +2 -0
  6. package/dist/{chunk-n003eq8w.js → chunk-1sdtg9np.js} +2 -2
  7. package/dist/chunk-24xhcqt9.js +2 -0
  8. package/dist/{chunk-yc4hf2ea.js → chunk-2cqymwe8.js} +2 -2
  9. package/dist/{chunk-1byqqwgm.js → chunk-2tn3dkcy.js} +2 -2
  10. package/dist/{chunk-2nvnd83c.js → chunk-3ar8gdyd.js} +1 -1
  11. package/dist/{chunk-4xcypfmg.js → chunk-45ffx66n.js} +1 -1
  12. package/dist/chunk-4rnncksa.js +2 -0
  13. package/dist/{chunk-se9qddyx.js → chunk-544e2jvd.js} +4 -4
  14. package/dist/chunk-5xsd1dw1.js +2 -0
  15. package/dist/chunk-6qsvh58v.js +2 -0
  16. package/dist/chunk-6xd9qbve.js +2 -0
  17. package/dist/{chunk-y8h823cb.js → chunk-74j18qk0.js} +28 -28
  18. package/dist/chunk-7fjatz47.js +2 -0
  19. package/dist/chunk-7j1cpa9d.js +2 -0
  20. package/dist/chunk-812sn7d5.js +18 -0
  21. package/dist/{chunk-5zaj400e.js → chunk-8bpyr4az.js} +1 -1
  22. package/dist/chunk-8bsz3ky4.js +2 -0
  23. package/dist/{chunk-gm6g6gar.js → chunk-8efg91ak.js} +2 -2
  24. package/dist/{chunk-5mmqe3hj.js → chunk-9zx4p42m.js} +1 -1
  25. package/dist/{chunk-cstvhr0r.js → chunk-ars3cbs5.js} +1099 -1099
  26. package/dist/{chunk-7xckcy9x.js → chunk-bnemhyg2.js} +1 -1
  27. package/dist/{chunk-5e6p2ndj.js → chunk-cfk3skk4.js} +1 -1
  28. package/dist/chunk-cg8hg6cs.js +3 -0
  29. package/dist/{chunk-pw34r8r5.js → chunk-cmej3vrr.js} +1 -1
  30. package/dist/{chunk-gjrbnzap.js → chunk-d2zw2e5m.js} +3 -3
  31. package/dist/chunk-d78wbjkz.js +2 -0
  32. package/dist/{chunk-x9a5a282.js → chunk-e15a8txv.js} +2 -2
  33. package/dist/{chunk-4acykd9n.js → chunk-eanwntq4.js} +1 -1
  34. package/dist/{chunk-pxmbee61.js → chunk-ebp212na.js} +5 -5
  35. package/dist/chunk-f9c58ag8.js +30 -0
  36. package/dist/{chunk-769t2y70.js → chunk-fads0sap.js} +1 -1
  37. package/dist/chunk-fmtyrdgg.js +2 -0
  38. package/dist/chunk-gmccacxc.js +2 -0
  39. package/dist/{chunk-6bwe6vsc.js → chunk-h074e6w3.js} +1 -1
  40. package/dist/chunk-h6ayvmaj.js +2 -0
  41. package/dist/{chunk-gasb5fhy.js → chunk-hra6t4ch.js} +2 -2
  42. package/dist/{chunk-z14y48en.js → chunk-jkf5k215.js} +3 -3
  43. package/dist/chunk-k8smv0at.js +2 -0
  44. package/dist/{chunk-7knc20mz.js → chunk-k9sbgax8.js} +1 -1
  45. package/dist/{chunk-2e4pegf1.js → chunk-kax708d4.js} +1 -1
  46. package/dist/chunk-kca543an.js +2 -0
  47. package/dist/{chunk-27k24mk0.js → chunk-kkrmhb5b.js} +1 -1
  48. package/dist/chunk-m08fk6ds.js +12 -0
  49. package/dist/chunk-mdkj4jj1.js +2 -0
  50. package/dist/chunk-n39zm07w.js +2 -0
  51. package/dist/{chunk-en3e0y6m.js → chunk-na5evt2b.js} +1 -1
  52. package/dist/chunk-pbfwbtg4.js +2 -0
  53. package/dist/{chunk-j9y50qt9.js → chunk-ptek61ts.js} +1 -1
  54. package/dist/{chunk-xt4990k8.js → chunk-pyqh70k2.js} +1 -1
  55. package/dist/{chunk-abb9xmdg.js → chunk-q7bs39wj.js} +1 -1
  56. package/dist/chunk-qyq7j8hp.js +2 -0
  57. package/dist/{chunk-0avd5kkb.js → chunk-rdp06c4s.js} +20 -20
  58. package/dist/{chunk-32kk8y2r.js → chunk-rgwvqmhh.js} +1 -1
  59. package/dist/chunk-rx3rxfrj.js +2 -0
  60. package/dist/{chunk-n6p2at6g.js → chunk-sz1s3k89.js} +1 -1
  61. package/dist/{chunk-ysptfks9.js → chunk-t2hkwjvd.js} +1 -1
  62. package/dist/{chunk-ktvr45qg.js → chunk-t61vdbje.js} +6 -6
  63. package/dist/chunk-tejeej39.js +2 -0
  64. package/dist/{chunk-nmnbdtsq.js → chunk-v6qxmac5.js} +6 -6
  65. package/dist/{chunk-p7j2g8y2.js → chunk-v83bpj84.js} +4 -4
  66. package/dist/chunk-vcjfwjr8.js +2 -0
  67. package/dist/chunk-w7m1w5qt.js +2 -0
  68. package/dist/{chunk-jbdqs7t6.js → chunk-wfqnxb38.js} +1 -1
  69. package/dist/{chunk-1bazr47z.js → chunk-wx25t40k.js} +1 -1
  70. package/dist/chunk-xjb0yzvq.js +2 -0
  71. package/dist/chunk-xk3wf5sh.js +2 -0
  72. package/dist/chunk-xk5972g0.js +2 -0
  73. package/dist/{chunk-gj90pnre.js → chunk-y36av1ac.js} +7 -7
  74. package/dist/{chunk-3q3174cn.js → chunk-y63bv55f.js} +2 -2
  75. package/dist/{chunk-pfm6cfph.js → chunk-ynvce0q6.js} +2 -2
  76. package/dist/{chunk-9g339c7b.js → chunk-z80d9dd2.js} +2 -2
  77. package/dist/{chunk-vvb3wq2p.js → chunk-z990jtmx.js} +1 -1
  78. package/dist/{chunk-azcvytqc.js → chunk-zr2trjex.js} +1 -1
  79. package/dist/cli.js +43 -43
  80. package/dist/client-script-bundler.js +1 -1
  81. package/dist/craft-entry.js +2 -2
  82. package/dist/craft.js +2 -2
  83. package/dist/database.js +2 -2
  84. package/dist/pwa.js +3 -3
  85. package/dist/signals.js +318 -158
  86. package/dist/ssg.js +2 -2
  87. package/dist/strip-literals.js +23 -8
  88. package/package.json +5 -5
  89. package/dist/chunk-0880qx3m.js +0 -2
  90. package/dist/chunk-0zf49qxk.js +0 -2
  91. package/dist/chunk-1tsz7v68.js +0 -2
  92. package/dist/chunk-2mv3wh0s.js +0 -2
  93. package/dist/chunk-4wjef6d8.js +0 -18
  94. package/dist/chunk-6ry01675.js +0 -2
  95. package/dist/chunk-97ezbs97.js +0 -2
  96. package/dist/chunk-99qf5fff.js +0 -2
  97. package/dist/chunk-a201b6rx.js +0 -2
  98. package/dist/chunk-aqdkct70.js +0 -2
  99. package/dist/chunk-bb7p822h.js +0 -2
  100. package/dist/chunk-bj31r6sj.js +0 -2
  101. package/dist/chunk-c1gp4xjy.js +0 -2
  102. package/dist/chunk-c8z3fghp.js +0 -2
  103. package/dist/chunk-esc6fahf.js +0 -2
  104. package/dist/chunk-f2rh0zhs.js +0 -2
  105. package/dist/chunk-h5k0c1jp.js +0 -2
  106. package/dist/chunk-hqfgbtsy.js +0 -30
  107. package/dist/chunk-j2pdtq0d.js +0 -2
  108. package/dist/chunk-kewh1a68.js +0 -2
  109. package/dist/chunk-kvfcm30m.js +0 -2
  110. package/dist/chunk-nahzfs7d.js +0 -2
  111. package/dist/chunk-s1075erh.js +0 -2
  112. package/dist/chunk-s2fpethy.js +0 -2
  113. package/dist/chunk-tps20cx5.js +0 -2
  114. package/dist/chunk-ts3jftxq.js +0 -2
  115. package/dist/chunk-wfmy7a0b.js +0 -2
  116. package/dist/chunk-xsdj6k6c.js +0 -2
  117. package/dist/chunk-y3cqh2jv.js +0 -12
  118. package/dist/chunk-yn2d8x8m.js +0 -3
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import{zo,Jr,Y,Le,vt,x,Be,Fe,zn,d,sn}from"./chunk-0adxpd3e.js";import{O}from"./chunk-58n62bxb.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(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(D.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 H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function no(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(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 B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[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 i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(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 T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var Te="private, no-store";function ro(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 ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function _(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-5564cka1.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function so(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function xr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=no(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-n39zm07w.js"),R=await b(),g={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],g,t)}let y=await p(l,g,t,{...S,...R,...n},new Set),w=y.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Cn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>${a}</title>
8
+ ${o?` ${o}
9
+ `:""} ${t.shellStyles.join(`
10
+ `)}
11
+ </head>
12
+ <body>
13
+ ${t.beforeSlot}
14
+ <div data-stx-content>${n}</div>
15
+ ${t.afterSlot}
16
+ ${t.shellScripts.filter((l)=>!l.includes("server")).join(`
17
+ `)}
18
+ ${c}
19
+ ${i}
20
+ </body>
21
+ </html>`}function ge(t,n={}){let e=t.trim();if(!sn(e))return t;let r=[],o=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(o){let c=o[1],u=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=u.exec(c))!==null)r.push(l[0]);let f=c.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(f)r.push(f[0]);let p=c.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(p)r.push(p[0])}if(n.preserveHead&&o){let c=[],u=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=u.exec(o[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;c.push(l[0])}if(c.length>0)r.unshift(`<!--${G}${Buffer.from(c.join(`
22
+ `),"utf8").toString("base64")}-->`)}let s=e.match(/<body\b[^>]*>/i),a=e.lastIndexOf("</body>");if(s&&a!==-1){let c=s.index+s[0].length,u=e.slice(c,a).trim();if(r.length>0)return r.join(`
23
+ `)+`
24
+ `+u;return u}let i=e;if(i=i.replace(/<!DOCTYPE\b[^>]*>/i,""),i=i.replace(/<html\b[^>]*>/i,""),i=i.replace(/<\/html\s*>/i,""),o)i=i.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,r.join(`
25
+ `));return i=i.replace(/<body\b[^>]*>/i,""),i=i.replace(/<\/body\s*>/i,""),i.trim()}var N=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function X(t,n,e,r){if(!N.test(n))return!1;let o=n.slice(0,n.indexOf(">")+1),s=/\sdata-stx-owner="([^"]+)"/i.exec(o)?.[1];if(!s)return!0;let a=`data-stx-scope="${s}"`;for(let i=t.indexOf(a);i!==-1;i=t.indexOf(a,i+a.length))if(i>=e&&i<r)return!1;return!0}function oo(t){return ne(t)}function re(t,n="main"){let e=t.trim(),r=[],o=[],s=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(s){let b=s[1],R=/<style\b[^>]*>[\s\S]*?<\/style>/gi,g;while((g=R.exec(b))!==null)r.push(g[0]);let y=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((g=y.exec(b))!==null){if(N.test(g[0])||g[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(g[0]))continue;o.push(g[0])}}let a=T(e,n);if(!a)return ge(t);let{tagName:i,start:c,end:u}=a,l=e.slice(c,u).trim(),f=[],p=e.match(/<body\b[^>]*>/i),h=e.lastIndexOf("</body>");if(p&&p.index!==void 0&&h!==-1){let R=[[p.index+p[0].length,a.openIndex],[u+`</${i}>`.length,h]],g=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[y,w]of R){if(y>=w)continue;let m=e.slice(y,w),C;g.lastIndex=0;while((C=g.exec(m))!==null){if(X(e,C[0],c,u))continue;f.push(C[0])}}}let S=[];if(r.length>0)S.push(r.join(`
26
+ `));if(o.length>0)S.push(o.join(`
27
+ `));if(f.length>0)S.push(f.join(`
28
+ `));return S.push(l),S.join(`
29
+ `)}function E(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 J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Sr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Sr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(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(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function lo(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function io(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function ao(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function co(t){let n=j.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}}async function It(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-gmccacxc.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-xk5972g0.js"),{defaultConfig:p}=await import("./chunk-h6ayvmaj.js"),h=r.streamBoundaries||{},S={...p,autoShell:!1},b=Object.keys(l).map((g)=>({id:g,render:async()=>{let y=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Jr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=zn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Jr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?vt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(zo(t.html,s)),context:e,cookies:r.cookies}}
30
+ export{no,Te,ro,ne,_,so,xr,Cn,ge,oo,re,io,ao,co,Sr,lo,It};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import g from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...r){let o=new Set;for(let s of r){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{o.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...o].sort()}async function M(r,o={}){if(r.length===0)return null;let s=process.cwd(),e=[],l=[];r.forEach((t,h)=>{let x=t.startsWith("npm:")?t.slice(4):g.resolve(s,t),a=`__stxRegistered${h}`,d=JSON.stringify(t);e.push(`import * as ${a} from ${JSON.stringify(x)};`),l.push(`if (!globalThis.__stxModules[${d}]) globalThis.__stxModules[${d}] = ${a};`)});let u=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...l].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-27k24mk0.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-xsdj6k6c.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-0e1rga0j.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-kkrmhb5b.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-1rbabtw0.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-0e1rga0j.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
4
4
  `)}export{M as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{So,ko,Co,mu}from"./chunk-rdp06c4s.js";import"./chunk-812sn7d5.js";import"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{So as buildNative,mu as default,Co as getAvailableFormats,ko as getAvailableTargets};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ql,yo,_a,eu,tu,nu,ru,su,Ta,Ra,ou,iu,au,cu}from"./chunk-v6qxmac5.js";import"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{_a as SUSPENSE_RESOLVER_RUNTIME,yo as buildSuspenseResolveScript,su as createStreamRenderer,nu as extractStreamBoundaries,cu as generateHydrationRuntime,Ra as islandDirective,iu as processSectionDirectives,tu as processStreamDirectives,ou as registerStreamingDirectives,eu as renderStreamingPage,Ql as streamTemplate,ru as streamTemplateSimple,au as streamToResponse,Ta as streamingSuspenseDirective};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ld,oc,os,is,Qo,ei,as,cs,Fn,ic,ti,ni,ac,He}from"./chunk-ag1v2tkm.js";import"./chunk-gjrbnzap.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-jbdqs7t6.js";import"./chunk-zydg3wgt.js";import"./chunk-gj90pnre.js";import"./chunk-p7j2g8y2.js";import"./chunk-pfm6cfph.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Ld as clearScriptScanCache,as as convertServerLoopAttributesToDirectives,Qo as convertSignalDirectivesToAttributes,cs as convertSignalLoopsToAttributes,ic as extractExports,ni as findMarkupIndexOutsideScripts,is as hasSignalsSyntax,os as parseLoopExpression,ei as preEvalLiteralReactiveIfs,Fn as processScriptSetup,ti as processSignals,ac as rewriteStxImportSpecifiers,oc as scanScriptTags,He as stripStxRuntimeImports};
2
+ import{Lu,oc,os,is,Qo,ei,as,cs,Fn,ic,ti,ni,ac,He}from"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Lu as clearScriptScanCache,as as convertServerLoopAttributesToDirectives,Qo as convertSignalDirectivesToAttributes,cs as convertSignalLoopsToAttributes,ic as extractExports,ni as findMarkupIndexOutsideScripts,is as hasSignalsSyntax,os as parseLoopExpression,ei as preEvalLiteralReactiveIfs,Fn as processScriptSetup,ti as processSignals,ac as rewriteStxImportSpecifiers,oc as scanScriptTags,He as stripStxRuntimeImports};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{I,Ec,o,R,zu,Hu}from"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{R as config,I as defaultConfig,zu as defineStxConfig,o as loadStxConfig,Ec as resolveStxDirectories,Hu as validateConfig};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{G}from"./chunk-88px183j.js";import{le,C}from"./chunk-zydg3wgt.js";import{hi}from"./chunk-0trfbqa7.js";import{a}from"./chunk-7tt84v1y.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function bt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Hr(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=G(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
3
  `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Vr(s,l,o={}){let i=bt(s,o);await Hr(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Ur(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function bd(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=bt(s,o);return await Hr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=bt(s,o);await Hr(s,t);let{loadStxConfig:e}=await import("./chunk-kewh1a68.js"),p=C((await e(s)).runtimeConfig);return await le(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Ur(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function bu(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=bt(s,o);return await Hr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=bt(s,o);await Hr(s,t);let{loadStxConfig:e}=await import("./chunk-h6ayvmaj.js"),p=C((await e(s)).runtimeConfig);return await le(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Wr(s,l,o){if(hi(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
6
- export{bt,Hr,Vr,Ur,bd,Wr};
6
+ export{bt,Hr,Vr,Ur,bu,Wr};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{m,Zt,w,Me,o,R}from"./chunk-ag1v2tkm.js";import{Wr}from"./chunk-gasb5fhy.js";import{s,be}from"./chunk-y3cqh2jv.js";import{a}from"./chunk-7tt84v1y.js";import g from"path";import S from"fs";function pe(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function fe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function P(e,t){let r=[];for(let l of fe(e)){if(pe(l)){let c=l.position||void 0;r.push({file:t||c?.file,line:c?.line,column:c?.column,message:l.message??"",lineText:c?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function De(e,t){return P(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",c=r.lineText?`
2
+ import{m,Zt,w,Me,o,R}from"./chunk-0adxpd3e.js";import{Wr}from"./chunk-hra6t4ch.js";import{s,be}from"./chunk-m08fk6ds.js";import{a}from"./chunk-7tt84v1y.js";import g from"path";import S from"fs";function pe(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function fe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function P(e,t){let r=[];for(let l of fe(e)){if(pe(l)){let c=l.position||void 0;r.push({file:t||c?.file,line:c?.line,column:c?.column,message:l.message??"",lineText:c?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function De(e,t){return P(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",c=r.lineText?`
3
3
  ${r.lineText.trim()}`:"";return l?`${l}: ${r.message}${c}`:`${r.message}${c}`}).join(`
4
- `)}var me=10;function V(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(g.basename(e))||Wr(e,t,r)}var re=1,se=new Map,W=600,ge=100,G=new Map;async function he(e){let t=G.get(e)??0;if(t>0&&t<ge){G.set(e,t+1);return}G.set(e,1);try{let r=(await S.promises.readdir(e)).filter((d)=>d.endsWith(".js"));if(r.length<=W)return;let c=(await Promise.all(r.map(async(d)=>{try{return{name:d,at:(await S.promises.stat(g.join(e,d))).mtimeMs}}catch{return null}}))).filter((d)=>d!==null);c.sort((d,u)=>u.at-d.at);for(let d of c.slice(W)){let u=d.name.slice(0,-3);await S.promises.rm(g.join(e,`${u}.js`),{force:!0}),await S.promises.rm(g.join(e,`${u}.deps.json`),{force:!0})}N("pruned bundle cache to",W,"entries")}catch{}}function ie(e){return se.get(e)??[]}function q(e,t){if(e)se.set(e,t)}function Na(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Na())console.log("[stx:bundler]",...e)}var Y=[];function Mo(e,t,r){Y.push({filePath:e||"<inline>",message:t,details:r})}function gt(){return Y.slice()}function mt(){Y.length=0}var H;function yd(e){H=e}function No(){if(H)return H;try{let e=R.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Z=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function ht(e){let t=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=t.exec(e))!==null){let c=r[1];if(!Z.some((u)=>u.test(c)))return N("detected user import:",c),!0}let l=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((r=l.exec(e))!==null){let c=r[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!Z.some((u)=>u.test(c)))return N("detected side-effect import:",c),!0}return!1}var Yt="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function La(e,t){return g.relative(e,t).split(g.sep).join("/")}function ja(e,t){if(t.size===0)return e;return e.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,(r,l,c,d)=>{let u=t.get(d);return u&&!d.startsWith(Yt)?`${l}${c}${u}${c}`:r})}function Ba(e,t){let r=0,l=(d)=>{let u=`__stxMod${r++}`,B=JSON.stringify(d);return t.push(`var ${u} = globalThis.__stxModules && globalThis.__stxModules[${B}];`,`if (${u} === undefined) throw new Error("[stx] module " + ${JSON.stringify(B)} + " is not registered on this page (#1957)");`),u},c=(d,u)=>{for(let B of d.split(",")){let _=B.trim();if(!_)continue;let f=_.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;let n=f[1].startsWith('"')?JSON.parse(f[1]):f[1],i=f[2]??n;t.push(`var ${i} = ${u}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,u,B)=>{let _=B.slice(Yt.length),f=l(_),n=u.trim(),i=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(i&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${i[1]} = ${f}.default;`),n=n.slice(i[0].length).trim();let p=n.match(/^\*\s*as\s+([\w$]+)$/);if(p)t.push(`var ${p[1]} = ${f};`);else if(n.startsWith("{"))c(n.replace(/^\{|\}$/g,""),f);return""}),e=e.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,u)=>(l(u.slice(Yt.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,g.join(e,"index.ts"),g.join(e,"index.tsx"),g.join(e,"index.js"),g.join(e,"index.mjs")];for(let r of t)try{if(S.existsSync(r)&&S.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function $e(e,t,r,l,c,d=new Map,u){let B=(f,n,i)=>{if(V(n,e,u))return null;if(!c||f!==r||!xe.test(n))return null;try{if(!S.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let p=`${Yt}${La(process.cwd(),n)}`;return d.set(i,p),{path:p,external:!0}},_=(f,n)=>{let i=f===r?t:g.dirname(f),p=g.resolve(i,n);return te(p)??p};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(n)=>({path:n.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(n)=>({path:n.path,external:!0})),f.onResolve({filter:/^\//},(n)=>{let i=te(n.path);if(i){let p=B(n.importer,i,n.path);if(p)return p;if(i!==r)l.add(i);return{path:i}}return{path:n.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(n)=>{let i=_(n.importer,n.path),p=B(n.importer,i,n.path);if(p)return p;return l.add(i),{path:i}}),f.onResolve({filter:/^[@~]\//},(n)=>{let i=g.resolve(e,n.path.slice(2)),p=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,g.join(i,"index.ts"),g.join(i,"index.tsx"),g.join(i,"index.js"),g.join(i,"index.mjs")];for(let E of p)if(S.existsSync(E)&&S.statSync(E,{throwIfNoEntry:!1})?.isFile()){let T=B(n.importer,E,n.path);if(T)return T;return N(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",E),l.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:i}}),c)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let i=`${Yt}npm:${n.path}`;return d.set(n.path,i),{path:i,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(V(n.path,e,u))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let i=g.extname(n.path).toLowerCase(),p=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:S.readFileSync(n.path,"utf8"),loader:p}})}}}var X=new Map,U=m(64),ne=Symbol.for("stx.client-bundle-build-queue");function Fa(e){let t=globalThis,l=(t[ne]??Promise.resolve()).then(e,e);return t[ne]=l.then(()=>{return},()=>{return}),l}async function yt(e,t,r={}){let l=r.projectRoot||process.cwd(),c=(await o(l)).serverApi,d=r.minify??!1,u=r.externalizeUserModules??!0,B=r.expose?.length?[...new Set(r.expose)].sort():void 0,_=r.cacheDir||a(l,"bundle-cache"),f=new Bun.CryptoHasher("md5");f.update(`${me}\x00${Me()}\x00${JSON.stringify(c??!1)}\x00${u?"registry":"inline"}\x00${B?B.join(","):"*"}\x00${e}\x00${t}`);let n=f.digest("hex").slice(0,12),i=g.join(_,`${n}.js`),p=U.get(i);if(p){if(Zt(p.files)&&p.files.every((A)=>!V(A.path,l,c))){N("memo hit:",n);let A=p.files.map((v)=>v.path);return q(t,A),r.collectInputs?.push(...A),p.code}U.delete(i),N("memo invalidated by dep change:",n)}let E=g.join(_,`${n}.deps.json`),T=Bun.file(i);if(await T.exists()){let A=Bun.file(E),v=!1,D=null;if(await A.exists())try{let k=JSON.parse(await A.text());if(k.metadataVersion!==re||!Array.isArray(k.files))v=!1;else D=k.files,v=!0;if(D&&(!Zt(D)||D.some((I)=>V(I.path,l,c))))v=!1}catch{v=!1}if(v){if(N("cache hit:",n),D)q(t,D.map((I)=>I.path)),r.collectInputs?.push(...D.map((I)=>I.path));let k=await T.text();if(D)U.set(i,{code:k,files:D});return k}N("cache invalidated by dep change:",n)}let M=X.get(n);if(M){let A=await M;if(r.collectInputs)r.collectInputs.push(...(U.get(i)?.files??[]).map((v)=>v.path));return A}let z=Fa(()=>ye(e,t,{projectRoot:l,minify:d,cacheDir:_,hash:n,cachePath:i,depsPath:E,collectInputs:r.collectInputs,externalizeUserModules:u,serverApi:c,expose:B}));X.set(n,z);try{return await z}finally{X.delete(n)}}var we=0;function za(e){return`${e}-${process.pid}-${++we}`}async function ye(e,t,r){let{projectRoot:l,minify:c,cacheDir:d,hash:u,cachePath:B,depsPath:_,externalizeUserModules:f}=r,n=a(l,"bundle-tmp"),i=za(u),p=g.join(n,`${i}.ts`),E=g.join(n,"out",i);S.mkdirSync(n,{recursive:!0}),S.mkdirSync(E,{recursive:!0});let T=g.dirname(t),M=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,A=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,v=s(e),{depths:D,balanced:k}=be(v),I=(j)=>!k||D[j]===0,b;while((b=z.exec(v))!==null){if(b[1])continue;if(!I(b.index))continue;if(b[2])b[2].split(",").forEach((j)=>{let h=Be(j);if(h)M.add(h)});else if(b[3])M.add(b[3])}while((b=A.exec(v))!==null){if(b[1])continue;if(!I(b.index))continue;M.add(b[2])}let oe=/^[ \t]*import\s+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((b=oe.exec(v))!==null){if(!I(b.index))continue;let j=/^\s*['"]([^'"]+)['"]/.exec(e.slice(b.index+b[0].length))?.[1];if(j&&Z.some((h)=>h.test(j)))continue;if(b[1])M.add(b[1]);if(b[2])M.add(b[2]);for(let h of(b[3]??"").split(",")){let y=h.trim();if(!y||/^type\s/.test(y))continue;let L=/\bas\s+(\w+)\s*$/.exec(y)?.[1]??/^\w+$/.exec(y)?.[0];if(L)M.add(L)}}for(let j of v.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let h of j[1].split(",")){let y=/\bas\s+(\w+)\s*$/.exec(h)?.[1]??/^\s*(\w+)\s*$/.exec(h)?.[1];if(y)M.delete(y)}let le=M.size>0?`
4
+ `)}var me=10;function V(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(g.basename(e))||Wr(e,t,r)}var re=1,se=new Map,W=600,ge=100,G=new Map;async function he(e){let t=G.get(e)??0;if(t>0&&t<ge){G.set(e,t+1);return}G.set(e,1);try{let r=(await S.promises.readdir(e)).filter((d)=>d.endsWith(".js"));if(r.length<=W)return;let c=(await Promise.all(r.map(async(d)=>{try{return{name:d,at:(await S.promises.stat(g.join(e,d))).mtimeMs}}catch{return null}}))).filter((d)=>d!==null);c.sort((d,u)=>u.at-d.at);for(let d of c.slice(W)){let u=d.name.slice(0,-3);await S.promises.rm(g.join(e,`${u}.js`),{force:!0}),await S.promises.rm(g.join(e,`${u}.deps.json`),{force:!0})}N("pruned bundle cache to",W,"entries")}catch{}}function ie(e){return se.get(e)??[]}function q(e,t){if(e)se.set(e,t)}function Na(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function N(...e){if(Na())console.log("[stx:bundler]",...e)}var Y=[];function Mo(e,t,r){Y.push({filePath:e||"<inline>",message:t,details:r})}function gt(){return Y.slice()}function mt(){Y.length=0}var H;function yu(e){H=e}function No(){if(H)return H;try{let e=R.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Z=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function ht(e){let t=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=t.exec(e))!==null){let c=r[1];if(!Z.some((u)=>u.test(c)))return N("detected user import:",c),!0}let l=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((r=l.exec(e))!==null){let c=r[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!Z.some((u)=>u.test(c)))return N("detected side-effect import:",c),!0}return!1}var Yt="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function La(e,t){return g.relative(e,t).split(g.sep).join("/")}function ja(e,t){if(t.size===0)return e;return e.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,(r,l,c,d)=>{let u=t.get(d);return u&&!d.startsWith(Yt)?`${l}${c}${u}${c}`:r})}function Ba(e,t){let r=0,l=(d)=>{let u=`__stxMod${r++}`,B=JSON.stringify(d);return t.push(`var ${u} = globalThis.__stxModules && globalThis.__stxModules[${B}];`,`if (${u} === undefined) throw new Error("[stx] module " + ${JSON.stringify(B)} + " is not registered on this page (#1957)");`),u},c=(d,u)=>{for(let B of d.split(",")){let _=B.trim();if(!_)continue;let f=_.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;let n=f[1].startsWith('"')?JSON.parse(f[1]):f[1],i=f[2]??n;t.push(`var ${i} = ${u}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,u,B)=>{let _=B.slice(Yt.length),f=l(_),n=u.trim(),i=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(i&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${i[1]} = ${f}.default;`),n=n.slice(i[0].length).trim();let p=n.match(/^\*\s*as\s+([\w$]+)$/);if(p)t.push(`var ${p[1]} = ${f};`);else if(n.startsWith("{"))c(n.replace(/^\{|\}$/g,""),f);return""}),e=e.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,u)=>(l(u.slice(Yt.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,g.join(e,"index.ts"),g.join(e,"index.tsx"),g.join(e,"index.js"),g.join(e,"index.mjs")];for(let r of t)try{if(S.existsSync(r)&&S.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function $e(e,t,r,l,c,d=new Map,u){let B=(f,n,i)=>{if(V(n,e,u))return null;if(!c||f!==r||!xe.test(n))return null;try{if(!S.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let p=`${Yt}${La(process.cwd(),n)}`;return d.set(i,p),{path:p,external:!0}},_=(f,n)=>{let i=f===r?t:g.dirname(f),p=g.resolve(i,n);return te(p)??p};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(n)=>({path:n.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(n)=>({path:n.path,external:!0})),f.onResolve({filter:/^\//},(n)=>{let i=te(n.path);if(i){let p=B(n.importer,i,n.path);if(p)return p;if(i!==r)l.add(i);return{path:i}}return{path:n.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(n)=>{let i=_(n.importer,n.path),p=B(n.importer,i,n.path);if(p)return p;return l.add(i),{path:i}}),f.onResolve({filter:/^[@~]\//},(n)=>{let i=g.resolve(e,n.path.slice(2)),p=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,g.join(i,"index.ts"),g.join(i,"index.tsx"),g.join(i,"index.js"),g.join(i,"index.mjs")];for(let E of p)if(S.existsSync(E)&&S.statSync(E,{throwIfNoEntry:!1})?.isFile()){let T=B(n.importer,E,n.path);if(T)return T;return N(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",E),l.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:i}}),c)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let i=`${Yt}npm:${n.path}`;return d.set(n.path,i),{path:i,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(V(n.path,e,u))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let i=g.extname(n.path).toLowerCase(),p=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:S.readFileSync(n.path,"utf8"),loader:p}})}}}var X=new Map,U=m(64),ne=Symbol.for("stx.client-bundle-build-queue");function Fa(e){let t=globalThis,l=(t[ne]??Promise.resolve()).then(e,e);return t[ne]=l.then(()=>{return},()=>{return}),l}async function yt(e,t,r={}){let l=r.projectRoot||process.cwd(),c=(await o(l)).serverApi,d=r.minify??!1,u=r.externalizeUserModules??!0,B=r.expose?.length?[...new Set(r.expose)].sort():void 0,_=r.cacheDir||a(l,"bundle-cache"),f=new Bun.CryptoHasher("md5");f.update(`${me}\x00${Me()}\x00${JSON.stringify(c??!1)}\x00${u?"registry":"inline"}\x00${B?B.join(","):"*"}\x00${e}\x00${t}`);let n=f.digest("hex").slice(0,12),i=g.join(_,`${n}.js`),p=U.get(i);if(p){if(Zt(p.files)&&p.files.every((A)=>!V(A.path,l,c))){N("memo hit:",n);let A=p.files.map((v)=>v.path);return q(t,A),r.collectInputs?.push(...A),p.code}U.delete(i),N("memo invalidated by dep change:",n)}let E=g.join(_,`${n}.deps.json`),T=Bun.file(i);if(await T.exists()){let A=Bun.file(E),v=!1,D=null;if(await A.exists())try{let k=JSON.parse(await A.text());if(k.metadataVersion!==re||!Array.isArray(k.files))v=!1;else D=k.files,v=!0;if(D&&(!Zt(D)||D.some((I)=>V(I.path,l,c))))v=!1}catch{v=!1}if(v){if(N("cache hit:",n),D)q(t,D.map((I)=>I.path)),r.collectInputs?.push(...D.map((I)=>I.path));let k=await T.text();if(D)U.set(i,{code:k,files:D});return k}N("cache invalidated by dep change:",n)}let M=X.get(n);if(M){let A=await M;if(r.collectInputs)r.collectInputs.push(...(U.get(i)?.files??[]).map((v)=>v.path));return A}let z=Fa(()=>ye(e,t,{projectRoot:l,minify:d,cacheDir:_,hash:n,cachePath:i,depsPath:E,collectInputs:r.collectInputs,externalizeUserModules:u,serverApi:c,expose:B}));X.set(n,z);try{return await z}finally{X.delete(n)}}var we=0;function za(e){return`${e}-${process.pid}-${++we}`}async function ye(e,t,r){let{projectRoot:l,minify:c,cacheDir:d,hash:u,cachePath:B,depsPath:_,externalizeUserModules:f}=r,n=a(l,"bundle-tmp"),i=za(u),p=g.join(n,`${i}.ts`),E=g.join(n,"out",i);S.mkdirSync(n,{recursive:!0}),S.mkdirSync(E,{recursive:!0});let T=g.dirname(t),M=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,A=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,v=s(e),{depths:D,balanced:k}=be(v),I=(j)=>!k||D[j]===0,b;while((b=z.exec(v))!==null){if(b[1])continue;if(!I(b.index))continue;if(b[2])b[2].split(",").forEach((j)=>{let h=Be(j);if(h)M.add(h)});else if(b[3])M.add(b[3])}while((b=A.exec(v))!==null){if(b[1])continue;if(!I(b.index))continue;M.add(b[2])}let oe=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((b=oe.exec(v))!==null){if(!I(b.index))continue;let j=/^\s*['"]([^'"]+)['"]/.exec(e.slice(b.index+b[0].length))?.[1];if(j&&Z.some((h)=>h.test(j)))continue;if(b[1])M.add(b[1]);if(b[2])M.add(b[2]);for(let h of(b[3]??"").split(",")){let y=h.trim();if(!y||/^type\s/.test(y))continue;let L=/\bas\s+(\w+)\s*$/.exec(y)?.[1]??/^\w+$/.exec(y)?.[0];if(L)M.add(L)}}for(let j of v.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let h of j[1].split(",")){let y=/\bas\s+(\w+)\s*$/.exec(h)?.[1]??/^\s*(\w+)\s*$/.exec(h)?.[1];if(y)M.delete(y)}let le=M.size>0?`
5
5
  export { ${[...M].join(", ")} }`:"";await Bun.write(p,e+le),N("bundling:",u,"from:",g.basename(t));let Q=new Set,K=new Map;try{let j=await Bun.build({entrypoints:[p],outdir:E,target:"browser",format:"esm",minify:c,plugins:[$e(l,T,p,Q,f,K,r.serverApi)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...w()},root:l});if(!j.success){let F=j.logs.filter((C)=>C.level==="error").map((C)=>C.message).join(", ")||`Unable to bundle ${g.basename(t)}`,O=P(j.logs,t||void 0);if(console.warn("[stx:bundler] build failed:",F),Mo(t||"",F,O),No()==="error")throw Error(F);return e}let h="";for(let x of j.outputs){h=await x.text();break}let y=[];for(let x of h.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let F of x[1].split(",")){let O=F.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(O){y.push([O[2],O[1]]);continue}let C=F.trim();if(/^[A-Za-z_$][\w$]*$/.test(C))y.push([C,C])}if(r.expose){let x=new Set(r.expose);for(let F=y.length-1;F>=0;F--)if(!x.has(y[F][0]))y.splice(F,1)}let L=[];h=Ba(ja(h,K),L);let ae=h.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];h=h.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let ee=`__stxBundle_${u}`,ce=y.map(([x,F])=>`${JSON.stringify(x)}: ${F}`).join(", "),ue=y.map(([x])=>`var ${x} = undefined;`).join(`
6
6
  `),de=y.map(([x])=>`${x} = ${ee}[${JSON.stringify(x)}];`).join(`
7
7
  `);if(h=`${ae.join(`
@@ -14,4 +14,4 @@ ${h}
14
14
  return { ${ce} };
15
15
  })();
16
16
  ${de}`.trim(),N("bundled:",u,"output:",h.length,"bytes"),M.size>0&&y.length===0)return console.warn(`[stx:bundler] dropped every binding for ${g.basename(t)} (${u}); serving the unbundled source and not caching this result`),e;S.mkdirSync(d,{recursive:!0}),await Bun.write(B,h);let J=Array.from(Q).map((x)=>{try{return{path:x,mtimeMs:S.statSync(x).mtimeMs}}catch{return null}}).filter((x)=>x!==null);return await Bun.write(_,JSON.stringify({metadataVersion:re,files:J})),q(t,J.map((x)=>x.path)),r.collectInputs?.push(...J.map((x)=>x.path)),U.set(B,{code:h,files:J}),await he(d),h}catch(j){let h=P(j,t||void 0),y=De(j,t||void 0);if(console.warn(`[stx:bundler] error: ${y}`),Mo(t||"",y,h),No()==="error")throw j;return e}finally{try{S.rmSync(p,{force:!0}),S.rmSync(E,{recursive:!0,force:!0})}catch{}}}function Be(e){let t=e.trim();if(!t)return null;let r=t.indexOf("=");if(r!==-1)t=t.slice(0,r).trim();let l=t.indexOf(":");if(l!==-1)t=t.slice(l+1).trim();if(t.startsWith("..."))t=t.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(t)?t:null}
17
- export{De,ie,Na,Mo,gt,mt,yd,No,ht,Yt,La,ja,Ba,Fa,yt,za};
17
+ export{De,ie,Na,Mo,gt,mt,yu,No,ht,Yt,La,ja,Ba,Fa,yt,za};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ui,eo,Wc,Wi,qi,qc,Kc}from"./chunk-pyqh70k2.js";import"./chunk-8bpyr4az.js";import"./chunk-jkf5k215.js";import"./chunk-hra6t4ch.js";import{ze,rc}from"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Ui as buildVirtualSource,ze as extractScriptBlocks,rc as extractTemplateExpressions,Wi as findRuntimeTypeDeclarations,qi as findStxModuleDeclarations,Kc as formatTypecheckDiagnostics,Wc as sourcePathFor,qc as typecheckStxFiles,eo as virtualPathFor};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- function uo(e){return e}class a{plugins=new Map;sortedPlugins=[];initialized=!1;async register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);if(e.dependencies){for(let r of e.dependencies)if(!this.plugins.has(r))throw Error(`Plugin "${e.name}" depends on "${r}" which is not registered`)}if(this.plugins.set(e.name,e),e.onRegister)await e.onRegister(t);this.sortPlugins()}async unregister(e){let t=this.plugins.get(e);if(!t)return!1;for(let[r,i]of this.plugins)if(i.dependencies?.includes(e))throw Error(`Cannot unregister "${e}" because "${r}" depends on it`);if(t.onUnregister)await t.onUnregister();return this.plugins.delete(e),this.sortPlugins(),!0}get(e){return this.plugins.get(e)}has(e){return this.plugins.has(e)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let e=[];for(let t of this.sortedPlugins)if(t.registerDirectives)e.push(...t.registerDirectives());return e}getAllFilters(){let e={};for(let t of this.sortedPlugins)if(t.registerFilters)Object.assign(e,t.registerFilters());return e}async runBeforeProcess(e){return this.runHooks("beforeProcess",e)}async runAfterParse(e){return this.runHooks("afterParse",e)}async runBeforeDirective(e,t){return this.runDirectiveHooks("beforeDirective",e,t)}async runAfterDirective(e,t){return this.runDirectiveHooks("afterDirective",e,t)}async runBeforeRender(e){return this.runHooks("beforeRender",e)}async runAfterRender(e){return this.runHooks("afterRender",e)}async runOnError(e){for(let t of this.sortedPlugins)if(t.onError)try{let r=await t.onError(e);if(r){if(r.template!==void 0)e.template=r.template;if(r.context)e.context={...e.context,...r.context};if(r.metadata)e.metadata={...e.metadata,...r.metadata};if(r.skip)return e}}catch(r){console.error(`Error in plugin "${t.name}" onError hook:`,r)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort((e,t)=>(e.priority??100)-(t.priority??100))}async runHooks(e,t){let r={...t};for(let i of this.sortedPlugins){let s=i[e];if(s)try{let n=await s(r);if(n){if(n.template!==void 0)r.template=n.template;if(n.context)r.context={...r.context,...n.context};if(n.metadata)r.metadata={...r.metadata,...n.metadata};if(n.skip)break}}catch(n){console.error(`Error in plugin "${i.name}" ${e} hook:`,n)}}return r}async runDirectiveHooks(e,t,r){let i={...r};for(let s of this.sortedPlugins){let n=s[e];if(n)try{let o=await n(t,i);if(o){if(o.template!==void 0)i.template=o.template;if(o.context)i.context={...i.context,...o.context};if(o.metadata)i.metadata={...i.metadata,...o.metadata};if(o.skip)break}}catch(o){console.error(`Error in plugin "${s.name}" ${e} hook:`,o)}}return i}}var dl=new a;var u=uo({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess(e){console.log("[stx-debug] beforeProcess:",e.filePath)},afterParse(e){console.log("[stx-debug] afterParse:",e.template.length,"chars")},beforeDirective(e,t){console.log("[stx-debug] beforeDirective:",e)},afterDirective(e,t){console.log("[stx-debug] afterDirective:",e)},beforeRender(e){console.log("[stx-debug] beforeRender")},afterRender(e){console.log("[stx-debug] afterRender:",e.template.length,"chars")},onError(e){console.error("[stx-debug] onError:",e.error.message,"in phase:",e.phase)}}),l=uo({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess(e){e.metadata.startTime=performance.now()},afterRender(e){let t=e.metadata.startTime;if(t){let r=performance.now()-t;console.log(`[stx-timing] Processing took ${r.toFixed(2)}ms`)}}});export{uo,dl};
2
+ function uo(e){return e}class a{plugins=new Map;sortedPlugins=[];initialized=!1;async register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);if(e.dependencies){for(let r of e.dependencies)if(!this.plugins.has(r))throw Error(`Plugin "${e.name}" depends on "${r}" which is not registered`)}if(this.plugins.set(e.name,e),e.onRegister)await e.onRegister(t);this.sortPlugins()}async unregister(e){let t=this.plugins.get(e);if(!t)return!1;for(let[r,i]of this.plugins)if(i.dependencies?.includes(e))throw Error(`Cannot unregister "${e}" because "${r}" depends on it`);if(t.onUnregister)await t.onUnregister();return this.plugins.delete(e),this.sortPlugins(),!0}get(e){return this.plugins.get(e)}has(e){return this.plugins.has(e)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let e=[];for(let t of this.sortedPlugins)if(t.registerDirectives)e.push(...t.registerDirectives());return e}getAllFilters(){let e={};for(let t of this.sortedPlugins)if(t.registerFilters)Object.assign(e,t.registerFilters());return e}async runBeforeProcess(e){return this.runHooks("beforeProcess",e)}async runAfterParse(e){return this.runHooks("afterParse",e)}async runBeforeDirective(e,t){return this.runDirectiveHooks("beforeDirective",e,t)}async runAfterDirective(e,t){return this.runDirectiveHooks("afterDirective",e,t)}async runBeforeRender(e){return this.runHooks("beforeRender",e)}async runAfterRender(e){return this.runHooks("afterRender",e)}async runOnError(e){for(let t of this.sortedPlugins)if(t.onError)try{let r=await t.onError(e);if(r){if(r.template!==void 0)e.template=r.template;if(r.context)e.context={...e.context,...r.context};if(r.metadata)e.metadata={...e.metadata,...r.metadata};if(r.skip)return e}}catch(r){console.error(`Error in plugin "${t.name}" onError hook:`,r)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort((e,t)=>(e.priority??100)-(t.priority??100))}async runHooks(e,t){let r={...t};for(let i of this.sortedPlugins){let s=i[e];if(s)try{let n=await s(r);if(n){if(n.template!==void 0)r.template=n.template;if(n.context)r.context={...r.context,...n.context};if(n.metadata)r.metadata={...r.metadata,...n.metadata};if(n.skip)break}}catch(n){console.error(`Error in plugin "${i.name}" ${e} hook:`,n)}}return r}async runDirectiveHooks(e,t,r){let i={...r};for(let s of this.sortedPlugins){let n=s[e];if(n)try{let o=await n(t,i);if(o){if(o.template!==void 0)i.template=o.template;if(o.context)i.context={...i.context,...o.context};if(o.metadata)i.metadata={...i.metadata,...o.metadata};if(o.skip)break}}catch(o){console.error(`Error in plugin "${s.name}" ${e} hook:`,o)}}return i}}var ul=new a;var u=uo({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess(e){console.log("[stx-debug] beforeProcess:",e.filePath)},afterParse(e){console.log("[stx-debug] afterParse:",e.template.length,"chars")},beforeDirective(e,t){console.log("[stx-debug] beforeDirective:",e)},afterDirective(e,t){console.log("[stx-debug] afterDirective:",e)},beforeRender(e){console.log("[stx-debug] beforeRender")},afterRender(e){console.log("[stx-debug] afterRender:",e.template.length,"chars")},onError(e){console.error("[stx-debug] onError:",e.error.message,"in phase:",e.phase)}}),l=uo({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess(e){e.metadata.startTime=performance.now()},afterRender(e){let t=e.metadata.startTime;if(t){let r=performance.now()-t;console.log(`[stx-timing] Processing took ${r.toFixed(2)}ms`)}}});export{uo,ul};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{o}from"./chunk-ag1v2tkm.js";import{kr}from"./chunk-r80km6mn.js";import p from"path";async function cl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(kr(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-0880qx3m.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-0adxpd3e.js";import{kr}from"./chunk-r80km6mn.js";import p from"path";async function cl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(kr(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-6qsvh58v.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{cl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{cl}from"./chunk-kax708d4.js";import"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{cl as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ie,Na,Mo,gt,mt,yd,No,ht,Yt,La,ja,Ba,Fa,yt,za}from"./chunk-z14y48en.js";import"./chunk-gasb5fhy.js";import"./chunk-ag1v2tkm.js";import"./chunk-gjrbnzap.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-jbdqs7t6.js";import"./chunk-zydg3wgt.js";import"./chunk-gj90pnre.js";import"./chunk-p7j2g8y2.js";import"./chunk-pfm6cfph.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Yt as MODULE_SPECIFIER_PREFIX,yt as bundleClientScript,mt as clearBundleFailures,ie as clientBundleDependencies,gt as getBundleFailures,ht as hasUserImports,ja as normalizeRegistrySpecifiers,Fa as queueClientBundleBuild,Mo as recordBundleFailure,La as registryIdForPath,No as resolveBundlerFallback,Ba as rewriteRegistryImports,yd as setBundlerFallbackMode,Na as shouldLogBundlerDiagnostics,za as tempBuildName};
2
+ import{ie,Na,Mo,gt,mt,yu,No,ht,Yt,La,ja,Ba,Fa,yt,za}from"./chunk-jkf5k215.js";import"./chunk-hra6t4ch.js";import"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Yt as MODULE_SPECIFIER_PREFIX,yt as bundleClientScript,mt as clearBundleFailures,ie as clientBundleDependencies,gt as getBundleFailures,ht as hasUserImports,ja as normalizeRegistrySpecifiers,Fa as queueClientBundleBuild,Mo as recordBundleFailure,La as registryIdForPath,No as resolveBundlerFallback,Ba as rewriteRegistryImports,yu as setBundlerFallbackMode,Na as shouldLogBundlerDiagnostics,za as tempBuildName};
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ function o(t,i){let n=t[i],e=i+1;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return t.length}function b(t,i){let n=i+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=mi(t,n+2),n<t.length)n++;continue}n++}return t.length}function mi(t,i){let n=1,e=i,r="{",f="";while(e<t.length){let l=t[e];if(l==="\\"){e+=2;continue}if(l==='"'||l==="'"){e=o(t,e),r=h,f="";continue}if(l==="`"){e=b(t,e),r=h,f="";continue}if(l==="/"&&t[e+1]==="/"){while(e<t.length&&t[e]!==`
3
+ `)e++;continue}if(l==="/"&&t[e+1]==="*"){e+=2;while(e<t.length&&t.slice(e,e+2)!=="*/")e++;e+=2;continue}if(l==="/"&&a(r,f)){let u=w(t,e);if(u!==-1){e=u,r=h,f="";continue}}if(l==="{")n++;else if(l==="}"){if(n--,n===0)return e}if(/[\w$]/.test(l))f=/[\w$]/.test(r)?f+l:l,r=l;else if(!/\s/.test(l))r=l,f="";e++}return t.length}var m=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function a(t,i){if(i)return m.has(i);return!(t===")"||t==="]"||t===h)}var h="\x00";function w(t,i){let n=i+1,e=!1;while(n<t.length){let r=t[n];if(r===`
4
+ `)return-1;if(r==="\\"){n+=2;continue}if(r==="[")e=!0;else if(r==="]")e=!1;else if(r==="/"&&!e){n++;while(n<t.length&&/[a-z]/i.test(t[n]))n++;return n}n++}return-1}function s(t){let i="",n=0,e="",r="";while(n<t.length){let f=t.slice(n,n+2);if(f==="//"){while(n<t.length&&t[n]!==`
5
+ `)i+=" ",n++;continue}if(f==="/*"){while(n<t.length&&t.slice(n,n+2)!=="*/")i+=t[n]===`
6
+ `?`
7
+ `:" ",n++;i+=" ",n+=2;continue}let l=t[n];if(l==='"'||l==="'"){let u=l;i+=" ",n++;while(n<t.length&&t[n]!==u){if(t[n]==="\\"){i+=" ",n+=2;continue}i+=t[n]===`
8
+ `?`
9
+ `:" ",n++}i+=" ",n++,e=h,r="";continue}if(l==="/"&&a(e,r)){let u=w(t,n);if(u!==-1){i+=`/${" ".repeat(u-n-2)}/`,n=u,e=h,r="";continue}}if(l==="`"){i+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){i+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let u=n+2,g=mi(t,u);if(i+=" ",i+=s(t.slice(u,g)),g<t.length)i+=" ";n=g+1;continue}i+=t[n]===`
10
+ `?`
11
+ `:" ",n++}i+=" ",n++,e=h,r="";continue}if(i+=l,n++,/[\w$]/.test(l))r=/[\w$]/.test(e)?r+l:l,e=l;else if(!/\s/.test(l))e=l,r=""}return i}function be(t){let i=new Uint16Array(t.length),n=0,e=!0;for(let r=0;r<t.length;r++){let f=t[r];if(f===")"||f==="]"||f==="}")if(n===0)e=!1;else n--;if(i[r]=n,f==="("||f==="["||f==="{")n++}return{depths:i,balanced:e&&n===0}}
12
+ export{mi,s,be};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Or,bl,wl}from"./chunk-8bpyr4az.js";import"./chunk-jkf5k215.js";import"./chunk-hra6t4ch.js";import"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{wl as clearComposableCache,bl as getComposableScript,Or as listComposableModules};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oi,Mi}from"./chunk-ars3cbs5.js";import"./chunk-ery19t9s.js";import"./chunk-2cqymwe8.js";import"./chunk-pyqh70k2.js";import"./chunk-90drf2ag.js";import"./chunk-sz1s3k89.js";import"./chunk-t2hkwjvd.js";import"./chunk-a8q8m5pp.js";import"./chunk-rgwvqmhh.js";import"./chunk-kax708d4.js";import"./chunk-na5evt2b.js";import{no}from"./chunk-f9c58ag8.js";import"./chunk-k9sbgax8.js";import"./chunk-z80d9dd2.js";import"./chunk-y63bv55f.js";import"./chunk-1k01h1zb.js";import"./chunk-7h57dt0z.js";import"./chunk-544e2jvd.js";import"./chunk-zasd9166.js";import"./chunk-bddjx2a2.js";import"./chunk-2bdthb37.js";import"./chunk-8bpyr4az.js";import"./chunk-9fr19qe4.js";import"./chunk-9pt8fd2n.js";import"./chunk-t1py7rbg.js";import"./chunk-fh1qrp68.js";import"./chunk-pbh4smw3.js";import"./chunk-amd6ey3t.js";import"./chunk-bnemhyg2.js";import"./chunk-01zwbzyw.js";import"./chunk-v6qxmac5.js";import"./chunk-812sn7d5.js";import"./chunk-5j5msbks.js";import"./chunk-jkf5k215.js";import"./chunk-hra6t4ch.js";import{me,Qt,en,K,d,n,Kn,I,o,ce}from"./chunk-0adxpd3e.js";import"./chunk-d2zw2e5m.js";import"./chunk-2n5pjbw9.js";import"./chunk-0trfbqa7.js";import"./chunk-wfqnxb38.js";import"./chunk-zydg3wgt.js";import"./chunk-y36av1ac.js";import"./chunk-v83bpj84.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-88px183j.js";import"./chunk-jz7pvh7b.js";export{Kn as buildWebComponents,en as cacheTemplate,Qt as checkCache,no as classifyAllScripts,Oi as createMiddleware,Mi as createRoute,I as defaultConfig,d as extractVariables,K as injectRouterScript,o as loadStxConfig,me as processClientScript,n as processDirectives,ce as readMarkdownFile};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{M,ae}from"./chunk-ag1v2tkm.js";import{le,C,Ke}from"./chunk-zydg3wgt.js";import{Ze,G,xe}from"./chunk-88px183j.js";import{Te,ne,_,re,co,Sr,lo,It}from"./chunk-hqfgbtsy.js";import{Ur}from"./chunk-gasb5fhy.js";import{Dt}from"./chunk-r80km6mn.js";import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ie=1024;function ce(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(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 ue(t){if(!t)return null;let e=pe(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 J=33554432,H=new Map,U=0;function me(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function Pt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ce(e.headers.get("content-type")))return e;let r=ue(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:Q(e.headers)});if(a.length<(o.threshold??ie))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),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),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 q{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",_(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}|${ne(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 B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,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 E=await v;return E?l(E):a()}}var de={".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 ll(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=co(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=Dt(r.routeRules),f=new q,h=Ur(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ke(i.html,m);b.set(n.pattern,i),v.set(n.pattern,xe(i.html)),E.set(n.pattern,ae(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Ke(A,m):A)}}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}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Pt(n,await le(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 X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};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,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Ze(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),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&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",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Te}}})}}let d=Sr(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",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await It(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return lo(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-kvfcm30m.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=xe(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ae(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=xe(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ae(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(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),Y)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:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{M,ae}from"./chunk-0adxpd3e.js";import{le,C,Ke}from"./chunk-zydg3wgt.js";import{Ze,G,xe}from"./chunk-88px183j.js";import{Te,ne,_,re,co,Sr,lo,It}from"./chunk-f9c58ag8.js";import{Ur}from"./chunk-hra6t4ch.js";import{Dt}from"./chunk-r80km6mn.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ie=1024;function ce(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(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 ue(t){if(!t)return null;let e=pe(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 J=33554432,H=new Map,U=0;function me(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function Pt(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ce(e.headers.get("content-type")))return e;let r=ue(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:Q(e.headers)});if(a.length<(o.threshold??ie))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),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),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}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class q{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",_(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}|${ne(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 B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,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 E=await v;return E?l(E):a()}}var de={".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 ll(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=co(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=Dt(r.routeRules),f=new q,h=Ur(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ke(i.html,m);b.set(n.pattern,i),v.set(n.pattern,xe(i.html)),E.set(n.pattern,ae(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Ke(A,m):A)}}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}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return Pt(n,await le(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 X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};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,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Ze(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),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&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",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Te}}})}}let d=Sr(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",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await It(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return lo(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-gmccacxc.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=xe(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ae(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=xe(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ae(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(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),Y)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:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{Pt,ll};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Zr,Qr,es,Mu,jn,Nu}from"./chunk-0adxpd3e.js";export{jn as clearImageDeliveryCatalog,Mu as deliveredImage,es as efficientDeliverySources,Zr as getImageDelivery,Qr as isTransparentImage,Nu as prepareImageDelivery};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-pfm6cfph.js";import"./chunk-2n5pjbw9.js";import"./chunk-gjrbnzap.js";import{a}from"./chunk-7tt84v1y.js";import f from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},o=t.snapshotDir||a(e.root,"story","snapshots");await f.promises.mkdir(o,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((i)=>t.filter.some((p)=>i.fileName.toLowerCase().includes(p.toLowerCase())));for(let i of r)await h(i,o,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let o=e.story;if(!o)return;for(let r of o.variants){n.total++;let i=l.join(t,`${e.id}-${r.id}.snap`),p=g(r.source||""),c=await w(i);if(s.update||!c){let u={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:p};if(await f.promises.writeFile(i,JSON.stringify(u,null,2)),!c)n.new++;n.passed++}else try{let u=await f.promises.readFile(i,"utf-8"),m=JSON.parse(u);if(m.hash===p)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,p)})}catch(u){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${u}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await f.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import"./chunk-d2zw2e5m.js";import{a}from"./chunk-7tt84v1y.js";import f from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},o=t.snapshotDir||a(e.root,"story","snapshots");await f.promises.mkdir(o,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((i)=>t.filter.some((p)=>i.fileName.toLowerCase().includes(p.toLowerCase())));for(let i of r)await h(i,o,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let o=e.story;if(!o)return;for(let r of o.variants){n.total++;let i=l.join(t,`${e.id}-${r.id}.snap`),p=g(r.source||""),c=await w(i);if(s.update||!c){let u={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:p};if(await f.promises.writeFile(i,JSON.stringify(u,null,2)),!c)n.new++;n.passed++}else try{let u=await f.promises.readFile(i,"utf-8"),m=JSON.parse(u);if(m.hash===p)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,p)})}catch(u){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${u}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await f.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-2jbyks2t.js";import{W,ze,ts,ns,qo,Ko,Xo,Go,Bn,rs,Jo,Yo,Zo,Ct,o}from"./chunk-ag1v2tkm.js";import{Or}from"./chunk-5zaj400e.js";import{a}from"./chunk-7tt84v1y.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Ct.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
2
+ import{y}from"./chunk-2jbyks2t.js";import{W,ze,ts,ns,qo,Ko,Xo,Go,Bn,rs,Jo,Yo,Zo,Ct,o}from"./chunk-0adxpd3e.js";import{Or}from"./chunk-8bpyr4az.js";import{a}from"./chunk-7tt84v1y.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Ct.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;s.push({line:w,column:f-(p.lastIndexOf(`
4
4
  `)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Ui(e,t="",s=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",i=rs(e)+ns(ts(e.code)),l=e.kind==="client"||e.kind==="plain"?Xo(t,e.code):"";return Bn(`${u+i}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{bt,Hr,Vr,Ur,bd,Wr}from"./chunk-gasb5fhy.js";import"./chunk-0trfbqa7.js";import"./chunk-zydg3wgt.js";import"./chunk-88px183j.js";export{Vr as buildServerApi,bd as createServerApi,bt as discoverServerApi,Hr as generateApiTypes,Wr as isServerApiSource,Ur as productionApiDispatcher};
2
+ import{bt,Hr,Vr,Ur,bu,Wr}from"./chunk-hra6t4ch.js";import"./chunk-0trfbqa7.js";import"./chunk-zydg3wgt.js";import"./chunk-88px183j.js";export{Vr as buildServerApi,bu as createServerApi,bt as discoverServerApi,Hr as generateApiTypes,Wr as isServerApiSource,Ur as productionApiDispatcher};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Br,$o,Eo,hu}from"./chunk-2tn3dkcy.js";export{Br as NATIVE_COMPONENTS,$o as compileToNative,Eo as createHotReloadServer,hu as default};