@stacksjs/stx 0.2.665 → 0.2.667

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 (157) hide show
  1. package/dist/chunk-028ee6q5.js +2 -0
  2. package/dist/chunk-02ymqwmj.js +2 -0
  3. package/dist/chunk-0syr525r.js +2 -0
  4. package/dist/chunk-1e79xcc8.js +2 -0
  5. package/dist/{chunk-2q50h7zv.js → chunk-1ffjj2c6.js} +5 -5
  6. package/dist/chunk-1pnp91wx.js +2 -0
  7. package/dist/{chunk-2h8ea0we.js → chunk-1sr6c0nk.js} +2 -2
  8. package/dist/chunk-1y5ampxc.js +2 -0
  9. package/dist/chunk-2265dwpm.js +2 -0
  10. package/dist/chunk-280p4q7a.js +2 -0
  11. package/dist/{chunk-hb08vrbb.js → chunk-2dp7hyv7.js} +21 -21
  12. package/dist/{chunk-x34scshq.js → chunk-2zzc7006.js} +2 -2
  13. package/dist/{chunk-wpm58d6p.js → chunk-30nes8ne.js} +2 -2
  14. package/dist/{chunk-zaaeneq6.js → chunk-365vg0eg.js} +2 -2
  15. package/dist/{chunk-2qbvsvwc.js → chunk-3850m7ab.js} +6 -6
  16. package/dist/{chunk-ewcrsyr7.js → chunk-3hxd5td3.js} +2 -2
  17. package/dist/{chunk-pxqh758g.js → chunk-3y41efsf.js} +64 -15
  18. package/dist/{chunk-cg3mvq4h.js → chunk-4701f9eh.js} +6 -6
  19. package/dist/{chunk-jrf01hfv.js → chunk-4c183zem.js} +1 -1
  20. package/dist/{chunk-dra341c0.js → chunk-4htp92hr.js} +15 -15
  21. package/dist/{chunk-pc48mjkc.js → chunk-4qh789bq.js} +4 -4
  22. package/dist/chunk-4s284y6c.js +2 -0
  23. package/dist/chunk-5zgrvj4b.js +2 -0
  24. package/dist/{chunk-38b3w1y4.js → chunk-6h06rqmj.js} +1 -1
  25. package/dist/{chunk-s3dyzxwx.js → chunk-6jwey47v.js} +4 -4
  26. package/dist/{chunk-yq021b3r.js → chunk-7d4z944r.js} +3 -3
  27. package/dist/{chunk-rjh2jwxx.js → chunk-7met6yva.js} +8 -8
  28. package/dist/chunk-7y2htsr8.js +2 -0
  29. package/dist/{chunk-zpc06ysq.js → chunk-85sa9q09.js} +1 -1
  30. package/dist/{chunk-2jh21f1n.js → chunk-89jbdtgw.js} +1 -1
  31. package/dist/{chunk-b6xv8jh9.js → chunk-8gy90n5q.js} +1 -1
  32. package/dist/chunk-an6y1v5h.js +2 -0
  33. package/dist/chunk-b42p0kvz.js +2 -0
  34. package/dist/{chunk-mrrrngzd.js → chunk-b4pcw34n.js} +1 -1
  35. package/dist/chunk-b54s3qde.js +2 -0
  36. package/dist/chunk-b7e07ybq.js +3 -0
  37. package/dist/{chunk-0jhdrgpr.js → chunk-b823zxq6.js} +2 -2
  38. package/dist/{chunk-c9k40352.js → chunk-bdg0fydw.js} +1 -1
  39. package/dist/{chunk-11zp67ds.js → chunk-bexp6dsp.js} +4 -4
  40. package/dist/chunk-bey0cjrp.js +2 -0
  41. package/dist/chunk-bheh3z8r.js +2 -0
  42. package/dist/chunk-bj2xzkv6.js +2 -0
  43. package/dist/{chunk-szyqxcfj.js → chunk-bnn7pd62.js} +2 -2
  44. package/dist/chunk-bs7hq5a3.js +2 -0
  45. package/dist/{chunk-qzy8ypk4.js → chunk-c7d09931.js} +40 -40
  46. package/dist/chunk-crcypbbq.js +2 -0
  47. package/dist/{chunk-w2zceynt.js → chunk-dpvxe52r.js} +1 -1
  48. package/dist/chunk-dq42tzg1.js +2 -0
  49. package/dist/chunk-dvrndj0q.js +2 -0
  50. package/dist/{chunk-np1k9vsr.js → chunk-e1fetwbr.js} +1 -1
  51. package/dist/chunk-e4vpr36s.js +2 -0
  52. package/dist/{chunk-43gr8ggc.js → chunk-ec9ztgxx.js} +2 -2
  53. package/dist/{chunk-yh0wb4n1.js → chunk-ecqrkyg8.js} +2 -2
  54. package/dist/{chunk-nm8yr8a9.js → chunk-f62hpbw8.js} +1 -1
  55. package/dist/{chunk-jh3r0qp7.js → chunk-fbcp9hm4.js} +1 -1
  56. package/dist/chunk-fmzhrwt1.js +2 -0
  57. package/dist/{chunk-gf4e5xtr.js → chunk-fqhmee37.js} +27 -27
  58. package/dist/{chunk-1z1632np.js → chunk-fsef9nvs.js} +41 -41
  59. package/dist/{chunk-een2wqah.js → chunk-fvtwec1r.js} +1 -1
  60. package/dist/{chunk-awe50wee.js → chunk-fwwt7nrc.js} +1 -1
  61. package/dist/{chunk-t9mfztcs.js → chunk-fzqj1mjz.js} +3 -3
  62. package/dist/chunk-gfmw85vw.js +2 -0
  63. package/dist/{chunk-tx6p6jnk.js → chunk-ghsmfkq9.js} +1 -1
  64. package/dist/{chunk-p2mrba1n.js → chunk-gjck0t32.js} +107 -107
  65. package/dist/chunk-hc70e121.js +2 -0
  66. package/dist/{chunk-0g4pr7ww.js → chunk-hjn7qqrq.js} +9 -9
  67. package/dist/chunk-hqwr25qg.js +2 -0
  68. package/dist/{chunk-5w2jy5r9.js → chunk-hvf2e7pr.js} +2 -2
  69. package/dist/{chunk-pmwb5kaf.js → chunk-j045bcpb.js} +2 -2
  70. package/dist/{chunk-nf9bykvg.js → chunk-j7mr8h2w.js} +5 -5
  71. package/dist/{chunk-edvmtk21.js → chunk-jzy0pqez.js} +5 -5
  72. package/dist/{chunk-r7kmsq3n.js → chunk-ka8befem.js} +1 -1
  73. package/dist/chunk-m72b5043.js +2 -0
  74. package/dist/{chunk-v2x9vzgw.js → chunk-md2jn67b.js} +2 -2
  75. package/dist/{chunk-zjsyw63k.js → chunk-mekhzhes.js} +9 -9
  76. package/dist/{chunk-2f1bk3bg.js → chunk-mn3mc6ax.js} +1 -1
  77. package/dist/chunk-n5r1xek6.js +2 -0
  78. package/dist/{chunk-8dcemd4a.js → chunk-ndffc344.js} +1 -1
  79. package/dist/{chunk-d3bsfd10.js → chunk-npa7gze7.js} +2 -2
  80. package/dist/{chunk-8nryyqb5.js → chunk-p472crv1.js} +1 -1
  81. package/dist/{chunk-4yf1w261.js → chunk-pn1ehs6a.js} +2 -2
  82. package/dist/{chunk-7rta163c.js → chunk-pxdww4rb.js} +2 -2
  83. package/dist/{chunk-eqrkhc18.js → chunk-qjtpxsyx.js} +2 -2
  84. package/dist/{chunk-bgra36az.js → chunk-qrq88ng0.js} +1 -1
  85. package/dist/{chunk-gf3bxnpq.js → chunk-qxmyaajq.js} +1 -1
  86. package/dist/{chunk-f2z8s2h9.js → chunk-qxsvd26z.js} +2 -2
  87. package/dist/chunk-r883qzmx.js +2 -0
  88. package/dist/{chunk-vjw3qrqj.js → chunk-rns1e0c5.js} +1 -1
  89. package/dist/{chunk-7ae140wv.js → chunk-sgj6dt85.js} +1 -1
  90. package/dist/{chunk-q1svy1nf.js → chunk-t226hswj.js} +1 -1
  91. package/dist/{chunk-a1p327a7.js → chunk-t886718q.js} +9 -9
  92. package/dist/{chunk-jkvr7e91.js → chunk-tp4eqfxq.js} +2 -2
  93. package/dist/chunk-w1qvq9jf.js +2 -0
  94. package/dist/{chunk-fzxyq6k5.js → chunk-w51q85zg.js} +61 -61
  95. package/dist/chunk-wfjq9ww1.js +2 -0
  96. package/dist/chunk-wpsm2p9x.js +2 -0
  97. package/dist/{chunk-xv43szx0.js → chunk-xqp4hstk.js} +1 -1
  98. package/dist/chunk-ydf4fmr6.js +3 -0
  99. package/dist/{chunk-c1dkh0es.js → chunk-yfvm7q6t.js} +3 -3
  100. package/dist/{chunk-d3vgtr0t.js → chunk-yphmswg3.js} +1 -1
  101. package/dist/{chunk-eecgcj41.js → chunk-yscr04dv.js} +1 -1
  102. package/dist/{chunk-v5916r3j.js → chunk-znb4y12p.js} +5 -5
  103. package/dist/{chunk-5z1n02nd.js → chunk-zwkc8yge.js} +37 -37
  104. package/dist/{chunk-577ntqeg.js → chunk-zx2vhrps.js} +1 -1
  105. package/dist/cli.js +36 -36
  106. package/dist/client/signals-for-runtime.js +51 -2
  107. package/dist/client/signals-process-element-runtime.js +1 -1
  108. package/dist/component-renderer.js +4 -2
  109. package/dist/craft-entry.js +1 -1
  110. package/dist/craft.js +1 -1
  111. package/dist/native/compiler/html-to-ir.js +14 -4
  112. package/dist/native/runtime/binding-tree.d.ts +1 -0
  113. package/dist/native/runtime/binding-tree.js +5 -0
  114. package/dist/native/runtime/craft-bridge.js +1 -0
  115. package/dist/native/runtime/craft.d.ts +1 -0
  116. package/dist/pwa.js +3 -3
  117. package/dist/signal-processing.js +1 -2
  118. package/dist/slot-scopes.js +10 -2
  119. package/dist/slots.d.ts +2 -2
  120. package/dist/slots.js +21 -5
  121. package/dist/ssg.js +5 -5
  122. package/dist/utils.js +1 -1
  123. package/package.json +5 -5
  124. package/dist/chunk-0eepx077.js +0 -2
  125. package/dist/chunk-0fhntp63.js +0 -2
  126. package/dist/chunk-2a4szpje.js +0 -3
  127. package/dist/chunk-3d39yer3.js +0 -2
  128. package/dist/chunk-4v9x7zz5.js +0 -2
  129. package/dist/chunk-5etmsv9z.js +0 -2
  130. package/dist/chunk-773frt6c.js +0 -2
  131. package/dist/chunk-8d2f2e42.js +0 -2
  132. package/dist/chunk-a2bw46t9.js +0 -2
  133. package/dist/chunk-d5pt75tp.js +0 -2
  134. package/dist/chunk-em3aepxz.js +0 -2
  135. package/dist/chunk-g53sg7e0.js +0 -2
  136. package/dist/chunk-gsw8g2ev.js +0 -2
  137. package/dist/chunk-gz90fqn8.js +0 -2
  138. package/dist/chunk-gzd7bmp5.js +0 -2
  139. package/dist/chunk-hcqyf26s.js +0 -2
  140. package/dist/chunk-hhmj9gpk.js +0 -2
  141. package/dist/chunk-k2byvram.js +0 -2
  142. package/dist/chunk-kph7cenp.js +0 -2
  143. package/dist/chunk-papqmch6.js +0 -2
  144. package/dist/chunk-qambfx8c.js +0 -2
  145. package/dist/chunk-stfqkgfv.js +0 -2
  146. package/dist/chunk-t34ds1e3.js +0 -2
  147. package/dist/chunk-t4cbrm81.js +0 -2
  148. package/dist/chunk-t60pt4gv.js +0 -2
  149. package/dist/chunk-t6yjxhn8.js +0 -2
  150. package/dist/chunk-w89mazpv.js +0 -2
  151. package/dist/chunk-wq2fq6b7.js +0 -2
  152. package/dist/chunk-wsp8sj9v.js +0 -3
  153. package/dist/chunk-x8knte1j.js +0 -2
  154. package/dist/chunk-y7xshkqn.js +0 -2
  155. package/dist/chunk-ypsym37h.js +0 -2
  156. package/dist/chunk-z58ybwsv.js +0 -2
  157. package/dist/chunk-zteaygxc.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ll,ul,Ce,dl,Qi,Gt,Kt,rp,ea,Xt,Fn,pl,fl,gl,qs,Jt,ml,Yt,hl}from"./chunk-t886718q.js";import"./chunk-ec9ztgxx.js";import"./chunk-md2jn67b.js";import"./chunk-fsef9nvs.js";import"./chunk-t226hswj.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Fn as MODULE_SPECIFIER_PREFIX,ll as bundleCacheDir,ul as bundleCacheEntryLimit,Yt as bundleClientScript,Kt as clearBundleFailures,Ce as clientBundleDependencies,Gt as getBundleFailures,Xt as hasUserImports,Jt as moduleSubstitutionKey,fl as normalizeRegistrySpecifiers,ml as queueClientBundleBuild,Qi as recordBundleFailure,pl as registryIdForPath,ea as resolveBundlerFallback,gl as rewriteRegistryImports,rp as setBundlerFallbackMode,dl as shouldLogBundlerDiagnostics,hl as tempBuildName,qs as withModuleSubstitutes};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kc,wi,_c,Cc,xi,Ec,Tc,$c,Rc,Si,Ac,Pu}from"./chunk-yq021b3r.js";import{Ii,Mc}from"./chunk-2jh21f1n.js";import{X,J,Y,Cn,pe,ke,Rr,ut,Ut,En,Tn,$n,Z,Rn,An,Ar}from"./chunk-0jhdrgpr.js";import{ol}from"./chunk-tre98h62.js";import"./chunk-c1dkh0es.js";export{J as DEFAULT_FORMATS,Y as DEFAULT_QUALITY,X as DEFAULT_WIDTHS,Ar as ImageProcessingError,Cc as clearImageCache,xi as createImageDirective,Mc as createImageHandler,Tc as createImagePlugin,Pu as defaultImageConfig,An as formatSize,Si as generateImageManifest,Ut as generateSizes,ut as generateSrcSet,En as getFallbackVariant,Rr as getImageMetadata,Z as getMimeType,Rn as getTotalSize,Tn as groupVariantsByFormat,Ii as handleImageRequest,Ec as imageDirective,pe as isImageBackendAvailable,$n as isImageFile,Cn as isSharpAvailable,Rc as optimizeDirectory,$c as optimizeImage,wi as parseImageComponent,ke as processImage,_c as processImageComponents,kc as renderImageComponent,ol as rewriteImagesWithSiblings,Ac as writeImageManifest};
