@stacksjs/stx 0.2.414 → 0.2.415

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 (58) hide show
  1. package/dist/builtins/image-delivery.js +19 -11
  2. package/dist/{chunk-3c74vag1.js → chunk-0pnj3zt2.js} +1 -1
  3. package/dist/{chunk-6sgswrqw.js → chunk-0zaess6f.js} +2 -2
  4. package/dist/{chunk-2mkcjw08.js → chunk-18vmfkcc.js} +1 -1
  5. package/dist/{chunk-hkxsewzk.js → chunk-1zs30k3y.js} +1 -1
  6. package/dist/{chunk-10957mcb.js → chunk-393341w7.js} +1 -1
  7. package/dist/{chunk-69mc2np8.js → chunk-3efw27as.js} +111 -111
  8. package/dist/{chunk-mepdnezf.js → chunk-42wbs8vq.js} +1 -1
  9. package/dist/{chunk-q4c06e8x.js → chunk-8eqrwj1k.js} +1 -1
  10. package/dist/{chunk-yvx1ap9b.js → chunk-96k8s808.js} +1 -1
  11. package/dist/{chunk-2gr351s0.js → chunk-9amp82bx.js} +1 -1
  12. package/dist/{chunk-e57rhf65.js → chunk-9p9qkbtg.js} +1 -1
  13. package/dist/{chunk-dvgv8nry.js → chunk-amtr3rmf.js} +1 -1
  14. package/dist/{chunk-z6d0jmjb.js → chunk-atws6p5s.js} +1 -1
  15. package/dist/{chunk-h0atqq82.js → chunk-b98be3yp.js} +1 -1
  16. package/dist/{chunk-2v8wztd5.js → chunk-dd8cja4h.js} +1 -1
  17. package/dist/{chunk-v091jft4.js → chunk-e9hs7kk6.js} +1 -1
  18. package/dist/{chunk-b52s5z0c.js → chunk-f1sxycmv.js} +1 -1
  19. package/dist/chunk-fbcv4fes.js +2 -0
  20. package/dist/{chunk-afhxw2t8.js → chunk-fpfzm238.js} +1 -1
  21. package/dist/{chunk-x72tv2cg.js → chunk-g03s93qr.js} +1 -1
  22. package/dist/{chunk-v4vaqxrf.js → chunk-g186znp9.js} +1 -1
  23. package/dist/{chunk-bmt7w2pk.js → chunk-gc1drn2p.js} +1 -1
  24. package/dist/{chunk-s2x4wcrz.js → chunk-gea5hf0v.js} +1 -1
  25. package/dist/chunk-gqv3ta5d.js +2 -0
  26. package/dist/{chunk-btmhj5t7.js → chunk-h6kp2m9r.js} +1 -1
  27. package/dist/{chunk-xtdw3692.js → chunk-hepd9qgx.js} +1 -1
  28. package/dist/{chunk-qz519eyp.js → chunk-hhnw2sn3.js} +1 -1
  29. package/dist/{chunk-4jjme6a5.js → chunk-hk1mj4tz.js} +1 -1
  30. package/dist/{chunk-sd47dzs0.js → chunk-hkrmcbwy.js} +1 -1
  31. package/dist/{chunk-pj1wg7jg.js → chunk-hn9pkyv8.js} +1 -1
  32. package/dist/{chunk-syaw6b75.js → chunk-hpgr4qgp.js} +1 -1
  33. package/dist/{chunk-d44b9ktb.js → chunk-jnkrn913.js} +1 -1
  34. package/dist/{chunk-dx7n22ed.js → chunk-jp10q90g.js} +1 -1
  35. package/dist/{chunk-866n724v.js → chunk-nc8my58s.js} +1 -1
  36. package/dist/{chunk-apg16xcn.js → chunk-nppdrf0x.js} +1 -1
  37. package/dist/{chunk-x5bpeb4a.js → chunk-pazfr1a1.js} +1 -1
  38. package/dist/{chunk-se7mwqd1.js → chunk-pdb5fw3r.js} +1 -1
  39. package/dist/{chunk-g578mcb0.js → chunk-qghxz7jm.js} +1 -1
  40. package/dist/{chunk-pqxzp1bb.js → chunk-re8b5r9x.js} +1 -1
  41. package/dist/{chunk-5g3y8kym.js → chunk-t5pvq5mx.js} +1 -1
  42. package/dist/{chunk-qet5gc6s.js → chunk-tafqyf2g.js} +5 -5
  43. package/dist/{chunk-daz5aqcf.js → chunk-v91p6ekp.js} +1 -1
  44. package/dist/{chunk-f6az0xj5.js → chunk-w72qx0eb.js} +1 -1
  45. package/dist/{chunk-scezfp0w.js → chunk-wfy1zq53.js} +2 -2
  46. package/dist/{chunk-ynvdvbat.js → chunk-wzx0164n.js} +2 -2
  47. package/dist/{chunk-rs4v4fha.js → chunk-xtvf6n6f.js} +1 -1
  48. package/dist/{chunk-gw07qmjk.js → chunk-xwzvfqcb.js} +1 -1
  49. package/dist/{chunk-1chw8xsw.js → chunk-z23kaxq6.js} +1 -1
  50. package/dist/{chunk-mhq0pjws.js → chunk-z8xn5ta3.js} +1 -1
  51. package/dist/cli.js +7 -7
  52. package/dist/craft-entry.js +1 -1
  53. package/dist/craft.js +1 -1
  54. package/dist/pwa.js +1 -1
  55. package/dist/ssg.js +2 -2
  56. package/package.json +5 -5
  57. package/dist/chunk-48bwk47q.js +0 -2
  58. package/dist/chunk-6y8hnymb.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y,i,T}from"./chunk-69mc2np8.js";import{P,kt}from"./chunk-h0atqq82.js";import{qr}from"./chunk-xtdw3692.js";import{he}from"./chunk-et0rr8c7.js";import{s,we}from"./chunk-169n1vpx.js";import{o}from"./chunk-fzapbw9p.js";import f from"path";import b from"fs";function de(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function pe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function U(e,t){let r=[];for(let l of pe(e)){if(de(l)){let u=l.position||void 0;r.push({file:t||u?.file,line:u?.line,column:u?.column,message:l.message??"",lineText:u?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function Me(e,t){return U(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",u=r.lineText?`
2
+ import{y,i,T}from"./chunk-3efw27as.js";import{P,kt}from"./chunk-b98be3yp.js";import{qr}from"./chunk-hepd9qgx.js";import{he}from"./chunk-et0rr8c7.js";import{s,we}from"./chunk-169n1vpx.js";import{o}from"./chunk-fzapbw9p.js";import f from"path";import b from"fs";function de(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function pe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function U(e,t){let r=[];for(let l of pe(e)){if(de(l)){let u=l.position||void 0;r.push({file:t||u?.file,line:u?.line,column:u?.column,message:l.message??"",lineText:u?.lineText});continue}r.push({file:t,message:l instanceof Error?l.message:String(l)})}return r}function Me(e,t){return U(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",u=r.lineText?`
3
3
  ${r.lineText.trim()}`:"";return l?`${l}: ${r.message}${u}`:`${r.message}${u}`}).join(`
4
4
  `)}var me=9;function z(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(f.basename(e))||qr(e,t,r)}var re=1,se=new Map,J=600,fe=100,V=new Map;async function ge(e){let t=V.get(e)??0;if(t>0&&t<fe){V.set(e,t+1);return}V.set(e,1);try{let r=(await b.promises.readdir(e)).filter((p)=>p.endsWith(".js"));if(r.length<=J)return;let u=(await Promise.all(r.map(async(p)=>{try{return{name:p,at:(await b.promises.stat(f.join(e,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,d)=>d.at-p.at);for(let p of u.slice(J)){let d=p.name.slice(0,-3);await b.promises.rm(f.join(e,`${d}.js`),{force:!0}),await b.promises.rm(f.join(e,`${d}.deps.json`),{force:!0})}F("pruned bundle cache to",J,"entries")}catch{}}function ce(e){return se.get(e)??[]}function G(e,t){if(e)se.set(e,t)}function Fa(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function F(...e){if(Fa())console.log("[stx:bundler]",...e)}var q=[];function Di(e,t,r){q.push({filePath:e||"<inline>",message:t,details:r})}function ft(){return q.slice()}function gt(){q.length=0}var X;function $u(e){X=e}function Oi(){if(X)return X;try{let e=T.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var ee=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function mt(e){let t=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,r;while((r=t.exec(e))!==null){let u=r[1];if(!ee.some((d)=>d.test(u)))return F("detected user import:",u),!0}let l=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((r=l.exec(e))!==null){let u=r[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!ee.some((d)=>d.test(u)))return F("detected side-effect import:",u),!0}return!1}var nn="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function za(e,t){return f.relative(e,t).split(f.sep).join("/")}function Ha(e,t){if(t.size===0)return e;return e.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,(r,l,u,p)=>{let d=t.get(p);return d&&!p.startsWith(nn)?`${l}${u}${d}${u}`:r})}function Va(e,t){let r=0,l=(p)=>{let d=`__stxMod${r++}`,x=JSON.stringify(p);return t.push(`var ${d} = globalThis.__stxModules && globalThis.__stxModules[${x}];`,`if (${d} === undefined) throw new Error("[stx] module " + ${JSON.stringify(x)} + " is not registered on this page (#1957)");`),d},u=(p,d)=>{for(let x of p.split(",")){let v=x.trim();if(!v)continue;let c=v.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!c)continue;let n=c[1].startsWith('"')?JSON.parse(c[1]):c[1],a=c[2]??n;t.push(`var ${a} = ${d}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d,x)=>{let v=x.slice(nn.length),c=l(v),n=d.trim(),a=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(a&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${a[1]} = ${c}.default;`),n=n.slice(a[0].length).trim();let m=n.match(/^\*\s*as\s+([\w$]+)$/);if(m)t.push(`var ${m[1]} = ${c};`);else if(n.startsWith("{"))u(n.replace(/^\{|\}$/g,""),c);return""}),e=e.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d)=>(l(d.slice(nn.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,f.join(e,"index.ts"),f.join(e,"index.tsx"),f.join(e,"index.js"),f.join(e,"index.mjs")];for(let r of t)try{if(b.existsSync(r)&&b.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function $e(e,t,r,l,u,p=new Map,d){let x=(c,n,a)=>{if(z(n,e,d))return null;if(!u||c!==r||!xe.test(n))return null;try{if(!b.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let m=`${nn}${za(process.cwd(),n)}`;return p.set(a,m),{path:m,external:!0}},v=(c,n)=>{let a=c===r?t:f.dirname(c),m=f.resolve(a,n);return te(m)??m};return{name:"stx-client-bundle",setup(c){if(c.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(n)=>({path:n.path,external:!0})),c.onResolve({filter:/^\//},(n)=>{let a=te(n.path);if(a){let m=x(n.importer,a,n.path);if(m)return m;if(a!==r)l.add(a);return{path:a}}return{path:n.path,external:!0}}),c.onResolve({filter:/^\.\.?\//},(n)=>{let a=v(n.importer,n.path),m=x(n.importer,a,n.path);if(m)return m;return l.add(a),{path:a}}),c.onResolve({filter:/^[@~]\//},(n)=>{let a=f.resolve(e,n.path.slice(2)),m=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,f.join(a,"index.ts"),f.join(a,"index.tsx"),f.join(a,"index.js"),f.join(a,"index.mjs")];for(let w of m)if(b.existsSync(w)&&b.statSync(w,{throwIfNoEntry:!1})?.isFile()){let I=x(n.importer,w,n.path);if(I)return I;return F(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",w),l.add(w),{path:w}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:a}}),u)c.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let a=`${nn}npm:${n.path}`;return p.set(n.path,a),{path:a,external:!0}});c.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(z(n.path,e,d))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let a=f.extname(n.path).toLowerCase(),m=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:b.readFileSync(n.path,"utf8"),loader:m}})}}}var W=new Map,L=P(64),ne=Symbol.for("stx.client-bundle-build-queue");function Ua(e){let t=globalThis,l=(t[ne]??Promise.resolve()).then(e,e);return t[ne]=l.then(()=>{return},()=>{return}),l}async function ht(e,t,r={}){let l=r.projectRoot||process.cwd(),u=(await i(l)).serverApi,p=r.minify??!1,d=r.externalizeUserModules??!0,x=r.cacheDir||o(l,"bundle-cache"),v=new Bun.CryptoHasher("md5");v.update(`${me}\x00${he()}\x00${JSON.stringify(u??!1)}\x00${d?"registry":"inline"}\x00${e}\x00${t}`);let c=v.digest("hex").slice(0,12),n=f.join(x,`${c}.js`),a=L.get(n);if(a){if(kt(a.files)&&a.files.every((E)=>!z(E.path,l,u))){F("memo hit:",c);let E=a.files.map((S)=>S.path);return G(t,E),r.collectInputs?.push(...E),a.code}L.delete(n),F("memo invalidated by dep change:",c)}let m=f.join(x,`${c}.deps.json`),w=Bun.file(n);if(await w.exists()){let E=Bun.file(m),S=!1,B=null;if(await E.exists())try{let D=JSON.parse(await E.text());if(D.metadataVersion!==re||!Array.isArray(D.files))S=!1;else B=D.files,S=!0;if(B&&(!kt(B)||B.some((N)=>z(N.path,l,u))))S=!1}catch{S=!1}if(S){if(F("cache hit:",c),B)G(t,B.map((N)=>N.path)),r.collectInputs?.push(...B.map((N)=>N.path));let D=await w.text();if(B)L.set(n,{code:D,files:B});return D}F("cache invalidated by dep change:",c)}let I=W.get(c);if(I){let E=await I;if(r.collectInputs)r.collectInputs.push(...(L.get(n)?.files??[]).map((S)=>S.path));return E}let _=Ua(()=>ye(e,t,{projectRoot:l,minify:p,cacheDir:x,hash:c,cachePath:n,depsPath:m,collectInputs:r.collectInputs,externalizeUserModules:d,serverApi:u}));W.set(c,_);try{return await _}finally{W.delete(c)}}var be=0;function Wa(e){return`${e}-${process.pid}-${++be}`}async function ye(e,t,r){let{projectRoot:l,minify:u,cacheDir:p,hash:d,cachePath:x,depsPath:v,externalizeUserModules:c}=r,n=o(l,"bundle-tmp"),a=Wa(d),m=f.join(n,`${a}.ts`),w=f.join(n,"out",a);b.mkdirSync(n,{recursive:!0}),b.mkdirSync(w,{recursive:!0});let I=f.dirname(t),_=new Set,E=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,S=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,B=s(e),{depths:D,balanced:N}=we(B),H=(j)=>!N||D[j]===0,M;while((M=E.exec(B))!==null){if(M[1])continue;if(!H(M.index))continue;if(M[2])M[2].split(",").forEach((j)=>{let h=Be(j);if(h)_.add(h)});else if(M[3])_.add(M[3])}while((M=S.exec(B))!==null){if(M[1])continue;if(!H(M.index))continue;_.add(M[2])}let ie=_.size>0?`
5
5
  export { ${[..._].join(", ")} }`:"";await Bun.write(m,e+ie),F("bundling:",d,"from:",f.basename(t));let Z=new Set,Y=new Map;try{let j=await Bun.build({entrypoints:[m],outdir:w,target:"browser",format:"esm",minify:u,plugins:[$e(l,I,m,Z,c,Y,r.serverApi)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...y()},root:l});if(!j.success){let R=j.logs.filter((k)=>k.level==="error").map((k)=>k.message).join(", ")||`Unable to bundle ${f.basename(t)}`,C=U(j.logs,t||void 0);if(console.warn("[stx:bundler] build failed:",R),Di(t||"",R,C),Oi()==="error")throw Error(R);return e}let h="";for(let g of j.outputs){h=await g.text();break}let A=[];for(let g of h.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let R of g[1].split(",")){let C=R.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(C){A.push([C[2],C[1]]);continue}let k=R.trim();if(/^[A-Za-z_$][\w$]*$/.test(k))A.push([k,k])}let Q=[];h=Va(Ha(h,Y),Q);let oe=h.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];h=h.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let K=`__stxBundle_${d}`,ae=A.map(([g,R])=>`${JSON.stringify(g)}: ${R}`).join(", "),le=A.map(([g])=>`var ${g} = undefined;`).join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m}from"./chunk-ce1sejr3.js";import{W,xt,He,hs,ys,Yi,Zi,Qi,eo,Wn,bs,to,no,ro,i}from"./chunk-69mc2np8.js";import{Mr}from"./chunk-v4vaqxrf.js";import{o}from"./chunk-fzapbw9p.js";import{existsSync as M,readFileSync as K}from"fs";import b from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=xt.filter((e)=>!me.has(e)).sort(),ne=[...m].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let h of l[1].matchAll(/[^,]+/g)){let S=h[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let c=x[1];if(!xe.has(c)||s.has(c))continue;let f=u.offset+g+h.index+x[0].length-c.length,p=e.slice(0,f),w=p.split(`
2
+ import{m}from"./chunk-ce1sejr3.js";import{W,xt,He,hs,ys,Yi,Zi,Qi,eo,Wn,bs,to,no,ro,i}from"./chunk-3efw27as.js";import{Mr}from"./chunk-g186znp9.js";import{o}from"./chunk-fzapbw9p.js";import{existsSync as M,readFileSync as K}from"fs";import b from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=xt.filter((e)=>!me.has(e)).sort(),ne=[...m].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let r=[];for(let u of t){if(u.offset===void 0)continue;let s=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let h of l[1].matchAll(/[^,]+/g)){let S=h[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let c=x[1];if(!xe.has(c)||s.has(c))continue;let f=u.offset+g+h.index+x[0].length-c.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;r.push({line:w,column:f-(p.lastIndexOf(`
4
4
  `)+1)+1,offset:f,length:c.length,name:c,kind:u.kind,message:Se(c,u.kind)})}}}return r}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(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 se(e,t,r){let u=we(e,r);if(!u)return;let s=new Set,l=(g)=>{if(s.has(g))return;s.add(g);let h=t(g);if(!h)return;let S=h.compilerOptions?.plugins;if(Array.isArray(S)){let c=S.find((p)=>p?.name===ke),f=Array.isArray(c?.libs)?c.libs.filter((p)=>typeof p==="string"):[];return c?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof h.extends==="string"?[h.extends]:Array.isArray(h.extends)?h.extends:[];for(let c of[...x].reverse()){if(typeof c!=="string"||!c.startsWith("."))continue;let f=T.resolve(T.dirname(g),c.endsWith(".json")?c:`${c}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Wo(e,t="",r=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",s=bs(e)+ys(hs(e.code)),l=e.kind==="client"||e.kind==="plain"?Qi(t,e.code):"";return Wn(`${u+s}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{p,l}from"./chunk-z0g9jvv0.js";import{h}from"./chunk-69mc2np8.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var x=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function b(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=b(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=b(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let c=i.lastIndexOf(u);if(c!==-1)i.splice(c);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let c=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=g||x.has(u)?-1:N(t,u,s);if(S===-1)o.push({start:n,end:s,slotName:c,element:m}),e=s;else o.push({start:n,end:S,slotName:c,element:m+t.slice(s,S)}),e=S;continue}if(!g&&!x.has(u)){if(i.push(u),u==="script"||u==="style"){let c=t.toLowerCase().indexOf(`</${u}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=b(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let c=i.lastIndexOf(g);if(c!==-1)i.splice(c);e=s;continue}if(g==="template"&&i.length===0){let c=a.match(r);if(c){let m=y(t,s);if(m!==-1){let S=c[1]||c[2]||c[3];o.push({start:n,end:m,slotName:S,content:t.slice(s,m-11).trim(),propsBinding:c[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!x.has(g)){if(i.push(g),g==="script"||g==="style"){let c=t.toLowerCase().indexOf(`</${g}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function Zo(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function dl(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function Qo(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((c)=>c.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return h(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return l(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ea(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",c=f||"",m={},S=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,w;while((w=S.exec(c))!==null){let E=w[1],R=w[2];m[E]=k(R,i)}return await Qo(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function pl(t){let o=Zo(t);return{defaultSlot:o.default,namedSlots:o.named}}async function fl(t,o,i,r){return await ea(t,{default:o,named:i},r)}
2
+ import{p,l}from"./chunk-z0g9jvv0.js";import{h}from"./chunk-3efw27as.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var x=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function b(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=b(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=b(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let c=i.lastIndexOf(u);if(c!==-1)i.splice(c);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let c=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=g||x.has(u)?-1:N(t,u,s);if(S===-1)o.push({start:n,end:s,slotName:c,element:m}),e=s;else o.push({start:n,end:S,slotName:c,element:m+t.slice(s,S)}),e=S;continue}if(!g&&!x.has(u)){if(i.push(u),u==="script"||u==="style"){let c=t.toLowerCase().indexOf(`</${u}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=b(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let c=i.lastIndexOf(g);if(c!==-1)i.splice(c);e=s;continue}if(g==="template"&&i.length===0){let c=a.match(r);if(c){let m=y(t,s);if(m!==-1){let S=c[1]||c[2]||c[3];o.push({start:n,end:m,slotName:S,content:t.slice(s,m-11).trim(),propsBinding:c[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!x.has(g)){if(i.push(g),g==="script"||g==="style"){let c=t.toLowerCase().indexOf(`</${g}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function Zo(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function dl(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function Qo(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((c)=>c.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return h(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return l(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ea(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",c=f||"",m={},S=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,w;while((w=S.exec(c))!==null){let E=w[1],R=w[2];m[E]=k(R,i)}return await Qo(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function pl(t){let o=Zo(t);return{defaultSlot:o.default,namedSlots:o.named}}async function fl(t,o,i,r){return await ea(t,{default:o,named:i},r)}
3
3
  export{Zo,dl,Qo,ea,pl,fl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Rt,S}from"./chunk-ngc2wke4.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=Rt();if(n||i){r.__stx_runtime_config=n??S(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-syaw6b75.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=S(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function xs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
2
+ import{Rt,S}from"./chunk-ngc2wke4.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=Rt();if(n||i){r.__stx_runtime_config=n??S(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-hpgr4qgp.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=S(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function xs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
3
3
  declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
4
4
  `),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
5
5
  declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{i}from"./chunk-69mc2np8.js";import{Cr}from"./chunk-9g27ybyr.js";import p from"path";async function cl(t={}){let d=performance.now(),o=t.root||process.cwd(),e=await i(o),u=t.ssr?.routeRules??e.routeRules??{};if(Cr(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:s}=await import("./ssg.js");n=await s({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:s}=await import("./chunk-6y8hnymb.js");l=await s({root:o,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
2
+ import{i}from"./chunk-3efw27as.js";import{Cr}from"./chunk-9g27ybyr.js";import p from"path";async function cl(t={}){let d=performance.now(),o=t.root||process.cwd(),e=await i(o),u=t.ssr?.routeRules??e.routeRules??{};if(Cr(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:s}=await import("./ssg.js");n=await s({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:s}=await import("./chunk-gqv3ta5d.js");l=await s({root:o,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
3
  export{cl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m}from"./chunk-ce1sejr3.js";import{R,Pt}from"./chunk-8nhshfz6.js";import{y,ze,N,i}from"./chunk-69mc2np8.js";import{ce,mt,ht}from"./chunk-mepdnezf.js";import{De,Xt,Q}from"./chunk-f46qsp4m.js";import f from"path";var l=new Map;function v(a,s){for(let n of a.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(n[1])s.add(n[1]);for(let n of a.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let r of(n[1]??"").split(",")){let o=((r.includes(":")?r.split(":").pop():r)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(o))s.add(o)}for(let n of a.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let r of(n[1]??"").split(",")){let c=r.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(c))s.add(c)}}async function ql(a){let s;if(a)s=f.resolve(a);else{let t=await i();s=f.resolve(t.root||process.cwd(),t.storesDir||"stores")}let n=new Bun.Glob("*.ts"),r=[];try{for await(let t of n.scan({cwd:s,absolute:!0})){let e=f.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return Q(l,s,"",""),null}let c=()=>[...new Set([...r,...r.flatMap((t)=>ce(t))])],o=De(c()),d=Xt(l,s,o);if(d!==void 0)return d||null;if(r.length===0)return Q(l,s,o,""),null;let p=[];for(let t of r){let e=await Bun.file(t).text();p.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}p.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let w=p.map((t)=>t.file),u=[],g=new Set,b=N({loader:"ts",target:"browser",define:y()});for(let t of w)try{let e=await Bun.file(t).text(),x=f.basename(t,".ts");if(v(e,g),mt(e))e=await ht(e,t,{projectRoot:process.cwd(),externalizeUserModules:!1});e=ze(e),e=R(e),e=Pt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=b.transformSync(e),u.push(`// Store: ${x}
2
+ import{m}from"./chunk-ce1sejr3.js";import{R,Pt}from"./chunk-8nhshfz6.js";import{y,ze,N,i}from"./chunk-3efw27as.js";import{ce,mt,ht}from"./chunk-42wbs8vq.js";import{De,Xt,Q}from"./chunk-f46qsp4m.js";import f from"path";var l=new Map;function v(a,s){for(let n of a.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(n[1])s.add(n[1]);for(let n of a.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let r of(n[1]??"").split(",")){let o=((r.includes(":")?r.split(":").pop():r)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(o))s.add(o)}for(let n of a.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let r of(n[1]??"").split(",")){let c=r.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(c))s.add(c)}}async function ql(a){let s;if(a)s=f.resolve(a);else{let t=await i();s=f.resolve(t.root||process.cwd(),t.storesDir||"stores")}let n=new Bun.Glob("*.ts"),r=[];try{for await(let t of n.scan({cwd:s,absolute:!0})){let e=f.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return Q(l,s,"",""),null}let c=()=>[...new Set([...r,...r.flatMap((t)=>ce(t))])],o=De(c()),d=Xt(l,s,o);if(d!==void 0)return d||null;if(r.length===0)return Q(l,s,o,""),null;let p=[];for(let t of r){let e=await Bun.file(t).text();p.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}p.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let w=p.map((t)=>t.file),u=[],g=new Set,b=N({loader:"ts",target:"browser",define:y()});for(let t of w)try{let e=await Bun.file(t).text(),x=f.basename(t,".ts");if(v(e,g),mt(e))e=await ht(e,t,{projectRoot:process.cwd(),externalizeUserModules:!1});e=ze(e),e=R(e),e=Pt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=b.transformSync(e),u.push(`// Store: ${x}
3
3
  ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(u.length===0)return Q(l,s,o,""),null;let h=u.join(`
4
4
 
5
5
  `),S=`;(function(){
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ql,Xl}from"./chunk-dvgv8nry.js";import"./chunk-mepdnezf.js";import"./chunk-xtdw3692.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Xl as clearStoreCache,ql as getStoreScript};
2
+ import{ql,Xl}from"./chunk-amtr3rmf.js";import"./chunk-42wbs8vq.js";import"./chunk-hepd9qgx.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Xl as clearStoreCache,ql as getStoreScript};
@@ -18,7 +18,7 @@ catch (e) {
18
18
  }
19
19
  throw e;
20
20
  }
21
- `),i.set(u,g)}return g(...d)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:c,context:n.slice()});return c}clear(){this.pool.length=0,this.fnCache.clear()}}var St=new Pe;class Be{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(t){this.enabled=t}isEnabled(){return this.enabled}setBudget(t,n){this.budgets.set(t,{warnThreshold:0.8,action:"warn",...n})}setBudgets(t){for(let[n,r]of Object.entries(t))this.setBudget(n,r)}removeBudget(t){this.budgets.delete(t)}getBudgets(){let t={};for(let[n,r]of this.budgets.entries())t[n]=r;return t}onViolation(t){this.violationHandlers.push(t)}offViolation(t){let n=this.violationHandlers.indexOf(t);if(n!==-1)this.violationHandlers.splice(n,1)}time(t,n){if(!this.enabled)return n();let r=performance.now(),s=n(),i=performance.now()-r;return this.recordTime(t,i),this.checkBudget(t,i),s}async timeAsync(t,n){if(!this.enabled)return n();let r=performance.now(),s=await n(),i=performance.now()-r;return this.recordTime(t,i),this.checkBudget(t,i),s}checkBudget(t,n){let r=this.budgets.get(t);if(!r)return;let s=n/r.maxTime*100,i=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,a=n>=r.maxTime;if(!i&&!a)return;let c={label:t,actualTime:n,budgetTime:r.maxTime,exceedancePercent:s,timestamp:new Date,isWarning:i};this.violations.push(c);while(this.violations.length>this.maxViolations)this.violations.shift();for(let l of this.violationHandlers)try{l(c)}catch{}let d=i?`[Performance Warning] "${t}" took ${n.toFixed(2)}ms (${s.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${t}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(s-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d);break;case"throw":if(a)throw Error(d);else console.warn(d);break}}recordTime(t,n){let r=this.metrics.get(t);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(t,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(t){if(t){let r=this.metrics.get(t);if(!r)return{};let s=this.budgets.get(t);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:s?.maxTime,budgetUtilization:s?r.totalTime/r.count/s.maxTime*100:void 0}}let n={};for(let[r,s]of this.metrics.entries()){let i=this.budgets.get(r);n[r]={count:s.count,avgTime:s.totalTime/s.count,totalTime:s.totalTime,maxTime:s.maxTime,minTime:s.minTime,budget:i?.maxTime,budgetUtilization:i?s.totalTime/s.count/i.maxTime*100:void 0}}return n}getViolations(t){if(t)return this.violations.filter((n)=>n.label===t);return[...this.violations]}getViolationStats(){let t={},n=0,r=0;for(let s of this.violations)if(t[s.label]=(t[s.label]||0)+1,s.isWarning)n++;else r++;return{total:this.violations.length,byLabel:t,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var se=null;function et(){if(!se)se=new Be;return se}var H=new Proxy({},{get(t,n){return et()[n]}});var Me=[];function P(t){let n=new z(t);return Me.push(n),n}function ho(){for(let t of Me)t.clear()}function D(t,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${t.length}\x00${Bun.hash(t)}`}function yo(t){let n=[];for(let r of new Set(t))try{n.push({path:r,mtimeMs:_e.statSync(r).mtimeMs})}catch{}return n}function kt(t){for(let n of t)try{if(_e.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var y=null,ie=!1,w=null,B="",v=!1,De=256,k=new Map,b=new Map,A=null,ze=null,O=new Map;function j(t){return Bun.hash(t).toString(16).padStart(16,"0").slice(0,16)}function re(t,n){if(k.has(t))k.delete(t);else if(k.size>=De)k.delete(k.keys().next().value);k.set(t,n)}function tt(t){let n=j(t);if(b.has(n))b.delete(n);else if(b.size>=De)b.delete(b.keys().next().value);return b.set(n,t),n}function zu(t){let n=b.get(t);if(n===void 0)return;return b.delete(t),b.set(t,n),n}async function nt(t,n=A){if(!n)return null;try{let r=Bun.file(h.join(n,`cw-${j(t)}.css`));if(!await r.exists())return null;return await r.text()}catch{return null}}async function st(t,n,r=A){if(!r)return;try{if(!fs.existsSync(r))fs.mkdirSync(r,{recursive:!0});await Bun.write(h.join(r,`cw-${j(t)}.css`),n)}catch{}}async function Oe(t){try{let n=await import(t);if(n&&n.CSSGenerator)return{CSSGenerator:n.CSSGenerator,config:n.config,build:n.build,defaultConfig:n.defaultConfig,extractClasses:n.extractClasses}}catch{}return null}var rt=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],it=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function ot(){let t=[],n=process.cwd();while(n!==h.dirname(n)){for(let r of["node_modules","pantry"])for(let s of rt)t.push(h.join(n,r,...s));n=h.dirname(n)}return t}function at(){let t=[],n=process.env.HOME||process.env.USERPROFILE||"",r=[n&&h.join(n,"Code","Tools","ts-css"),n&&h.join(n,"Code","Tools","crosswind"),n&&h.join(n,"repos","stacks-org","ts-css"),n&&h.join(n,"repos","stacks-org","crosswind"),h.join(process.cwd(),"..","ts-css"),h.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let s of r)t.push(h.join(s,"packages","toolkit","dist","engine","index.js")),t.push(h.join(s,"packages","toolkit","src","engine","index.ts"));if(n)t.push(h.join(n,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return t}async function vo(){if(ie)return y;ie=!0;try{let t=async(i)=>{for(let a of i){if(!await Bun.file(a).exists())continue;let c=await Oe(a);if(c){if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${h.dirname(h.dirname(a))}`);return c}}return null};if(process.env.CROSSWIND_SRC){let i=h.resolve(process.env.CROSSWIND_SRC),a=await t([i]);if(!a)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return y=a,y}let n=await t(ot());if(n)return y=n,y;let r=it;for(let i of r){let a=await Oe(i);if(a){if(y=a,!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return y}}let s=await t(at());if(s)return y=s,y;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Hu(){oe.clear(),y=null,ie=!1,w=null,B="",k.clear(),b.clear(),ze=null,O.clear()}var je=!1;async function wo(t){try{let n=Ae({name:"css",cwd:t})?"css":Ae({name:"crosswind",cwd:t})?"crosswind":null;if(!n)return null;if(n==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!je)je=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:r}=await import("bunfig"),s=await r({name:n,cwd:t,defaultConfig:{},checkEnv:!1,verbose:!1});if(!s?.path||!s.config||Object.keys(s.config).length===0)return null;let i=h.relative(t,s.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||s.path}`);return s.config}catch(n){if(n instanceof Error&&n.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,n instanceof Error?n.message:n),null}}async function Cc(t){let n=null;try{let{loadStxConfig:r}=await import("./chunk-syaw6b75.js"),s=await r(t);if(s.css)if(typeof s.css==="string"){let i=h.isAbsolute(s.css)?s.css:h.resolve(t,s.css);if(await Bun.file(i).exists()){let a=await import(i);n=a.default||a,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${s.css}`)}}else{if(n={...s.css,content:s.css.content||[],preflight:s.css.preflight??!0,minify:s.css.minify??!1},s.css.config){let i=h.isAbsolute(s.css.config)?s.css.config:h.resolve(t,s.css.config);if(await Bun.file(i).exists()){let a=await import(i);n={...a.default||a,...n}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return n||await wo(t)}function $c(t){try{let n=new WeakSet;return j(JSON.stringify(t??{},(r,s)=>{if(typeof s==="function")return`[fn]${String(s)}`;if(typeof s==="object"&&s!==null){if(n.has(s))return"[circular]";n.add(s)}return s})??"")}catch{return"unhashable"}}async function Tt(t){if(v)return B;v=!0;try{let n=await vo();if(!n||!n.build)return v=!1,"";if(!w)w=await wo(t);if(!w)return v=!1,"";let r=n.defaultConfig?.theme||{},s=w.theme||{},i={...n.defaultConfig,...w,theme:{...r,...s,extend:{...r.extend||{},...s.extend||{}}}},a=performance.now(),c=await n.build(i),d=performance.now()-a;if(B=c.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${c.classes.size} classes in ${d.toFixed(1)}ms`),i.output){let l=h.isAbsolute(i.output)?i.output:h.join(t,i.output),u=h.dirname(l);if(!fs.existsSync(u))fs.mkdirSync(u,{recursive:!0});await Bun.write(l,c.css)}return v=!1,c.css}catch(n){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,n),v=!1,B}}async function ln(t){w=null,await Tt(t)}function Vu(){return B}function Ec(t){let n=new Set,r=/class\s*=\s*["']([^"']+)["']/gi,s=r.exec(t);while(s!==null){for(let c of s[1].split(/\s+/))if(c.trim())n.add(c.trim());s=r.exec(t)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,a=i.exec(t);while(a!==null){let c=a[1].match(/'([^']+)'/g);if(c){for(let d of c)for(let l of d.slice(1,-1).split(/\s+/))if(l.trim())n.add(l.trim())}a=i.exec(t)}return n}var oe=P(64);async function Tc(t,n){let r=()=>O.get(n?h.resolve(n):process.cwd())?.fingerprint??null,s=oe.get(D(t,n,r()));if(s!==void 0)return s;let i=await ct(t,n);if(i)oe.set(D(t,n,r()),i);return i}async function ct(t,n){try{let r=await vo();if(!r)return"";let s=typeof r.extractClasses==="function"?r.extractClasses(t):Ec(t);if(s.size===0)return"";let i=n?h.resolve(n):process.cwd(),a=o(i,"cache");if(!A)A=a;let c=O.get(i);if(!c){let x=await Cc(i);c={config:x,fingerprint:$c(x)},O.set(i,c),ze=c.fingerprint}let d=[...s].sort().join(" "),l=`${c.fingerprint||"default"}::${d}`,u=k.get(l);if(u!==void 0)return re(l,u),u;let g=await nt(l,a);if(g!==null)return re(l,g),g;let p=r.defaultConfig||r.config,m=c.config||{},S=be(p,m),{safelist:C,includePreflight:ae,minify:ce,tokenCSS:Ie}=S,I=S.config,L=new r.CSSGenerator(I),K=I.shortcuts||m.shortcuts||{},le=Object.keys(K).filter((x)=>s.has(x)||C.includes(x));for(let x of C)if(!K[x])L.generate(x);for(let x of s)if(!K[x])L.generate(x);let E="";if(le.length>0){let x=new r.CSSGenerator(I);for(let Le of le)x.generate(Le);if(E=x.toCSS(!1,ce),E&&!E.endsWith(`
21
+ `),i.set(u,g)}return g(...d)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:c,context:n.slice()});return c}clear(){this.pool.length=0,this.fnCache.clear()}}var St=new Pe;class Be{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(t){this.enabled=t}isEnabled(){return this.enabled}setBudget(t,n){this.budgets.set(t,{warnThreshold:0.8,action:"warn",...n})}setBudgets(t){for(let[n,r]of Object.entries(t))this.setBudget(n,r)}removeBudget(t){this.budgets.delete(t)}getBudgets(){let t={};for(let[n,r]of this.budgets.entries())t[n]=r;return t}onViolation(t){this.violationHandlers.push(t)}offViolation(t){let n=this.violationHandlers.indexOf(t);if(n!==-1)this.violationHandlers.splice(n,1)}time(t,n){if(!this.enabled)return n();let r=performance.now(),s=n(),i=performance.now()-r;return this.recordTime(t,i),this.checkBudget(t,i),s}async timeAsync(t,n){if(!this.enabled)return n();let r=performance.now(),s=await n(),i=performance.now()-r;return this.recordTime(t,i),this.checkBudget(t,i),s}checkBudget(t,n){let r=this.budgets.get(t);if(!r)return;let s=n/r.maxTime*100,i=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,a=n>=r.maxTime;if(!i&&!a)return;let c={label:t,actualTime:n,budgetTime:r.maxTime,exceedancePercent:s,timestamp:new Date,isWarning:i};this.violations.push(c);while(this.violations.length>this.maxViolations)this.violations.shift();for(let l of this.violationHandlers)try{l(c)}catch{}let d=i?`[Performance Warning] "${t}" took ${n.toFixed(2)}ms (${s.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${t}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(s-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d);break;case"throw":if(a)throw Error(d);else console.warn(d);break}}recordTime(t,n){let r=this.metrics.get(t);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(t,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(t){if(t){let r=this.metrics.get(t);if(!r)return{};let s=this.budgets.get(t);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:s?.maxTime,budgetUtilization:s?r.totalTime/r.count/s.maxTime*100:void 0}}let n={};for(let[r,s]of this.metrics.entries()){let i=this.budgets.get(r);n[r]={count:s.count,avgTime:s.totalTime/s.count,totalTime:s.totalTime,maxTime:s.maxTime,minTime:s.minTime,budget:i?.maxTime,budgetUtilization:i?s.totalTime/s.count/i.maxTime*100:void 0}}return n}getViolations(t){if(t)return this.violations.filter((n)=>n.label===t);return[...this.violations]}getViolationStats(){let t={},n=0,r=0;for(let s of this.violations)if(t[s.label]=(t[s.label]||0)+1,s.isWarning)n++;else r++;return{total:this.violations.length,byLabel:t,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var se=null;function et(){if(!se)se=new Be;return se}var H=new Proxy({},{get(t,n){return et()[n]}});var Me=[];function P(t){let n=new z(t);return Me.push(n),n}function ho(){for(let t of Me)t.clear()}function D(t,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${t.length}\x00${Bun.hash(t)}`}function yo(t){let n=[];for(let r of new Set(t))try{n.push({path:r,mtimeMs:_e.statSync(r).mtimeMs})}catch{}return n}function kt(t){for(let n of t)try{if(_e.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var y=null,ie=!1,w=null,B="",v=!1,De=256,k=new Map,b=new Map,A=null,ze=null,O=new Map;function j(t){return Bun.hash(t).toString(16).padStart(16,"0").slice(0,16)}function re(t,n){if(k.has(t))k.delete(t);else if(k.size>=De)k.delete(k.keys().next().value);k.set(t,n)}function tt(t){let n=j(t);if(b.has(n))b.delete(n);else if(b.size>=De)b.delete(b.keys().next().value);return b.set(n,t),n}function zu(t){let n=b.get(t);if(n===void 0)return;return b.delete(t),b.set(t,n),n}async function nt(t,n=A){if(!n)return null;try{let r=Bun.file(h.join(n,`cw-${j(t)}.css`));if(!await r.exists())return null;return await r.text()}catch{return null}}async function st(t,n,r=A){if(!r)return;try{if(!fs.existsSync(r))fs.mkdirSync(r,{recursive:!0});await Bun.write(h.join(r,`cw-${j(t)}.css`),n)}catch{}}async function Oe(t){try{let n=await import(t);if(n&&n.CSSGenerator)return{CSSGenerator:n.CSSGenerator,config:n.config,build:n.build,defaultConfig:n.defaultConfig,extractClasses:n.extractClasses}}catch{}return null}var rt=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],it=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function ot(){let t=[],n=process.cwd();while(n!==h.dirname(n)){for(let r of["node_modules","pantry"])for(let s of rt)t.push(h.join(n,r,...s));n=h.dirname(n)}return t}function at(){let t=[],n=process.env.HOME||process.env.USERPROFILE||"",r=[n&&h.join(n,"Code","Tools","ts-css"),n&&h.join(n,"Code","Tools","crosswind"),n&&h.join(n,"repos","stacks-org","ts-css"),n&&h.join(n,"repos","stacks-org","crosswind"),h.join(process.cwd(),"..","ts-css"),h.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let s of r)t.push(h.join(s,"packages","toolkit","dist","engine","index.js")),t.push(h.join(s,"packages","toolkit","src","engine","index.ts"));if(n)t.push(h.join(n,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return t}async function vo(){if(ie)return y;ie=!0;try{let t=async(i)=>{for(let a of i){if(!await Bun.file(a).exists())continue;let c=await Oe(a);if(c){if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${h.dirname(h.dirname(a))}`);return c}}return null};if(process.env.CROSSWIND_SRC){let i=h.resolve(process.env.CROSSWIND_SRC),a=await t([i]);if(!a)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return y=a,y}let n=await t(ot());if(n)return y=n,y;let r=it;for(let i of r){let a=await Oe(i);if(a){if(y=a,!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return y}}let s=await t(at());if(s)return y=s,y;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Hu(){oe.clear(),y=null,ie=!1,w=null,B="",k.clear(),b.clear(),ze=null,O.clear()}var je=!1;async function wo(t){try{let n=Ae({name:"css",cwd:t})?"css":Ae({name:"crosswind",cwd:t})?"crosswind":null;if(!n)return null;if(n==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!je)je=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:r}=await import("bunfig"),s=await r({name:n,cwd:t,defaultConfig:{},checkEnv:!1,verbose:!1});if(!s?.path||!s.config||Object.keys(s.config).length===0)return null;let i=h.relative(t,s.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||s.path}`);return s.config}catch(n){if(n instanceof Error&&n.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,n instanceof Error?n.message:n),null}}async function Cc(t){let n=null;try{let{loadStxConfig:r}=await import("./chunk-hpgr4qgp.js"),s=await r(t);if(s.css)if(typeof s.css==="string"){let i=h.isAbsolute(s.css)?s.css:h.resolve(t,s.css);if(await Bun.file(i).exists()){let a=await import(i);n=a.default||a,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${s.css}`)}}else{if(n={...s.css,content:s.css.content||[],preflight:s.css.preflight??!0,minify:s.css.minify??!1},s.css.config){let i=h.isAbsolute(s.css.config)?s.css.config:h.resolve(t,s.css.config);if(await Bun.file(i).exists()){let a=await import(i);n={...a.default||a,...n}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return n||await wo(t)}function $c(t){try{let n=new WeakSet;return j(JSON.stringify(t??{},(r,s)=>{if(typeof s==="function")return`[fn]${String(s)}`;if(typeof s==="object"&&s!==null){if(n.has(s))return"[circular]";n.add(s)}return s})??"")}catch{return"unhashable"}}async function Tt(t){if(v)return B;v=!0;try{let n=await vo();if(!n||!n.build)return v=!1,"";if(!w)w=await wo(t);if(!w)return v=!1,"";let r=n.defaultConfig?.theme||{},s=w.theme||{},i={...n.defaultConfig,...w,theme:{...r,...s,extend:{...r.extend||{},...s.extend||{}}}},a=performance.now(),c=await n.build(i),d=performance.now()-a;if(B=c.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${c.classes.size} classes in ${d.toFixed(1)}ms`),i.output){let l=h.isAbsolute(i.output)?i.output:h.join(t,i.output),u=h.dirname(l);if(!fs.existsSync(u))fs.mkdirSync(u,{recursive:!0});await Bun.write(l,c.css)}return v=!1,c.css}catch(n){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,n),v=!1,B}}async function ln(t){w=null,await Tt(t)}function Vu(){return B}function Ec(t){let n=new Set,r=/class\s*=\s*["']([^"']+)["']/gi,s=r.exec(t);while(s!==null){for(let c of s[1].split(/\s+/))if(c.trim())n.add(c.trim());s=r.exec(t)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,a=i.exec(t);while(a!==null){let c=a[1].match(/'([^']+)'/g);if(c){for(let d of c)for(let l of d.slice(1,-1).split(/\s+/))if(l.trim())n.add(l.trim())}a=i.exec(t)}return n}var oe=P(64);async function Tc(t,n){let r=()=>O.get(n?h.resolve(n):process.cwd())?.fingerprint??null,s=oe.get(D(t,n,r()));if(s!==void 0)return s;let i=await ct(t,n);if(i)oe.set(D(t,n,r()),i);return i}async function ct(t,n){try{let r=await vo();if(!r)return"";let s=typeof r.extractClasses==="function"?r.extractClasses(t):Ec(t);if(s.size===0)return"";let i=n?h.resolve(n):process.cwd(),a=o(i,"cache");if(!A)A=a;let c=O.get(i);if(!c){let x=await Cc(i);c={config:x,fingerprint:$c(x)},O.set(i,c),ze=c.fingerprint}let d=[...s].sort().join(" "),l=`${c.fingerprint||"default"}::${d}`,u=k.get(l);if(u!==void 0)return re(l,u),u;let g=await nt(l,a);if(g!==null)return re(l,g),g;let p=r.defaultConfig||r.config,m=c.config||{},S=be(p,m),{safelist:C,includePreflight:ae,minify:ce,tokenCSS:Ie}=S,I=S.config,L=new r.CSSGenerator(I),K=I.shortcuts||m.shortcuts||{},le=Object.keys(K).filter((x)=>s.has(x)||C.includes(x));for(let x of C)if(!K[x])L.generate(x);for(let x of s)if(!K[x])L.generate(x);let E="";if(le.length>0){let x=new r.CSSGenerator(I);for(let Le of le)x.generate(Le);if(E=x.toCSS(!1,ce),E&&!E.endsWith(`
22
22
  `))E+=`
23
23
  `}let R=E+L.toCSS(ae,ce);return R=Ie+R,re(l,R),st(l,R,a),R}catch(r){return console.warn("Failed to generate Css CSS:",r),""}}async function f(t,n,r=!1,s=!1){let i=await Tc(t,n);if(!i)return s?cn(t):t;let a=r?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${tt(i)}.css">`:`<style data-css="generated">
24
24
  ${i}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{wi,xi,Si,ku}from"./chunk-sd47dzs0.js";import"./chunk-ynvdvbat.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{wi as buildNative,ku as default,Si as getAvailableFormats,xi as getAvailableTargets};
2
+ import{wi,xi,Si,ku}from"./chunk-hkrmcbwy.js";import"./chunk-wzx0164n.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{wi as buildNative,ku as default,Si as getAvailableFormats,xi as getAvailableTargets};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import{y,N}from"./chunk-69mc2np8.js";import"./chunk-z0g9jvv0.js";import{P,D}from"./chunk-h0atqq82.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-2gr351s0.js";import"./chunk-7gkv67ky.js";import"./chunk-752hw7cd.js";import f from"path";var b=["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","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","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"],M=new Set(b);var l=new Map,h=P(64),S=new Set,v=0,C=new Set(b);function W(){l.clear(),h.clear()}function E(o){let n=new Map;for(let r of o){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=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function R(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function I(o){if(!o)return[];let n=D(o,v),r=h.get(n);if(r)return r.slice();let a=o.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 C){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=I(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=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=E(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)=>k.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$/,"")}
2
+ import"./chunk-ce1sejr3.js";import"./chunk-8nhshfz6.js";import{y,N}from"./chunk-3efw27as.js";import"./chunk-z0g9jvv0.js";import{P,D}from"./chunk-b98be3yp.js";import"./chunk-shr559s7.js";import"./chunk-czxt605c.js";import"./chunk-m4sk62wb.js";import"./chunk-xfp7k0v8.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-9amp82bx.js";import"./chunk-7gkv67ky.js";import"./chunk-752hw7cd.js";import f from"path";var b=["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","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","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"],M=new Set(b);var l=new Map,h=P(64),S=new Set,v=0,C=new Set(b);function W(){l.clear(),h.clear()}function E(o){let n=new Map;for(let r of o){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=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function R(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function I(o){if(!o)return[];let n=D(o,v),r=h.get(n);if(r)return r.slice();let a=o.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 C){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=I(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=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=E(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)=>k.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
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 w=r.filter((s)=>!d.has(s)&&!R(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.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 O=[...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
4
  `),x=`<script data-stx-framework-composables>
5
5
  ;(function(){
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Gc}from"./chunk-daz5aqcf.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Gc as startInteractive};
2
+ import{Gc}from"./chunk-v91p6ekp.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Gc as startInteractive};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Mo,No}from"./chunk-tafqyf2g.js";import"./chunk-md8rqn48.js";import"./chunk-y1cmjvk3.js";import"./chunk-8eqrwj1k.js";import"./chunk-3kthfs03.js";import"./chunk-v91p6ekp.js";import"./chunk-xtvf6n6f.js";import"./chunk-x0q32ees.js";import"./chunk-ej9j6k1q.js";import"./chunk-9p9qkbtg.js";import"./chunk-g03s93qr.js";import{ti}from"./chunk-wfy1zq53.js";import"./chunk-340a824p.js";import"./chunk-eed4fwps.js";import"./chunk-96k8s808.js";import"./chunk-mp6hy8g4.js";import"./chunk-pgzvyrv6.js";import"./chunk-gawrg4gb.js";import"./chunk-6h38kkjf.js";import"./chunk-vgvtnwxa.js";import"./chunk-t4hzprsm.js";import"./chunk-g186znp9.js";import"./chunk-5qns2sdz.js";import"./chunk-9pt8fd2n.js";import"./chunk-bay9s6rs.js";import"./chunk-fh1qrp68.js";import"./chunk-pbh4smw3.js";import"./chunk-amd6ey3t.js";import"./chunk-amtr3rmf.js";import"./chunk-qghxz7jm.js";import"./chunk-765e1s44.js";import{Zt,Qt}from"./chunk-re8b5r9x.js";import"./chunk-wzx0164n.js";import"./chunk-r3f9jcf7.js";import"./chunk-42wbs8vq.js";import"./chunk-hepd9qgx.js";import{ye,X,d,r,Kn,A,i,ue}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Kn as buildWebComponents,Qt as cacheTemplate,Zt as checkCache,ti as classifyAllScripts,Mo as createMiddleware,No as createRoute,A as defaultConfig,d as extractVariables,X as injectRouterScript,i as loadStxConfig,ye as processClientScript,r as processDirectives,ue as readMarkdownFile};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ll}from"./chunk-x72tv2cg.js";import"./chunk-scezfp0w.js";import"./chunk-xtdw3692.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{ll as startProductionServer};
2
+ import{ll}from"./chunk-g03s93qr.js";import"./chunk-wfy1zq53.js";import"./chunk-hepd9qgx.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{ll as startProductionServer};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{le}from"./chunk-69mc2np8.js";import{de,S,Ke}from"./chunk-ngc2wke4.js";import{z}from"./chunk-h0atqq82.js";import{Y,Ce}from"./chunk-czxt605c.js";import{Pe,se,C,ie,ai,kr,ci,Mt}from"./chunk-scezfp0w.js";import{Wr}from"./chunk-xtdw3692.js";import{Nt}from"./chunk-9g27ybyr.js";import J from"fs";import M from"path";var{serve:ae}=globalThis.Bun;import k from"zlib";import{promisify as q}from"util";var Q=q(k.brotliCompress),Z=q(k.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[s,...i]=a.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of i){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function oe(t){if(!t)return null;let e=re(t),a=e.get("*"),s=(i)=>e.get(i)??a??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function Ot(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let s=oe(t.headers.get("accept-encoding"));if(!s)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:W(e.headers)});if(i.length<(a.threshold??te))return l();try{let m=s==="br"?await Q(i,{params:{[k.constants.BROTLI_PARAM_QUALITY]:a.quality??5,[k.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Z(i);if(m.length>=i.length)return l();let f=W(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function W(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class D{now;entries=new z(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let s,i=async()=>{let r=s??await a();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${se(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,B=async()=>{let r=await a();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return i();v=B().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):i()}}var ce={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ll(t={}){let e=M.resolve(t.outputDir||".output"),a=t.port??3000,s=ai(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let i=Nt(s.routeRules),l=new D,m=Wr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,B=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),c=JSON.parse(await Bun.file(R).text());if(g)c.html=Ke(c.html,g);b.set(n.pattern,c),v.set(n.pattern,Ce(c.html)),E.set(n.pattern,le(c.html));let N=M.join(e,n.fragmentPath);if(await Bun.file(N).exists()){let A=await Bun.file(N).text();B.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:c}=Y(n.pattern);T.push({regex:R,route:n,paramNames:c})}else r.set(n.pattern,n);let L=ae({port:a,async fetch(n){return Ot(n,await de(g??S(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let N=await m(n);if(N)return N;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=ce[h]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=se(n),y=null,G={};if(y=r.get(c)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let o=c.match(p);if(o){y=d,u.forEach((h,j)=>{G[h]=o[j+1]});break}}if(!y){let p=r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let O=i(c),U=Object.keys(O).length>0;return l.respond(n,O.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=B.get(y.pattern);if(o){let h=v.get(y.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=kr(n.method),u=b.get(y.pattern);if(!u){let o=r.get("/500")||null;if(o){let h=b.get(o.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:h,redirect:j,cookies:_,status:H,headers:I}=await Mt(u,{params:G,request:n,method:n.method,__stx_strict_hydration:U,__stx_runtime_config:g});if(j)return ci(j,_,I);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:F}=await import("./chunk-bmt7w2pk.js"),X=new Headers({...C(),...I,"Cache-Control":"private, no-store"});for(let V of _??[])X.append("Set-Cookie",V);if(A&&!d){let V=Ce(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",le(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return F(P(A&&!d?ie(o,s.routerContainer||"main"):o,h,{timeoutMs:30000}),{status:H??u.status??200,headers:X})}let w=new Headers({"Content-Type":"text/html",...C(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of _??[])w.append("Set-Cookie",P);for(let[P,F]of Object.entries(I??{}))w.set(P,F);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=Ce(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",le(o)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(ie(o,s.routerContainer||"main"),{status:H??u.status??200,headers:w})}return new Response(o,{status:H??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),U)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
2
+ import{le}from"./chunk-3efw27as.js";import{de,S,Ke}from"./chunk-ngc2wke4.js";import{z}from"./chunk-b98be3yp.js";import{Y,Ce}from"./chunk-czxt605c.js";import{Pe,se,C,ie,ai,kr,ci,Mt}from"./chunk-wfy1zq53.js";import{Wr}from"./chunk-hepd9qgx.js";import{Nt}from"./chunk-9g27ybyr.js";import J from"fs";import M from"path";var{serve:ae}=globalThis.Bun;import k from"zlib";import{promisify as q}from"util";var Q=q(k.brotliCompress),Z=q(k.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[s,...i]=a.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of i){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function oe(t){if(!t)return null;let e=re(t),a=e.get("*"),s=(i)=>e.get(i)??a??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function Ot(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let s=oe(t.headers.get("accept-encoding"));if(!s)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:W(e.headers)});if(i.length<(a.threshold??te))return l();try{let m=s==="br"?await Q(i,{params:{[k.constants.BROTLI_PARAM_QUALITY]:a.quality??5,[k.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Z(i);if(m.length>=i.length)return l();let f=W(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function W(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class D{now;entries=new z(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let s,i=async()=>{let r=s??await a();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${se(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,B=async()=>{let r=await a();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return i();v=B().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):i()}}var ce={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ll(t={}){let e=M.resolve(t.outputDir||".output"),a=t.port??3000,s=ai(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let i=Nt(s.routeRules),l=new D,m=Wr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,B=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),c=JSON.parse(await Bun.file(R).text());if(g)c.html=Ke(c.html,g);b.set(n.pattern,c),v.set(n.pattern,Ce(c.html)),E.set(n.pattern,le(c.html));let N=M.join(e,n.fragmentPath);if(await Bun.file(N).exists()){let A=await Bun.file(N).text();B.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:c}=Y(n.pattern);T.push({regex:R,route:n,paramNames:c})}else r.set(n.pattern,n);let L=ae({port:a,async fetch(n){return Ot(n,await de(g??S(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let N=await m(n);if(N)return N;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=ce[h]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=se(n),y=null,G={};if(y=r.get(c)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let o=c.match(p);if(o){y=d,u.forEach((h,j)=>{G[h]=o[j+1]});break}}if(!y){let p=r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let O=i(c),U=Object.keys(O).length>0;return l.respond(n,O.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=B.get(y.pattern);if(o){let h=v.get(y.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...O.cache?{}:{"Cache-Control":Pe}}})}}let d=kr(n.method),u=b.get(y.pattern);if(!u){let o=r.get("/500")||null;if(o){let h=b.get(o.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:h,redirect:j,cookies:_,status:H,headers:I}=await Mt(u,{params:G,request:n,method:n.method,__stx_strict_hydration:U,__stx_runtime_config:g});if(j)return ci(j,_,I);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:F}=await import("./chunk-gc1drn2p.js"),X=new Headers({...C(),...I,"Cache-Control":"private, no-store"});for(let V of _??[])X.append("Set-Cookie",V);if(A&&!d){let V=Ce(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",le(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return F(P(A&&!d?ie(o,s.routerContainer||"main"):o,h,{timeoutMs:30000}),{status:H??u.status??200,headers:X})}let w=new Headers({"Content-Type":"text/html",...C(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of _??[])w.append("Set-Cookie",P);for(let[P,F]of Object.entries(I??{}))w.set(P,F);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=Ce(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",le(o)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(ie(o,s.routerContainer||"main"),{status:H??u.status??200,headers:w})}return new Response(o,{status:H??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),U)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
3
3
  export{Ot,ll};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m}from"./chunk-ce1sejr3.js";import{R,Pt}from"./chunk-8nhshfz6.js";import{y,ze,N,i}from"./chunk-69mc2np8.js";import{ce,mt,ht}from"./chunk-mepdnezf.js";import{De,Xt,Q}from"./chunk-f46qsp4m.js";import _ from"path";var g=new Map,v=new Map,P=["composables","functions"];function E(n){let t=_.basename(n,".ts");return t==="index"||t==="types"||n.endsWith(".d.ts")}async function G(n){if(n)return _.resolve(n);let t=`<default>:${process.cwd()}`,l=v.get(t);if(l!==void 0)return l;let s=await J();if(s!==null)v.set(t,s);return s}async function J(){let n=await i(),t=n.root||process.cwd(),l=n.composablesDir;if(l)return _.resolve(t,l);for(let s of P){let r=_.resolve(t,s);try{let c=new Bun.Glob("**/*.ts");for await(let a of c.scan({cwd:r,absolute:!0}))if(!E(a))return r}catch{}}return null}async function j(n){let t=Array.isArray(n)?n:n?[_.resolve(n)]:(await i())._layerComposableDirs??[await G()].filter((s)=>!!s),l=new Map;for(let s of t){let r=new Bun.Glob("**/*.ts");try{for await(let c of r.scan({cwd:s,absolute:!0})){let a=_.relative(s,c);if(!E(c)&&!l.has(a))l.set(a,c)}}catch{}}return{key:t.join("\x00"),files:[...l.values()].sort()}}async function Mr(n){let{files:t}=await j(n),l=N({loader:"ts",target:"browser",define:y()}),s=[];for(let r of t)try{let c=await Bun.file(r).text(),a=l.scan(c).exports.filter((d)=>d!=="default");if(a.length>0)s.push({file:r,names:a})}catch{}return s}function T(n,t){return new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(n)}function z(n,t,l){let s=new Map;for(let{file:d,names:f}of n)for(let u of f)if(!s.has(u))s.set(u,d);let r=(d)=>{let f=[];for(let[u,w]of s)if(T(d,u))f.push(w);return f},c=new Set,a=l.flatMap(r);while(a.length>0){let d=[];for(let f of a){if(c.has(f))continue;c.add(f);for(let u of r(t.get(f)??""))if(!c.has(u))d.push(u)}a=d}return c}async function bl(n,t,l){let{key:s,files:r}=await j(n);if(!s)return null;let c=()=>[...new Set([...r,...r.flatMap((e)=>ce(e))])],a=De(c());if(r.length===0)return Q(g,s,a,""),null;r.sort();let d=N({loader:"ts",target:"browser",define:y()}),f=new Map,u=[];for(let e of r)try{let o=await Bun.file(e).text();f.set(e,o);let h=d.scan(o).exports.filter((p)=>p!=="default");if(h.length>0)u.push({file:e,names:h})}catch{f.set(e,"")}let w=t===void 0?new Set(r):z(u,f,l?[t,...l]:[t]);if(w.size===0)return null;let B=r.filter((e)=>w.has(e)),x=`${s}\x00${B.join("\x00")}`,M=Xt(g,x,a);if(M!==void 0)return M||null;let S=[],b=new Set,D=new Set;for(let e of B)try{let o=f.get(e)??await Bun.file(e).text(),h=_.basename(e,".ts");for(let p of o.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(p[1])D.add(p[1]);try{for(let p of d.scan(o).exports)if(p!=="default")b.add(p)}catch{}if(o=R(o),mt(o))o=await ht(o,e,{projectRoot:process.cwd(),externalizeUserModules:!1}),o=ze(o);o=Pt(o),o=o.replace(/^export\s+(default\s+)?/gm,""),o=d.transformSync(o),S.push(`// Composable: ${h}
2
+ import{m}from"./chunk-ce1sejr3.js";import{R,Pt}from"./chunk-8nhshfz6.js";import{y,ze,N,i}from"./chunk-3efw27as.js";import{ce,mt,ht}from"./chunk-42wbs8vq.js";import{De,Xt,Q}from"./chunk-f46qsp4m.js";import _ from"path";var g=new Map,v=new Map,P=["composables","functions"];function E(n){let t=_.basename(n,".ts");return t==="index"||t==="types"||n.endsWith(".d.ts")}async function G(n){if(n)return _.resolve(n);let t=`<default>:${process.cwd()}`,l=v.get(t);if(l!==void 0)return l;let s=await J();if(s!==null)v.set(t,s);return s}async function J(){let n=await i(),t=n.root||process.cwd(),l=n.composablesDir;if(l)return _.resolve(t,l);for(let s of P){let r=_.resolve(t,s);try{let c=new Bun.Glob("**/*.ts");for await(let a of c.scan({cwd:r,absolute:!0}))if(!E(a))return r}catch{}}return null}async function j(n){let t=Array.isArray(n)?n:n?[_.resolve(n)]:(await i())._layerComposableDirs??[await G()].filter((s)=>!!s),l=new Map;for(let s of t){let r=new Bun.Glob("**/*.ts");try{for await(let c of r.scan({cwd:s,absolute:!0})){let a=_.relative(s,c);if(!E(c)&&!l.has(a))l.set(a,c)}}catch{}}return{key:t.join("\x00"),files:[...l.values()].sort()}}async function Mr(n){let{files:t}=await j(n),l=N({loader:"ts",target:"browser",define:y()}),s=[];for(let r of t)try{let c=await Bun.file(r).text(),a=l.scan(c).exports.filter((d)=>d!=="default");if(a.length>0)s.push({file:r,names:a})}catch{}return s}function T(n,t){return new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(n)}function z(n,t,l){let s=new Map;for(let{file:d,names:f}of n)for(let u of f)if(!s.has(u))s.set(u,d);let r=(d)=>{let f=[];for(let[u,w]of s)if(T(d,u))f.push(w);return f},c=new Set,a=l.flatMap(r);while(a.length>0){let d=[];for(let f of a){if(c.has(f))continue;c.add(f);for(let u of r(t.get(f)??""))if(!c.has(u))d.push(u)}a=d}return c}async function bl(n,t,l){let{key:s,files:r}=await j(n);if(!s)return null;let c=()=>[...new Set([...r,...r.flatMap((e)=>ce(e))])],a=De(c());if(r.length===0)return Q(g,s,a,""),null;r.sort();let d=N({loader:"ts",target:"browser",define:y()}),f=new Map,u=[];for(let e of r)try{let o=await Bun.file(e).text();f.set(e,o);let h=d.scan(o).exports.filter((p)=>p!=="default");if(h.length>0)u.push({file:e,names:h})}catch{f.set(e,"")}let w=t===void 0?new Set(r):z(u,f,l?[t,...l]:[t]);if(w.size===0)return null;let B=r.filter((e)=>w.has(e)),x=`${s}\x00${B.join("\x00")}`,M=Xt(g,x,a);if(M!==void 0)return M||null;let S=[],b=new Set,D=new Set;for(let e of B)try{let o=f.get(e)??await Bun.file(e).text(),h=_.basename(e,".ts");for(let p of o.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(p[1])D.add(p[1]);try{for(let p of d.scan(o).exports)if(p!=="default")b.add(p)}catch{}if(o=R(o),mt(o))o=await ht(o,e,{projectRoot:process.cwd(),externalizeUserModules:!1}),o=ze(o);o=Pt(o),o=o.replace(/^export\s+(default\s+)?/gm,""),o=d.transformSync(o),S.push(`// Composable: ${h}
3
3
  ${o.trim()}`)}catch(o){console.warn(`[stx] Failed to load composable ${e}:`,o)}if(S.length===0||b.size===0)return Q(g,x,a,""),null;let F=[...b].map((e)=>` try { if (!(${JSON.stringify(e)} in __c)) __c[${JSON.stringify(e)}] = ${e}; } catch (e) {}`).join(`
4
4
  `),k=JSON.stringify([...b]),C=S.join(`
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Kl,mi,_a,Gl,Jl,Yl,Zl,Ql,Ra,Aa,eu,tu,nu,ru}from"./chunk-g578mcb0.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{_a as SUSPENSE_RESOLVER_RUNTIME,mi as buildSuspenseResolveScript,Ql as createStreamRenderer,Yl as extractStreamBoundaries,ru as generateHydrationRuntime,Aa as islandDirective,tu as processSectionDirectives,Jl as processStreamDirectives,eu as registerStreamingDirectives,Gl as renderStreamingPage,Kl as streamTemplate,Zl as streamTemplateSimple,nu as streamToResponse,Ra as streamingSuspenseDirective};
2
+ import{Kl,mi,_a,Gl,Jl,Yl,Zl,Ql,Ra,Aa,eu,tu,nu,ru}from"./chunk-qghxz7jm.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{_a as SUSPENSE_RESOLVER_RUNTIME,mi as buildSuspenseResolveScript,Ql as createStreamRenderer,Yl as extractStreamBoundaries,ru as generateHydrationRuntime,Aa as islandDirective,tu as processSectionDirectives,Jl as processStreamDirectives,eu as registerStreamingDirectives,Gl as renderStreamingPage,Kl as streamTemplate,Zl as streamTemplateSimple,nu as streamToResponse,Ra as streamingSuspenseDirective};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Pa,lu,uu,du,pu,Ia,Da,fu,gu,mu,hu,Zt,Qt,Dn}from"./chunk-pqxzp1bb.js";import{he}from"./chunk-et0rr8c7.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{pu as __setSignalsGeneratorsForTest,he as cacheEngineFingerprint,Qt as cacheTemplate,Zt as checkCache,hu as clearDevCaches,Da as getCachedRouterScript,Ia as getCachedSignalsRuntime,fu as getServeClientAsset,mu as getServeModuleBundle,Dn as hashFilePath,uu as invalidateFileCache,du as invalidateFileCacheByDir,lu as readFileCached,gu as registerServeModuleBundle,Pa as templateCache};
2
+ import{Pa,lu,uu,du,pu,Ia,Da,fu,gu,mu,hu,Zt,Qt,Dn}from"./chunk-re8b5r9x.js";import{he}from"./chunk-et0rr8c7.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{pu as __setSignalsGeneratorsForTest,he as cacheEngineFingerprint,Qt as cacheTemplate,Zt as checkCache,hu as clearDevCaches,Da as getCachedRouterScript,Ia as getCachedSignalsRuntime,fu as getServeClientAsset,mu as getServeModuleBundle,Dn as hashFilePath,uu as invalidateFileCache,du as invalidateFileCacheByDir,lu as readFileCached,gu as registerServeModuleBundle,Pa as templateCache};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Jc}from"./chunk-xtvf6n6f.js";import"./chunk-wfy1zq53.js";import"./chunk-765e1s44.js";import"./chunk-hepd9qgx.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{Jc as buildForProduction};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{St,as,Ki,dc}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{dc as declareBareLoopHead,St as parseLoopBinding,Ki as processLoops,as as reportDeferredLoopWarnings};
2
+ import{St,as,Ki,dc}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{dc as declareBareLoopHead,St as parseLoopBinding,Ki as processLoops,as as reportDeferredLoopWarnings};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{Y}from"./chunk-czxt605c.js";import{de,S}from"./chunk-ngc2wke4.js";import{fo}from"./chunk-ak1cgcah.js";import{o}from"./chunk-fzapbw9p.js";import v from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function yt(s,l={}){let i=m.resolve(s,l.dir??"server/api"),a=[],f=new Map;if(!v.existsSync(i))return a;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:i})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,I)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&I!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(i,e);P.add(m.resolve(R)),P.add(v.realpathSync(R)),a.push({pattern:w,method:g,filePath:R})}return a.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Vr(s,l){let i=o(s,"api-types.d.ts"),a=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(i),t.filePath).replace(/\\/g,"/")}`,{params:p}=Y(t.pattern);a.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}a.push(" }","}","export {}","");let f=a.join(`
3
3
  `);if(!await Bun.file(i).exists()||await Bun.file(i).text()!==f)await Bun.write(i,f);return i}async function Ur(s,l,i={}){let a=yt(s,i);await Vr(s,a);let f=[];for(let t of a){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function j(s,l){let i=s.map((a)=>({route:a,...Y(a.pattern)}));return async(a)=>{let f=new URL(a.url).pathname,t=i.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=a.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(a,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Wr(s,l){return j(l,async(i)=>(await import(O(m.resolve(s,i.filePath)).href)).default)}async function Eu(s,l){if(!l)return async()=>null;let i=l===!0?{}:l,a=yt(s,i);return await Vr(s,a),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=yt(s,i);await Vr(s,t);let{loadStxConfig:e}=await import("./chunk-syaw6b75.js"),p=S((await e(s)).runtimeConfig);return await de(p,()=>j(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function j(s,l){let i=s.map((a)=>({route:a,...Y(a.pattern)}));return async(a)=>{let f=new URL(a.url).pathname,t=i.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=a.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(a,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Wr(s,l){return j(l,async(i)=>(await import(O(m.resolve(s,i.filePath)).href)).default)}async function Eu(s,l){if(!l)return async()=>null;let i=l===!0?{}:l,a=yt(s,i);return await Vr(s,a),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=yt(s,i);await Vr(s,t);let{loadStxConfig:e}=await import("./chunk-hpgr4qgp.js"),p=S((await e(s)).runtimeConfig);return await de(p,()=>j(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function qr(s,l,i){if(fo(s))return!0;let a=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(a.test(m.basename(s)))return!0;try{if(a.test(m.basename(v.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!i)return!1;let f=m.resolve(l,typeof i==="object"?i.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
6
6
  export{yt,Vr,Ur,Wr,Eu,qr};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{d,os,qi,Xi,fc,gc,mc,hc,yc,bc,Ve,N,Ue,vc,qn,wc,so,xc,We,n,Xn,io,g,K,ju}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{K as clearComponentCache,xc as componentClientSignalNames,os as convertToCommonJS,g as createDetailedErrorMessage,yc as extractDirectiveNames,qi as extractScriptFromTemplate,d as extractVariables,n as fileExists,ju as getComponentCacheStats,gc as getPositionInfo,N as getSharedTranspiler,io as getSourceLineInfo,hc as hasDirectives,Xi as hasVariables,wc as isHydrateTrigger,bc as isJavaScriptScript,We as renderComponentWithSlot,Xn as resolveTemplatePath,vc as scopeOnRootElement,Ve as shouldTranspileTypeScript,so as slotContentHasExpressions,Ue as transpileTypeScript,qn as userComponentFileExists,mc as validateDirective,fc as validateTemplate};
2
+ import{d,os,qi,Xi,fc,gc,mc,hc,yc,bc,Ve,N,Ue,vc,qn,wc,so,xc,We,n,Xn,io,g,K,ju}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{K as clearComponentCache,xc as componentClientSignalNames,os as convertToCommonJS,g as createDetailedErrorMessage,yc as extractDirectiveNames,qi as extractScriptFromTemplate,d as extractVariables,n as fileExists,ju as getComponentCacheStats,gc as getPositionInfo,N as getSharedTranspiler,io as getSourceLineInfo,hc as hasDirectives,Xi as hasVariables,wc as isHydrateTrigger,bc as isJavaScriptScript,We as renderComponentWithSlot,Xn as resolveTemplatePath,vc as scopeOnRootElement,Ve as shouldTranspileTypeScript,so as slotContentHasExpressions,Ue as transpileTypeScript,qn as userComponentFileExists,mc as validateDirective,fc as validateTemplate};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{rn,Qa,ts}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import{ke}from"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{ke as freeIdentifiers,ts as processComponents,Qa as processESImports,rn as rendersAsElement};
2
+ import{rn,Qa,ts}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import{ke}from"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{ke as freeIdentifiers,ts as processComponents,Qa as processESImports,rn as rendersAsElement};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$i}from"./chunk-ynvdvbat.js";import{u}from"./chunk-cg8hg6cs.js";import{existsSync as z,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as re}from"child_process";import{tmpdir as M,homedir as q,platform as ae}from"os";var yu=`
2
+ import{$i}from"./chunk-wzx0164n.js";import{u}from"./chunk-cg8hg6cs.js";import{existsSync as z,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as re}from"child_process";import{tmpdir as M,homedir as q,platform as ae}from"os";var yu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ce,Fa,Di,ft,gt,$u,Oi,mt,nn,za,Ha,Va,Ua,ht,Wa}from"./chunk-mepdnezf.js";import"./chunk-xtdw3692.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{nn as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,ce as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,Ha as normalizeRegistrySpecifiers,Ua as queueClientBundleBuild,Di as recordBundleFailure,za as registryIdForPath,Oi as resolveBundlerFallback,Va as rewriteRegistryImports,$u as setBundlerFallbackMode,Fa as shouldLogBundlerDiagnostics,Wa as tempBuildName};
2
+ import{ce,Fa,Di,ft,gt,$u,Oi,mt,nn,za,Ha,Va,Ua,ht,Wa}from"./chunk-42wbs8vq.js";import"./chunk-hepd9qgx.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{nn as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,ce as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,Ha as normalizeRegistrySpecifiers,Ua as queueClientBundleBuild,Di as recordBundleFailure,za as registryIdForPath,Oi as resolveBundlerFallback,Va as rewriteRegistryImports,$u as setBundlerFallbackMode,Fa as shouldLogBundlerDiagnostics,Wa as tempBuildName};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{A,Sc,i,T,Bu,Fu}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{T as config,A as defaultConfig,Bu as defineStxConfig,i as loadStxConfig,Sc as resolveStxDirectories,Fu as validateConfig};
2
+ import{A,Sc,i,T,Bu,Fu}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{T as config,A as defaultConfig,Bu as defineStxConfig,i as loadStxConfig,Sc as resolveStxDirectories,Fu as validateConfig};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import g from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...r){let o=new Set;for(let s of r){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{o.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...o].sort()}async function M(r,o={}){if(r.length===0)return null;let s=process.cwd(),e=[],l=[];r.forEach((t,h)=>{let x=t.startsWith("npm:")?t.slice(4):g.resolve(s,t),a=`__stxRegistered${h}`,d=JSON.stringify(t);e.push(`import * as ${a} from ${JSON.stringify(x)};`),l.push(`if (!globalThis.__stxModules[${d}]) globalThis.__stxModules[${d}] = ${a};`)});let u=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...l].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-pj1wg7jg.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-866n724v.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-2ce7f416.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-hn9pkyv8.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-nc8my58s.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-2ce7f416.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
4
4
  `)}export{M as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{an,xs}from"./chunk-2gr351s0.js";import"./chunk-ngc2wke4.js";export{xs as generateRuntimeConfigTypes,an as prepareRuntimeConfig};
2
+ import{an,xs}from"./chunk-9amp82bx.js";import"./chunk-ngc2wke4.js";export{xs as generateRuntimeConfigTypes,an as prepareRuntimeConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{W,Xr,Kr,qa,bt,Mi,Ni,Li,Tu,Le,Gr,ye}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import{po,s}from"./chunk-169n1vpx.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{W as BROWSER_CORE_IMPORTS,qa as STX_AUTO_IMPORTS,Xr as extractAndStripCssImports,Le as extractBridgeData,po as findInterpolationEnd,Li as generateAutoImportDestructuring,Tu as generateBrowserAutoImportDestructuring,Gr as generateServerDataBridge,bt as injectBrowserCoreAutoImports,ye as processClientScript,Ni as referencesName,Kr as renderVendorStyleTags,s as stripCommentsAndLiterals,Mi as transformAutoImports};
2
+ import{W,Xr,Kr,qa,bt,Mi,Ni,Li,Tu,Le,Gr,ye}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import{po,s}from"./chunk-169n1vpx.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{W as BROWSER_CORE_IMPORTS,qa as STX_AUTO_IMPORTS,Xr as extractAndStripCssImports,Le as extractBridgeData,po as findInterpolationEnd,Li as generateAutoImportDestructuring,Tu as generateBrowserAutoImportDestructuring,Gr as generateServerDataBridge,bt as injectBrowserCoreAutoImports,ye as processClientScript,Ni as referencesName,Kr as renderVendorStyleTags,s as stripCommentsAndLiterals,Mi as transformAutoImports};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Zo,dl,Qo,ea,pl,fl}from"./chunk-yvx1ap9b.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{fl as applySlots,pl as extractSlotContent,dl as parseSlotElement,Zo as parseSlots,ea as processSlots,Qo as renderSlot};
2
+ import{Zo,dl,Qo,ea,pl,fl}from"./chunk-96k8s808.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{fl as applySlots,pl as extractSlotContent,dl as parseSlotElement,Zo as parseSlots,ea as processSlots,Qo as renderSlot};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{cl}from"./chunk-e57rhf65.js";import"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{cl as buildApp};
2
+ import{cl}from"./chunk-9p9qkbtg.js";import"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{cl as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{X,ps,gs,ms,r}from"./chunk-69mc2np8.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-2gr351s0.js";import"./chunk-h0atqq82.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{X as injectRouterScript,r as processDirectives,ps as processJsonDirective,gs as processOnceDirective,ms as validateClientScript};
2
+ import{X,ps,gs,ms,r}from"./chunk-3efw27as.js";import"./chunk-752hw7cd.js";import"./chunk-shr559s7.js";import"./chunk-ak1cgcah.js";import"./chunk-9amp82bx.js";import"./chunk-b98be3yp.js";import"./chunk-ngc2wke4.js";import"./chunk-xfp7k0v8.js";import"./chunk-m4sk62wb.js";import"./chunk-z0g9jvv0.js";import"./chunk-8nhshfz6.js";import"./chunk-7gkv67ky.js";import"./chunk-ce1sejr3.js";import"./chunk-czxt605c.js";export{X as injectRouterScript,r as processDirectives,ps as processJsonDirective,gs as processOnceDirective,ms as validateClientScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{h,d,r,g,A}from"./chunk-69mc2np8.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],i=n[2];t.push({type:"suspense",name:s,content:i}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Kl(e,t={},o={}){let n={...A,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,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 r(c,y,e,n,u);for(let b=0;b<p.length;b+=s)i.enqueue(p.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await r(I,y,e,n,u);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await r(_.content,y,e,n,u);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await r(_,y,e,n,u);i.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await r(l.content,y,e,n,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
2
+ import{h,d,r,g,A}from"./chunk-3efw27as.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],i=n[2];t.push({type:"suspense",name:s,content:i}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Kl(e,t={},o={}){let n={...A,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,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 r(c,y,e,n,u);for(let b=0;b<p.length;b+=s)i.enqueue(p.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await r(I,y,e,n,u);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await r(_.content,y,e,n,u);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await r(_,y,e,n,u);i.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await r(l.content,y,e,n,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.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,r(l.content,y,e,n,u))}i.enqueue(`
5
5
  <script>
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{n,K}from"./chunk-69mc2np8.js";import{ho}from"./chunk-h0atqq82.js";import{he}from"./chunk-et0rr8c7.js";import{o}from"./chunk-fzapbw9p.js";import c from"fs";import l from"path";var Pa=new Map,m=new Map;async function lu(e){let r;for(let s=0;s<3;s++)try{let g=(await c.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),S=(await c.promises.stat(e)).mtime.getTime();if(S!==g)continue;return m.set(e,{content:h,mtime:S}),h}catch(i){r=i;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function uu(e){m.delete(e)}function du(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var d=null,v=null,y=null;function pu(e){y=e}async function Ia(e=!1){let t=y??await import("./chunk-5gsxpaqk.js");if(e)return t.generateSignalsRuntimeDev();if(d===null)d=t.generateSignalsRuntime();return d}var f=null;async function Da(){if(f===null){let{getRouterScript:e}=await import("./chunk-jk4njz0w.js");f=e()}return f}var w={};async function fu(e,t=!1){let r=e==="runtime"?await Ia(t):await Da(),s=e==="runtime"&&t?"runtime-debug":e,i=w[s];if(!i||i.content!==r)i={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},w[s]=i;return{content:r,hash:i.hash,url:`/_stx/${e}.${i.hash}.js`}}var T=500,u=new Map;function x(e){return o(process.cwd(),"module-bundles",`${e}.js`)}function gu(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.has(t);if(r)u.delete(t);u.set(t,e);while(u.size>T)u.delete(u.keys().next().value);if(!r)try{let s=x(t);if(!c.existsSync(s))c.mkdirSync(l.dirname(s),{recursive:!0}),c.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function mu(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return c.readFileSync(x(e),"utf8")}catch{return}}function hu(){m.clear(),K(),ho(),d=null,v=null,f=null}function C(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 Zt(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),s=l.join(r,`${Dn(e)}.html`),i=l.join(r,`${Dn(e)}.meta.json`);if(!await n(s)||!await n(i))return null;let g=await Bun.file(i).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==he())return null;if(a.optionsSignature!==C(t))return null;if((await c.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let p of a.dependencies)if(await n(p)){if((await c.promises.stat(p)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(s).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qt(e,t,r,s){try{if(!s.cachePath)return;let i=l.resolve(s.cachePath);await c.promises.mkdir(i,{recursive:!0});let g=l.join(i,`${Dn(e)}.html`),a=l.join(i,`${Dn(e)}.meta.json`),h=await c.promises.stat(e);await Bun.write(g,t);let p={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:s.cacheVersion,engine:he(),optionsSignature:C(s),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(p,null,2)),Pa.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(i){console.warn(`Failed to cache template ${e}:`,i)}}var E=16;function Dn(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,E)}
2
+ import{n,K}from"./chunk-3efw27as.js";import{ho}from"./chunk-b98be3yp.js";import{he}from"./chunk-et0rr8c7.js";import{o}from"./chunk-fzapbw9p.js";import c from"fs";import l from"path";var Pa=new Map,m=new Map;async function lu(e){let r;for(let s=0;s<3;s++)try{let g=(await c.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),S=(await c.promises.stat(e)).mtime.getTime();if(S!==g)continue;return m.set(e,{content:h,mtime:S}),h}catch(i){r=i;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function uu(e){m.delete(e)}function du(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var d=null,v=null,y=null;function pu(e){y=e}async function Ia(e=!1){let t=y??await import("./chunk-5gsxpaqk.js");if(e)return t.generateSignalsRuntimeDev();if(d===null)d=t.generateSignalsRuntime();return d}var f=null;async function Da(){if(f===null){let{getRouterScript:e}=await import("./chunk-jk4njz0w.js");f=e()}return f}var w={};async function fu(e,t=!1){let r=e==="runtime"?await Ia(t):await Da(),s=e==="runtime"&&t?"runtime-debug":e,i=w[s];if(!i||i.content!==r)i={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},w[s]=i;return{content:r,hash:i.hash,url:`/_stx/${e}.${i.hash}.js`}}var T=500,u=new Map;function x(e){return o(process.cwd(),"module-bundles",`${e}.js`)}function gu(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.has(t);if(r)u.delete(t);u.set(t,e);while(u.size>T)u.delete(u.keys().next().value);if(!r)try{let s=x(t);if(!c.existsSync(s))c.mkdirSync(l.dirname(s),{recursive:!0}),c.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function mu(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return c.readFileSync(x(e),"utf8")}catch{return}}function hu(){m.clear(),K(),ho(),d=null,v=null,f=null}function C(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 Zt(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),s=l.join(r,`${Dn(e)}.html`),i=l.join(r,`${Dn(e)}.meta.json`);if(!await n(s)||!await n(i))return null;let g=await Bun.file(i).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==he())return null;if(a.optionsSignature!==C(t))return null;if((await c.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let p of a.dependencies)if(await n(p)){if((await c.promises.stat(p)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(s).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Qt(e,t,r,s){try{if(!s.cachePath)return;let i=l.resolve(s.cachePath);await c.promises.mkdir(i,{recursive:!0});let g=l.join(i,`${Dn(e)}.html`),a=l.join(i,`${Dn(e)}.meta.json`),h=await c.promises.stat(e);await Bun.write(g,t);let p={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:s.cacheVersion,engine:he(),optionsSignature:C(s),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(p,null,2)),Pa.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(i){console.warn(`Failed to cache template ${e}:`,i)}}var E=16;function Dn(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,E)}
3
3
  export{Pa,lu,uu,du,pu,Ia,Da,fu,gu,mu,hu,Zt,Qt,Dn};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{yt,Vr,Ur,Wr,Eu,qr}from"./chunk-xtdw3692.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-czxt605c.js";export{Ur as buildServerApi,Eu as createServerApi,yt as discoverServerApi,Vr as generateApiTypes,qr as isServerApiSource,Wr as productionApiDispatcher};
2
+ import{yt,Vr,Ur,Wr,Eu,qr}from"./chunk-hepd9qgx.js";import"./chunk-ak1cgcah.js";import"./chunk-ngc2wke4.js";import"./chunk-czxt605c.js";export{Ur as buildServerApi,Eu as createServerApi,yt as discoverServerApi,Vr as generateApiTypes,qr as isServerApiSource,Wr as productionApiDispatcher};