@stacksjs/stx 0.2.681 → 0.2.683

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 (89) hide show
  1. package/dist/{chunk-19kc8xnw.js → chunk-0h22d9cb.js} +1 -1
  2. package/dist/{chunk-6xtzsw17.js → chunk-0t65m9nw.js} +1 -1
  3. package/dist/{chunk-9fnt6q57.js → chunk-1dbw2j4q.js} +1 -1
  4. package/dist/{chunk-rxmmrafq.js → chunk-246k73ga.js} +1 -1
  5. package/dist/chunk-29c177cz.js +2 -0
  6. package/dist/{chunk-haqbkrdk.js → chunk-2rvprm39.js} +1 -1
  7. package/dist/{chunk-j3qcxtvc.js → chunk-3353tc28.js} +4 -4
  8. package/dist/{chunk-g2h12kza.js → chunk-3vgfwsft.js} +2 -2
  9. package/dist/{chunk-hy4j4r8a.js → chunk-3waphqhe.js} +1 -1
  10. package/dist/{chunk-0kk86z2m.js → chunk-551vqymy.js} +1 -1
  11. package/dist/{chunk-pfvjqvzd.js → chunk-56w1njc8.js} +6 -6
  12. package/dist/{chunk-2efy5ftv.js → chunk-5wpny9k3.js} +5 -5
  13. package/dist/chunk-6rrr362d.js +2 -0
  14. package/dist/{chunk-d2z2kvyj.js → chunk-70fdw728.js} +1 -1
  15. package/dist/{chunk-7afqwh0m.js → chunk-7fgsqs43.js} +2 -2
  16. package/dist/{chunk-8fetb3cr.js → chunk-840aejkc.js} +27 -27
  17. package/dist/chunk-8s10jjf1.js +2 -0
  18. package/dist/chunk-979g7g0r.js +2 -0
  19. package/dist/{chunk-9nzx4fv4.js → chunk-aenajaxk.js} +1 -1
  20. package/dist/{chunk-zcht5y0v.js → chunk-bsvwzma0.js} +1 -1
  21. package/dist/chunk-c3dqsjv0.js +2 -0
  22. package/dist/{chunk-0w1132a5.js → chunk-cd6s5k6e.js} +1 -1
  23. package/dist/{chunk-gvpwc9hr.js → chunk-cfbev664.js} +1 -1
  24. package/dist/{chunk-3cr308sm.js → chunk-d2nkm1jt.js} +1 -1
  25. package/dist/{chunk-5s9pjs20.js → chunk-d4f6dkrt.js} +1 -1
  26. package/dist/{chunk-avthzrdg.js → chunk-drd4t5v4.js} +2 -2
  27. package/dist/chunk-e1fgpb46.js +2 -0
  28. package/dist/{chunk-6aahems6.js → chunk-ff3d0eh9.js} +1 -1
  29. package/dist/{chunk-ar4yk1rk.js → chunk-g93jkztp.js} +1 -1
  30. package/dist/{chunk-5cvdc2a0.js → chunk-gny4j06b.js} +1 -1
  31. package/dist/{chunk-0c6ag7mk.js → chunk-gtktv6nn.js} +2 -2
  32. package/dist/chunk-hfk17t81.js +2 -0
  33. package/dist/{chunk-y5ase5av.js → chunk-j87n6mh0.js} +2 -2
  34. package/dist/chunk-jf717wps.js +2 -0
  35. package/dist/{chunk-gfa0dxjd.js → chunk-jg4932ma.js} +1 -1
  36. package/dist/{chunk-esz22r0a.js → chunk-js8ytnrn.js} +1 -1
  37. package/dist/{chunk-144wmtba.js → chunk-kbagpk8a.js} +1 -1
  38. package/dist/{chunk-a358zpqd.js → chunk-kbt9r41q.js} +1 -1
  39. package/dist/{chunk-wqn17d09.js → chunk-kq8t4xn9.js} +2 -2
  40. package/dist/chunk-mjqf15e7.js +2 -0
  41. package/dist/chunk-p1a6y65v.js +2 -0
  42. package/dist/{chunk-5yc7btc2.js → chunk-p21prjzh.js} +1 -1
  43. package/dist/{chunk-aezxgrd2.js → chunk-pqg3ghvh.js} +1 -1
  44. package/dist/{chunk-5ha6gkfr.js → chunk-px9p7q26.js} +4 -4
  45. package/dist/{chunk-3h7k7cnr.js → chunk-q7z1ybcn.js} +1 -1
  46. package/dist/{chunk-a2fa9aj4.js → chunk-qjccq0yd.js} +7 -7
  47. package/dist/{chunk-x65g450d.js → chunk-qpvasda5.js} +1 -1
  48. package/dist/{chunk-4nst5nj4.js → chunk-qq40hxg9.js} +60 -60
  49. package/dist/chunk-sk2ae1qj.js +2 -0
  50. package/dist/chunk-smdxvjhn.js +25 -0
  51. package/dist/{chunk-793qv470.js → chunk-sme7phry.js} +3 -3
  52. package/dist/{chunk-1x0jwz8m.js → chunk-t0644y3k.js} +2 -2
  53. package/dist/{chunk-ms9v5tc9.js → chunk-t257ye4c.js} +1 -1
  54. package/dist/chunk-thkw9ez9.js +54 -0
  55. package/dist/{chunk-km92eh3c.js → chunk-tkypg1xx.js} +1 -1
  56. package/dist/{chunk-q7v05zcy.js → chunk-w1wzydvp.js} +1 -1
  57. package/dist/chunk-wbn3x66p.js +2 -0
  58. package/dist/{chunk-a6h6ansh.js → chunk-xv8yy1cz.js} +5 -5
  59. package/dist/{chunk-yzf8g9h1.js → chunk-yfr4tsn1.js} +2 -2
  60. package/dist/chunk-yq9dtdkn.js +2 -0
  61. package/dist/{chunk-r8xzqz8z.js → chunk-yrq24gyy.js} +3 -3
  62. package/dist/chunk-yxy3brpr.js +2 -0
  63. package/dist/chunk-z9xhpkn6.js +2 -0
  64. package/dist/{chunk-ekztn3f5.js → chunk-zj5x4yk2.js} +2 -2
  65. package/dist/{chunk-ab5fc7cj.js → chunk-zx468wjw.js} +1 -1
  66. package/dist/cli.js +8 -8
  67. package/dist/craft-entry.js +1 -1
  68. package/dist/craft.js +1 -1
  69. package/dist/pwa.js +1 -1
  70. package/dist/ssg.js +2 -2
  71. package/dist/utils.js +13 -1
  72. package/package.json +5 -5
  73. package/dist/chunk-1h995e54.js +0 -2
  74. package/dist/chunk-4vxe0605.js +0 -54
  75. package/dist/chunk-540jj8a7.js +0 -2
  76. package/dist/chunk-5b1q41vy.js +0 -2
  77. package/dist/chunk-877tm3sp.js +0 -2
  78. package/dist/chunk-8q3j4jxr.js +0 -2
  79. package/dist/chunk-9cmmdbzc.js +0 -25
  80. package/dist/chunk-d3qxmety.js +0 -2
  81. package/dist/chunk-ehe5f2yn.js +0 -2
  82. package/dist/chunk-gjaqez01.js +0 -2
  83. package/dist/chunk-gr1331xc.js +0 -2
  84. package/dist/chunk-hsgbsj0g.js +0 -2
  85. package/dist/chunk-j7rzh56k.js +0 -2
  86. package/dist/chunk-me4f7ekt.js +0 -2
  87. package/dist/chunk-mndxjbmy.js +0 -2
  88. package/dist/chunk-ythdsen4.js +0 -2
  89. package/dist/chunk-zc6bkctv.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{g,m,d}from"./chunk-4nst5nj4.js";import{N}from"./chunk-ekztn3f5.js";import{o}from"./chunk-8fetb3cr.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],i=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>i){let a=e.slice(i,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),i=n.index+n[0].length}if(i<e.length){let s=e.slice(i);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function cd(e,t={},i={}){let n={...N,...i,streaming:{...q,...i.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),f=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(f.trim())await g(f,h,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await o(c,h,e,n,u);for(let b=0;b<p.length;b+=s)r.enqueue(p.slice(b,b+s)),await new Promise((y)=>setTimeout(y,0))}else{let p=[],b=new RegExp(T.source,"g"),y;while((y=b.exec(c))!==null)p.push({name:y[1],content:y[2],start:y.index,end:y.index+y[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await o(I,h,e,n,u);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await o(_.content,h,e,n,u);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await o(_,h,e,n,u);r.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await o(l.content,h,e,n,u);r.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;r.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
