@stacksjs/stx 0.2.434 → 0.2.436

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 (63) hide show
  1. package/dist/{chunk-d7stgehg.js → chunk-053t5wrs.js} +1 -1
  2. package/dist/{chunk-9zf2xmj5.js → chunk-0jgvwa50.js} +1 -1
  3. package/dist/{chunk-7envdam0.js → chunk-1cq9w2qz.js} +1 -1
  4. package/dist/{chunk-d35y8thn.js → chunk-1n7d9ag2.js} +1 -1
  5. package/dist/{chunk-qrzhpzdw.js → chunk-36kkc60p.js} +1 -1
  6. package/dist/{chunk-w926gc13.js → chunk-397fy72k.js} +1 -1
  7. package/dist/{chunk-1j2z24r5.js → chunk-3akpy7er.js} +1 -1
  8. package/dist/{chunk-bqjty9dx.js → chunk-44zjqsh9.js} +1 -1
  9. package/dist/{chunk-jtysg2ss.js → chunk-48w0qzmk.js} +1 -1
  10. package/dist/{chunk-tmj5b3r0.js → chunk-4bpc0tsf.js} +1 -1
  11. package/dist/{chunk-1njrhrmw.js → chunk-4gmdfym5.js} +5 -5
  12. package/dist/{chunk-8bew5svs.js → chunk-5ahb6arz.js} +1 -1
  13. package/dist/{chunk-xc6x218s.js → chunk-5ty8h14h.js} +2 -2
  14. package/dist/{chunk-w6gyrqjp.js → chunk-5zahqrb4.js} +12 -2
  15. package/dist/{chunk-et2kt16p.js → chunk-6faqgn2f.js} +1 -1
  16. package/dist/{chunk-begfdc6a.js → chunk-771hf74z.js} +1 -1
  17. package/dist/{chunk-x819gynv.js → chunk-7a0ffmer.js} +2 -2
  18. package/dist/{chunk-j4kqw34b.js → chunk-7tkwt0a9.js} +1 -1
  19. package/dist/{chunk-11h97cn9.js → chunk-87c76jq3.js} +1 -1
  20. package/dist/{chunk-80q2becc.js → chunk-8h0nbb7t.js} +1 -1
  21. package/dist/{chunk-9jr7jbgv.js → chunk-a9necy79.js} +18 -18
  22. package/dist/{chunk-zc6k6164.js → chunk-awqft00q.js} +1 -1
  23. package/dist/{chunk-weegyd19.js → chunk-cczrcjfs.js} +1 -1
  24. package/dist/{chunk-z0t6509y.js → chunk-dc89a93n.js} +1 -1
  25. package/dist/chunk-ksyb5bgt.js +2 -0
  26. package/dist/{chunk-60pc7151.js → chunk-mh4qh1dk.js} +1 -1
  27. package/dist/{chunk-r2ahyhj0.js → chunk-mtb5000n.js} +1 -1
  28. package/dist/{chunk-nhg3r4ae.js → chunk-nq7z26y6.js} +2 -2
  29. package/dist/{chunk-8bpf8d7n.js → chunk-p3462q2p.js} +1 -1
  30. package/dist/{chunk-vn8qdcxp.js → chunk-pey0cpyh.js} +1 -1
  31. package/dist/{chunk-9xmdj73x.js → chunk-qke87dwv.js} +1 -1
  32. package/dist/chunk-r7pmpd2x.js +12 -0
  33. package/dist/{chunk-x6cyhkk6.js → chunk-r9vrqxma.js} +1 -1
  34. package/dist/{chunk-hb3epf4b.js → chunk-rnth7r2v.js} +1 -1
  35. package/dist/{chunk-7jw2zhb9.js → chunk-s4ypqjhp.js} +1 -1
  36. package/dist/{chunk-tf11gc47.js → chunk-tnbgy59s.js} +1 -1
  37. package/dist/{chunk-d2z6tmzw.js → chunk-tprtjzzc.js} +1 -1
  38. package/dist/{chunk-sbs74y50.js → chunk-tv7hxprx.js} +1 -1
  39. package/dist/{chunk-x3vv7hhh.js → chunk-vw8a7yfw.js} +1 -1
  40. package/dist/{chunk-mq75bc92.js → chunk-vzey1tm1.js} +1 -1
  41. package/dist/{chunk-basztgd4.js → chunk-w040f2er.js} +1 -1
  42. package/dist/{chunk-m73mswbe.js → chunk-w88efb66.js} +1 -1
  43. package/dist/{chunk-v190nt4m.js → chunk-xeb3vyhx.js} +1 -1
  44. package/dist/{chunk-a0v1fxzj.js → chunk-xfv7evmd.js} +1 -1
  45. package/dist/{chunk-f6cz5n4m.js → chunk-xq5hzqg5.js} +1 -1
  46. package/dist/{chunk-4xqtfka6.js → chunk-xx5gx241.js} +1 -1
  47. package/dist/{chunk-nvr0ph6b.js → chunk-yhxazetv.js} +1 -1
  48. package/dist/{chunk-4x884b3c.js → chunk-z9154ddm.js} +1 -1
  49. package/dist/{chunk-zgj9fsrd.js → chunk-zdkspb3m.js} +1 -1
  50. package/dist/{chunk-5dh5cdmv.js → chunk-zpnz1k3b.js} +1 -1
  51. package/dist/cli.js +8 -8
  52. package/dist/composables/index.d.ts +2 -0
  53. package/dist/composables/index.js +1 -0
  54. package/dist/craft-entry.js +1 -1
  55. package/dist/craft.js +1 -1
  56. package/dist/includes.js +2 -2
  57. package/dist/pwa.js +1 -1
  58. package/dist/signals.js +12 -2
  59. package/dist/ssg.js +2 -2
  60. package/dist/unresolved-identifiers.js +1 -0
  61. package/package.json +5 -5
  62. package/dist/chunk-a5qzw9te.js +0 -12
  63. package/dist/chunk-dpxj1gez.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{In,za,yu,Ha,bu,Va,Dn,h,wt,he,Ua,Gr,Wa,wu,W,qa,vu,b,xu}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qa as applyFilters,bu as clearCustomFilters,Ua as clientLoopScopes,In as defaultFilters,h as escapeHtml,wt as escapeHtmlValue,b as evaluateExpression,Va as findMustacheEnd,Ha as getAllFilters,Wa as interpolateScriptAttributes,Gr as interpolateScriptExpressions,wu as interpolateScriptsInTemplate,W as processExpressions,za as registerFilter,yu as registerFilters,Dn as replaceInterpolations,vu as resetRejectedExpressionWarnings,xu as unescapeHtml,he as usesSignalsInScript};
