@stacksjs/stx 0.2.317 → 0.2.318
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-vgwcpt59.js → chunk-0ggq64sc.js} +1 -1
- package/dist/{chunk-dexbmqrm.js → chunk-0saq3nwy.js} +1 -1
- package/dist/{chunk-6g4arx7a.js → chunk-1ppaw4xs.js} +1 -1
- package/dist/{chunk-gvw5agnj.js → chunk-5qseeh5t.js} +1 -1
- package/dist/{chunk-vah1scec.js → chunk-65hqene1.js} +1 -1
- package/dist/{chunk-bgj9ep3g.js → chunk-6c1ebjat.js} +1 -1
- package/dist/chunk-6xmx6stb.js +2 -0
- package/dist/{chunk-t088w4j2.js → chunk-8618n28z.js} +1 -1
- package/dist/{chunk-w3qdxrpv.js → chunk-8avktqwz.js} +1 -1
- package/dist/{chunk-knt8aerb.js → chunk-8z11nkyk.js} +1 -1
- package/dist/{chunk-s1enwpyh.js → chunk-95jjdgmb.js} +1 -1
- package/dist/{chunk-v7pagafp.js → chunk-9g14542g.js} +1 -1
- package/dist/{chunk-zrnh6ybt.js → chunk-9h4fkwtj.js} +1 -1
- package/dist/{chunk-1sv0pxa3.js → chunk-acctstj3.js} +1 -1
- package/dist/{chunk-43052kx3.js → chunk-b73h0vd8.js} +1 -1
- package/dist/{chunk-fxjyj3j9.js → chunk-bbq82jww.js} +5 -5
- package/dist/{chunk-dy6aq1fx.js → chunk-bxvqqejm.js} +1 -1
- package/dist/{chunk-asb365rs.js → chunk-djf1p5cy.js} +1 -1
- package/dist/{chunk-bnw3wnw8.js → chunk-egr5663e.js} +1 -1
- package/dist/{chunk-gg85dhn4.js → chunk-f9qrz82p.js} +1 -1
- package/dist/chunk-g8vf2fc7.js +2 -0
- package/dist/{chunk-j18h8dbg.js → chunk-gcavh7hk.js} +1 -1
- package/dist/{chunk-n25whneb.js → chunk-gpesxpwq.js} +2 -2
- package/dist/{chunk-x3s0e6wv.js → chunk-h63vszd3.js} +1 -1
- package/dist/{chunk-pn60d9sp.js → chunk-hxf6zg80.js} +1 -1
- package/dist/{chunk-7nes75cd.js → chunk-jdcn0ms1.js} +1 -1
- package/dist/{chunk-gd62grxx.js → chunk-jg2gbd58.js} +1 -1
- package/dist/{chunk-t9acxg0e.js → chunk-jr79tvvs.js} +1 -1
- package/dist/chunk-n0t2at1c.js +2 -0
- package/dist/{chunk-734mjk29.js → chunk-pknc4efv.js} +1 -1
- package/dist/{chunk-v1507pxw.js → chunk-prry9kgy.js} +1 -1
- package/dist/{chunk-tdrpxx1h.js → chunk-r3220h2n.js} +1 -1
- package/dist/{chunk-9yhtehv9.js → chunk-s2kxa1tb.js} +1 -1
- package/dist/{chunk-thhgk7x1.js → chunk-s5wwa0t4.js} +2 -2
- package/dist/{chunk-4zkwqprq.js → chunk-spzbfqjn.js} +17 -17
- package/dist/{chunk-60jcfv31.js → chunk-szkq9s8n.js} +1 -1
- package/dist/{chunk-860dhpmy.js → chunk-tqayztkh.js} +1 -1
- package/dist/{chunk-wvfed9sj.js → chunk-tzhcjtkr.js} +1 -1
- package/dist/{chunk-k2gsnfaa.js → chunk-v02j99gh.js} +2 -2
- package/dist/{chunk-46dsqwx0.js → chunk-v1j4myd8.js} +1 -1
- package/dist/chunk-vnh668fb.js +2 -0
- package/dist/{chunk-wd6skrxf.js → chunk-w33gx25k.js} +1 -1
- package/dist/{chunk-1zw2abe0.js → chunk-w3dfvxar.js} +1 -1
- package/dist/{chunk-vb16zpbw.js → chunk-w6ncyp18.js} +1 -1
- package/dist/{chunk-w84fgaqj.js → chunk-wb24hk90.js} +1 -1
- package/dist/{chunk-dm93r8kq.js → chunk-wcp0dt2c.js} +1 -1
- package/dist/{chunk-ndyxw7f5.js → chunk-wkcnyv6m.js} +1 -1
- package/dist/{chunk-gb3fk53c.js → chunk-ycgtkfbm.js} +1 -1
- package/dist/{chunk-f5mkztvk.js → chunk-yzb20ane.js} +1 -1
- package/dist/{chunk-9bc55xwj.js → chunk-yzy6e4je.js} +9 -9
- package/dist/{chunk-wb0n3rmf.js → chunk-z82sc99z.js} +1 -1
- package/dist/{chunk-r97y1cy2.js → chunk-zebypbks.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-478m6jex.js +0 -2
- package/dist/chunk-50mk56ph.js +0 -2
- package/dist/chunk-mdbhyxnr.js +0 -2
- package/dist/chunk-sc70p4kj.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bg as WJ,Dg as YJ,Fg as jJ,lg as ZJ,ng as g,pg as A,vg as n,yg as GJ}from"./chunk-
|
|
2
|
+
import{Bg as WJ,Dg as YJ,Fg as jJ,lg as ZJ,ng as g,pg as A,vg as n,yg as GJ}from"./chunk-gpesxpwq.js";import{Ig as $J}from"./chunk-dvvx1wny.js";import{yl as XJ}from"./chunk-zebypbks.js";import{uo as h}from"./chunk-spzbfqjn.js";import{ut as e}from"./chunk-egr5663e.js";import{su as QJ,wu as i,yu as p}from"./chunk-18p8dqya.js";import{Sv as l,Wv as VJ,pv as KJ}from"./chunk-bbq82jww.js";import{ew as DJ}from"./chunk-jryjwara.js";import JJ from"fs";import k from"path";var{serve:wJ}=globalThis.Bun;VJ();import y from"zlib";import{promisify as a}from"util";var IJ=a(y.brotliCompress),OJ=a(y.gzip),UJ=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],BJ=["text/event-stream","multipart/x-mixed-replace"],_J=1024;function zJ(K){if(!K)return!1;let J=K.toLowerCase();if(BJ.some((G)=>J.startsWith(G)))return!1;return UJ.some((G)=>J.startsWith(G))}function FJ(K){let J=new Map;for(let G of K.split(",")){let[Z,...W]=G.trim().split(";"),O=Z.trim().toLowerCase();if(!O)continue;let U=1;for(let B of W){let w=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(B);if(!w)continue;let F=Number.parseFloat(w[1]);if(Number.isFinite(F))U=F}J.set(O,U)}return J}function LJ(K){if(!K)return null;let J=FJ(K),G=J.get("*"),Z=(W)=>J.get(W)??G??0;if(Z("br")>0)return"br";if(Z("gzip")>0)return"gzip";return null}async function t(K,J,G={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!zJ(J.headers.get("content-type")))return J;let Z=LJ(K.headers.get("accept-encoding"));if(!Z)return J;let W;try{W=new Uint8Array(await J.arrayBuffer())}catch{return J}let O=()=>new Response(W,{status:J.status,statusText:J.statusText,headers:s(J.headers)});if(W.length<(G.threshold??_J))return O();try{let U=Z==="br"?await IJ(W,{params:{[y.constants.BROTLI_PARAM_QUALITY]:G.quality??5,[y.constants.BROTLI_PARAM_SIZE_HINT]:W.length}}):await OJ(W);if(U.length>=W.length)return O();let B=s(J.headers);return B.set("Content-Encoding",Z),B.set("Content-Length",String(U.length)),new Response(U,{status:J.status,statusText:J.statusText,headers:B})}catch{return O()}}function s(K){let J=new Headers(K),G=J.get("Vary");if(!G)return J.set("Vary","Accept-Encoding"),J;if(!G.split(",").some((W)=>W.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${G}, Accept-Encoding`);return J}class d{now;entries=new e(1000,{maxBytes:33554432,sizeOf:(K)=>K.body.byteLength+JSON.stringify(K.headers).length*2});pending=new Map;generation=0;constructor(K=Date.now){this.now=K}invalidate(K){this.generation++,this.pending.clear();for(let J of Array.from(this.entries.keys()))if(K===void 0||this.entries.get(J)?.path===K)this.entries.delete(J)}async respond(K,J,G){let Z,W=async()=>{let X=Z??await G();return X.headers.set("Cache-Control","private, no-store"),X.headers.set("Vary",A(X.headers.get("Vary")).Vary),X};if(!J||K.method!=="GET"||K.headers.has("Cookie")||K.headers.has("Authorization")||K.headers.has("Range"))return W();let O=new URL(K.url),U=`${O.origin}${O.pathname}${O.search}|${g(K)?"fragment":"document"}`,B=this.entries.get(U),w=(X)=>{let T=new Headers(X.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-X.created)/1000)))),new Response(X.body.slice(0),{headers:T})},F=B?(this.now()-B.created)/1000:1/0;if(B&&F<J.maxAge)return w(B);let S=this.generation,q=async()=>{let X=await G();Z=X;let T=(X.headers.get("Vary")??"").toLowerCase().split(",").map((L)=>L.trim()).filter(Boolean);if(X.status!==200||X.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(X.headers.get("Cache-Control")??"")||T.some((L)=>L!=="x-stx-router"&&L!=="accept-encoding"))return null;let M=await X.clone().arrayBuffer();if(M.byteLength>1048576)return null;X.headers.set("Vary",A(X.headers.get("Vary")).Vary);let Q={body:M,headers:Array.from(X.headers.entries()),created:this.now(),path:O.pathname};if(this.generation===S)this.entries.set(U,Q);return Q},H=this.pending.get(U);if(!H){if(this.pending.size>=1000)return W();H=q().finally(()=>{if(this.pending.get(U)===H)this.pending.delete(U)}),this.pending.set(U,H)}if(B&&F<J.maxAge+(J.swr??0))return H.catch(()=>{}),w(B);let x=await H;return x?w(x):W()}}var HJ={".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 uJ(K={}){let J=k.resolve(K.outputDir||".output"),G=K.port??3000,Z=GJ(J);if(!Z)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Z.routes.length} routes...`);let W=$J(Z.routeRules),O=new d,U=XJ(J,Z.apiRoutes??[]),B=Bun.file(k.join(J,"server/runtime-config.json")),w=K.runtimeConfig??(await B.exists()?await B.json():void 0),F=w?i(w):void 0,S=new Map,q=new Map,H=new Map,x=new Map;for(let Q of Z.routes)try{let L=k.join(J,Q.compiledPath),Y=JSON.parse(await Bun.file(L).text());if(F)Y.html=p(Y.html,F);S.set(Q.pattern,Y),H.set(Q.pattern,l(Y.html)),x.set(Q.pattern,h(Y.html));let C=k.join(J,Q.fragmentPath);if(await Bun.file(C).exists()){let P=await Bun.file(C).text();q.set(Q.pattern,F?p(P,F):P)}}catch(L){console.warn(`[stx] Failed to load route ${Q.pattern}:`,L)}let X=new Map,T=[];for(let Q of Z.routes)if(Q.hasParams){let{regex:L,params:Y}=KJ(Q.pattern);T.push({regex:L,route:Q,paramNames:Y})}else X.set(Q.pattern,Q);let M=wJ({port:G,async fetch(Q){return t(Q,await QJ(F??i(),async()=>{let Y=new URL(Q.url).pathname;if(K.onRequest){let j=await K.onRequest(Q);if(j)return j}if(K.apiRouter){let j=await K.apiRouter.handleRequest(Q);if(j.status!==404)return j}if(K.apiRoutes?.[Y])return K.apiRoutes[Y](Q);let C=await U(Q);if(C)return C;if((Q.method==="GET"||Q.method==="HEAD")&&Y!=="/"){let j=k.resolve(J,"public"),_;try{_=decodeURIComponent(Y)}catch{_=Y}if(!_.includes("\x00")){let I=k.resolve(j,`.${_}`);if(I===j||I.startsWith(`${j}${k.sep}`))try{if(JJ.existsSync(I)&&JJ.statSync(I).isFile()){let z=k.extname(I).toLowerCase(),E=HJ[z]||"application/octet-stream",v=Y.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(Y);return new Response(Bun.file(I),{headers:{"Content-Type":E,"Cache-Control":v?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=g(Q),D=null,o={};if(D=X.get(Y)||null,!D)for(let{regex:j,route:_,paramNames:I}of T){let $=Y.match(j);if($){D=_,I.forEach((z,E)=>{o[z]=$[E+1]});break}}if(!D){let j=X.get("/404")||null;if(j){let _=S.get(j.pattern);if(_)return new Response(_.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}let R=W(Y),r=Object.keys(R).length>0;return O.respond(Q,R.cache,async()=>{let j=S.get(D.pattern);if(P&&Q.method==="GET"&&j&&!j.hasServerScripts&&Object.keys(j.placeholders).length===0){let $=q.get(D.pattern);if($){let z=H.get(D.pattern);return new Response($,{status:j.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...x.has(D.pattern)?{"X-STX-Runtime":x.get(D.pattern)?"true":"false"}:{},...z?{"X-STX-Layout":z.layout,"X-STX-Layout-Group":z.group}:{},...A(),...R.cache?{}:{"Cache-Control":ZJ}}})}}let _=WJ(Q.method),I=S.get(D.pattern);if(!I){let $=X.get("/500")||null;if($){let z=S.get($.pattern);if(z)return new Response(z.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(D.prerendered&&_)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!_&&!I.hasServerScripts&&Object.keys(I.placeholders).length===0)return new Response(I.html,{status:I.status??200,headers:{"Content-Type":"text/html",...A(),"Cache-Control":"public, max-age=60"}});try{let{html:$,boundaries:z,redirect:E,cookies:v,status:m,headers:c}=await jJ(I,{params:o,request:Q,method:Q.method,__stx_strict_hydration:r,__stx_runtime_config:F});if(E)return YJ(E,v,c);if(z&&z.length>0){let{renderStreamingPage:N,streamToResponse:u}=await import("./chunk-f9qrz82p.js"),b=new Headers({...A(),...c,"Cache-Control":"private, no-store"});for(let f of v??[])b.append("Set-Cookie",f);if(P&&!_){let f=l($);b.set("X-STX-Fragment","true"),b.set("X-STX-Runtime",h($)?"true":"false"),b.set("X-STX-Layout",f.layout),b.set("X-STX-Layout-Group",f.group)}return u(N(P&&!_?n($,Z.routerContainer||"main"):$,z,{timeoutMs:30000}),{status:m??I.status??200,headers:b})}let V=new Headers({"Content-Type":"text/html",...A(),...R.cache?{}:{"Cache-Control":"private, no-store"}});for(let N of v??[])V.append("Set-Cookie",N);for(let[N,u]of Object.entries(c??{}))V.set(N,u);if(V.set("Vary",A(V.get("Vary")).Vary),P&&!_){let N=l($);return V.set("X-STX-Fragment","true"),V.set("X-STX-Runtime",h($)?"true":"false"),V.set("X-STX-Layout",N.layout),V.set("X-STX-Layout-Group",N.group),new Response(n($,Z.routerContainer||"main"),{status:m??I.status??200,headers:V})}return new Response($,{status:m??I.status??200,headers:V})}catch($){if(console.error(`[stx] Hydration error for ${Y}:`,$),r)return new Response("Internal Server Error",{status:500});return new Response(I.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${M.port}`),console.log(`[stx] Serving ${Z.routes.length} routes (${S.size} pre-loaded)`),{port:M.port,stop:()=>{O.invalidate(),M.stop()},invalidate:(Q)=>O.invalidate(Q)}}
|
|
3
3
|
export{zJ as Ve,LJ as We,t as Xe,uJ as Ye};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Hg as I}from"./chunk-dvvx1wny.js";import{yr as H}from"./chunk-
|
|
2
|
+
import{Hg as I}from"./chunk-dvvx1wny.js";import{yr as H}from"./chunk-spzbfqjn.js";import{ew as G}from"./chunk-jryjwara.js";import L from"path";async function Q(k={}){let J=performance.now(),A=k.root||process.cwd(),j=await H(A),B=k.ssr?.routeRules??j.routeRules??{};if(I(B),!j.ssr&&Object.keys(B).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!j.ssr&&(k.ssr?.serverApi??j.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let q=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${q.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let D,E;if(q==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");D=await z({pagesDir:L.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,router:j.router,...k.ssg})}else{let{buildForProduction:z}=await import("./chunk-g8vf2fc7.js");E=await z({root:A,outputDir:".output",debug:k.debug,...k.ssr})}let K=Math.round(performance.now()-J);return{mode:q,ssg:D,ssr:E,duration:K}}
|
|
3
3
|
export{Q as Ue};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Al as GJ}from"./chunk-
|
|
2
|
+
import{Al as GJ}from"./chunk-zebypbks.js";import{fm as $J,yr as HJ,zr as zJ}from"./chunk-spzbfqjn.js";import{jt as KJ,kt as ZJ}from"./chunk-397rqs12.js";import{Bt as u,xt as WJ}from"./chunk-egr5663e.js";import{ou as c}from"./chunk-4ee1aaet.js";import X from"path";import O from"fs";function OJ(J){if(!J||typeof J!=="object")return!1;let K=J;return typeof K.message==="string"&&(K.name==="BuildMessage"||K.name==="ResolveMessage"||("position"in K))}function wJ(J){if(J&&typeof J==="object"&&Array.isArray(J.errors))return J.errors;return[J]}function b(J,K){let $=[];for(let W of wJ(J)){if(OJ(W)){let H=W.position||void 0;$.push({file:K||H?.file,line:H?.line,column:H?.column,message:W.message??"",lineText:H?.lineText});continue}$.push({file:K,message:W instanceof Error?W.message:String(W)})}return $}function s(J,K){return b(J,K).map(($)=>{let W=$.file?`${$.file}${$.line?`:${$.line}${$.column?`:${$.column}`:""}`:""}`:"",H=$.lineText?`
|
|
3
3
|
${$.lineText.trim()}`:"";return W?`${W}: ${$.message}${H}`:`${$.message}${H}`}).join(`
|
|
4
4
|
`)}var UJ=9;function P(J,K,$){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(X.basename(J))||GJ(J,K,$)}var QJ=1,YJ=new Map,f=600,LJ=100,g=new Map;async function TJ(J){let K=g.get(J)??0;if(K>0&&K<LJ){g.set(J,K+1);return}g.set(J,1);try{let $=(await O.promises.readdir(J)).filter((z)=>z.endsWith(".js"));if($.length<=f)return;let H=(await Promise.all($.map(async(z)=>{try{return{name:z,at:(await O.promises.stat(X.join(J,z))).mtimeMs}}catch{return null}}))).filter((z)=>z!==null);H.sort((z,Y)=>Y.at-z.at);for(let z of H.slice(f)){let Y=z.name.slice(0,-3);await O.promises.rm(X.join(J,`${Y}.js`),{force:!0}),await O.promises.rm(X.join(J,`${Y}.deps.json`),{force:!0})}I("pruned bundle cache to",f,"entries")}catch{}}function mJ(J){return YJ.get(J)??[]}function h(J,K){if(J)YJ.set(J,K)}function AJ(J=process.env){return J.STX_DEBUG==="true"||J.STX_DEBUG==="1"}function I(...J){if(AJ())console.log("[stx:bundler]",...J)}var n=[];function t(J,K,$){n.push({filePath:J||"<inline>",message:K,details:$})}function uJ(){return n.slice()}function hJ(){n.length=0}var p;function pJ(J){p=J}function r(){if(p)return p;try{let J=zJ.strict;return typeof J==="object"&&J!==null?J.bundlerFallback??"warn":"warn"}catch{return"warn"}}var a=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function cJ(J){let K=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,$;while(($=K.exec(J))!==null){let H=$[1];if(!a.some((Y)=>Y.test(H)))return I("detected user import:",H),!0}let W=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while(($=W.exec(J))!==null){let H=$[1];if(/\.css(?:\?.*)?$/.test(H))continue;if(!a.some((Y)=>Y.test(H)))return I("detected side-effect import:",H),!0}return!1}var D="stx-module:",CJ=/\.(?:[cm]?[jt]sx?|json)$/i;function MJ(J,K){return X.relative(J,K).split(X.sep).join("/")}function xJ(J,K){if(K.size===0)return J;return J.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,($,W,H,z)=>{let Y=K.get(z);return Y&&!z.startsWith(D)?`${W}${H}${Y}${H}`:$})}function IJ(J,K){let $=0,W=(z)=>{let Y=`__stxMod${$++}`,j=JSON.stringify(z);return K.push(`var ${Y} = globalThis.__stxModules && globalThis.__stxModules[${j}];`,`if (${Y} === undefined) throw new Error("[stx] module " + ${JSON.stringify(j)} + " is not registered on this page (#1957)");`),Y},H=(z,Y)=>{for(let j of z.split(",")){let T=j.trim();if(!T)continue;let Q=T.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!Q)continue;let Z=Q[1].startsWith('"')?JSON.parse(Q[1]):Q[1],G=Q[2]??Z;K.push(`var ${G} = ${Y}[${JSON.stringify(Z)}];`)}};return J=J.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(z,Y,j)=>{let T=j.slice(D.length),Q=W(T),Z=Y.trim(),G=Z.match(/^([\w$]+)\s*(?:,\s*|$)/);if(G&&!Z.startsWith("{")&&!Z.startsWith("*"))K.push(`var ${G[1]} = ${Q}.default;`),Z=Z.slice(G[0].length).trim();let q=Z.match(/^\*\s*as\s+([\w$]+)$/);if(q)K.push(`var ${q[1]} = ${Q};`);else if(Z.startsWith("{"))H(Z.replace(/^\{|\}$/g,""),Q);return""}),J=J.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(z,Y)=>{return W(Y.slice(D.length)),""}),J}function e(J){let K=[J,`${J}.ts`,`${J}.tsx`,`${J}.js`,`${J}.mjs`,`${J}.jsx`,X.join(J,"index.ts"),X.join(J,"index.tsx"),X.join(J,"index.js"),X.join(J,"index.mjs")];for(let $ of K)try{if(O.existsSync($)&&O.statSync($,{throwIfNoEntry:!1})?.isFile())return $}catch{}return}function NJ(J,K,$,W,H,z=new Map,Y){let j=(Q,Z,G)=>{if(P(Z,J,Y))return null;if(!H||Q!==$||!CJ.test(Z))return null;try{if(!O.statSync(Z,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}W.add(Z);let q=`${D}${MJ(process.cwd(),Z)}`;return z.set(G,q),{path:q,external:!0}},T=(Q,Z)=>{let G=Q===$?K:X.dirname(Q),q=X.resolve(G,Z);return e(q)??q};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(Z)=>({path:Z.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(Z)=>({path:Z.path,external:!0})),Q.onResolve({filter:/^\//},(Z)=>{let G=e(Z.path);if(G){let q=j(Z.importer,G,Z.path);if(q)return q;if(G!==$)W.add(G);return{path:G}}return{path:Z.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(Z)=>{let G=T(Z.importer,Z.path),q=j(Z.importer,G,Z.path);if(q)return q;return W.add(G),{path:G}}),Q.onResolve({filter:/^[@~]\//},(Z)=>{let G=X.resolve(J,Z.path.slice(2)),q=[G,`${G}.ts`,`${G}.tsx`,`${G}.js`,`${G}.mjs`,`${G}.jsx`,X.join(G,"index.ts"),X.join(G,"index.tsx"),X.join(G,"index.js"),X.join(G,"index.mjs")];for(let A of q)if(O.existsSync(A)&&O.statSync(A,{throwIfNoEntry:!1})?.isFile()){let U=j(Z.importer,A,Z.path);if(U)return U;return I(`resolved ${Z.path[0]}/ import:`,Z.path,"\u2192",A),W.add(A),{path:A}}return console.warn(`[stx:bundler] could not resolve ${Z.path[0]}/ import:`,Z.path),{path:G}}),Q.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(Z)=>{if(!H||Z.importer!==$)return;let G=`${D}npm:${Z.path}`;return z.set(Z.path,G),{path:G,external:!0}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(Z)=>{if(P(Z.path,J,Y))throw Error(`Server-only API source cannot be imported by a client script: ${Z.path}`);let G=X.extname(Z.path).toLowerCase(),q=G===".json"?"json":G===".tsx"?"tsx":G===".jsx"?"jsx":G===".ts"||G===".mts"||G===".cts"?"ts":"js";if(Z.path!==$)W.add(Z.path);return{contents:O.readFileSync(Z.path,"utf8"),loader:q}})}}}var m=new Map,F=WJ(64),JJ=Symbol.for("stx.client-bundle-build-queue");function _J(J){let K=globalThis,W=(K[JJ]??Promise.resolve()).then(J,J);return K[JJ]=W.then(()=>{return},()=>{return}),W}async function nJ(J,K,$={}){let W=$.projectRoot||process.cwd(),H=(await HJ(W)).serverApi,z=$.minify??!1,Y=$.externalizeUserModules??!0,j=$.cacheDir||c(W,"bundle-cache"),T=new Bun.CryptoHasher("md5");T.update(`${UJ}\x00${JSON.stringify(H??!1)}\x00${Y?"registry":"inline"}\x00${J}\x00${K}`);let Q=T.digest("hex").slice(0,12),Z=X.join(j,`${Q}.js`),G=F.get(Z);if(G){if(u(G.files)&&G.files.every((C)=>!P(C.path,W,H))){I("memo hit:",Q);let C=G.files.map((w)=>w.path);return h(K,C),$.collectInputs?.push(...C),G.code}F.delete(Z),I("memo invalidated by dep change:",Q)}let q=X.join(j,`${Q}.deps.json`),A=Bun.file(Z);if(await A.exists()){let C=Bun.file(q),w=!1,M=null;if(await C.exists())try{let _=JSON.parse(await C.text());if(_.metadataVersion!==QJ||!Array.isArray(_.files))w=!1;else M=_.files,w=!0;if(M&&(!u(M)||M.some((S)=>P(S.path,W,H))))w=!1}catch{w=!1}if(w){if(I("cache hit:",Q),M)h(K,M.map((S)=>S.path)),$.collectInputs?.push(...M.map((S)=>S.path));let _=await A.text();if(M)F.set(Z,{code:_,files:M});return _}I("cache invalidated by dep change:",Q)}let U=m.get(Q);if(U){let C=await U;if($.collectInputs)$.collectInputs.push(...(F.get(Z)?.files??[]).map((w)=>w.path));return C}let v=_J(()=>SJ(J,K,{projectRoot:W,minify:z,cacheDir:j,hash:Q,cachePath:Z,depsPath:q,collectInputs:$.collectInputs,externalizeUserModules:Y,serverApi:H}));m.set(Q,v);try{return await v}finally{m.delete(Q)}}async function SJ(J,K,$){let{projectRoot:W,minify:H,cacheDir:z,hash:Y,cachePath:j,depsPath:T,externalizeUserModules:Q}=$,Z=c(W,"bundle-tmp"),G=X.join(Z,`${Y}.ts`),q=X.join(Z,"out",Y);O.mkdirSync(Z,{recursive:!0}),O.mkdirSync(q,{recursive:!0});let A=X.dirname(K),U=new Set,v=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,C=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,w=KJ(J),{depths:M,balanced:_}=ZJ(w),S=(L)=>!_||M[L]===0,x;while((x=v.exec(w))!==null){if(x[1])continue;if(!S(x.index))continue;if(x[2])x[2].split(",").forEach((L)=>{let k=BJ(L);if(k)U.add(k)});else if(x[3])U.add(x[3])}while((x=C.exec(w))!==null){if(x[1])continue;if(!S(x.index))continue;U.add(x[2])}let XJ=U.size>0?`
|
|
5
5
|
export { ${[...U].join(", ")} }`:"";await Bun.write(G,J+XJ),I("bundling:",Y,"from:",X.basename(K));let o=new Set,l=new Map;try{let L=await Bun.build({entrypoints:[G],outdir:q,target:"browser",format:"esm",minify:H,plugins:[NJ(W,A,G,o,Q,l,$.serverApi)],define:{"process.env.NODE_ENV":H?'"production"':'"development"',...$J()},root:W});if(!L.success){let B=L.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||`Unable to bundle ${X.basename(K)}`,R=b(L.logs,K||void 0);if(console.warn("[stx:bundler] build failed:",B),t(K||"",B,R),r()==="error")throw Error(B);return J}let k="";for(let V of L.outputs){k=await V.text();break}let N=[];for(let V of k.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let B of V[1].split(",")){let R=B.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(R){N.push([R[2],R[1]]);continue}let y=B.trim();if(/^[A-Za-z_$][\w$]*$/.test(y))N.push([y,y])}let d=[];k=IJ(xJ(k,l),d);let qJ=k.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];k=k.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let i=`__stxBundle_${Y}`,VJ=N.map(([V,B])=>`${JSON.stringify(V)}: ${B}`).join(", "),kJ=N.map(([V])=>`var ${V} = undefined;`).join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$p as w,Jo as x,Qo as k,Zl as A,_l as b,bn as T,cn as y,do as M,om as B,qm as F,vo as R,wr as P}from"./chunk-
|
|
2
|
+
import{$p as w,Jo as x,Qo as k,Zl as A,_l as b,bn as T,cn as y,do as M,om as B,qm as F,vo as R,wr as P}from"./chunk-spzbfqjn.js";import{ew as v}from"./chunk-jryjwara.js";function j(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,Y){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(Y?.some((X)=>q>=X.start&&N<=X.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,Y)=>J.start-Y.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function D(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>b(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as f,resolve as H}from"path";function S(K){let z=K,G=M(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],Y=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],X=$[2],E=$[0],Z=N.includes("server");if(Y(X))J.push(E);else if(Z)Q.push(X);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,X,E=[];while((X=N.exec(q))!==null){let Z=X.index+X[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:X.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -14,5 +14,5 @@ ${Q.join(`
|
|
|
14
14
|
`)}`}else{if(G.processClientScripts!==!1&&Q.length>0){let N=Y.__stx_event_bindings||[],X=B(Y),Z=(await Promise.all(Q.map(async(I)=>{let W=I.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!W)return I;return await F(W[1],{eventBindings:N,templateContent:q,serverData:X,filePath:z})}))).join(`
|
|
15
15
|
`);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${Z}
|
|
16
16
|
$1`);else q+=`
|
|
17
|
-
${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCss:N}=await import("./chunk-
|
|
17
|
+
${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCss:N}=await import("./chunk-djf1p5cy.js");q=await N(q)}catch{}return q}
|
|
18
18
|
export{j as xk,C as yk,D as zk,o as Ak,r as Bk,V as Ck};
|