2
+ import{g,m,d}from"./chunk-qq40hxg9.js";import{N}from"./chunk-zj5x4yk2.js";import{o}from"./chunk-840aejkc.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],i=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>i){let a=e.slice(i,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),i=n.index+n[0].length}if(i<e.length){let s=e.slice(i);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function cd(e,t={},i={}){let n={...N,...i,streaming:{...q,...i.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),f=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(f.trim())await g(f,h,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await o(c,h,e,n,u);for(let b=0;b<p.length;b+=s)r.enqueue(p.slice(b,b+s)),await new Promise((y)=>setTimeout(y,0))}else{let p=[],b=new RegExp(T.source,"g"),y;while((y=b.exec(c))!==null)p.push({name:y[1],content:y[2],start:y.index,end:y.index+y[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await o(I,h,e,n,u);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await o(_.content,h,e,n,u);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await o(_,h,e,n,u);r.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await o(l.content,h,e,n,u);r.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;r.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(l.name,o(l.content,h,e,n,u))}r.enqueue(`
5
5
  <script>
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ve,Lo,jo,Ql,It,Xa,Bo,Ja,Op,Ne,fn,De}from"./chunk-4nst5nj4.js";import{nc,r}from"./chunk-9tg4995v.js";import"./chunk-5cvdc2a0.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-0c6ag7mk.js";export{ve as BROWSER_CORE_IMPORTS,Ql as STX_AUTO_IMPORTS,Lo as extractAndStripCssImports,Ne as extractBridgeData,nc as findInterpolationEnd,Ja as generateAutoImportDestructuring,Op as generateBrowserAutoImportDestructuring,fn as generateServerDataBridge,It as injectBrowserCoreAutoImports,De as processClientScript,Bo as referencesName,jo as renderVendorStyleTags,r as stripCommentsAndLiterals,Xa as transformAutoImports};
2
+ import{ve,Lo,jo,Ql,It,Xa,Bo,Ja,Op,Ne,fn,De}from"./chunk-qq40hxg9.js";import{nc,r}from"./chunk-9tg4995v.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{ve as BROWSER_CORE_IMPORTS,Ql as STX_AUTO_IMPORTS,Lo as extractAndStripCssImports,Ne as extractBridgeData,nc as findInterpolationEnd,Ja as generateAutoImportDestructuring,Op as generateBrowserAutoImportDestructuring,fn as generateServerDataBridge,It as injectBrowserCoreAutoImports,De as processClientScript,Bo as referencesName,jo as renderVendorStyleTags,r as stripCommentsAndLiterals,Xa as transformAutoImports};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{bp,Rl,uo,Ur,Xn,po,fo,Wr,qr,Gr,go,ua,Al,ht}from"./chunk-avthzrdg.js";import"./chunk-5ha6gkfr.js";import"./chunk-zt5hp5w5.js";import"./chunk-ekztn3f5.js";import"./chunk-gvpwc9hr.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import{L}from"./chunk-4nst5nj4.js";import"./chunk-5cvdc2a0.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-0c6ag7mk.js";export{bp as clearScriptScanCache,Wr as convertServerLoopAttributesToDirectives,po as convertSignalDirectivesToAttributes,qr as convertSignalLoopsToAttributes,Xn as extractClientSignalNames,L as extractExports,ua as findMarkupIndexOutsideScripts,Ur as hasSignalsSyntax,uo as parseLoopExpression,fo as preEvalLiteralReactiveIfs,Gr as processScriptSetup,go as processSignals,Al as rewriteStxImportSpecifiers,Rl as scanScriptTags,ht as stripStxRuntimeImports};
2
+ import{bp,Rl,uo,Ur,Xn,po,fo,Wr,qr,Gr,go,ua,Al,ht}from"./chunk-drd4t5v4.js";import"./chunk-px9p7q26.js";import"./chunk-zt5hp5w5.js";import"./chunk-zj5x4yk2.js";import"./chunk-cfbev664.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import{L}from"./chunk-qq40hxg9.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{bp as clearScriptScanCache,Wr as convertServerLoopAttributesToDirectives,po as convertSignalDirectivesToAttributes,qr as convertSignalLoopsToAttributes,Xn as extractClientSignalNames,L as extractExports,ua as findMarkupIndexOutsideScripts,Ur as hasSignalsSyntax,uo as parseLoopExpression,fo as preEvalLiteralReactiveIfs,Gr as processScriptSetup,go as processSignals,Al as rewriteStxImportSpecifiers,Rl as scanScriptTags,ht as stripStxRuntimeImports};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Pa,n,pe}from"./chunk-4nst5nj4.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-xvs84gas.js";import o from"fs";import l from"path";var Pl=new Map,m=new Map;async function vp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function wp(e){m.delete(e)}function xp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Sp(e){x=e}async function Il(e=!1){let t=x??await import("./chunk-aezxgrd2.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function Ol(){if(S===null){let{getRouterScript:e}=await import("./chunk-pvn0fc7j.js");S=e()}return S}var y={};async function kp(e,t=!1){let r=e==="runtime"?await Il(t):await Ol(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function _p(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function ho(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Cp(){m.clear(),pe(),Pa(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Zn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Xr(e)}.html`),s=l.join(r,`${Xr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Qe())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Xr(e)}.html`),a=l.join(s,`${Xr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Qe(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Pl.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Xr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
2
+ import{Pa,n,pe}from"./chunk-qq40hxg9.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-xvs84gas.js";import o from"fs";import l from"path";var Pl=new Map,m=new Map;async function vp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function wp(e){m.delete(e)}function xp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Sp(e){x=e}async function Il(e=!1){let t=x??await import("./chunk-pqg3ghvh.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function Ol(){if(S===null){let{getRouterScript:e}=await import("./chunk-pvn0fc7j.js");S=e()}return S}var y={};async function kp(e,t=!1){let r=e==="runtime"?await Il(t):await Ol(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function _p(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function ho(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Cp(){m.clear(),pe(),Pa(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Zn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Xr(e)}.html`),s=l.join(r,`${Xr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Qe())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Xr(e)}.html`),a=l.join(s,`${Xr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Qe(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Pl.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Xr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
3
3
  export{Pl,vp,wp,xp,Sp,Il,Ol,kp,_p,ho,Cp,Zn,Qn,Xr};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Mc,$i,Lu,Lc,jc,ju,Bu}from"./chunk-56w1njc8.js";import"./chunk-qjccq0yd.js";import"./chunk-5wpny9k3.js";import"./chunk-d4f6dkrt.js";import"./chunk-374nhgyf.js";import"./chunk-drd4t5v4.js";import"./chunk-px9p7q26.js";import"./chunk-zt5hp5w5.js";import"./chunk-zj5x4yk2.js";import"./chunk-cfbev664.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import{Rt,Wl}from"./chunk-qq40hxg9.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Mc as buildVirtualSource,Rt as extractScriptBlocks,Wl as extractTemplateExpressions,Lc as findRuntimeTypeDeclarations,jc as findStxModuleDeclarations,Bu as formatTypecheckDiagnostics,Lu as sourcePathFor,ju as typecheckStxFiles,$i as virtualPathFor};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-3cr308sm.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-6kam8r5y.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-6xtzsw17.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-9859r1d5.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-d2nkm1jt.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-6kam8r5y.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-0t65m9nw.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-9859r1d5.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
4
4
  `)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import"./chunk-0c6ag7mk.js";import"./chunk-6beg47t4.js";import{b,w,S,J}from"./chunk-4nst5nj4.js";import"./chunk-w28wc7mv.js";import"./chunk-t6m5d64b.js";import"./chunk-5cvdc2a0.js";import f from"path";var h=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(h);var l=new Map,x=b(64),y=new Set,O=0,R=new Set(h);function T(){l.clear(),x.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=w(n,O),r=x.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(y.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),x.set(o,t),t.slice()}async function A(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=J({loader:"ts",target:"browser",define:S()}),C=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
- ${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!d.has(s)&&!I(n,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let E=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
- `),k=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
2
+ import"./chunk-gtktv6nn.js";import"./chunk-6beg47t4.js";import{b,w,k,J}from"./chunk-qq40hxg9.js";import"./chunk-w28wc7mv.js";import"./chunk-t6m5d64b.js";import"./chunk-gny4j06b.js";import f from"path";var h=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(h);var l=new Map,S=b(64),x=new Set,O=0,R=new Set(h);function T(){l.clear(),S.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=w(n,O),r=S.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(x.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),S.set(o,t),t.slice()}async function A(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=J({loader:"ts",target:"browser",define:k()}),C=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
+ ${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let y=r.filter((s)=>!d.has(s)&&!I(n,s));if(y.length>0)console.warn(`[stx] could not bundle ${y.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let E=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
+ `),v=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
5
5
  ;(function(){
6
6
  var __s = window.stx = window.stx || {};
7
7
  ${m.join(`
@@ -9,4 +9,4 @@ ${m.join(`
9
9
  `)}
10
10
  ${E}
11
11
  })();
12
- </script>`;return l.set(t,k),k}function W(n){y.clear();for(let o of n)y.add(o);O++}export{W as __setRuntimeOwnedForTest,T as clearFrameworkComposableCache,A as getFrameworkComposableScript,M as referencedFrameworkComposables,P as selectComposableFiles};
12
+ </script>`;return l.set(t,v),v}function W(n){x.clear();for(let o of n)x.add(o);O++}export{W as __setRuntimeOwnedForTest,T as clearFrameworkComposableCache,A as getFrameworkComposableScript,M as referencedFrameworkComposables,P as selectComposableFiles};
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{x}from"./chunk-0c6ag7mk.js";import{T,xn}from"./chunk-6beg47t4.js";import{S,J}from"./chunk-4nst5nj4.js";import{i}from"./chunk-ekztn3f5.js";import{Ee,Yt,Zt,Qt}from"./chunk-2efy5ftv.js";import{ht}from"./chunk-avthzrdg.js";import{pt,Nn,qt,ae}from"./chunk-2pga7zzb.js";import{C,wr}from"./chunk-2ajbhefk.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Ud(c){let n;if(c)n=p.resolve(c);else{let t=await i();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Zt()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ae(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ee(t))])],f=pt(l()),d=qt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ae(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let y=u.map((t)=>t.file),m=[],g=new Set,v=J({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Yt(e))e=await Qt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=xn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
2
+ import{S}from"./chunk-gtktv6nn.js";import{T,xn}from"./chunk-6beg47t4.js";import{k,J}from"./chunk-qq40hxg9.js";import{i}from"./chunk-zj5x4yk2.js";import{Ee,Yt,Zt,Qt}from"./chunk-5wpny9k3.js";import{ht}from"./chunk-drd4t5v4.js";import{pt,Nn,qt,ae}from"./chunk-2pga7zzb.js";import{C,wr}from"./chunk-2ajbhefk.js";import p from"path";var a=new Map;function _(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let o of(s[1]??"").split(",")){let l=((o.includes(":")?o.split(":").pop():o)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let o of(s[1]??"").split(",")){let r=o.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Ud(c){let n;if(c)n=p.resolve(c);else{let t=await i();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Zt()}`,o=new Bun.Glob("*.ts"),r=[];try{for await(let t of o.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return ae(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>Ee(t))])],f=pt(l()),d=qt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return ae(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let x=u.map((t)=>t.file),m=[],g=new Set,y=J({loader:"ts",target:"browser",define:k()});for(let t of x)try{let e=await Bun.file(t).text(),v=p.basename(t,".ts");if(_(e,g),Yt(e))e=await Qt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=ht(e),e=T(e),e=xn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=y.transformSync(e),m.push(`// Store: ${v}
3
3
  ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return ae(a,s,f,""),null;let h=m.join(`
4
4
 
5
5
  `),w=`;(function(){
6
6
  var __stx = window.stx || {};
7
- ${x.filter((t)=>!g.has(t)&&new RegExp(`\\b${t}\\b`).test(h)).map((t)=>`var ${t} = __stx[${JSON.stringify(t)}];`).join(`
7
+ ${S.filter((t)=>!g.has(t)&&new RegExp(`\\b${t}\\b`).test(h)).map((t)=>`var ${t} = __stx[${JSON.stringify(t)}];`).join(`
8
8
  `)}
9
9
  ${h}
10
10
  })();`,b=C()?wr(w):w;return f=pt(l()),ae(a,s,f,b),b}function Wd(){a.clear(),Nn()}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{hn,Vo}from"./chunk-5cvdc2a0.js";import"./chunk-t6m5d64b.js";export{Vo as generateRuntimeConfigTypes,hn as prepareRuntimeConfig};
2
+ import{hn,Vo}from"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";export{Vo as generateRuntimeConfigTypes,hn as prepareRuntimeConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{be,ws,cu,Dp,lu,Mp,Ot,d,V,Y,mn,we,uu,Ho,du,Lp,k,pu,jp,_,Bp}from"./chunk-4nst5nj4.js";import"./chunk-5cvdc2a0.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-0c6ag7mk.js";export{pu as applyFilters,Mp as clearCustomFilters,uu as clientLoopScopes,ws as defaultFilters,mn as escapeAttributeValue,d as escapeHtml,V as escapeHtmlValue,Y as escapeInterpolatedHtmlValue,_ as evaluateExpression,be as findMustacheEnd,lu as getAllFilters,du as interpolateScriptAttributes,Ho as interpolateScriptExpressions,Lp as interpolateScriptsInTemplate,k as processExpressions,cu as registerFilter,Dp as registerFilters,Ot as replaceInterpolations,jp as resetRejectedExpressionWarnings,Bp as unescapeHtml,we as usesSignalsInScript};
2
+ import{be,ws,cu,Dp,lu,Mp,Ot,d,V,Y,mn,we,uu,Ho,du,Lp,x,pu,jp,_,Bp}from"./chunk-qq40hxg9.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{pu as applyFilters,Mp as clearCustomFilters,uu as clientLoopScopes,ws as defaultFilters,mn as escapeAttributeValue,d as escapeHtml,V as escapeHtmlValue,Y as escapeInterpolatedHtmlValue,_ as evaluateExpression,be as findMustacheEnd,lu as getAllFilters,du as interpolateScriptAttributes,Ho as interpolateScriptExpressions,Lp as interpolateScriptsInTemplate,x as processExpressions,cu as registerFilter,Dp as registerFilters,Ot as replaceInterpolations,jp as resetRejectedExpressionWarnings,Bp as unescapeHtml,we as usesSignalsInScript};
@@ -1,18 +1,18 @@
1
1
  // @bun
2
- import{x}from"./chunk-0c6ag7mk.js";import{ve,Rt,Ao,Po,Oa,Na,Da,Ma,gs,Oo,La,ja,Ba,pn}from"./chunk-4nst5nj4.js";import{i}from"./chunk-ekztn3f5.js";import{Ws}from"./chunk-a2fa9aj4.js";import{c}from"./chunk-xvs84gas.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=pn.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),ye=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function xe(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let o=y[1];if(!ye.has(o)||s.has(o))continue;let f=u.offset+g+m.index+y[0].length-o.length,p=e.slice(0,f),w=p.split(`
2
+ import{S}from"./chunk-gtktv6nn.js";import{ve,Rt,Ao,Po,Oa,Na,Da,Ma,gs,Oo,La,ja,Ba,pn}from"./chunk-qq40hxg9.js";import{i}from"./chunk-zj5x4yk2.js";import{Ws}from"./chunk-qjccq0yd.js";import{c}from"./chunk-xvs84gas.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=pn.filter((e)=>!ge.has(e)).sort(),te=[...S].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),ye=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function xe(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let x=m[0];if(/^\s*type\s/.test(x))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(x);if(!y)continue;let o=y[1];if(!ye.has(o)||s.has(o))continue;let f=u.offset+g+m.index+y[0].length-o.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;r.push({line:w,column:f-(p.lastIndexOf(`
4
- `)+1)+1,offset:f,length:o.length,name:o,kind:u.kind,message:xe(o,u.kind)})}}}return r}import T from"path";var Se="@stacksjs/stx-typescript-plugin";function ke(e,t){let r=T.resolve(e);for(;;){let u=T.join(r,"tsconfig.json");if(t(u))return u;let s=T.dirname(r);if(s===r)return;r=s}}function ie(e,t,r){let u=ke(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let o=S.find((p)=>p?.name===Se),f=Array.isArray(o?.libs)?o.libs.filter((p)=>typeof p==="string"):[];return o?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let o of[...y].reverse()){if(typeof o!=="string"||!o.startsWith("."))continue;let f=T.resolve(T.dirname(g),o.endsWith(".json")?o:`${o}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Mc(e,t="",r=""){let u=e.startLine>1?`
4
+ `)+1)+1,offset:f,length:o.length,name:o,kind:u.kind,message:xe(o,u.kind)})}}}return r}import T from"path";var Se="@stacksjs/stx-typescript-plugin";function ke(e,t){let r=T.resolve(e);for(;;){let u=T.join(r,"tsconfig.json");if(t(u))return u;let s=T.dirname(r);if(s===r)return;r=s}}function ie(e,t,r){let u=ke(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let m=t(g);if(!m)return;let x=m.compilerOptions?.plugins;if(Array.isArray(x)){let o=x.find((p)=>p?.name===Se),f=Array.isArray(o?.libs)?o.libs.filter((p)=>typeof p==="string"):[];return o?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let o of[...y].reverse()){if(typeof o!=="string"||!o.startsWith("."))continue;let f=T.resolve(T.dirname(g),o.endsWith(".json")?o:`${o}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Mc(e,t="",r=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",s=Oo(e)+Po(Ao(e.code)),l=e.kind==="client"||e.kind==="plain"?Da(t,e.code):"";return gs(`${u+s}
6
6
  ${l}
7
7
  export {}
8
- `,r)}var we=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function $e(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],r=new Set(x),u=[];for(let{file:s,names:l}of e){let g=JSON.stringify(s.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let m of l){if(r.has(m)||we.has(m))continue;r.add(m),t.push(`declare const ${m}: typeof import(${g})[${JSON.stringify(m)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
8
+ `,r)}var we=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function $e(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],r=new Set(S),u=[];for(let{file:s,names:l}of e){let g=JSON.stringify(s.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let m of l){if(r.has(m)||we.has(m))continue;r.add(m),t.push(`declare const ${m}: typeof import(${g})[${JSON.stringify(m)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
9
9
  `)}function $i(e,t,r){return`${e}.__stx_${t}${r}.ts`}function Lu(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Lc(){return se("stx.d.ts")}function jc(){return se("stx-module.d.ts")}function se(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function re(e){let t="",r=!1,u=!1;for(let s=0;s<e.length;s++){let l=e[s];if(r){if(t+=l,u)u=!1;else if(l==="\\")u=!0;else if(l==='"')r=!1;continue}if(l==='"'){r=!0,t+=l;continue}if(l==="/"&&e[s+1]==="/"){while(s<e.length&&e[s]!==`
10
10
  `)s++;t+=`
11
- `;continue}if(l==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&!(e[s]==="*"&&e[s+1]==="/"))s++;s++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(re(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),r;for(;;){let o=h.join(t,"tsconfig.json");if(M(o)){r=o;break}let f=h.dirname(t);if(f===t)break;t=f}if(!r)return{};let u=new Set,s=r,l,g,m=r;while(s&&!u.has(s)){u.add(s);let o;try{o=JSON.parse(re(K(s,"utf8")))}catch{break}let f=o?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=s;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(s),f.baseUrl);if(l&&g)break;s=typeof o?.extends==="string"?h.resolve(h.dirname(s),o.extends.endsWith(".json")?o.extends:`${o.extends}.json`):void 0}if(!l)return{};let S=g??h.dirname(m),y={};for(let[o,f]of Object.entries(l)){if(!Array.isArray(f))continue;y[o]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(S,p):p)}return{paths:y}}async function ju(e,t={}){let r=t.client!==!1,u=t.server!==!1,s=t.templates!==!1,l=t.componentsDir??(s?(await i()).componentsDir:void 0),g=new Map,m=new Map,S=[],y=[],o=0,f=0,p=Lc();for(let n of e){let a=await Bun.file(n).text(),b=Rt(a).filter((d)=>{if(d.kind==="server")return u;return r}),k=Rt(a).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
12
- `);for(let d of ne(a,b))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(r&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>Ma(k,O.code)))];if(E.length>0)m.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=h.dirname(h.resolve(n)),v=s?La(a,{runtimeGlobals:!p,originDir:D,filePath:h.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(b.length===0&&R===0)continue;if(y.push(n),o+=b.length,f+=R,b.forEach((d,E)=>{g.set($i(n,d.kind,E),{source:Mc(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set($i(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:S,checkedFiles:y,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>h.resolve(n)),oe=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,M);for(let n of oe?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?jc():null;if(G)w.push(G);let X=`${c()}/typecheck/__stx_globals.d.ts`,ce=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Oa(p?Na(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...x.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...ve.map((n)=>`declare const ${n}: any`)].join(`
11
+ `;continue}if(l==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&!(e[s]==="*"&&e[s+1]==="/"))s++;s++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(re(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),r;for(;;){let o=h.join(t,"tsconfig.json");if(M(o)){r=o;break}let f=h.dirname(t);if(f===t)break;t=f}if(!r)return{};let u=new Set,s=r,l,g,m=r;while(s&&!u.has(s)){u.add(s);let o;try{o=JSON.parse(re(K(s,"utf8")))}catch{break}let f=o?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=s;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(s),f.baseUrl);if(l&&g)break;s=typeof o?.extends==="string"?h.resolve(h.dirname(s),o.extends.endsWith(".json")?o.extends:`${o.extends}.json`):void 0}if(!l)return{};let x=g??h.dirname(m),y={};for(let[o,f]of Object.entries(l)){if(!Array.isArray(f))continue;y[o]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(x,p):p)}return{paths:y}}async function ju(e,t={}){let r=t.client!==!1,u=t.server!==!1,s=t.templates!==!1,l=t.componentsDir??(s?(await i()).componentsDir:void 0),g=new Map,m=new Map,x=[],y=[],o=0,f=0,p=Lc();for(let n of e){let a=await Bun.file(n).text(),b=Rt(a).filter((d)=>{if(d.kind==="server")return u;return r}),k=Rt(a).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
12
+ `);for(let d of ne(a,b))x.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(r&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>Ma(k,O.code)))];if(E.length>0)m.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=h.dirname(h.resolve(n)),v=s?La(a,{runtimeGlobals:!p,originDir:D,filePath:h.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(b.length===0&&R===0)continue;if(y.push(n),o+=b.length,f+=R,b.forEach((d,E)=>{g.set($i(n,d.kind,E),{source:Mc(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set($i(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:x,checkedFiles:y,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>h.resolve(n)),oe=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,M);for(let n of oe?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?jc():null;if(G)w.push(G);let X=`${c()}/typecheck/__stx_globals.d.ts`,ce=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Oa(p?Na(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...S.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...ve.map((n)=>`declare const ${n}: any`)].join(`
13
13
  `),$e(await Ws())].filter(Boolean).join(`
14
14
  `),_=`${c()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(X,ce);let N=new Map,ae=0;for(let[n,a]of g){let b=`${ae++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${_}/${b}`,a.source),N.set(b,a)}let le={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Oe(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},F=async(n,a)=>{let b=`${_}/tsconfig${a===1?"":`.${a}`}.json`;await Bun.write(b,JSON.stringify({compilerOptions:le,files:n.map((D)=>`${_}/${D}`).concat(X,...w)},null,2));let k=Bun.spawnSync(["bun","x","tsc","-p",b,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(k.stdout)+new TextDecoder().decode(k.stderr),exitCode:k.exitCode??0}},V=await F([...N.keys()],1),J=V.output,I=[],U=V.exitCode,W=0,ue=new Set(w.map((n)=>n.split("/").pop())),z=0,B=new Set,q=(n)=>{for(let a of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
15
- `)){let b=a.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,k,D,v,R,d,E]=b,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Q;if(C.virtual){let P=Ba(C.virtual,A,L);if(!P?.expression)continue;if(ja(P,Number(d)))continue;A=P.line,L=P.column,Q=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Q})}};q(J);let pe=W,de=z;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((a)=>!B.has(a));q((await F(n,2)).output)}if(r)for(let[n,a]of m){if(a.names.length===0)continue;I.push({file:n,line:a.line,column:1,code:0,message:`${a.names.length===1?"1 value reaches":`${a.names.length} values reach`} this block on the implicit bridge and ${a.names.length===1?"is":"are"} untyped: ${a.names.join(", ")}. Declare them with defineClientPayload({ ${a.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:a.kind})}I.push(...S);let H=new Set,j=I.filter((n)=>{let a=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(a))return!1;return H.add(a),!0});j.sort((n,a)=>n.file.localeCompare(a.file)||n.line-a.line||n.column-a.column);let Z=de>0&&j.length===0,fe=Z||U!==0&&pe===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
15
+ `)){let b=a.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,k,D,v,R,d,E]=b,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Q;if(C.virtual){let P=Ba(C.virtual,A,L);if(!P?.expression)continue;if(ja(P,Number(d)))continue;A=P.line,L=P.column,Q=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Q})}};q(J);let pe=W,de=z;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((a)=>!B.has(a));q((await F(n,2)).output)}if(r)for(let[n,a]of m){if(a.names.length===0)continue;I.push({file:n,line:a.line,column:1,code:0,message:`${a.names.length===1?"1 value reaches":`${a.names.length} values reach`} this block on the implicit bridge and ${a.names.length===1?"is":"are"} untyped: ${a.names.join(", ")}. Declare them with defineClientPayload({ ${a.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:a.kind})}I.push(...x);let H=new Set,j=I.filter((n)=>{let a=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(a))return!1;return H.add(a),!0});j.sort((n,a)=>n.file.localeCompare(a.file)||n.line-a.line||n.column-a.column);let Z=de>0&&j.length===0,fe=Z||U!==0&&pe===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
16
16
  ${J.trim().split(`
17
17
  `).slice(0,12).join(`
18
18
  `)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:y,blockCount:o,expressionCount:f,failure:fe}}function Bu(e){return e.map((t)=>{let r=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${r}`}).join(`
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{Vn,Te}from"./chunk-374nhgyf.js";import{L,b,ir,ds,S}from"./chunk-4nst5nj4.js";import{i,R}from"./chunk-ekztn3f5.js";import{eo}from"./chunk-5s9pjs20.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-xvs84gas.js";import{r,fe}from"./chunk-9tg4995v.js";import d from"path";import B from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||eo(t,e,n)}var ot=2;function gl(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function nt(t,e){let n=t;for(let o of xt(e))if(o!==d.sep)n=n.split(o).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let o=e;try{o=B.realpathSync(e)}catch{}n=[...new Set([e,o])].sort((u,m)=>m.length-u.length),st.set(e,n)}return n}function $t(t,e){try{let n=B.statSync(t),o=d.resolve(e),u=t.startsWith(`${o}${d.sep}`);return{path:u?d.relative(o,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(B.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function yt(t,e){for(let n of t){let o=at(n,e);try{let u=B.statSync(o);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(B.readFileSync(o)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,bt=100;function ml(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function wt(t){let e=G.get(t)??0;if(e>0&&e<bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await B.promises.readdir(t)).filter((l)=>l.endsWith(".js")),o=ml();if(n.length<=o)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await B.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,y)=>y.at-l.at);for(let l of m.slice(o)){let y=l.name.slice(0,-3);await B.promises.rm(d.join(t,`${y}.js`),{force:!0}),await B.promises.rm(d.join(t,`${y}.deps.json`),{force:!0})}C("pruned bundle cache to",o,"entries")}catch{}}function Ee(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function hl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(hl())console.log("[stx:bundler]",...t)}var Y=[];function ra(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Xt(){return Y.slice()}function Jt(){Y.length=0}var Z;function cp(t){Z=t}function sa(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Yt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let o=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=o.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Hn="stx-module:",St=/\.(?:[cm]?[jt]sx?|json)$/i;function yl(t,e){return d.relative(t,e).split(d.sep).join("/")}function bl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,o,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Hn)?`${o}${u}${l}${u}`:n})}function vl(t,e){let n=0,o=(m)=>{let l=`__stxMod${n++}`,y=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${y}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(y)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let y of m.split(",")){let I=y.trim();if(!I)continue;let j=I.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let _=j[1].startsWith('"')?JSON.parse(j[1]):j[1],p=j[2]??_;e.push(`var ${p} = ${l}[${JSON.stringify(_)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,y)=>{let I=y.slice(Hn.length),j=o(I),_=l.trim(),p=_.match(/^([\w$]+)\s*(?:,\s*|$)/);if(p&&!_.startsWith("{")&&!_.startsWith("*"))e.push(`var ${p[1]} = ${j}.default;`),_=_.slice(p[0].length).trim();let s=_.match(/^\*\s*as\s+([\w$]+)$/);if(s)e.push(`var ${s[1]} = ${j};`);else if(_.startsWith("{"))u(_.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(o(l.slice(Hn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(B.existsSync(n)&&B.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function Js(t,e){let n=new Bun.CryptoHasher("md5");for(let[o,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${o}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Zt(){return K.getStore()?.key??""}function vt(t,e,n,o,u,m,l=new Map,y,I){let j=(p,s,a)=>{if(X(s,t,y))return null;if(!m||p!==n||!St.test(s))return null;try{if(!B.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(s);let w=`${Hn}${yl(process.cwd(),s)}`;return l.set(a,w),{path:w,external:!0}},_=(p,s)=>{let a=p===n?e:d.dirname(p),w=d.resolve(a,s);return rt(w)??w};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{if(s.path===n)return{path:n};let a=rt(s.path);if(a){let w=j(s.importer,a,s.path);if(w)return w;if(a!==n)u.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=_(s.importer,s.path),w=j(s.importer,a,s.path);if(w)return w;return u.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),w=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let x of w)if(B.existsSync(x)&&B.statSync(x,{throwIfNoEntry:!1})?.isFile()){let N=j(s.importer,x,s.path);if(N)return N;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",x),u.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),m)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Hn}npm:${s.path}`;return l.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(s.path===n)return{contents:o,loader:"ts"};if(X(s.path,t,y))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),w=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)u.add(s.path);let x=I?.get(s.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:B.readFileSync(s.path,"utf8"),loader:w}})}}}var H=new Map,P=b(64),it=Symbol.for("stx.client-bundle-build-queue");function wl(t){let e=globalThis,o=(e[it]??Promise.resolve()).then(t,t);return e[it]=o.then(()=>{return},()=>{return}),o}async function Qt(t,e,n={}){let o=n.projectRoot||process.cwd(),u=(await i(o)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,y=n.expose?.length?[...new Set(n.expose)].sort():void 0,I=n.cacheDir||gl(o),j=K.getStore(),_=new Bun.CryptoHasher("md5");_.update(`${ht}\x00${Qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${y?y.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,o)}\x00${nt(e,o)}`);let p=_.digest("hex").slice(0,12),s=d.join(I,`${p}.js`),a=P.get(s);if(a){if(ds(a.files)&&a.files.every((F)=>!X(F.path,o,u))){C("memo hit:",p);let F=a.files.map((A)=>A.path);return q(e,F),n.collectInputs?.push(...F),a.code}P.delete(s),C("memo invalidated by dep change:",p)}let w=d.join(I,`${p}.deps.json`),x=Bun.file(s);if(await x.exists()){let F=Bun.file(w),A=!1,O=null;if(await F.exists())try{let D=JSON.parse(await F.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&yt(D.files,o))O=ir(D.files.map((g)=>at(g,o))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,o,u))}catch{A=!1}if(A){if(C("cache hit:",p),O)q(e,O.map((U)=>U.path)),n.collectInputs?.push(...O.map((U)=>U.path));let D=await x.text(),g=new Date;if(B.promises.utimes(s,g,g).catch(()=>{}),O)P.set(s,{code:D,files:O});return D}C("cache invalidated by dep change:",p)}let N=H.get(p);if(N){let F=await N;if(n.collectInputs)n.collectInputs.push(...(P.get(s)?.files??[]).map((A)=>A.path));return F}let V=wl(()=>jt(t,e,{projectRoot:o,minify:m,cacheDir:I,hash:p,cachePath:s,depsPath:w,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:y,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(p,V);try{return await V}finally{H.delete(p)}}var Bt=0;function xl(t){return`${t}-${process.pid}-${++Bt}`}async function jt(t,e,n){let{projectRoot:o,minify:u,cacheDir:m,hash:l,cachePath:y,depsPath:I,externalizeUserModules:j}=n,_=c(o,"bundle-tmp"),p=xl(l),s=d.join(o,`.stx-client-${p}.ts`),a=d.join(_,"out",p);B.mkdirSync(a,{recursive:!0});let w=d.dirname(e),x=new Set,N=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,F=r(t),{depths:A,balanced:O}=fe(F),D=(E)=>!O||A[E]===0,g;while((g=N.exec(F))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((E)=>{let f=_t(E);if(f)x.add(f)});else if(g[3])x.add(g[3])}while((g=V.exec(F))!==null){if(g[1])continue;if(!D(g.index))continue;x.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(F))!==null){if(!D(g.index))continue;let E=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(E&&Q.some((f)=>f.test(E)))continue;if(g[1])x.add(g[1]);if(g[2])x.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let k=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(k)x.add(k)}}for(let E of F.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of E[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)x.delete(v)}let lt=x.size>0?`
3
- export { ${[...x].join(", ")} }`:"";C("bundling:",l,"from:",d.basename(e));let tt=new Set,et=new Map;try{let E=await Bun.build({entrypoints:[s],outdir:a,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[vt(o,w,s,t+lt,tt,j,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...S()},root:o});if(!E.success){let M=E.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${d.basename(e)}`,z=Vn(E.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",M),ra(e||"",M,z),n.throwOnFailure||sa()==="error")throw Error(M);return t}let f="";for(let h of E.outputs){f=await h.text();break}let v=[];for(let h of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let M of h[1].split(",")){let z=M.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){v.push([z[2],z[1]]);continue}let T=M.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))v.push([T,T])}if(n.expose){let h=new Set(n.expose);for(let M=v.length-1;M>=0;M--)if(!h.has(v[M][0]))v.splice(M,1)}let k=[];f=vl(bl(f,et),k);let ut=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,dt=new Set(L(t,!0).split(",").map((h)=>h.trim())),pt=v.map(([h,M])=>`get ${JSON.stringify(h)}() { return ${M} }${dt.has(h)?`, set ${JSON.stringify(h)}(__stxValue_${M}) { ${M} = __stxValue_${M} }`:""}`).join(", "),ft=v.map(([h])=>`var ${h} = undefined;`).join(`
4
- `),mt=v.map(([h])=>`${h} = ${J}[${JSON.stringify(h)}];`).join(`
2
+ import{Vn,Te}from"./chunk-374nhgyf.js";import{L,b,ir,ds,k}from"./chunk-qq40hxg9.js";import{i,R}from"./chunk-zj5x4yk2.js";import{eo}from"./chunk-d4f6dkrt.js";import{Qe}from"./chunk-yn9kvsk1.js";import{c}from"./chunk-xvs84gas.js";import{r,fe}from"./chunk-9tg4995v.js";import d from"path";import v from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||eo(t,e,n)}var ot=2;function gl(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function nt(t,e){let n=t;for(let o of xt(e))if(o!==d.sep)n=n.split(o).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let o=e;try{o=v.realpathSync(e)}catch{}n=[...new Set([e,o])].sort((u,m)=>m.length-u.length),st.set(e,n)}return n}function $t(t,e){try{let n=v.statSync(t),o=d.resolve(e),u=t.startsWith(`${o}${d.sep}`);return{path:u?d.relative(o,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(v.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function yt(t,e){for(let n of t){let o=at(n,e);try{let u=v.statSync(o);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(v.readFileSync(o)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,bt=100;function ml(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function wt(t){let e=G.get(t)??0;if(e>0&&e<bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await v.promises.readdir(t)).filter((l)=>l.endsWith(".js")),o=ml();if(n.length<=o)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await v.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,y)=>y.at-l.at);for(let l of m.slice(o)){let y=l.name.slice(0,-3);await v.promises.rm(d.join(t,`${y}.js`),{force:!0}),await v.promises.rm(d.join(t,`${y}.deps.json`),{force:!0})}O("pruned bundle cache to",o,"entries")}catch{}}function Ee(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function hl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function O(...t){if(hl())console.log("[stx:bundler]",...t)}var Y=[];function ra(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Xt(){return Y.slice()}function Jt(){Y.length=0}var Z;function cp(t){Z=t}function sa(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Yt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return O("detected user import:",u),!0}let o=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=o.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return O("detected side-effect import:",u),!0}return!1}var Hn="stx-module:",St=/\.(?:[cm]?[jt]sx?|json)$/i;function yl(t,e){return d.relative(t,e).split(d.sep).join("/")}function bl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,o,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Hn)?`${o}${u}${l}${u}`:n})}function vl(t,e){let n=0,o=(m)=>{let l=`__stxMod${n++}`,y=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${y}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(y)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let y of m.split(",")){let F=y.trim();if(!F)continue;let B=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!B)continue;let j=B[1].startsWith('"')?JSON.parse(B[1]):B[1],p=B[2]??j;e.push(`var ${p} = ${l}[${JSON.stringify(j)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,y)=>{let F=y.slice(Hn.length),B=o(F),j=l.trim(),p=j.match(/^([\w$]+)\s*(?:,\s*|$)/);if(p&&!j.startsWith("{")&&!j.startsWith("*"))e.push(`var ${p[1]} = ${B}.default;`),j=j.slice(p[0].length).trim();let s=j.match(/^\*\s*as\s+([\w$]+)$/);if(s)e.push(`var ${s[1]} = ${B};`);else if(j.startsWith("{"))u(j.replace(/^\{|\}$/g,""),B);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(o(l.slice(Hn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(v.existsSync(n)&&v.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function Js(t,e){let n=new Bun.CryptoHasher("md5");for(let[o,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${o}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Zt(){return K.getStore()?.key??""}function vt(t,e,n,o,u,m,l=new Map,y,F){let B=(p,s,a)=>{if(X(s,t,y))return null;if(!m||p!==n||!St.test(s))return null;try{if(!v.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}u.add(s);let w=`${Hn}${yl(process.cwd(),s)}`;return l.set(a,w),{path:w,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),w=d.resolve(a,s);return rt(w)??w};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{if(s.path===n)return{path:n};let a=rt(s.path);if(a){let w=B(s.importer,a,s.path);if(w)return w;if(a!==n)u.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),w=B(s.importer,a,s.path);if(w)return w;return u.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),w=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let x of w)if(v.existsSync(x)&&v.statSync(x,{throwIfNoEntry:!1})?.isFile()){let A=B(s.importer,x,s.path);if(A)return A;return O(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",x),u.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),m)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Hn}npm:${s.path}`;return l.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(s.path===n)return{contents:o,loader:"ts"};if(X(s.path,t,y))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),w=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)u.add(s.path);let x=F?.get(s.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:v.readFileSync(s.path,"utf8"),loader:w}})}}}var H=new Map,P=b(64),it=Symbol.for("stx.client-bundle-build-queue");function wl(t){let e=globalThis,o=(e[it]??Promise.resolve()).then(t,t);return e[it]=o.then(()=>{return},()=>{return}),o}async function Qt(t,e,n={}){let o=n.projectRoot||process.cwd(),u=(await i(o)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,y=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||gl(o),B=K.getStore(),j=new Bun.CryptoHasher("md5");j.update(`${ht}\x00${Qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${y?y.join(","):"*"}\x00${m?"minified":"readable"}\x00${B?.key??""}\x00${nt(t,o)}\x00${nt(e,o)}`);let p=j.digest("hex").slice(0,12),s=d.join(F,`${p}.js`),a=P.get(s);if(a){if(ds(a.files)&&a.files.every((M)=>!X(M.path,o,u))){O("memo hit:",p);let M=a.files.map((C)=>C.path);return q(e,M),n.collectInputs?.push(...M),a.code}P.delete(s),O("memo invalidated by dep change:",p)}let w=d.join(F,`${p}.deps.json`),x=Bun.file(s);if(await x.exists()){let M=Bun.file(w),C=!1,D=null;if(await M.exists())try{let I=JSON.parse(await M.text());if(I.metadataVersion===ot&&Array.isArray(I.files)&&yt(I.files,o))D=ir(I.files.map((g)=>at(g,o))),C=D.length===I.files.length&&!D.some((g)=>X(g.path,o,u))}catch{C=!1}if(C){if(O("cache hit:",p),D)q(e,D.map((T)=>T.path)),n.collectInputs?.push(...D.map((T)=>T.path));let I=await x.text(),g=new Date;if(v.promises.utimes(s,g,g).catch(()=>{}),D)P.set(s,{code:I,files:D});return I}O("cache invalidated by dep change:",p)}let A=H.get(p);if(A){let M=await A;if(n.collectInputs)n.collectInputs.push(...(P.get(s)?.files??[]).map((C)=>C.path));return M}let V=wl(()=>jt(t,e,{projectRoot:o,minify:m,cacheDir:F,hash:p,cachePath:s,depsPath:w,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:y,throwOnFailure:n.throwOnFailure,substitutes:B?.modules}));H.set(p,V);try{return await V}finally{H.delete(p)}}var Bt=0;function xl(t){return`${t}-${process.pid}-${++Bt}`}async function jt(t,e,n){let{projectRoot:o,minify:u,cacheDir:m,hash:l,cachePath:y,depsPath:F,externalizeUserModules:B}=n,j=c(o,"bundle-tmp"),p=xl(l),s=d.join(o,`.stx-client-${p}.ts`),a=d.join(j,"out",p);v.mkdirSync(a,{recursive:!0});let w=d.dirname(e),x=new Set,A=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=r(t),{depths:C,balanced:D}=fe(M),I=(_)=>!D||C[_]===0,g;while((g=A.exec(M))!==null){if(g[1])continue;if(!I(g.index))continue;if(g[2])g[2].split(",").forEach((_)=>{let f=_t(_);if(f)x.add(f)});else if(g[3])x.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!I(g.index))continue;x.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!I(g.index))continue;let _=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(_&&Q.some((f)=>f.test(_)))continue;if(g[1])x.add(g[1]);if(g[2])x.add(g[2]);for(let f of(g[3]??"").split(",")){let S=f.trim();if(!S||/^type\s/.test(S))continue;let U=/\bas\s+(\w+)\s*$/.exec(S)?.[1]??/^\w+$/.exec(S)?.[0];if(U)x.add(U)}}for(let _ of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of _[1].split(",")){let S=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(S)x.delete(S)}let lt=x.size>0?`
3
+ export { ${[...x].join(", ")} }`:"";O("bundling:",l,"from:",d.basename(e));let tt=new Set,et=new Map;try{let _=await Bun.build({entrypoints:[s],outdir:a,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[vt(o,w,s,t+lt,tt,B,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...k()},root:o});if(!_.success){let E=_.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,z=Vn(_.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",E),ra(e||"",E,z),n.throwOnFailure||sa()==="error")throw Error(E);return t}let f="";for(let h of _.outputs){f=await h.text();break}let S=[];for(let h of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let E of h[1].split(",")){let z=E.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){S.push([z[2],z[1]]);continue}let N=E.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))S.push([N,N])}if(n.expose){let h=new Set(n.expose);for(let E=S.length-1;E>=0;E--)if(!h.has(S[E][0]))S.splice(E,1)}let U=[];f=vl(bl(f,et),U);let ut=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,dt=new Set(L(t,!0).split(",").map((h)=>h.trim())),pt=S.map(([h,E])=>`get ${JSON.stringify(h)}() { return ${E} }${dt.has(h)?`, set ${JSON.stringify(h)}(__stxValue_${E}) { ${E} = __stxValue_${E} }`:""}`).join(", "),ft=S.map(([h])=>`var ${h} = undefined;`).join(`
4
+ `),mt=S.map(([h])=>`${h} = ${J}[${JSON.stringify(h)}];`).join(`
5
5
  `);if(f=`${ut.join(`
6
6
  `)}
7
7
  ${ft}
8
8
  var ${J} = (function() {
9
- ${k.join(`
9
+ ${U.join(`
10
10
  `)}
11
11
  ${f}
12
12
  return { ${pt} };
@@ -16,5 +16,5 @@ var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiv
16
16
  Object.keys(${J}).forEach(function(name) {
17
17
  if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
18
18
  Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${J}, name));
19
- });`.trim(),C("bundled:",l,"output:",f.length,"bytes"),x.size>0&&v.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${l}); serving the unbundled source and not caching this result`),t;B.mkdirSync(m,{recursive:!0}),await Bun.write(y,f);let W=ir(tt);return await Bun.write(I,JSON.stringify({metadataVersion:ot,files:W.map((h)=>$t(h.path,o)).filter((h)=>h!==null)})),q(e,W.map((h)=>h.path)),n.collectInputs?.push(...W.map((h)=>h.path)),P.set(y,{code:f,files:W}),await wt(m),f}catch(E){let f=Vn(E,e||void 0),v=Te(E,e||void 0);if(console.warn(`[stx:bundler] error: ${v}`),ra(e||"",v,f),n.throwOnFailure||sa()==="error")throw E;return t}finally{try{B.rmSync(a,{recursive:!0,force:!0})}catch{}}}function _t(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let o=e.indexOf(":");if(o!==-1)e=e.slice(o+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
19
+ });`.trim(),O("bundled:",l,"output:",f.length,"bytes"),x.size>0&&S.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${l}); serving the unbundled source and not caching this result`),t;v.mkdirSync(m,{recursive:!0}),await Bun.write(y,f);let W=ir(tt);return await Bun.write(F,JSON.stringify({metadataVersion:ot,files:W.map((h)=>$t(h.path,o)).filter((h)=>h!==null)})),q(e,W.map((h)=>h.path)),n.collectInputs?.push(...W.map((h)=>h.path)),P.set(y,{code:f,files:W}),await wt(m),f}catch(_){let f=Vn(_,e||void 0),S=Te(_,e||void 0);if(console.warn(`[stx:bundler] error: ${S}`),ra(e||"",S,f),n.throwOnFailure||sa()==="error")throw _;return t}finally{try{v.rmSync(a,{recursive:!0,force:!0})}catch{}}}function _t(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let o=e.indexOf(":");if(o!==-1)e=e.slice(o+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
20
20
  export{gl,ml,Ee,hl,ra,Xt,Jt,cp,sa,Yt,Hn,yl,bl,vl,Js,Zt,wl,Qt,xl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qu}from"./chunk-kbagpk8a.js";import"./chunk-zj5x4yk2.js";import"./chunk-cfbev664.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import"./chunk-qq40hxg9.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{Qu as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{N,Nl,yo,i,R,Ep,Tp}from"./chunk-ekztn3f5.js";import"./chunk-gvpwc9hr.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import"./chunk-4nst5nj4.js";import"./chunk-5cvdc2a0.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-0c6ag7mk.js";export{R as config,N as defaultConfig,Ep as defineStxConfig,yo as discoverConfig,i as loadStxConfig,Nl as resolveStxDirectories,Tp as validateConfig};
2
+ import{N,Nl,yo,i,R,Ep,Tp}from"./chunk-zj5x4yk2.js";import"./chunk-cfbev664.js";import"./chunk-tenbwcts.js";import"./chunk-912r15hr.js";import"./chunk-nbjyed3q.js";import"./chunk-gymmbbzc.js";import"./chunk-qq40hxg9.js";import"./chunk-gny4j06b.js";import"./chunk-t6m5d64b.js";import"./chunk-w28wc7mv.js";import"./chunk-6beg47t4.js";import"./chunk-gtktv6nn.js";export{R as config,N as defaultConfig,Ep as defineStxConfig,yo as discoverConfig,i as loadStxConfig,Nl as resolveStxDirectories,Tp as validateConfig};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ue,Fa,hs,dn,g,Ne,De}from"./chunk-4nst5nj4.js";import{er,Je,N}from"./chunk-ekztn3f5.js";import{Un,o}from"./chunk-8fetb3cr.js";import{ye}from"./chunk-5ha6gkfr.js";function b(s){return s.endsWith(".md")||s.endsWith(".markdown")}function k(s){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let u;while((u=n.exec(s))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function R(s,e={}){let{data:r,content:m}=er(s),a=await(e.renderer??((n)=>Je(n)))(m);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(s){let e=s,r=ue(s);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(s))!==null){let i=u[1],l=u[2],d=u[0],f=i.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=i.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let i of c)t=t.replace(i,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(s,e){return`<!DOCTYPE html>
2
+ import{ue,Fa,hs,dn,g,Ne,De}from"./chunk-qq40hxg9.js";import{er,Je,N}from"./chunk-zj5x4yk2.js";import{Un,o}from"./chunk-840aejkc.js";import{ye}from"./chunk-px9p7q26.js";function b(s){return s.endsWith(".md")||s.endsWith(".markdown")}function k(s){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let u;while((u=n.exec(s))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function R(s,e={}){let{data:r,content:m}=er(s),a=await(e.renderer??((n)=>Je(n)))(m);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(s){let e=s,r=ue(s);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(s))!==null){let i=u[1],l=u[2],d=u[0],f=i.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=i.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let i of c)t=t.replace(i,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(s,e){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -14,5 +14,5 @@ ${a.join(`
14
14
  `)}`}else{if(r.processClientScripts!==!1&&a.length>0){let i=p.__stx_event_bindings||[],l=Ne(p),d=await Promise.all(a.map(async(w)=>{let C=w.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(C))return w;let h=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!h)return w;return await De(h[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})})),x=[await Un(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
15
15
  `);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${x}
16
16
  $1`);else t+=`
17
- ${x}`}t=await ye(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-hsgbsj0g.js");t=await i(t)}catch{}return t}
17
+ ${x}`}t=await ye(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-979g7g0r.js");t=await i(t)}catch{}return t}
18
18
  export{Zi};