2
+ import{In,za,yu,Ha,bu,Va,Dn,h,wt,he,Ua,Gr,Wa,wu,W,qa,vu,b,xu}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qa as applyFilters,bu as clearCustomFilters,Ua as clientLoopScopes,In as defaultFilters,h as escapeHtml,wt as escapeHtmlValue,b as evaluateExpression,Va as findMustacheEnd,Ha as getAllFilters,Wa as interpolateScriptAttributes,Gr as interpolateScriptExpressions,wu as interpolateScriptsInTemplate,W as processExpressions,za as registerFilter,yu as registerFilters,Dn as replaceInterpolations,vu as resetRejectedExpressionWarnings,xu as unescapeHtml,he as usesSignalsInScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ou,nc,es,ts,Vi,Ui,ns,rs,Ln,rc,Wi,qi,sc,ze}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ou as clearScriptScanCache,ns as convertServerLoopAttributesToDirectives,Vi as convertSignalDirectivesToAttributes,rs as convertSignalLoopsToAttributes,rc as extractExports,qi as findMarkupIndexOutsideScripts,ts as hasSignalsSyntax,es as parseLoopExpression,Ui as preEvalLiteralReactiveIfs,Ln as processScriptSetup,Wi as processSignals,sc as rewriteStxImportSpecifiers,nc as scanScriptTags,ze as stripStxRuntimeImports};
2
+ import{Ou,nc,es,ts,Vi,Ui,ns,rs,Ln,rc,Wi,qi,sc,ze}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ou as clearScriptScanCache,ns as convertServerLoopAttributesToDirectives,Vi as convertSignalDirectivesToAttributes,rs as convertSignalLoopsToAttributes,rc as extractExports,qi as findMarkupIndexOutsideScripts,ts as hasSignalsSyntax,es as parseLoopExpression,Ui as preEvalLiteralReactiveIfs,Ln as processScriptSetup,Wi as processSignals,sc as rewriteStxImportSpecifiers,nc as scanScriptTags,ze as stripStxRuntimeImports};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{oe,Oa,Ii,ft,gt,gu,Di,mt,Jt,Ma,Na,La,ja,ht,Ba}from"./chunk-begfdc6a.js";import"./chunk-d2z6tmzw.js";import"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Jt as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,oe as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,Na as normalizeRegistrySpecifiers,ja as queueClientBundleBuild,Ii as recordBundleFailure,Ma as registryIdForPath,Di as resolveBundlerFallback,La as rewriteRegistryImports,gu as setBundlerFallbackMode,Oa as shouldLogBundlerDiagnostics,Ba as tempBuildName};
2
+ import{oe,Oa,Ii,ft,gt,gu,Di,mt,Jt,Ma,Na,La,ja,ht,Ba}from"./chunk-771hf74z.js";import"./chunk-tprtjzzc.js";import"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Jt as MODULE_SPECIFIER_PREFIX,ht as bundleClientScript,gt as clearBundleFailures,oe as clientBundleDependencies,ft as getBundleFailures,mt as hasUserImports,Na as normalizeRegistrySpecifiers,ja as queueClientBundleBuild,Ii as recordBundleFailure,Ma as registryIdForPath,Di as resolveBundlerFallback,La as rewriteRegistryImports,gu as setBundlerFallbackMode,Oa as shouldLogBundlerDiagnostics,Ba as tempBuildName};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Me,Ka,Su,ku,Cu,$u,Xa,Ga,Eu,Tu,Bi,_u,Zt,Qt,On}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{$u as __setSignalsGeneratorsForTest,Me as cacheEngineFingerprint,Qt as cacheTemplate,Zt as checkCache,_u as clearDevCaches,Ga as getCachedRouterScript,Xa as getCachedSignalsRuntime,Eu as getServeClientAsset,Bi as getServeModuleBundle,On as hashFilePath,ku as invalidateFileCache,Cu as invalidateFileCacheByDir,Su as readFileCached,Tu as registerServeModuleBundle,Ka as templateCache};
2
+ import{Me,Ka,Su,ku,Cu,$u,Xa,Ga,Eu,Tu,Bi,_u,Zt,Qt,On}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{$u as __setSignalsGeneratorsForTest,Me as cacheEngineFingerprint,Qt as cacheTemplate,Zt as checkCache,_u as clearDevCaches,Ga as getCachedRouterScript,Xa as getCachedSignalsRuntime,Eu as getServeClientAsset,Bi as getServeModuleBundle,On as hashFilePath,ku as invalidateFileCache,Cu as invalidateFileCacheByDir,Su as readFileCached,Tu as registerServeModuleBundle,Ka as templateCache};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{W,n}from"./chunk-9jr7jbgv.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
2
+ import{W,n}from"./chunk-a9necy79.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ho,Zs,Hc,Vo,Uo,Vc,Uc}from"./chunk-1j2z24r5.js";import"./chunk-a0v1fxzj.js";import"./chunk-begfdc6a.js";import"./chunk-d2z6tmzw.js";import{He,fc}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ho as buildVirtualSource,He as extractScriptBlocks,fc as extractTemplateExpressions,Vo as findRuntimeTypeDeclarations,Uo as findStxModuleDeclarations,Uc as formatTypecheckDiagnostics,Hc as sourcePathFor,Vc as typecheckStxFiles,Zs as virtualPathFor};
2
+ import{Ho,Zs,Hc,Vo,Uo,Vc,Uc}from"./chunk-3akpy7er.js";import"./chunk-xfv7evmd.js";import"./chunk-771hf74z.js";import"./chunk-tprtjzzc.js";import{He,fc}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{Ho as buildVirtualSource,He as extractScriptBlocks,fc as extractTemplateExpressions,Vo as findRuntimeTypeDeclarations,Uo as findStxModuleDeclarations,Uc as formatTypecheckDiagnostics,Hc as sourcePathFor,Vc as typecheckStxFiles,Zs as virtualPathFor};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m}from"./chunk-1yj3p63h.js";import{H,St,He,gs,ms,Zi,Qi,eo,to,Hn,hs,no,ro,so,i}from"./chunk-9jr7jbgv.js";import{Ir}from"./chunk-a0v1fxzj.js";import{a}from"./chunk-wtms9jhs.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=St.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 o=x[1];if(!xe.has(o)||s.has(o))continue;let f=u.offset+g+h.index+x[0].length-o.length,p=e.slice(0,f),w=p.split(`
2
+ import{m}from"./chunk-1yj3p63h.js";import{H,St,He,gs,ms,Zi,Qi,eo,to,Hn,hs,no,ro,so,i}from"./chunk-a9necy79.js";import{Ir}from"./chunk-xfv7evmd.js";import{a}from"./chunk-wtms9jhs.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=St.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 o=x[1];if(!xe.has(o)||s.has(o))continue;let f=u.offset+g+h.index+x[0].length-o.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:o.length,name:o,kind:u.kind,message:Se(o,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 o=S.find((p)=>p?.name===ke),f=Array.isArray(o?.libs)?o.libs.filter((p)=>typeof p==="string"):[];return o?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof h.extends==="string"?[h.extends]:Array.isArray(h.extends)?h.extends:[];for(let o of[...x].reverse()){if(typeof o!=="string"||!o.startsWith("."))continue;let f=T.resolve(T.dirname(g),o.endsWith(".json")?o:`${o}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Ho(e,t="",r=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",s=hs(e)+ms(gs(e.code)),l=e.kind==="client"||e.kind==="plain"?eo(t,e.code):"";return Hn(`${u+s}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{V,ae}from"./chunk-9jr7jbgv.js";import{le,S,Ke}from"./chunk-ptjqacjd.js";import{Ze,X,xe}from"./chunk-pxqs3psa.js";import{_e,ne,C,re,oi,vr,ai,Pt}from"./chunk-x819gynv.js";import{Hr}from"./chunk-d2z6tmzw.js";import{It}from"./chunk-8zf5q1m3.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.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 se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){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 ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(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 q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(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,i){let s,c=async()=>{let r=s??await i();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 c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(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,O=async()=>{let r=await i();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 c();v=O().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):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ol(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=oi(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 c=It(s.routeRules),l=new G,m=Hr(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,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.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:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=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?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}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=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null: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,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{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(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=vr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.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:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return ai(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-80q2becc.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
2
+ import{V,ae}from"./chunk-a9necy79.js";import{le,S,Ke}from"./chunk-ptjqacjd.js";import{Ze,X,xe}from"./chunk-pxqs3psa.js";import{_e,ne,C,re,oi,vr,ai,Pt}from"./chunk-7a0ffmer.js";import{Hr}from"./chunk-tprtjzzc.js";import{It}from"./chunk-8zf5q1m3.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.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 se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){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 ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(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 q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(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,i){let s,c=async()=>{let r=s??await i();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 c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(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,O=async()=>{let r=await i();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 c();v=O().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):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ol(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=oi(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 c=It(s.routeRules),l=new G,m=Hr(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,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.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:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=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?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}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=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null: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,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{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(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=vr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.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:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return ai(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-8h0nbb7t.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
3
3
  export{At,ol};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{an,ws}from"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";export{ws as generateRuntimeConfigTypes,an as prepareRuntimeConfig};
2
+ import{an,ws}from"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";export{ws as generateRuntimeConfigTypes,an as prepareRuntimeConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{qc}from"./chunk-qrzhpzdw.js";import"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qc as startInteractive};
2
+ import{qc}from"./chunk-36kkc60p.js";import"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{qc as startInteractive};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{K,un,te,_,Et}from"./chunk-b9wpgn7b.js";import{Ze,gn,sr,ir,or,Qe,et,tt,nt,rt,st,xe}from"./chunk-pxqs3psa.js";import{U,h,Zt,Qt,e,vt,en,f,je,xt,Be,Fe,Z,M,ae,q,d,ye,Yi,ls,n,r,ee,Wn,i,T,ce}from"./chunk-9jr7jbgv.js";import{_e,ti,ne,C,ni,wr,kn,ge,ri,re}from"./chunk-x819gynv.js";import{At}from"./chunk-bqjty9dx.js";import{De}from"./chunk-begfdc6a.js";import{a}from"./chunk-wtms9jhs.js";import{D}from"./chunk-yqsza22w.js";function Fs(t,o){let s=[],p=`${o}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)s.push(m);continue}if(l===o){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))s.push(m),c++}}return s}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
2
+ import{K,un,te,_,Et}from"./chunk-b9wpgn7b.js";import{Ze,gn,sr,ir,or,Qe,et,tt,nt,rt,st,xe}from"./chunk-pxqs3psa.js";import{U,h,Zt,Qt,e,vt,en,f,je,xt,Be,Fe,Z,M,ae,q,d,ye,Yi,ls,n,r,ee,Wn,i,T,ce}from"./chunk-a9necy79.js";import{_e,ti,ne,C,ni,wr,kn,ge,ri,re}from"./chunk-7a0ffmer.js";import{At}from"./chunk-44zjqsh9.js";import{De}from"./chunk-771hf74z.js";import{a}from"./chunk-wtms9jhs.js";import{D}from"./chunk-yqsza22w.js";function Fs(t,o){let s=[],p=`${o}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)s.push(m);continue}if(l===o){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))s.push(m),c++}}return s}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
3
3
  /* Theme selector for code blocks */
4
4
  .theme-selector {
5
5
  margin: 1rem 0;
@@ -1786,7 +1786,7 @@ else {
1786
1786
  })()
1787
1787
  </script>
1788
1788
  `;import Me from"fs";import Te from"path";function An(t){try{return Me.statSync(t).mtimeMs}catch{return null}}function Mt(t,o){let s=Math.max(0,Math.round((o-t)/1000));if(s<60)return`${s}s ago`;if(s<3600)return`${Math.round(s/60)}m ago`;return`${Math.round(s/3600)}h ago`}function Pi(t,o){try{return globalThis.Bun?.resolveSync(t,o)??null}catch{return null}}function Dn(t,o="stx"){let s=Te.resolve(t);for(let p=0;p<10;p++){let c=Te.join(s,"pantry","@stacksjs",o);if(Me.existsSync(c))return c;let l=Te.dirname(s);if(l===s)break;s=l}return null}var Mn=["@stacksjs/stx","bun-plugin-stx"];function Oi(t){try{let o=Me.readFileSync(Te.join(t,"package.json"),"utf8"),s=JSON.parse(o)?.version;return typeof s==="string"?s:null}catch{return null}}function Ai(t,o=6){let s=Te.resolve(t),p=[],c=new Set;function l(u,y){if(y>o)return;let g;try{g=Me.realpathSync(u)}catch{return}if(c.has(g))return;c.add(g);for(let w of Mn){let S=Te.join(u,w),E=Oi(S);if(E!==null)p.push({name:w,version:E,dir:Te.relative(s,S)||S,nested:y>0})}let b;try{b=Me.readdirSync(u,{withFileTypes:!0})}catch{return}for(let w of b){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=Te.join(u,w.name);if(w.name.startsWith("@")){let v;try{v=Me.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let R=Te.join(S,x.name,"node_modules");if(Me.existsSync(R))l(R,y+1)}continue}let E=Te.join(S,"node_modules");if(Me.existsSync(E))l(E,y+1)}}let m=Te.join(s,"node_modules");if(Me.existsSync(m))l(m,0);return p}function Di(t){let o=[];for(let s of Mn){let p=t.filter((m)=>m.name===s);if(p.length<=1)continue;let c=[...new Set(p.map((m)=>m.version))],l=p.map((m)=>`${m.version} at ${m.dir}`).join("; ");if(c.length===1){o.push({name:`${s} copies`,status:"info",detail:`${p.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}o.push({name:`${s} copies disagree`,status:"error",detail:`${c.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${s}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${s}/package.json' -exec grep -H '"version"' {} +`})}return o}async function pr(t={}){let o=t.cwd?Te.resolve(t.cwd):process.cwd(),s=t.resolve??Pi,p=Date.now(),c=[],l=s("@stacksjs/stx",o);c.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let m=s("bun-plugin-stx",o);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let y of Di(Ai(o)))c.push(y);let u=Dn(o,"stx");if(!u)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let y=Te.join(u,"src/signals.ts"),g=[Te.join(u,"dist/index.js"),Te.join(u,"dist/signals.js")].find((v)=>Me.existsSync(v))||null,b=An(y),w=g?An(g):null;if(b==null)c.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${u} but no src/signals.ts to compare`});else if(w==null)c.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${u} && bun build.ts`});else if(w<b){let v=Math.round((b-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${Mt(w,p)}) is OLDER than src/signals.ts (${Mt(b,p)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${u} && bun build.ts`})}else c.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${Mt(b,p)}, dist ${Mt(w,p)})`});let S=Te.join(o,"node_modules/@stacksjs/stx"),E=null;try{E=Me.lstatSync(S)}catch{E=null}if(!E)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(E.isSymbolicLink()){let v=null;try{v=Me.realpathSync(S)}catch{}let x=(()=>{try{return Me.realpathSync(u)}catch{return u}})();c.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else c.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(c.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let g=t.generateRuntime().length;c.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(y){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${y.message}`})}return{checks:c,ok:!c.some((y)=>y.status==="error")}}function fr(t){let o={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},s=["stx runtime resolution:"];for(let p of t.checks)if(s.push(` ${o[p.status]} ${p.name}: ${p.detail}`),p.fix)s.push(` \u2192 ${p.fix}`);return s.push(""),s.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),s.join(`
1789
- `)}var ft={name:"bun-plugin-stx",async setup(t){let s={...await i(),...t.config?.stx},p=new Set,c=s.webComponents?.enabled?`./${_t.relative(_t.dirname(t.config?.outdir||"dist"),s.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(s.webComponents?.enabled)try{let m=await Wn(s,p);if(l.push(...m),s.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(s.cache&&s.cachePath){let x=await Zt(m,s);if(x){if(s.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let y=await te(()=>Bun.file(m).text(),"",(x)=>{throw new un(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!y)throw new un(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:b,allScripts:w}=U.time("script-extraction",()=>{let x=y,R=Z(y);if(R)x=R.content.trim();let k=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",L=[];for(let P of k){let I=P.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=P.match(/<script\b([^>]*)>/i),G=F?F[1]:"";if(/\bserver\b/i.test(G))B=I;else L.push(P)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:L}}),S={__filename:m,__dirname:_t.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let R=new K(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(_.log(R,{filePath:m,scriptContent:g}),s.debug)throw R});let v=await U.timeAsync("directive-processing",async()=>await n(b,S,m,s,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-d7stgehg.js"),R=x(w.join(`
1789
+ `)}var ft={name:"bun-plugin-stx",async setup(t){let s={...await i(),...t.config?.stx},p=new Set,c=s.webComponents?.enabled?`./${_t.relative(_t.dirname(t.config?.outdir||"dist"),s.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(s.webComponents?.enabled)try{let m=await Wn(s,p);if(l.push(...m),s.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(s.cache&&s.cachePath){let x=await Zt(m,s);if(x){if(s.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let y=await te(()=>Bun.file(m).text(),"",(x)=>{throw new un(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!y)throw new un(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:b,allScripts:w}=U.time("script-extraction",()=>{let x=y,R=Z(y);if(R)x=R.content.trim();let k=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],B="",L=[];for(let P of k){let I=P.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",F=P.match(/<script\b([^>]*)>/i),G=F?F[1]:"";if(/\bserver\b/i.test(G))B=I;else L.push(P)}let j=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:B,templateContent:j,allScripts:L}}),S={__filename:m,__dirname:_t.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>d(g,S,m),void 0,(x)=>{let R=new K(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(_.log(R,{filePath:m,scriptContent:g}),s.debug)throw R});let v=await U.timeAsync("directive-processing",async()=>await n(b,S,m,s,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-053t5wrs.js"),R=x(w.join(`
1790
1790
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+R+`
1791
1791
  `+v.slice(k);else v+=`
1792
1792
  ${R}`}if(v=await q(v),u.forEach((x)=>p.add(x)),s.cache&&s.cachePath){if(await Qt(m,v,u,s),s.debug)console.log(`Cached template ${m} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let y=u instanceof Error?u:new K(`Plugin processing failed: ${String(u)}`,m);if(_.log(y,{filePath:m,buildConfig:t.config}),Et.logDetailedError(y,{filePath:m,plugin:"bun-plugin-stx"}),s.debug)console.error("stx Plugin Error:",y);let g=y,b=g.line||null,w=g.context||null;return{contents:s.debug||D()?`<!DOCTYPE html>
@@ -1849,7 +1849,7 @@ ${R}`}if(v=await q(v),u.forEach((x)=>p.add(x)),s.cache&&s.cachePath){if(await Qt
1849
1849
  <h1>Something went wrong</h1>
1850
1850
  <p>An internal error occurred. Please try again later.</p>
1851
1851
  </body>
1852
- </html>`,loader:"html"}}})}};async function yn(t,o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,o);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let y=a(process.cwd(),"output");Ne.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},F=await Bun.build({entrypoints:[u],outdir:y,plugins:[I,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let G=F.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await b())return!1;let S=Se.dirname(u);await vt(S);let E=s;try{if(E=await Ye(s),E!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${E} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=o.hmrPort||E+1;l=Pt({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,R;try{let{loadStxConfig:I}=await import("./chunk-dpxj1gez.js"),F=await I();if(R=o.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-h4avjh3q.js"),$e=F.broadcasting;await G($e);let he=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Oe=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Oe))try{let le=await oe(Oe);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-j4kqw34b.js"),L=await k(process.cwd(),R);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${E}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=zi({port:E,async fetch(I){return At(I,await(async()=>{let F=new URL(I.url);if([y,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>B(Se.join(le,F.pathname),process.cwd(),R)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(I);if(le.status!==404)return le}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await L(I);if(G)return G;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(o.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(o.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(y,F.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let $e=Se.dirname(u),he=Se.join($e,F.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let Oe=Se.join(process.cwd(),"public",F.pathname);if(Ne.existsSync(Oe)&&Ne.statSync(Oe).isFile()){let le=Bun.file(Oe),W=Se.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1852
+ </html>`,loader:"html"}}})}};async function yn(t,o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=Se.resolve(t);if(!Ne.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,o);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let y=a(process.cwd(),"output");Ne.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,b=async()=>{try{let I={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},F=await Bun.build({entrypoints:[u],outdir:y,plugins:[I,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!F.success)return console.error(`${e.red}Build failed:${e.reset}`,F.logs),!1;let G=F.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(I){return console.error(`${e.red}Error building stx file:${e.reset}`,I),!1}};if(!await b())return!1;let S=Se.dirname(u);await vt(S);let E=s;try{if(E=await Ye(s),E!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${E} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let I=o.hmrPort||E+1;l=Pt({wsPort:I,verbose:!1}),m=l.start(I)}let v={},x=null,R;try{let{loadStxConfig:I}=await import("./chunk-ksyb5bgt.js"),F=await I();if(R=o.stxOptions?.serverApi??F.serverApi,F?.apiRouter)x=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){v=F.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-h4avjh3q.js"),$e=F.broadcasting;await G($e);let he=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Oe=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(Oe))try{let le=await oe(Oe);console.log(`${e.blue}Loaded ${e.bright}${le} broadcast channel${le!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(le){console.warn(`${e.yellow}Failed to load channels.ts: ${le.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:B}=await import("./chunk-7tkwt0a9.js"),L=await k(process.cwd(),R);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${E}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let j=zi({port:E,async fetch(I){return At(I,await(async()=>{let F=new URL(I.url);if([y,Se.dirname(u),Se.join(process.cwd(),"public")].some((le)=>B(Se.join(le,F.pathname),process.cwd(),R)))return new Response("Not Found",{status:404});if(x)try{let le=await x.handleRequest(I);if(le.status!==404)return le}catch{}if(v[F.pathname])try{return await v[F.pathname](I)}catch(le){return new Response(JSON.stringify({error:le.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await L(I);if(G)return G;if(F.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(o.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(o.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(y,F.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let le=Bun.file(oe),W=Se.extname(oe).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let $e=Se.dirname(u),he=Se.join($e,F.pathname);if(Ne.existsSync(he)&&Ne.statSync(he).isFile()){let le=Bun.file(he),W=Se.extname(he).toLowerCase(),H="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}let Oe=Se.join(process.cwd(),"public",F.pathname);if(Ne.existsSync(Oe)&&Ne.statSync(Oe).isFile()){let le=Bun.file(Oe),W=Se.extname(Oe).toLowerCase(),H="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await le.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":H="text/html";break;case".css":H="text/css";break;case".js":H="text/javascript";break;case".json":H="application/json";break;case".png":H="image/png";break;case".jpg":case".jpeg":H="image/jpeg";break;case".gif":H="image/gif";break;case".svg":H="image/svg+xml";break;case".ico":H="image/x-icon";break;case".woff":H="font/woff";break;case".woff2":H="font/woff2";break;case".ttf":H="font/ttf";break;case".otf":H="font/otf";break;case".eot":H="application/vnd.ms-fontobject";break}return new Response(le,{headers:{"Content-Type":H}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1853
1853
  ${I.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1854
1854
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1855
1855
  ${e.bright}\u2192 ${e.cyan}http://localhost:${E}/${e.reset}`),console.log(`
@@ -2025,9 +2025,9 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
2025
2025
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2026
2026
  ${e.bright}\u2192 ${e.cyan}http://localhost:${b}/${e.reset}`),console.log(`
2027
2027
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),E=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Pe.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of u){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");E.push({route:x,filePath:Pe.relative(process.cwd(),v.filePath),fileType:"stx"})}if(E.sort((v,x)=>v.route.localeCompare(x.route)),E.forEach((v,x)=>{let k=x===E.length-1?"\u2514\u2500 ":"\u251C\u2500 ",B=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${B}`)}),console.log(`
2028
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,R)=>{if(!R)return;if(R.endsWith(".stx")||R.endsWith(".js")||R.endsWith(".ts")||R.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${R}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await y()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Vn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ui}=globalThis.Bun;import ve from"fs";import ie from"path";async function Kn(t){try{return xt(await Bun.file(t).text())}catch{return}}function qt(t){let o=Bun.file(t),s=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(s)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(o,{headers:{"Content-Type":p[s]||"application/octet-stream",...l}})}async function wn(t=".",o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=ie.resolve(t),{loadStxConfig:y}=await import("./chunk-dpxj1gez.js"),g=await y(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-j4kqw34b.js"),S=o.stxOptions?.serverApi??g.serverApi,E=await b(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=o.pagesDir||g.pagesDir||"pages",R=ie.join(v,x);if(!ve.existsSync(R)&&!g._layerPageDirs?.some((O)=>ve.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${R}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=M(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[R,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${R}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],L=[];for(let{dir:O,prefix:z}of B)if(ve.existsSync(O)){let N=M(ie.dirname(O),{pagesDir:ie.basename(O)});for(let V of N){let we=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;L.push({route:{...V,pattern:we},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,P=null,I=null;if(o.stxOptions?.shell!==!1){if(I=await ni(u,o.stxOptions?.shell),I){if(P=await wr(I,o.stxOptions||{}),P)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let F=et();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:O}=await import("./chunk-dpxj1gez.js"),z=await O(u);if(z?.apiRouter)oe=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){G=z.apiRoutes;let N=Object.keys(G).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-h4avjh3q.js"),we=z.broadcasting;await N(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(u,"output");ve.mkdirSync($e,{recursive:!0});let he=new Map,Oe=new Set,le=async(O)=>{let z=ir(R,O);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!N.success)return null;let V=N.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(O,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-dpxj1gez.js"),{checkCache:se,cacheTemplate:Q,readFileCached:X,templateCache:J}=await import("./chunk-d35y8thn.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},A={...we,...ke,...o.stxOptions,autoShell:!0};if(o.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(u,"cache");let be=!z&&!o.profile,pe=A.cache!==!1;if(pe&&be){let de=J.get(O.filePath);if(de)try{if((await ve.promises.stat(O.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Re of de.dependencies){if(!ve.existsSync(Re)){ze=!1;break}if((await ve.promises.stat(Re)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Re=de.output;if(P)Re=ge(Re,{preserveHead:!0});let gt=W.get(O.filePath);return{route:O,content:Re,status:gt?.status??await Kn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(O.filePath,A);if(Ie){let He=Ie;if(P)He=ge(He,{preserveHead:!0});let ze=W.get(O.filePath);return{route:O,content:He,status:ze?.status??await Kn(O.filePath),headers:ze?.headers}}}let me=pe?await X(O.filePath):await Bun.file(O.filePath).text(),Ce=xt(me),{classifyAllScripts:Y}=await import("./chunk-dpxj1gez.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:O.filePath,__dirname:ie.dirname(O.filePath),__stx_options:A,params:z??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,O.filePath)}catch(Ie){if(o.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let Ke=new Set,Ae;if(o.profile){let de=performance.now();Ae=await N(ue,fe,O.filePath,A,Ke);let Ie=performance.now()-de,He=ie.relative(u,O.filePath)||O.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Ae=await N(ue,fe,O.filePath,A,Ke);if(!P)Ae=await Ge(Ae,{router:A.router});{let{interpolateScriptExpressions:de}=await import("./chunk-d7stgehg.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(P)Ae=ge(Ae,{preserveHead:!0});if(pe&&be)await Q(O.filePath,Ae,Ke,A);let{extractStreamBoundaries:Xn}=await import("./chunk-80q2becc.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...A,autoShell:!1},He=Object.keys(mt).map((Re)=>({id:Re,render:async()=>{let gt=typeof de[Re]==="function"?await de[Re]():void 0;return N(mt[Re],{...fe,$boundary:gt},O.filePath,Ie,new Set)}})),ze=new Set(He.map((Re)=>Re.id));lt=[...(lt||[]).filter((Re)=>!ze.has(Re.id)),...He]}if(lt&&lt.length>0)Oe.add(O.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Ae,status:Kt??Ce,headers:Xt,boundaries:lt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Ue=8,qe=async()=>{he.clear(),j.clear();for(let O=0;O<k.length;O+=Ue){let z=k.slice(O,O+Ue),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)he.set(V.route.pattern,V)}for(let O=0;O<L.length;O+=Ue){let z=L.slice(O,O+Ue),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await vt(u);let at=s;try{if(at=await Ye(s),at!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=o.hmrPort||at+1;l=Pt({wsPort:O,verbose:!1}),m=l.start(O)}let Lt=(O,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(O.includes("</head>"))return O.replace("</head>",`${V}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+O};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ui({port:at,async fetch(O){let z=new URL(O.url),N=g?.publicDir||"public",V=ie.join(u,N,z.pathname),we=ie.join(u,z.pathname),We=ie.join($e,z.pathname);if([V,we,We].some((A)=>w(A,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(z.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(z.pathname.slice(16));if(A)try{let be=`<${A} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${A}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-ynrnx1tp.js"),be=await A(O,{publicDir:ie.join(u,N),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let A=await oe.handleRequest(O);if(A.status!==404)return A}catch{}if(G[z.pathname])try{return await G[z.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await E(O);if(X)return X;let J=gn(z.pathname,k);if(J){let A=he.get(J.route.pattern),be=Oe.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await H(J.route,J.params);if(pe)A=pe}if(A){let pe=A.status??200,me=A.headers??{},Ce=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Le=nt(z.pathname,J.params,Ce,z.search),Ve=rt(Le,null,O,{isServer:!0}),ue=await st(Ce.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Ae=new Headers(ue.responseHeaders);return Ae.set("Location",fe),new Response(null,{status:Ke,headers:Ae})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${fe}</head>`)}}let Y=A.content;if(P&&ri(O)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ti(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[Yi]:ls(),...C(),"Cache-Control":_e}})}if(P)Y=kn(P,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(o.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(o.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-80q2becc.js");return Ve(Le(Y,A.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(L.length>0){let A=L.map((pe)=>pe.route),be=gn(z.pathname,A);if(be){let pe=j.get(be.route.pattern);if(pe){let me=pe.content;if(P)me=kn(P,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of B)if(pe!=="/"&&z.pathname.startsWith(pe)){let me=j.get(pe)||j.get(pe+"/");if(me){let Ce=me.content;if(P)Ce=kn(P,Ce);if(Ce=await f(Ce,u),c)Ce=Xe(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let A=ke.content;if(A=await f(A,u),c)A=Xe(A,m);if(o.native)if(A.includes("<head>"))A=A.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let A=Je;if(A=await f(A,u),c)A=Xe(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let z=await le(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
2028
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(w.url.toString(),()=>{if(p)it.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,R)=>{if(!R)return;if(R.endsWith(".stx")||R.endsWith(".js")||R.endsWith(".ts")||R.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${R}${e.yellow} changed, rebuilding...${e.reset}`),ye.clear(),ee(),await y()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Vn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ui}=globalThis.Bun;import ve from"fs";import ie from"path";async function Kn(t){try{return xt(await Bun.file(t).text())}catch{return}}function qt(t){let o=Bun.file(t),s=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(s)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(o,{headers:{"Content-Type":p[s]||"application/octet-stream",...l}})}async function wn(t=".",o={}){let s=o.port||3000,p=o.watch!==!1,c=o.hotReload!==!1&&p,l=null,m=o.hmrPort||s+1,u=ie.resolve(t),{loadStxConfig:y}=await import("./chunk-ksyb5bgt.js"),g=await y(u),{createServerApi:b,isServerApiSource:w}=await import("./chunk-7tkwt0a9.js"),S=o.stxOptions?.serverApi??g.serverApi,E=await b(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=o.pagesDir||g.pagesDir||"pages",R=ie.join(v,x);if(!ve.existsSync(R)&&!g._layerPageDirs?.some((O)=>ve.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${R}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=M(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[R,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${R}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let B=g?._pluginPageDirs||[],L=[];for(let{dir:O,prefix:z}of B)if(ve.existsSync(O)){let N=M(ie.dirname(O),{pagesDir:ie.basename(O)});for(let V of N){let we=z==="/"?V.pattern:`${z}${V.pattern==="/"?"":V.pattern}`;L.push({route:{...V,pattern:we},prefix:z})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${z}${e.reset}`)}let j=new Map,P=null,I=null;if(o.stxOptions?.shell!==!1){if(I=await ni(u,o.stxOptions?.shell),I){if(P=await wr(I,o.stxOptions||{}),P)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,I)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Qe(),await tt(u);let F=et();if(F.length>0)console.log(`${e.blue}Loaded ${e.bright}${F.length}${e.blue} middleware: ${e.dim}${F.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:O}=await import("./chunk-ksyb5bgt.js"),z=await O(u);if(z?.apiRouter)oe=z?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(z?.apiRoutes){G=z.apiRoutes;let N=Object.keys(G).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(z?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:V}=await import("./chunk-h4avjh3q.js"),we=z.broadcasting;await N(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let $e=a(u,"output");ve.mkdirSync($e,{recursive:!0});let he=new Map,Oe=new Set,le=async(O)=>{let z=ir(R,O);if(!z)return null;try{let N=await Bun.build({entrypoints:[z],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...o.stxOptions});if(!N.success)return null;let V=N.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,H=async(O,z)=>{try{let{processDirectives:N,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-ksyb5bgt.js"),{checkCache:se,cacheTemplate:Q,readFileCached:X,templateCache:J}=await import("./chunk-1n7d9ag2.js"),ke=await We(u),Je=(de)=>{if(!de)return de;if(ie.isAbsolute(de))return de;return ie.resolve(u,de)},A={...we,...ke,...o.stxOptions,autoShell:!0};if(o.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(u,"cache");let be=!z&&!o.profile,pe=A.cache!==!1;if(pe&&be){let de=J.get(O.filePath);if(de)try{if((await ve.promises.stat(O.filePath)).mtime.getTime()<=de.mtime){let ze=!0;for(let Re of de.dependencies){if(!ve.existsSync(Re)){ze=!1;break}if((await ve.promises.stat(Re)).mtime.getTime()>de.mtime){ze=!1;break}}if(ze){let Re=de.output;if(P)Re=ge(Re,{preserveHead:!0});let gt=W.get(O.filePath);return{route:O,content:Re,status:gt?.status??await Kn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(O.filePath,A);if(Ie){let He=Ie;if(P)He=ge(He,{preserveHead:!0});let ze=W.get(O.filePath);return{route:O,content:He,status:ze?.status??await Kn(O.filePath),headers:ze?.headers}}}let me=pe?await X(O.filePath):await Bun.file(O.filePath).text(),Ce=xt(me),{classifyAllScripts:Y}=await import("./chunk-ksyb5bgt.js"),Le=Y(me),Ve=Le.server.map((de)=>de.content),ue=me;for(let de of Le.server)ue=ue.replace(de.fullTag,"");let fe={__filename:O.filePath,__dirname:ie.dirname(O.filePath),__stx_options:A,params:z??{},__stx_runtime_head:{}};for(let de of Ve)try{await V(de,fe,O.filePath)}catch(Ie){if(o.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let Ke=new Set,Ae;if(o.profile){let de=performance.now();Ae=await N(ue,fe,O.filePath,A,Ke);let Ie=performance.now()-de,He=ie.relative(u,O.filePath)||O.filePath;console.log(`[stx:profile] ${He} \u2192 ${Ie.toFixed(2)}ms`)}else Ae=await N(ue,fe,O.filePath,A,Ke);if(!P)Ae=await Ge(Ae,{router:A.router});{let{interpolateScriptExpressions:de}=await import("./chunk-053t5wrs.js");Ae=Ae.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,He,ze)=>{if(!/function\s+__stx_setup_/.test(ze))return Ie;return`<script${He}>${de(ze,fe)}</script>`})}if(P)Ae=ge(Ae,{preserveHead:!0});if(pe&&be)await Q(O.filePath,Ae,Ke,A);let{extractStreamBoundaries:Xn}=await import("./chunk-8h0nbb7t.js"),lt=Xn(fe),mt=fe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let de=fe.streamBoundaries||{},Ie={...A,autoShell:!1},He=Object.keys(mt).map((Re)=>({id:Re,render:async()=>{let gt=typeof de[Re]==="function"?await de[Re]():void 0;return N(mt[Re],{...fe,$boundary:gt},O.filePath,Ie,new Set)}})),ze=new Set(He.map((Re)=>Re.id));lt=[...(lt||[]).filter((Re)=>!ze.has(Re.id)),...He]}if(lt&&lt.length>0)Oe.add(O.pattern);else lt=void 0;let Kt=Be(fe),Xt=Fe(fe);if(be)W.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Ae,status:Kt??Ce,headers:Xt,boundaries:lt}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Ue=8,qe=async()=>{he.clear(),j.clear();for(let O=0;O<k.length;O+=Ue){let z=k.slice(O,O+Ue),N=await Promise.all(z.map((V)=>H(V)));for(let V of N)if(V)he.set(V.route.pattern,V)}for(let O=0;O<L.length;O+=Ue){let z=L.slice(O,O+Ue),N=await Promise.all(z.map(({route:V})=>H(V)));for(let V of N)if(V)j.set(V.route.pattern,V)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await vt(u);let at=s;try{if(at=await Ye(s),at!==s)console.log(`${e.yellow}Port ${s} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=o.hmrPort||at+1;l=Pt({wsPort:O,verbose:!1}),m=l.start(O)}let Lt=(O,z)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(z).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(O.includes("</head>"))return O.replace("</head>",`${V}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+O};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ui({port:at,async fetch(O){let z=new URL(O.url),N=g?.publicDir||"public",V=ie.join(u,N,z.pathname),we=ie.join(u,z.pathname),We=ie.join($e,z.pathname);if([V,we,We].some((A)=>w(A,u,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(se?.isFile()&&!w(we,u,S))return qt(we);if(Q?.isFile()&&!w(We,u,S))return qt(We);if(z.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(z.pathname.slice(16));if(A)try{let be=`<${A} />`,pe={...buildConfig,autoShell:!1},me=await processDirectives(be,{},ie.join(u,"components",`${A}.stx`),pe,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(z.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-ynrnx1tp.js"),be=await A(O,{publicDir:ie.join(u,N),cacheDir:a(u,"cache","img")});if(be)return be}if(oe)try{let A=await oe.handleRequest(O);if(A.status!==404)return A}catch{}if(G[z.pathname])try{return await G[z.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await E(O);if(X)return X;let J=gn(z.pathname,k);if(J){let A=he.get(J.route.pattern),be=Oe.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let pe=await H(J.route,J.params);if(pe)A=pe}if(A){let pe=A.status??200,me=A.headers??{},Ce=(J.route.filePath?je(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Ce.validate){if(!await Ce.validate({params:J.params})){let Ve=await le(404);if(Ve){let ue=Ve;if(ue=await f(ue,u),c)ue=Xe(ue,m);return new Response(ue,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Ce.middleware){let Le=nt(z.pathname,J.params,Ce,z.search),Ve=rt(Le,null,O,{isServer:!0}),ue=await st(Ce.middleware,Ve);if(ue.redirect){let fe=ue.redirect.path,Ke=ue.redirect.options.redirectCode||302,Ae=new Headers(ue.responseHeaders);return Ae.set("Location",fe),new Response(null,{status:Ke,headers:Ae})}if(ue.abort){let{statusCode:fe,message:Ke}=ue.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${fe}</title></head><body><h1>Error ${fe}</h1><p>${Ke}</p></body></html>`,{status:fe,headers:{"Content-Type":"text/html"}})}if(Object.keys(ue.state).length>0){let fe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ue.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${fe}</head>`)}}let Y=A.content;if(P&&ri(O)){let Le=xe(Y),Ve=ae(Y),ue=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),fe=ue?ti(ue[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:pe,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...fe&&{"X-STX-Title":encodeURIComponent(fe)},[Yi]:ls(),...C(),"Cache-Control":_e}})}if(P)Y=kn(P,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(o.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(o.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-8h0nbb7t.js");return Ve(Le(Y,A.boundaries,{timeoutMs:30000}),{status:pe,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:pe,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(L.length>0){let A=L.map((pe)=>pe.route),be=gn(z.pathname,A);if(be){let pe=j.get(be.route.pattern);if(pe){let me=pe.content;if(P)me=kn(P,me);if(Object.keys(be.params).length>0)me=Lt(me,be.params);if(me=await f(me,u),c)me=Xe(me,m);return new Response(me,{status:pe.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:pe}of B)if(pe!=="/"&&z.pathname.startsWith(pe)){let me=j.get(pe)||j.get(pe+"/");if(me){let Ce=me.content;if(P)Ce=kn(P,Ce);if(Ce=await f(Ce,u),c)Ce=Xe(Ce,m);return new Response(Ce,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Ze(z.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=he.get("/");if(ke){let A=ke.content;if(A=await f(A,u),c)A=Xe(A,m);if(o.native)if(A.includes("<head>"))A=A.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await le(404);if(Je){let A=Je;if(A=await f(A,u),c)A=Xe(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let z=await le(500);if(z)return new Response(z,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
2029
2029
  ${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
2030
2030
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2031
2031
  ${e.bright}\u2192 ${e.cyan}http://localhost:${at}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
2032
2032
  ${e.yellow}Routes:${e.reset}`);let jt=[...or(k,u)];for(let{route:O}of L)jt.push(`${O.pattern}`);if(jt.forEach((O,z)=>{let V=z===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${O}`)}),console.log(`
2033
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),o.native){let O,z=ie.join(R,"index.stx");if(ve.existsSync(z)){let V=await Bun.file(z).text();O=Tt(V)}let N=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??o.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(se)=>se.startsWith("public/")||se.startsWith("public\\"),z=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},N=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let X of Object.values(Q.resources)){if(!ve.existsSync(X))continue;let J=ve.realpathSync(X);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,X]of N)if(!se.has(Q))X.close(),N.delete(Q);for(let Q of se)if(!N.has(Q)&&ve.existsSync(Q))N.set(Q,ve.watch(Q,{recursive:!0},(X,J)=>{We(Q,X,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,X)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,X)),we),Ge=async(se,Q,X)=>{if(!X||Rt(X))return;if(Ct(X)){if(g._layerGraph){let J=await y(u);Object.assign(g,J),k.splice(0,k.length,...M(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[R,...J._layerPageDirs.slice(1)]:void 0})),V()}if(O(X)){if(console.log(`${e.cyan}${X} changed${e.reset}`),c&&l)l.reload(X)}else if(z(X)){console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-d35y8thn.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(I&&X){if(ie.resolve(se,X)===I||ie.basename(I)===X){let ke=await wr(I,o.stxOptions||{});if(ke)P=ke}}if(await qe(),await en(u),c&&l)l.reload(X)}else{console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-d35y8thn.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(await qe(),c&&l)l.reload(X)}}else if($t(X)){if(console.log(`${e.cyan}CSS ${X} changed${e.reset}`),c&&l)l.updateCss(X)}};V(),process.on("SIGINT",()=>{for(let se of N.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Fs,zs,Hs,Vs,dr,Us,Ws,qs,Io,Do,pr,fr,yn,bn,wn};
2033
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),ot(It.url.toString(),()=>{if(l)ht();It.stop()}),o.native){let O,z=ie.join(R,"index.stx");if(ve.existsSync(z)){let V=await Bun.file(z).text();O=Tt(V)}let N=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??o.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(se)=>se.startsWith("public/")||se.startsWith("public\\"),z=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},N=new Map,V=()=>{let se=new Set([u,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let X of Object.values(Q.resources)){if(!ve.existsSync(X))continue;let J=ve.realpathSync(X);if(![...se].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))se.add(J)}for(let[Q,X]of N)if(!se.has(Q))X.close(),N.delete(Q);for(let Q of se)if(!N.has(Q)&&ve.existsSync(Q))N.set(Q,ve.watch(Q,{recursive:!0},(X,J)=>{We(Q,X,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},we=Promise.resolve(),We=(se,Q,X)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,X)),we),Ge=async(se,Q,X)=>{if(!X||Rt(X))return;if(Ct(X)){if(g._layerGraph){let J=await y(u);Object.assign(g,J),k.splice(0,k.length,...M(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[R,...J._layerPageDirs.slice(1)]:void 0})),V()}if(O(X)){if(console.log(`${e.cyan}${X} changed${e.reset}`),c&&l)l.reload(X)}else if(z(X)){console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-1n7d9ag2.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(I&&X){if(ie.resolve(se,X)===I||ie.basename(I)===X){let ke=await wr(I,o.stxOptions||{});if(ke)P=ke}}if(await qe(),await en(u),c&&l)l.reload(X)}else{console.log(`${e.yellow}${X} changed, rebuilding...${e.reset}`),ye.clear(),ee();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-1n7d9ag2.js");J(ie.resolve(se,X)),ke.delete(ie.resolve(se,X))}catch{}if(await qe(),c&&l)l.reload(X)}}else if($t(X)){if(console.log(`${e.cyan}CSS ${X} changed${e.reset}`),c&&l)l.updateCss(X)}};V(),process.on("SIGINT",()=>{for(let se of N.values())se.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Fs,zs,Hs,Vs,dr,Us,Ws,qs,Io,Do,pr,fr,yn,bn,wn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$t,S}from"./chunk-ptjqacjd.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=$t();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-7jw2zhb9.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 ws(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{$t,S}from"./chunk-ptjqacjd.js";import m from"fs";import e from"path";async function an(r,o,i){if(r.__stx_runtime_config)return;let n=$t();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-s4ypqjhp.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 ws(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,5 +1,5 @@
1
1
  // @bun
2
- import{Pn,Oe,Ne,me,Hi,Mn,Z,q,nn,d,n,A}from"./chunk-9jr7jbgv.js";import{dirname as C,resolve as R}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:m}=Pn(o),c=await(e.renderer??((s)=>Oe(s)))(m);return{html:_(c),frontmatter:r??{}}}function k(o){let e=o,r=Z(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function v(o,e){return`<!DOCTYPE html>
2
+ import{Pn,Oe,Ne,me,Hi,Mn,Z,q,nn,d,n,A}from"./chunk-a9necy79.js";import{dirname as C,resolve as R}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:m}=Pn(o),c=await(e.renderer??((s)=>Oe(s)))(m);return{html:_(c),frontmatter:r??{}}}function k(o){let e=o,r=Z(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function v(o,e){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -14,5 +14,5 @@ ${c.join(`
14
14
  `)}`}else{if(r.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=Ne(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await me(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
15
15
  `);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${g}
16
16
  $1`);else t+=`
17
- ${g}`}t=await q(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-8bpf8d7n.js");t=await i(t)}catch{}return t}
17
+ ${g}`}t=await q(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-p3462q2p.js");t=await i(t)}catch{}return t}
18
18
  export{Ci};
@@ -39,8 +39,17 @@ console.log('[stx] entering IIFE');
39
39
  },
40
40
  removeAttribute: function(node, name) { node.removeAttribute(name); },
41
41
  setStyle: function(node, value) {
42
- if (typeof value === 'object' && value !== null) Object.assign(node.style, value);
43
- else if (typeof value === 'string') node.style.cssText = value;
42
+ if (typeof value === 'object' && value !== null) {
43
+ Object.assign(node.style, value);
44
+ if (Object.prototype.hasOwnProperty.call(value, 'display')) node.__stx_display = value.display || '';
45
+ }
46
+ else if (typeof value === 'string') {
47
+ node.style.cssText = value;
48
+ node.__stx_display = node.style.display || '';
49
+ }
50
+ // Reactive style updates must not clear the display:none owned by :show.
51
+ // This also keeps the latest explicit display for when the gate opens.
52
+ if (node.__stx_visible === false) node.style.display = 'none';
44
53
  },
45
54
 
46
55
  // Structural operations, for the bindings that build rows rather than
@@ -91,6 +100,7 @@ console.log('[stx] entering IIFE');
91
100
  node.__stx_display = (d && d !== 'none') ? d : '';
92
101
  }
93
102
  var was = node.style.display !== 'none';
103
+ node.__stx_visible = visible;
94
104
  node.style.display = visible ? node.__stx_display : 'none';
95
105
  return was;
96
106
  },
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{q,us,ds,ps,n}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{q as injectRouterScript,n as processDirectives,us as processJsonDirective,ds as processOnceDirective,ps as validateClientScript};
2
+ import{q,us,ds,ps,n}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{q as injectRouterScript,n as processDirectives,us as processJsonDirective,ds as processOnceDirective,ps as validateClientScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y,Me,I,Yt,i,T}from"./chunk-9jr7jbgv.js";import{Vr}from"./chunk-d2z6tmzw.js";import{s,be}from"./chunk-3pxp0r0a.js";import{a}from"./chunk-wtms9jhs.js";import m from"path";import j from"fs";function pe(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function fe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function J(e,t){let r=[];for(let l of fe(e)){if(pe(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 De(e,t){return J(e,t).map((r)=>{let l=r.file?`${r.file}${r.line?`:${r.line}${r.column?`:${r.column}`:""}`:""}`:"",u=r.lineText?`
2
+ import{y,Me,I,Yt,i,T}from"./chunk-a9necy79.js";import{Vr}from"./chunk-tprtjzzc.js";import{s,be}from"./chunk-3pxp0r0a.js";import{a}from"./chunk-wtms9jhs.js";import m from"path";import j from"fs";function pe(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.message==="string"&&(t.name==="BuildMessage"||t.name==="ResolveMessage"||("position"in t))}function fe(e){if(e&&typeof e==="object"&&Array.isArray(e.errors))return e.errors;return[e]}function J(e,t){let r=[];for(let l of fe(e)){if(pe(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 De(e,t){return J(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=10;function P(e,t,r){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(m.basename(e))||Vr(e,t,r)}var re=1,se=new Map,W=600,ge=100,G=new Map;async function he(e){let t=G.get(e)??0;if(t>0&&t<ge){G.set(e,t+1);return}G.set(e,1);try{let r=(await j.promises.readdir(e)).filter((p)=>p.endsWith(".js"));if(r.length<=W)return;let u=(await Promise.all(r.map(async(p)=>{try{return{name:p,at:(await j.promises.stat(m.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(W)){let d=p.name.slice(0,-3);await j.promises.rm(m.join(e,`${d}.js`),{force:!0}),await j.promises.rm(m.join(e,`${d}.deps.json`),{force:!0})}A("pruned bundle cache to",W,"entries")}catch{}}function oe(e){return se.get(e)??[]}function q(e,t){if(e)se.set(e,t)}function Oa(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function A(...e){if(Oa())console.log("[stx:bundler]",...e)}var Y=[];function Ii(e,t,r){Y.push({filePath:e||"<inline>",message:t,details:r})}function ft(){return Y.slice()}function gt(){Y.length=0}var H;function gu(e){H=e}function Di(){if(H)return H;try{let e=T.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Z=[/^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(!Z.some((d)=>d.test(u)))return A("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(!Z.some((d)=>d.test(u)))return A("detected side-effect import:",u),!0}return!1}var Jt="stx-module:",xe=/\.(?:[cm]?[jt]sx?|json)$/i;function Ma(e,t){return m.relative(e,t).split(m.sep).join("/")}function Na(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(Jt)?`${l}${u}${d}${u}`:r})}function La(e,t){let r=0,l=(p)=>{let d=`__stxMod${r++}`,b=JSON.stringify(p);return t.push(`var ${d} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${d} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),d},u=(p,d)=>{for(let b of p.split(",")){let M=b.trim();if(!M)continue;let c=M.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!c)continue;let n=c[1].startsWith('"')?JSON.parse(c[1]):c[1],o=c[2]??n;t.push(`var ${o} = ${d}[${JSON.stringify(n)}];`)}};return e=e.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,d,b)=>{let M=b.slice(Jt.length),c=l(M),n=d.trim(),o=n.match(/^([\w$]+)\s*(?:,\s*|$)/);if(o&&!n.startsWith("{")&&!n.startsWith("*"))t.push(`var ${o[1]} = ${c}.default;`),n=n.slice(o[0].length).trim();let f=n.match(/^\*\s*as\s+([\w$]+)$/);if(f)t.push(`var ${f[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(Jt.length)),"")),e}function te(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,m.join(e,"index.ts"),m.join(e,"index.tsx"),m.join(e,"index.js"),m.join(e,"index.mjs")];for(let r of t)try{if(j.existsSync(r)&&j.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return}function $e(e,t,r,l,u,p=new Map,d){let b=(c,n,o)=>{if(P(n,e,d))return null;if(!u||c!==r||!xe.test(n))return null;try{if(!j.statSync(n,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(n);let f=`${Jt}${Ma(process.cwd(),n)}`;return p.set(o,f),{path:f,external:!0}},M=(c,n)=>{let o=c===r?t:m.dirname(c),f=m.resolve(o,n);return te(f)??f};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 o=te(n.path);if(o){let f=b(n.importer,o,n.path);if(f)return f;if(o!==r)l.add(o);return{path:o}}return{path:n.path,external:!0}}),c.onResolve({filter:/^\.\.?\//},(n)=>{let o=M(n.importer,n.path),f=b(n.importer,o,n.path);if(f)return f;return l.add(o),{path:o}}),c.onResolve({filter:/^[@~]\//},(n)=>{let o=m.resolve(e,n.path.slice(2)),f=[o,`${o}.ts`,`${o}.tsx`,`${o}.js`,`${o}.mjs`,`${o}.jsx`,m.join(o,"index.ts"),m.join(o,"index.tsx"),m.join(o,"index.js"),m.join(o,"index.mjs")];for(let E of f)if(j.existsSync(E)&&j.statSync(E,{throwIfNoEntry:!1})?.isFile()){let N=b(n.importer,E,n.path);if(N)return N;return A(`resolved ${n.path[0]}/ import:`,n.path,"\u2192",E),l.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${n.path[0]}/ import:`,n.path),{path:o}}),u)c.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(n)=>{if(n.importer!==r)return;let o=`${Jt}npm:${n.path}`;return p.set(n.path,o),{path:o,external:!0}});c.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(n)=>{if(P(n.path,e,d))throw Error(`Server-only API source cannot be imported by a client script: ${n.path}`);let o=m.extname(n.path).toLowerCase(),f=o===".json"?"json":o===".tsx"?"tsx":o===".jsx"?"jsx":o===".ts"||o===".mts"||o===".cts"?"ts":"js";if(n.path!==r)l.add(n.path);return{contents:j.readFileSync(n.path,"utf8"),loader:f}})}}}var X=new Map,U=I(64),ne=Symbol.for("stx.client-bundle-build-queue");function ja(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,b=r.cacheDir||a(l,"bundle-cache"),M=new Bun.CryptoHasher("md5");M.update(`${me}\x00${Me()}\x00${JSON.stringify(u??!1)}\x00${d?"registry":"inline"}\x00${e}\x00${t}`);let c=M.digest("hex").slice(0,12),n=m.join(b,`${c}.js`),o=U.get(n);if(o){if(Yt(o.files)&&o.files.every((F)=>!P(F.path,l,u))){A("memo hit:",c);let F=o.files.map((_)=>_.path);return q(t,F),r.collectInputs?.push(...F),o.code}U.delete(n),A("memo invalidated by dep change:",c)}let f=m.join(b,`${c}.deps.json`),E=Bun.file(n);if(await E.exists()){let F=Bun.file(f),_=!1,v=null;if(await F.exists())try{let D=JSON.parse(await F.text());if(D.metadataVersion!==re||!Array.isArray(D.files))_=!1;else v=D.files,_=!0;if(v&&(!Yt(v)||v.some((k)=>P(k.path,l,u))))_=!1}catch{_=!1}if(_){if(A("cache hit:",c),v)q(t,v.map((k)=>k.path)),r.collectInputs?.push(...v.map((k)=>k.path));let D=await E.text();if(v)U.set(n,{code:D,files:v});return D}A("cache invalidated by dep change:",c)}let N=X.get(c);if(N){let F=await N;if(r.collectInputs)r.collectInputs.push(...(U.get(n)?.files??[]).map((_)=>_.path));return F}let S=ja(()=>ye(e,t,{projectRoot:l,minify:p,cacheDir:b,hash:c,cachePath:n,depsPath:f,collectInputs:r.collectInputs,externalizeUserModules:d,serverApi:u}));X.set(c,S);try{return await S}finally{X.delete(c)}}var we=0;function Ba(e){return`${e}-${process.pid}-${++we}`}async function ye(e,t,r){let{projectRoot:l,minify:u,cacheDir:p,hash:d,cachePath:b,depsPath:M,externalizeUserModules:c}=r,n=a(l,"bundle-tmp"),o=Ba(d),f=m.join(n,`${o}.ts`),E=m.join(n,"out",o);j.mkdirSync(n,{recursive:!0}),j.mkdirSync(E,{recursive:!0});let N=m.dirname(t),S=new Set,F=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,_=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,v=s(e),{depths:D,balanced:k}=be(v),V=(w)=>!k||D[w]===0,h;while((h=F.exec(v))!==null){if(h[1])continue;if(!V(h.index))continue;if(h[2])h[2].split(",").forEach((w)=>{let g=Be(w);if(g)S.add(g)});else if(h[3])S.add(h[3])}while((h=_.exec(v))!==null){if(h[1])continue;if(!V(h.index))continue;S.add(h[2])}let ie=/^[ \t]*import\s+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((h=ie.exec(v))!==null){if(!V(h.index))continue;let w=/^\s*['"]([^'"]+)['"]/.exec(e.slice(h.index+h[0].length))?.[1];if(w&&Z.some((g)=>g.test(w)))continue;if(h[1])S.add(h[1]);if(h[2])S.add(h[2]);for(let g of(h[3]??"").split(",")){let B=g.trim();if(!B||/^type\s/.test(B))continue;let L=/\bas\s+(\w+)\s*$/.exec(B)?.[1]??/^\w+$/.exec(B)?.[0];if(L)S.add(L)}}for(let w of v.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let g of w[1].split(",")){let B=/\bas\s+(\w+)\s*$/.exec(g)?.[1]??/^\s*(\w+)\s*$/.exec(g)?.[1];if(B)S.delete(B)}let le=S.size>0?`
5
5
  export { ${[...S].join(", ")} }`:"";await Bun.write(f,e+le),A("bundling:",d,"from:",m.basename(t));let Q=new Set,K=new Map;try{let w=await Bun.build({entrypoints:[f],outdir:E,target:"browser",format:"esm",minify:u,plugins:[$e(l,N,f,Q,c,K,r.serverApi)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...y()},root:l});if(!w.success){let R=w.logs.filter((C)=>C.level==="error").map((C)=>C.message).join(", ")||`Unable to bundle ${m.basename(t)}`,O=J(w.logs,t||void 0);if(console.warn("[stx:bundler] build failed:",R),Ii(t||"",R,O),Di()==="error")throw Error(R);return e}let g="";for(let x of w.outputs){g=await x.text();break}let B=[];for(let x of g.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let R of x[1].split(",")){let O=R.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(O){B.push([O[2],O[1]]);continue}let C=R.trim();if(/^[A-Za-z_$][\w$]*$/.test(C))B.push([C,C])}let L=[];g=La(Na(g,K),L);let ae=g.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];g=g.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let ee=`__stxBundle_${d}`,ce=B.map(([x,R])=>`${JSON.stringify(x)}: ${R}`).join(", "),ue=B.map(([x])=>`var ${x} = undefined;`).join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ji,Xr,Y,Le,wt,b,Be,Fe,jn,d,rn}from"./chunk-9jr7jbgv.js";import{D}from"./chunk-yqsza22w.js";import E from"path";var j=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(j.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ei(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var _e="private, no-store";function ti(t){return t.replace(/&#(\d+);/g,(n,e)=>O(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>O(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function O(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function C(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function W(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-0n28xm1q.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function ni(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function wr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=ei(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:x,loadStxConfig:y}=await import("./chunk-dpxj1gez.js"),R=await y(),g={__filename:t,__dirname:E.dirname(t)};for(let m of a){let A=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!m.includes("client")&&!m.includes('type="module"'))await h(A[1],g,t)}let S=await p(l,g,t,{...x,...R,...n},new Set),w=S.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:S.substring(0,w),afterSlot:S.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function kn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{ji,Xr,Y,Le,wt,b,Be,Fe,jn,d,rn}from"./chunk-a9necy79.js";import{D}from"./chunk-yqsza22w.js";import E from"path";var j=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(j.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ei(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var _e="private, no-store";function ti(t){return t.replace(/&#(\d+);/g,(n,e)=>O(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>O(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function O(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function C(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function W(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-0n28xm1q.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function ni(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function wr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=ei(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:x,loadStxConfig:y}=await import("./chunk-ksyb5bgt.js"),R=await y(),g={__filename:t,__dirname:E.dirname(t)};for(let m of a){let A=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!m.includes("client")&&!m.includes('type="module"'))await h(A[1],g,t)}let S=await p(l,g,t,{...x,...R,...n},new Set),w=S.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:S.substring(0,w),afterSlot:S.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function kn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -26,5 +26,5 @@ ${i}
26
26
  `));if(o.length>0)x.push(o.join(`
27
27
  `));if(f.length>0)x.push(f.join(`
28
28
  `));return x.push(l),x.join(`
29
- `)}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function vr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!vr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function ai(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function si(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function ii(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function oi(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-80q2becc.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-et2kt16p.js"),{defaultConfig:p}=await import("./chunk-7jw2zhb9.js"),h=r.streamBoundaries||{},x={...p,autoShell:!1},y=Object.keys(l).map((g)=>({id:g,render:async()=>{let S=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:S},t.sourceFile,x,new Set)}})),R=new Set(y.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...y]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Xr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await N(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=jn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Xr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=b(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?wt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(ji(t.html,s)),context:e,cookies:r.cookies}}
29
+ `)}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function vr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!vr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function ai(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function si(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function ii(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function oi(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-8h0nbb7t.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-6faqgn2f.js"),{defaultConfig:p}=await import("./chunk-s4ypqjhp.js"),h=r.streamBoundaries||{},x={...p,autoShell:!1},y=Object.keys(l).map((g)=>({id:g,render:async()=>{let S=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:S},t.sourceFile,x,new Set)}})),R=new Set(y.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...y]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Xr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await N(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=jn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Xr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=b(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?wt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(ji(t.html,s)),context:e,cookies:r.cookies}}
30
30
  export{ei,_e,ti,ne,C,ni,wr,kn,ge,ri,re,si,ii,oi,vr,ai,Pt};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{yt,Fr,zr,Hr,mu,Vr}from"./chunk-d2z6tmzw.js";import"./chunk-t7x753ga.js";import"./chunk-ptjqacjd.js";import"./chunk-pxqs3psa.js";export{zr as buildServerApi,mu as createServerApi,yt as discoverServerApi,Fr as generateApiTypes,Vr as isServerApiSource,Hr as productionApiDispatcher};
2
+ import{yt,Fr,zr,Hr,mu,Vr}from"./chunk-tprtjzzc.js";import"./chunk-t7x753ga.js";import"./chunk-ptjqacjd.js";import"./chunk-pxqs3psa.js";export{zr as buildServerApi,mu as createServerApi,yt as discoverServerApi,Fr as generateApiTypes,Vr as isServerApiSource,Hr as productionApiDispatcher};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kt,is,Gi,pc}from"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{pc as declareBareLoopHead,kt as parseLoopBinding,Gi as processLoops,is as reportDeferredLoopWarnings};
2
+ import{kt,is,Gi,pc}from"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{pc as declareBareLoopHead,kt as parseLoopBinding,Gi as processLoops,is as reportDeferredLoopWarnings};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jl,gi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu}from"./chunk-nvr0ph6b.js";import"./chunk-9jr7jbgv.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-8bew5svs.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{$a as SUSPENSE_RESOLVER_RUNTIME,gi as buildSuspenseResolveScript,tu as createStreamRenderer,Ql as extractStreamBoundaries,iu as generateHydrationRuntime,Ta as islandDirective,ru as processSectionDirectives,Zl as processStreamDirectives,nu as registerStreamingDirectives,Yl as renderStreamingPage,Jl as streamTemplate,eu as streamTemplateSimple,su as streamToResponse,Ea as streamingSuspenseDirective};
2
+ import{Jl,gi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu}from"./chunk-yhxazetv.js";import"./chunk-a9necy79.js";import"./chunk-8wkja2z2.js";import"./chunk-8x47zcfa.js";import"./chunk-t7x753ga.js";import"./chunk-5ahb6arz.js";import"./chunk-ptjqacjd.js";import"./chunk-my3jkpv7.js";import"./chunk-721yq8qx.js";import"./chunk-b9wpgn7b.js";import"./chunk-axydabse.js";import"./chunk-1yj3p63h.js";import"./chunk-pxqs3psa.js";import"./chunk-114zdbnd.js";export{$a as SUSPENSE_RESOLVER_RUNTIME,gi as buildSuspenseResolveScript,tu as createStreamRenderer,Ql as extractStreamBoundaries,iu as generateHydrationRuntime,Ta as islandDirective,ru as processSectionDirectives,Zl as processStreamDirectives,nu as registerStreamingDirectives,Yl as renderStreamingPage,Jl as streamTemplate,eu as streamTemplateSimple,su as streamToResponse,Ea as streamingSuspenseDirective};