2
+ import{kc,wi,_c,Cc,xi,Ec,Tc,$c,Rc,Si,Ac,Pu}from"./chunk-7d4z944r.js";import{Ii,Mc}from"./chunk-89jbdtgw.js";import{X,J,Y,Cn,pe,_e,Rr,dt,Ut,En,Tn,$n,Z,Rn,An,Ar}from"./chunk-b823zxq6.js";import{ol}from"./chunk-tre98h62.js";import"./chunk-yfvm7q6t.js";export{J as DEFAULT_FORMATS,Y as DEFAULT_QUALITY,X as DEFAULT_WIDTHS,Ar as ImageProcessingError,Cc as clearImageCache,xi as createImageDirective,Mc as createImageHandler,Tc as createImagePlugin,Pu as defaultImageConfig,An as formatSize,Si as generateImageManifest,Ut as generateSizes,dt as generateSrcSet,En as getFallbackVariant,Rr as getImageMetadata,Z as getMimeType,Rn as getTotalSize,Tn as groupVariantsByFormat,Ii as handleImageRequest,Ec as imageDirective,pe as isImageBackendAvailable,$n as isImageFile,Cn as isSharpAvailable,Rc as optimizeDirectory,$c as optimizeImage,wi as parseImageComponent,_e as processImage,_c as processImageComponents,kc as renderImageComponent,ol as rewriteImagesWithSiblings,Ac as writeImageManifest};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Mu}from"./chunk-6h06rqmj.js";import"./chunk-znb4y12p.js";import"./chunk-3y41efsf.js";import"./chunk-ec9ztgxx.js";import"./chunk-w51q85zg.js";import"./chunk-j7mr8h2w.js";import"./chunk-prf164ct.js";import"./chunk-4qh789bq.js";import"./chunk-mekhzhes.js";import"./chunk-hjn7qqrq.js";import"./chunk-ka8befem.js";import"./chunk-1ffjj2c6.js";import"./chunk-jzy0pqez.js";import"./chunk-p472crv1.js";import"./chunk-qrq88ng0.js";import"./chunk-fsef9nvs.js";import"./chunk-t226hswj.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Mu as buildForProduction};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr}from"./chunk-qrq88ng0.js";import{Ze}from"./chunk-2zzc7006.js";import"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{yp as __setSignalsGeneratorsForTest,Ze as cacheEngineFingerprint,Jn as cacheTemplate,Xn as checkCache,wp as clearDevCaches,$l as getCachedRouterScript,Tl as getCachedSignalsRuntime,bp as getServeClientAsset,uo as getServeModuleBundle,Wr as hashFilePath,mp as invalidateFileCache,hp as invalidateFileCacheByDir,gp as readFileCached,vp as registerServeModuleBundle,El as templateCache};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Wo,Dp,Mp,oc,Be,cu,ks,Lp,jp,Bp,Fp,zp,Hp,Vp,Up,Wp}from"./chunk-hb08vrbb.js";export{Hp as applyHead,Lp as definePageMeta,Wo as getHead,Dp as getPageMeta,Be as mergeHeadConfigs,Vp as processHeadDirective,Wp as processMetaDirective,Up as processTitleDirective,zp as renderBodyAttrs,Bp as renderHead,Fp as renderHtmlAttrs,Mp as resetHead,ks as seoMetaToHeadConfig,oc as useHead,jp as usePageTitle,cu as useSeoMeta,jp as useTitle};
2
+ import{Wo,Dp,Mp,oc,Fe,cu,ks,Lp,jp,Bp,Fp,zp,Hp,Vp,Up,Wp}from"./chunk-2dp7hyv7.js";export{Hp as applyHead,Lp as definePageMeta,Wo as getHead,Dp as getPageMeta,Fe as mergeHeadConfigs,Vp as processHeadDirective,Wp as processMetaDirective,Up as processTitleDirective,zp as renderBodyAttrs,Bp as renderHead,Fp as renderHtmlAttrs,Mp as resetHead,ks as seoMetaToHeadConfig,oc as useHead,jp as usePageTitle,cu as useSeoMeta,jp as useTitle};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{X,J,Y,Cn,pe,_e,Rr,Fc,dt,Ut,En,Tn,$n,Z,Rn,An,Ar}from"./chunk-b823zxq6.js";import"./chunk-yfvm7q6t.js";export{J as DEFAULT_FORMATS,Y as DEFAULT_QUALITY,X as DEFAULT_WIDTHS,Ar as ImageProcessingError,An as formatSize,Ut as generateSizes,dt as generateSrcSet,En as getFallbackVariant,Rr as getImageMetadata,Z as getMimeType,Rn as getTotalSize,Tn as groupVariantsByFormat,pe as isImageBackendAvailable,$n as isImageFile,Cn as isSharpAvailable,_e as processImage,Fc as resizeAndConvert};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ie}from"./chunk-zaaeneq6.js";import{Le,A}from"./chunk-2h8ea0we.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
2
+ import{ie}from"./chunk-365vg0eg.js";import{je,A}from"./chunk-1sr6c0nk.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
3
  `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ks(s,l,o={}){let i=Zt(s,o);await Gs(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-qambfx8c.js"),a=A((await e(s)).runtimeConfig);return await Le(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-b54s3qde.js"),a=A((await e(s)).runtimeConfig);return await je(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Js(s,l,o){if(ba(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
6
6
  export{Zt,Gs,Ks,Xs,sp,Js};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fe,wn,Jo}from"./chunk-wpm58d6p.js";function Es(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?Fe(a,e):null,h=u?wn(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
2
+ import{ze,wn,Jo}from"./chunk-30nes8ne.js";function Es(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?ze(a,e):null,h=u?wn(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
3
3
  * Service Worker - Auto-generated by stx
4
4
  * Cache Version: ${i}
5
5
  *
@@ -825,5 +825,5 @@ self.addEventListener('message', (event) => {
825
825
  event.waitUntil(registerFormSync(event.data.payload));
826
826
  }
827
827
  });
828
- `}function jt(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function bc(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function gu(e,a){if(!e.pwa?.enabled)return"";if(bc(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-5w2jy5r9.js");return t(e,a)}return Es(e,a)}
828
+ `}function jt(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function bc(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function gu(e,a){if(!e.pwa?.enabled)return"";if(bc(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-hvf2e7pr.js");return t(e,a)}return Es(e,a)}
829
829
  export{Es,jt,bc,gu};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{o}from"./chunk-1z1632np.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-zteaygxc.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
2
+ import{o}from"./chunk-fsef9nvs.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-dq42tzg1.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
3
  export{Ku};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{B}from"./chunk-qzy8ypk4.js";import{Le,A,Ot}from"./chunk-2h8ea0we.js";import{lt,xe,O,Se,Ai,Bs,Pi,kn}from"./chunk-v5916r3j.js";import{bt,ie,Xe}from"./chunk-zaaeneq6.js";import{Xs}from"./chunk-43gr8ggc.js";import{_n}from"./chunk-vqc4h16r.js";import{ge}from"./chunk-edvmtk21.js";import Z from"fs";import T from"path";var{serve:pe}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((o)=>e.startsWith(o)))return!1;return te.some((o)=>e.startsWith(o))}function oe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ce(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function xn(t,e,o={}){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 r=ae(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??re))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await K(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await ee(a),ce(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new B(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",O(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${xe(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,N=async()=>{let s=await o();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",O(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return a();x=N().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):a()}}var ue={".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 $u(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=Ai(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=_n(r.routeRules),f=new G,h=Xs(e,r.apiRoutes??[]),g=Bun.file(T.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?A(l):void 0,v=new Map,N=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=T.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ot(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Xe(i.html)),M.set(n.pattern,ge(i.html));let X=T.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let P=await Bun.file(X).text();N.set(n.pattern,m?Ot(P,m):P)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=ie(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let E=pe({port:o,async fetch(n){return xn(n,await Le(m??A(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),L=ue[R]||"application/octet-stream",_=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=xe(n),C=null,q={};if(C=s.get(i)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let c=i.match(p);if(c){C=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!C){let p=bt(i)?null:s.get("/404")||null;if(p){let d=v.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=a(i),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=N.get(C.pattern);if(c){let R=x.get(C.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...O(),...k.cache?{}:{"Cache-Control":lt}}})}}let d=Bs(n.method),u=v.get(C.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=v.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.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",...O(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:_,status:I,headers:D}=await kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return Pi(L,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-kph7cenp.js"),j=new Headers({...O(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(P&&!d){let V=Xe(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ge(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(P&&!d?Se(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...O(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",O(w.get("Vary")).Vary),P&&!d){let S=Xe(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ge(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Se(c,r.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(c,{status:I??u.status??200,headers:w})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{B}from"./chunk-c7d09931.js";import{je,A,Ot}from"./chunk-1sr6c0nk.js";import{ut,Se,O,ke,Ai,Bs,Pi,kn}from"./chunk-znb4y12p.js";import{vt,ie,Je}from"./chunk-365vg0eg.js";import{Xs}from"./chunk-ec9ztgxx.js";import{_n}from"./chunk-vqc4h16r.js";import{ge}from"./chunk-jzy0pqez.js";import Z from"fs";import T from"path";var{serve:pe}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((o)=>e.startsWith(o)))return!1;return te.some((o)=>e.startsWith(o))}function oe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ce(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function xn(t,e,o={}){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 r=ae(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??re))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await K(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await ee(a),ce(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new B(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",O(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Se(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,N=async()=>{let s=await o();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",O(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return a();x=N().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):a()}}var ue={".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 $u(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=Ai(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=_n(r.routeRules),f=new G,h=Xs(e,r.apiRoutes??[]),g=Bun.file(T.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?A(l):void 0,v=new Map,N=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=T.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ot(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Je(i.html)),M.set(n.pattern,ge(i.html));let X=T.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let P=await Bun.file(X).text();N.set(n.pattern,m?Ot(P,m):P)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=ie(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let E=pe({port:o,async fetch(n){return xn(n,await je(m??A(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),L=ue[R]||"application/octet-stream",_=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=Se(n),C=null,q={};if(C=s.get(i)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let c=i.match(p);if(c){C=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!C){let p=vt(i)?null:s.get("/404")||null;if(p){let d=v.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=a(i),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=N.get(C.pattern);if(c){let R=x.get(C.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...O(),...k.cache?{}:{"Cache-Control":ut}}})}}let d=Bs(n.method),u=v.get(C.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=v.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.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",...O(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:_,status:I,headers:D}=await kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return Pi(L,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-m72b5043.js"),j=new Headers({...O(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(P&&!d){let V=Je(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ge(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(P&&!d?ke(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...O(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",O(w.get("Vary")).Vary),P&&!d){let S=Je(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ge(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(ke(c,r.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(c,{status:I??u.status??200,headers:w})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{xn,$u};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$u}from"./chunk-fbcp9hm4.js";import"./chunk-znb4y12p.js";import"./chunk-ec9ztgxx.js";import"./chunk-jzy0pqez.js";import"./chunk-fsef9nvs.js";import"./chunk-t226hswj.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{$u as startProductionServer};