@stacksjs/stx 0.2.894 → 0.2.896
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.
- package/dist/{chunk-qn45rk5n.js → chunk-0k437z3q.js} +1 -1
- package/dist/{chunk-4s3ts344.js → chunk-142n73c3.js} +1 -1
- package/dist/{chunk-0waheg6m.js → chunk-18gfzvn5.js} +1 -1
- package/dist/{chunk-pg3yatv3.js → chunk-19v28wj2.js} +2 -2
- package/dist/{chunk-5zs5hrgz.js → chunk-1bft48gk.js} +2 -2
- package/dist/{chunk-s32gsz18.js → chunk-1y4ad3ma.js} +5 -5
- package/dist/{chunk-z8sv926e.js → chunk-2nqmw4dv.js} +1 -1
- package/dist/{chunk-gk0h2hp7.js → chunk-35j7gaj5.js} +1 -1
- package/dist/chunk-38gz54d6.js +182 -0
- package/dist/{chunk-j1mr34da.js → chunk-3jrn01rc.js} +1 -1
- package/dist/{chunk-tc94atxh.js → chunk-3sc1w0dz.js} +1 -1
- package/dist/{chunk-mj0dnha4.js → chunk-3wz8eys3.js} +1 -1
- package/dist/{chunk-90qwzwsm.js → chunk-4akw3bym.js} +1 -1
- package/dist/{chunk-vya7cck4.js → chunk-4d85str1.js} +1 -1
- package/dist/{chunk-hxm31y5q.js → chunk-54dk6rbc.js} +3 -3
- package/dist/chunk-55w7a5tt.js +3 -0
- package/dist/{chunk-8qgcvc9r.js → chunk-5zztnr63.js} +1 -1
- package/dist/{chunk-ae0qvjkz.js → chunk-66qwkxrv.js} +1 -1
- package/dist/{chunk-pjpf21y9.js → chunk-690518hw.js} +1 -1
- package/dist/{chunk-5spnw5zr.js → chunk-6s81gd2p.js} +1 -1
- package/dist/{chunk-ccecyvwf.js → chunk-6shfk0tt.js} +1 -1
- package/dist/{chunk-xdn58ea6.js → chunk-6yqeqesa.js} +4 -4
- package/dist/{chunk-0hfn4cek.js → chunk-7vr7nw7p.js} +1 -1
- package/dist/{chunk-khaem3zq.js → chunk-7xk40zsm.js} +1 -1
- package/dist/{chunk-xvprhdcb.js → chunk-80ky40mm.js} +1 -1
- package/dist/chunk-8abrg1v2.js +2 -0
- package/dist/{chunk-gzc16hs8.js → chunk-8ccgty8s.js} +2 -2
- package/dist/chunk-8e38dzxv.js +2 -0
- package/dist/{chunk-n64zbwzr.js → chunk-9rjgq8k4.js} +1 -1
- package/dist/{chunk-c5q6jdm9.js → chunk-9tngkmry.js} +4 -4
- package/dist/{chunk-s9a9kda4.js → chunk-9v2bpwgb.js} +2 -2
- package/dist/chunk-9vpcsn2f.js +2 -0
- package/dist/{chunk-kd7k31x3.js → chunk-aj5tsksz.js} +4 -4
- package/dist/{chunk-mdrdp6c4.js → chunk-avn3panj.js} +2 -2
- package/dist/chunk-b35t77m0.js +2 -0
- package/dist/chunk-c8hyr9vb.js +2 -0
- package/dist/{chunk-9f8fda1j.js → chunk-ch9028z3.js} +1 -1
- package/dist/{chunk-z012vpdz.js → chunk-cmg9x1ka.js} +3 -3
- package/dist/chunk-cp5x6kx1.js +2 -0
- package/dist/{chunk-x9036mfd.js → chunk-cphc60zw.js} +2 -2
- package/dist/chunk-e8szp5wa.js +2 -0
- package/dist/{chunk-wk36dj2m.js → chunk-er0hgd96.js} +1 -1
- package/dist/{chunk-p06tqhp9.js → chunk-exb4wc0c.js} +1 -1
- package/dist/{chunk-j5m4hy3m.js → chunk-fjpaxmvv.js} +2 -2
- package/dist/{chunk-yrjm6zyh.js → chunk-fnpq78k3.js} +1 -1
- package/dist/{chunk-e9c56r58.js → chunk-g71ppt0e.js} +4 -4
- package/dist/{chunk-3mdg7w2d.js → chunk-gxpcdhr3.js} +1 -1
- package/dist/{chunk-v6ja6a65.js → chunk-h19fp8g8.js} +2 -2
- package/dist/{chunk-d8ptv989.js → chunk-h91ry9p1.js} +4 -4
- package/dist/chunk-hn679t1s.js +2 -0
- package/dist/{chunk-gjqdp0zx.js → chunk-jrbkvptj.js} +1 -1
- package/dist/chunk-jre984qm.js +2 -0
- package/dist/chunk-jyd9trff.js +2 -0
- package/dist/{chunk-8a71xvx1.js → chunk-knhf7dkn.js} +16 -16
- package/dist/{chunk-t79khbtp.js → chunk-m136gh80.js} +2 -2
- package/dist/chunk-n2d0jzyv.js +2 -0
- package/dist/{chunk-y54vpvy0.js → chunk-n8mfvqqz.js} +1 -1
- package/dist/{chunk-cbjvabsa.js → chunk-p1wqyf10.js} +43 -43
- package/dist/{chunk-8n5bjars.js → chunk-q671arjn.js} +1 -1
- package/dist/chunk-qe3z3x39.js +2 -0
- package/dist/{chunk-1a8ev0eh.js → chunk-rr0wvqa3.js} +1 -1
- package/dist/chunk-rspsbhcv.js +2 -0
- package/dist/{chunk-66qt9q6e.js → chunk-rvn63nv2.js} +19 -19
- package/dist/{chunk-c9xg8rc2.js → chunk-s5xfmr87.js} +2 -2
- package/dist/chunk-snbhzrfy.js +2 -0
- package/dist/{chunk-na92k4va.js → chunk-srsb2zvm.js} +1 -1
- package/dist/{chunk-kfbw96c5.js → chunk-t0ttxayz.js} +2 -2
- package/dist/chunk-t31twwh0.js +2 -0
- package/dist/{chunk-qrk535j6.js → chunk-t3zmfh8w.js} +4 -4
- package/dist/{chunk-60z8rka9.js → chunk-t6sdtsf8.js} +5 -5
- package/dist/{chunk-gcjqxvbb.js → chunk-ta07gj66.js} +2 -2
- package/dist/chunk-tbh7r1wh.js +2 -0
- package/dist/chunk-tspz0z7d.js +2 -0
- package/dist/chunk-tznd1egg.js +2 -0
- package/dist/{chunk-hdqy5v4v.js → chunk-w5kq4k7f.js} +1 -1
- package/dist/{chunk-mxf6cfbg.js → chunk-whcrca58.js} +6 -6
- package/dist/chunk-x57p5bay.js +2 -0
- package/dist/{chunk-6yy54yyp.js → chunk-xbqt53jj.js} +1 -1
- package/dist/{chunk-ac3e6nhg.js → chunk-xmg6bmh6.js} +3 -3
- package/dist/{chunk-hxq5tsqa.js → chunk-xtq8swr2.js} +1 -1
- package/dist/chunk-xvmd0aja.js +2 -0
- package/dist/{chunk-2eq3aret.js → chunk-xwrjre34.js} +1 -1
- package/dist/{chunk-h7yme97q.js → chunk-xy8smv5e.js} +2 -2
- package/dist/{chunk-z3ar05m3.js → chunk-xzj4jyhy.js} +5 -5
- package/dist/chunk-ycge4wfk.js +2 -0
- package/dist/chunk-z1dym2re.js +2 -0
- package/dist/{chunk-1csmm3f6.js → chunk-z3kvxk73.js} +1 -1
- package/dist/{chunk-8y39f6z3.js → chunk-zf68afyh.js} +3 -3
- package/dist/{chunk-qv4qwa61.js → chunk-zkq66keq.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.d.ts +0 -15
- package/dist/native/accessibility.js +2 -6
- package/dist/native/compiler/html-to-ir.js +1 -27
- package/dist/offline/app-service-worker.d.ts +4 -1
- package/dist/offline/app-service-worker.js +23 -5
- package/dist/process.js +4 -3
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +10 -10
- package/package.json +5 -5
- package/dist/chunk-0d14783x.js +0 -2
- package/dist/chunk-0yw075t7.js +0 -2
- package/dist/chunk-3ngbdap1.js +0 -2
- package/dist/chunk-484x27q5.js +0 -2
- package/dist/chunk-4eyyshsq.js +0 -2
- package/dist/chunk-4fcb8rmm.js +0 -2
- package/dist/chunk-4mmy5pfh.js +0 -2
- package/dist/chunk-4pq32bt3.js +0 -2
- package/dist/chunk-5kfe3smn.js +0 -2
- package/dist/chunk-b4kbj9kq.js +0 -2
- package/dist/chunk-b77t5zy2.js +0 -2
- package/dist/chunk-brmmkfnq.js +0 -2
- package/dist/chunk-btjhb71k.js +0 -2
- package/dist/chunk-dz1mkvdw.js +0 -2
- package/dist/chunk-dz2zehsh.js +0 -2
- package/dist/chunk-eenw264a.js +0 -2
- package/dist/chunk-erka2w6z.js +0 -2
- package/dist/chunk-gd5a11h2.js +0 -2
- package/dist/chunk-jjz64ac2.js +0 -2
- package/dist/chunk-jqnfvdx5.js +0 -182
- package/dist/chunk-nqarmx3w.js +0 -3
- package/dist/chunk-nxjfdtc0.js +0 -2
- package/dist/chunk-vm57848v.js +0 -2
- package/dist/chunk-xv471ek2.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ze,z,Jt}from"./chunk-41z7f41b.js";import{T}from"./chunk-0jdz31q1.js";import{Tt,je,V,st,Be,Da,Lo,La,Kn}from"./chunk-z3ar05m3.js";import{Dt,Se,pt}from"./chunk-gzc16hs8.js";import{Qo}from"./chunk-mdrdp6c4.js";import{Gn}from"./chunk-nq60tjkz.js";import{Re}from"./chunk-60z8rka9.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import O from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){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 se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function oe(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=J)break;H.delete(a),U-=r.length}}async function Un(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await Y(O.brotliCompress)(i,{params:{[O.constants.BROTLI_PARAM_QUALITY]:h,[O.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(O.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",V(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${je(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,_=async()=>{let s=await a();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",V(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 i();x=_().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):i()}}var ie={".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 Cm(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=Da(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 i=Gn(r.routeRules),f=new G,h=Qo(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?z(l):void 0,v=new Map,_=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Jt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,pt(c.html)),M.set(n.pattern,Re(c.html));let j=P.join(e,n.fragmentPath);if(st(c.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let A=await Bun.file(j).text();_.set(n.pattern,m?Jt(A,m):A)}}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:c}=Se(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return Un(n,await Ze(m??z(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let j=await h(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",X=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":X?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=je(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=Dt(c)?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 N=i(c),W=Object.keys(N).length>0;return f.respond(n,N.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=_.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{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}:{},...V(),...N.cache?{}:{"Cache-Control":Tt}}})}}let d=Lo(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.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",...V(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:X,status:F,headers:I}=await Kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return La(B,X,I);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:D}=await import("./chunk-4mmy5pfh.js"),L=new Headers({...V(),...I,"Cache-Control":"private, no-store"});for(let k of X??[])L.append("Set-Cookie",k);if(A&&!d&&st(o,r.routerContainer||"main")){let k=pt(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",Re(o)?"true":"false"),L.set("X-STX-Layout",k.layout),L.set("X-STX-Layout-Group",k.group)}return D(S(A&&!d&&st(o,r.routerContainer||"main")?Be(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:F??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...V(),...N.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of X??[])w.append("Set-Cookie",S);for(let[S,D]of Object.entries(I??{}))w.set(S,D);if(w.set("Vary",V(w.get("Vary")).Vary),A&&!d&&st(o,r.routerContainer||"main")){let S=pt(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",Re(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Be(o,r.routerContainer||"main",!0),{status:F??u.status??200,headers:w})}return new Response(o,{status:F??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),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
|
-
export{
|
|
2
|
+
import{Ze,z,Jt}from"./chunk-41z7f41b.js";import{T}from"./chunk-0jdz31q1.js";import{Tt,je,U,st,Be,Da,Lo,La,Kn}from"./chunk-xzj4jyhy.js";import{Dt,Se,pt}from"./chunk-8ccgty8s.js";import{Qo}from"./chunk-avn3panj.js";import{Gn}from"./chunk-nq60tjkz.js";import{Re}from"./chunk-t6sdtsf8.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import O from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){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 se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,V=new Map,D=0;function oe(t,e){if(e.length>J/8)return;V.set(t,e),D+=e.length;for(let[a,r]of V){if(D<=J)break;V.delete(a),D-=r.length}}async function Vn(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=V.get(g);if(!l)l=r==="br"?await Y(O.brotliCompress)(i,{params:{[O.constants.BROTLI_PARAM_QUALITY]:h,[O.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(O.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",U(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${je(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,_=async()=>{let s=await a();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",U(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 i();x=_().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):i()}}var ie={".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 Cm(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=Da(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 i=Gn(r.routeRules),f=new G,h=Qo(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?z(l):void 0,v=new Map,_=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(y).text());if(m)c.html=Jt(c.html,m);v.set(n.pattern,c),x.set(n.pattern,pt(c.html)),M.set(n.pattern,Re(c.html));let j=P.join(e,n.fragmentPath);if(st(c.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let A=await Bun.file(j).text();_.set(n.pattern,m?Jt(A,m):A)}}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:c}=Se(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ae({port:a,async fetch(n){return Vn(n,await Ze(m??z(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let j=await h(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),B=ie[R]||"application/octet-stream",X=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":X?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=je(n),C=null,q={};if(C=s.get(c)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let o=c.match(p);if(o){C=d,u.forEach((R,B)=>{q[R]=o[B+1]});break}}if(!C){let p=Dt(c)?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 N=i(c),W=Object.keys(N).length>0;return f.respond(n,N.cache,async()=>{let p=v.get(C.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=_.get(C.pattern);if(o){let R=x.get(C.pattern);return new Response(o,{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}:{},...U(),...N.cache?{}:{"Cache-Control":Tt}}})}}let d=Lo(n.method),u=v.get(C.pattern);if(!u){let o=s.get("/500")||null;if(o){let R=v.get(o.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",...U(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:R,redirect:B,cookies:X,status:H,headers:F}=await Kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return La(B,X,F);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:I}=await import("./chunk-8abrg1v2.js"),L=new Headers({...U(),...F,"Cache-Control":"private, no-store"});for(let k of X??[])L.append("Set-Cookie",k);if(A&&!d&&st(o,r.routerContainer||"main")){let k=pt(o);L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",Re(o)?"true":"false"),L.set("X-STX-Layout",k.layout),L.set("X-STX-Layout-Group",k.group)}return I(S(A&&!d&&st(o,r.routerContainer||"main")?Be(o,r.routerContainer||"main",!0):o,R,{timeoutMs:30000}),{status:H??u.status??200,headers:L})}let w=new Headers({"Content-Type":"text/html",...U(),...N.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of X??[])w.append("Set-Cookie",S);for(let[S,I]of Object.entries(F??{}))w.set(S,I);if(w.set("Vary",U(w.get("Vary")).Vary),A&&!d&&st(o,r.routerContainer||"main")){let S=pt(o);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",Re(o)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(Be(o,r.routerContainer||"main",!0),{status:H??u.status??200,headers:w})}return new Response(o,{status:H??u.status??200,headers:w})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),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
|
+
export{Vn,Cm};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{iy,lg,ct,Ic,ay,_s,Cs,Es}from"./chunk-9tngkmry.js";import"./chunk-s5xfmr87.js";import"./chunk-55w7a5tt.js";import"./chunk-80ky40mm.js";import"./chunk-9rjgq8k4.js";import"./chunk-knhf7dkn.js";import"./chunk-5zztnr63.js";import"./chunk-41z7f41b.js";import"./chunk-xmg6bmh6.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-0jdz31q1.js";import"./chunk-cphc60zw.js";export{ay as clearOnceStore,Ic as onceStore,ct as partialsCache,_s as processIncludes,Cs as processStackPushDirectives,Es as processStackReplacements,iy as resetUnscopedSignalWarnings,lg as topLevelElements};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{es,Co,hm,eu,Eo}from"./chunk-
|
|
2
|
+
import{es,Co,hm,eu,Eo}from"./chunk-h19fp8g8.js";import"./chunk-n6q1d66k.js";import"./chunk-3b3mkgpj.js";import"./chunk-0jdz31q1.js";export{hm as buildModuleRegistryScript,Eo as buildSharedModuleRegistries,eu as exportsMutableBinding,es as registeredModuleIdsIn,Co as registeredModuleNamesIn};
|