@stacksjs/stx 0.2.365 → 0.2.367
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-r5dta1qf.js → chunk-0vgexs1k.js} +16 -16
- package/dist/{chunk-se8fh272.js → chunk-17s5aghd.js} +1 -1
- package/dist/{chunk-77g77ygz.js → chunk-22rr5608.js} +1 -1
- package/dist/{chunk-v8ccphfs.js → chunk-243n8zxy.js} +1 -1
- package/dist/{chunk-dk40tcv1.js → chunk-2sngz0mn.js} +1 -1
- package/dist/{chunk-bh1m0x85.js → chunk-3ab5knmx.js} +1 -1
- package/dist/{chunk-d5r4zwyd.js → chunk-3bcmvdzz.js} +8 -8
- package/dist/{chunk-n5791wn3.js → chunk-4nty9rg5.js} +1 -1
- package/dist/{chunk-wkeymrkg.js → chunk-51x9g5xc.js} +1 -1
- package/dist/{chunk-mks2cgty.js → chunk-59vxqjdn.js} +1 -1
- package/dist/{chunk-6tk817fg.js → chunk-8gm2ctc2.js} +1 -1
- package/dist/{chunk-4dzsp35z.js → chunk-8wr21vxv.js} +1 -1
- package/dist/{chunk-eczq4cxz.js → chunk-azg8n1ez.js} +1 -1
- package/dist/{chunk-k10f0c00.js → chunk-bjvksac7.js} +1 -1
- package/dist/{chunk-k3ktx8w2.js → chunk-ccre21me.js} +1 -1
- package/dist/{chunk-bszp4vx1.js → chunk-cf4191be.js} +1 -1
- package/dist/{chunk-hyrm54da.js → chunk-cjevg8se.js} +1 -1
- package/dist/{chunk-y3ns6824.js → chunk-dqgtzhfj.js} +1 -1
- package/dist/{chunk-atf4tj9y.js → chunk-dtxx5xze.js} +1 -1
- package/dist/{chunk-8zdq8kk5.js → chunk-dxp0rdvp.js} +1 -1
- package/dist/{chunk-xr8ergcp.js → chunk-fpsvcam8.js} +1 -1
- package/dist/{chunk-zjqw2fde.js → chunk-fy5k7xh8.js} +1 -1
- package/dist/{chunk-ttw7qrz0.js → chunk-g3ksdqyc.js} +1 -1
- package/dist/{chunk-kmd694ky.js → chunk-gyv6ge1q.js} +2 -2
- package/dist/{chunk-p33qyhtc.js → chunk-h8de9t8c.js} +1 -1
- package/dist/{chunk-jerrq5k1.js → chunk-hvkzj71k.js} +1 -1
- package/dist/{chunk-0t0b5yex.js → chunk-j68egpw9.js} +1 -1
- package/dist/{chunk-2aqq5j7c.js → chunk-k4my696m.js} +1 -1
- package/dist/{chunk-bxnx8sga.js → chunk-k8gb8b8h.js} +1 -1
- package/dist/{chunk-346jyc33.js → chunk-mcc96y04.js} +1 -1
- package/dist/{chunk-0thch80p.js → chunk-nhhdqk62.js} +1 -1
- package/dist/{chunk-7yyfbhna.js → chunk-p9jgsbrd.js} +1 -1
- package/dist/{chunk-g63sh9bx.js → chunk-pfn13pck.js} +1 -1
- package/dist/{chunk-5qs1t2cd.js → chunk-pkma79bf.js} +1 -1
- package/dist/{chunk-ry56srm9.js → chunk-q2jvq038.js} +1 -1
- package/dist/{chunk-r8hr3jhh.js → chunk-qz8bkt99.js} +1 -1
- package/dist/{chunk-1nv116m3.js → chunk-rg7d10cb.js} +1 -1
- package/dist/{chunk-czzy14fj.js → chunk-rnzwf3z2.js} +98 -53
- package/dist/{chunk-7ptewn2w.js → chunk-rvmgbjbh.js} +2 -2
- package/dist/{chunk-p8nasx5y.js → chunk-ttb07mnn.js} +1 -1
- package/dist/{chunk-5t826ypq.js → chunk-v7zx438v.js} +1 -1
- package/dist/{chunk-a47e67th.js → chunk-v8hhk3cd.js} +1 -1
- package/dist/{chunk-q28ekhhb.js → chunk-vs5zebkb.js} +2 -2
- package/dist/{chunk-6njr31wk.js → chunk-w54m70rf.js} +1 -1
- package/dist/{chunk-tfnq0cj6.js → chunk-wda7kq69.js} +1 -1
- package/dist/{chunk-pbt7f5h9.js → chunk-whpk0ekx.js} +1 -1
- package/dist/{chunk-z274qgsn.js → chunk-xcxa0grg.js} +1 -1
- package/dist/{chunk-11v2ysbe.js → chunk-yf8bdka7.js} +1 -1
- package/dist/{chunk-syy0njsk.js → chunk-yt532p7h.js} +1 -1
- package/dist/{chunk-1q2b0r3v.js → chunk-z81k9w7b.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +98 -53
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bm as O,Io as R,Lp as H,qq as x,vr as g}from"./chunk-
|
|
2
|
+
import{Bm as O,Io as R,Lp as H,qq as x,vr as g}from"./chunk-0vgexs1k.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Sw as H}from"./chunk-m8kem5ca.js";import P from"path";var $=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function G(...w){let v=new Set;for(let q of w){if(!q||!q.includes("__stxModules["))continue;for(let z of q.matchAll($))try{v.add(JSON.parse(`"${z[1]}"`))}catch{}}return[...v].sort()}async function T(w,v={}){if(w.length===0)return null;let q=process.cwd(),z=[],J=[];w.forEach((j,X)=>{let Z=j.startsWith("npm:")?j.slice(4):P.resolve(q,j),N=`__stxRegistered${X}`,O=JSON.stringify(j);z.push(`import * as ${N} from ${JSON.stringify(Z)};`),J.push(`if (!globalThis.__stxModules[${O}]) globalThis.__stxModules[${O}] = ${N};`)});let L=[...z,"globalThis.__stxModules = globalThis.__stxModules || {};",...J].join(`
|
|
3
|
-
`),B;try{let{bundleClientScript:j}=await import("./chunk-
|
|
3
|
+
`),B;try{let{bundleClientScript:j}=await import("./chunk-cjevg8se.js");B=await j(L,P.join(q,".stx-module-registry.ts"),{projectRoot:q,minify:v.minify,externalizeUserModules:!1,collectInputs:v.collectInputs})}catch(j){return console.warn("[stx] could not build the page module registry (#1957):",j),null}let{transformAutoImports:Q,generateAutoImportDestructuring:U}=await import("./chunk-fpsvcam8.js"),F=Q(B),V=U(F.stxImports,F.browserImports),{transformStoreImports:W}=await import("./chunk-bqm306xw.js");B=W(F.code);let M=JSON.stringify(new Bun.CryptoHasher("md5").update(L).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${M}]) return;`,` __stxBundles[${M}] = true;`,V,B,"})();"].join(`
|
|
4
4
|
`)}export{G as registeredModuleIdsIn,T as buildModuleRegistryScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ki as O,Li as w,Mi as Z}from"./chunk-ra1s4s6b.js";import{_k as R,fl as U,ll as T}from"./chunk-
|
|
2
|
+
import{Ki as O,Li as w,Mi as Z}from"./chunk-ra1s4s6b.js";import{_k as R,fl as U,ll as T}from"./chunk-17s5aghd.js";import{bm as M,fq as k,xr as C,zo as W}from"./chunk-0vgexs1k.js";import{vv as E,wv as L}from"./chunk-ta6z7k4p.js";import{Av as B}from"./chunk-7racewc5.js";import $ from"path";var Y=new Map;function b(Q,z){for(let J of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(J[1])z.add(J[1]);for(let J of Q.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let H of(J[1]??"").split(",")){let K=((H.includes(":")?H.split(":").pop():H)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(K))z.add(K)}for(let J of Q.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let H of(J[1]??"").split(",")){let V=H.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(V))z.add(V)}}async function l(Q){let z;if(Q)z=$.resolve(Q);else{let q=await C();z=$.resolve(q.root||process.cwd(),q.storesDir||"stores")}let J=new Bun.Glob("*.ts"),H=[];try{for await(let q of J.scan({cwd:z,absolute:!0})){let y=$.basename(q,".ts");if(["index","types"].includes(y))continue;if(q.includes(".d.ts"))continue;H.push(q)}}catch{return Z(Y,z,"",""),null}let V=()=>[...new Set([...H,...H.flatMap((q)=>R(q))])],K=O(V()),P=w(Y,z,K);if(P!==void 0)return P||null;if(H.length===0)return Z(Y,z,K,""),null;let A=[];for(let q of H){let y=await Bun.file(q).text();A.push({file:q,hasUseStore:/useStore\s*\(/.test(y)})}A.sort((q,y)=>{if(q.hasUseStore===y.hasUseStore)return 0;return q.hasUseStore?1:-1});let N=A.map((q)=>q.file),G=[],X=new Set,F=k({loader:"ts",target:"browser",define:M()});for(let q of N)try{let y=await Bun.file(q).text(),I=$.basename(q,".ts");if(b(y,X),U(y))y=await T(y,q,{projectRoot:process.cwd(),externalizeUserModules:!1});y=W(y),y=E(y),y=L(y),y=y.replace(/^export\s+(default\s+)?/gm,""),y=F.transformSync(y),G.push(`// Store: ${I}
|
|
3
3
|
${y.trim()}`)}catch(y){console.warn(`[stx] Failed to load store ${q}:`,y)}if(G.length===0)return Z(Y,z,K,""),null;let j=G.join(`
|
|
4
4
|
|
|
5
5
|
`),x=`;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{am as c,dm as d,em as e,fm as f,gm as g,hm as h,im as i,jm as j,km as k,lm as l,mm as m,nm as n}from"./chunk-
|
|
2
|
+
import{am as c,dm as d,em as e,fm as f,gm as g,hm as h,im as i,jm as j,km as k,lm as l,mm as m,nm as n}from"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import{ps as a,qs as b}from"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{h as transformAutoImports,b as stripCommentsAndLiterals,e as renderVendorStyleTags,i as referencesName,n as processClientScript,g as injectBrowserCoreAutoImports,m as generateServerDataBridge,k as generateBrowserAutoImportDestructuring,j as generateAutoImportDestructuring,a as findInterpolationEnd,l as extractBridgeData,d as extractAndStripCssImports,f as STX_AUTO_IMPORTS,c as BROWSER_CORE_IMPORTS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Oo as a,Po as b,Qo as c,Ro as d}from"./chunk-
|
|
2
|
+
import{Oo as a,Po as b,Qo as c,Ro as d}from"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{b as reportDeferredLoopWarnings,c as processLoops,a as parseLoopBinding,d as declareBareLoopHead};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bg as ZJ,dg as g,fg as A,lg as n,og as GJ,rg as WJ,tg as YJ,vg as jJ}from"./chunk-
|
|
2
|
+
import{bg as ZJ,dg as g,fg as A,lg as n,og as GJ,rg as WJ,tg as YJ,vg as jJ}from"./chunk-vs5zebkb.js";import{yg as $J}from"./chunk-0knxnyq6.js";import{rl as XJ}from"./chunk-q2jvq038.js";import{lo as h}from"./chunk-0vgexs1k.js";import{Hs as e}from"./chunk-243n8zxy.js";import{It as QJ,Mt as i,Ot as p}from"./chunk-xk402w4a.js";import{Dw as l,Iw as VJ,aw as KJ}from"./chunk-e03m4har.js";import{Sw as DJ}from"./chunk-m8kem5ca.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-yt532p7h.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 We,LJ as Xe,t as Ye,uJ as Ze};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Io as V}from"./chunk-
|
|
2
|
+
import{a as x,b as u,c as b,d as Az,e as G,f as d,h as y,i as I,j as Uz,k as v}from"./chunk-0y46fbkx.js";import{l as h,m as f,n as g}from"./chunk-q9n5swx7.js";import{Io as V}from"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import{Sw as F}from"./chunk-m8kem5ca.js";import l from"fs";import R from"path";function m(z,J){let Z=[R.join(z.root,"stx.config.ts"),R.join(z.root,"stx.config.js"),R.join(z.root,"stx.config.mjs")],K=J.debounceMs??300,$=null,X=[];for(let B of Z)try{if(!l.existsSync(B))continue;let Y=l.watch(B,(W)=>{if(W==="change"){if($)clearTimeout($);$=setTimeout(async()=>{d("Config file changed, restarting...");try{await J.onChange()}catch(j){G(`Failed to restart: ${j}`)}},K)}});X.push(Y)}catch{}return{stop(){if($)clearTimeout($);for(let B of X)B.close()}}}import E from"fs";import i from"path";var Gz=".stx/story/analytics.json",Nz=1,c=1e4;class M{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(z){this.storagePath=i.join(z,Gz),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let z=E.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Nz,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let z=i.dirname(this.storagePath);if(await E.promises.mkdir(z,{recursive:!0}),this.storage.events.length>c)this.storage.events=this.storage.events.slice(-c);await E.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Hz(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(z){this.storage.events.push({...z,timestamp:Date.now()}),this.dirty=!0}trackView(z,J){if(this.endViewTiming(z),this.viewStartTimes.set(z,Date.now()),this.track({type:"view",componentId:z,variantId:J}),this.currentSession&&!this.currentSession.componentViews.includes(z))this.currentSession.componentViews.push(z)}endViewTiming(z){let J=this.viewStartTimes.get(z);if(J){let Z=Date.now()-J;this.track({type:"view",componentId:z,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete(z)}}trackPropChange(z,J,Z){this.track({type:"prop_change",componentId:z,propName:J,metadata:{value:Z}})}trackVariantSwitch(z,J){this.track({type:"variant_switch",componentId:z,variantId:J})}trackSearch(z,J){this.track({type:"search",query:z,metadata:{resultCount:J}})}getComponentAnalytics(z,J){let Z=this.storage.events.filter((Q)=>Q.componentId===z),K=Z.filter((Q)=>Q.type==="view"&&!Q.metadata?.endView),$=Z.filter((Q)=>Q.type==="prop_change"),X=Z.filter((Q)=>Q.type==="variant_switch"),B={};for(let Q of $)if(Q.propName)B[Q.propName]=(B[Q.propName]||0)+1;let Y={};for(let Q of X)if(Q.variantId)Y[Q.variantId]=(Y[Q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((Q)=>Q.componentViews.includes(z)).map((Q)=>Q.id)),j=Z.filter((Q)=>Q.metadata?.duration).map((Q)=>Q.metadata.duration),U=j.length>0?j.reduce((Q,D)=>Q+D,0)/j.length:0,_=Object.entries(B).sort((Q,D)=>D[1]-Q[1]).slice(0,5).map(([Q])=>Q);return{componentId:z,componentName:J,viewCount:K.length,uniqueViews:W.size,lastViewed:K[K.length-1]?.timestamp,propChanges:B,topChangedProps:_,variantViews:Y,avgTimeSpent:U}}getMostViewedComponents(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)J.set(Z.componentId,(J.get(Z.componentId)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({componentId:Z,viewCount:K})).sort((Z,K)=>K.viewCount-Z.viewCount).slice(0,z)}getMostChangedProps(z=10){let J=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)J.set(Z.propName,(J.get(Z.propName)||0)+1);return Array.from(J.entries()).map(([Z,K])=>({propName:Z,changeCount:K})).sort((Z,K)=>K.changeCount-Z.changeCount).slice(0,z)}getSearchAnalytics(){let z=this.storage.events.filter(($)=>$.type==="search"),J=new Map,Z=0;for(let $ of z){if($.query)J.set($.query,(J.get($.query)||0)+1);if($.metadata?.resultCount!==void 0)Z+=$.metadata.resultCount}let K=Array.from(J.entries()).map(([$,X])=>({query:$,count:X})).sort(($,X)=>X.count-$.count).slice(0,10);return{totalSearches:z.length,topQueries:K,avgResultCount:z.length>0?Z/z.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Hz(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import P from"fs";import p from"path";var Fz=".stx/story/bookmarks.json",Vz=1;class T{storage;storagePath;dirty=!1;constructor(z){this.storagePath=p.join(z,Fz),this.storage=this.loadStorage()}loadStorage(){try{let z=P.readFileSync(this.storagePath,"utf-8");return JSON.parse(z)}catch{return{version:Vz,bookmarks:[]}}}async save(){if(!this.dirty)return;let z=p.dirname(this.storagePath);await P.promises.mkdir(z,{recursive:!0}),await P.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(z,J,Z,K={}){let $={id:Rz(),name:K.name||`${z}/${J}`,storyId:z,variantId:J,props:Z,created:Date.now(),notes:K.notes,color:K.color};return this.storage.bookmarks.push($),this.dirty=!0,$}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(z){return this.storage.bookmarks.filter((J)=>J.storyId===z)}getBookmark(z){return this.storage.bookmarks.find((J)=>J.id===z)}isBookmarked(z,J){return this.storage.bookmarks.some((Z)=>Z.storyId===z&&Z.variantId===J)}updateBookmark(z,J){let Z=this.getBookmark(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deleteBookmark(z){let J=this.storage.bookmarks.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.bookmarks.splice(J,1),this.dirty=!0,!0}toggleBookmark(z,J,Z){let K=this.storage.bookmarks.find((X)=>X.storyId===z&&X.variantId===J);if(K)return this.deleteBookmark(K.id),{added:!1};return{added:!0,bookmark:this.addBookmark(z,J,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(z,J=!0){let Z=JSON.parse(z),K=0;for(let $ of Z.bookmarks){if(J){let X=this.storage.bookmarks.find((B)=>B.id===$.id);if(X)Object.assign(X,$);else this.storage.bookmarks.push($)}else this.storage.bookmarks.push($);K++}if(K>0)this.dirty=!0;return K}}function Rz(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var N=new Set;function s(){return{open(z){N.add(z),z.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(z){N.delete(z)},message(z,J){}}}function q(z){let J=JSON.stringify({...z,timestamp:z.timestamp||Date.now()});for(let Z of N)try{Z.send(J)}catch{N.delete(Z)}}function n(z,J){q({type:"story-update",data:{storyId:z,...J}})}function a(z,J){q({type:"story-add",data:{storyId:z,...J}})}function o(z){q({type:"story-remove",data:{storyId:z}})}function r(z){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${z}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-
|
|
559
|
+
`}import w from"fs";import Xz from"path";var Mz=".stx/story/presets.json",C=1,Pz=10;class k{storage;storagePath;dirty=!1;constructor(z){this.storagePath=Xz.join(z,Mz),this.storage=this.loadStorage()}loadStorage(){try{let z=w.readFileSync(this.storagePath,"utf-8"),J=JSON.parse(z);if(J.version!==C)return this.migrateStorage(J);return J}catch{return{version:C,presets:[],recentIds:[]}}}migrateStorage(z){return{version:C,presets:z.presets||[],recentIds:z.recentIds||[]}}async save(){if(!this.dirty)return;let z=Xz.dirname(this.storagePath);await w.promises.mkdir(z,{recursive:!0}),await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(z,J,Z={}){let K={id:Tz(),name:z,description:Z.description,props:J,componentId:Z.componentId,created:Date.now(),usageCount:0,tags:Z.tags};return this.storage.presets.push(K),this.dirty=!0,K}getPreset(z){return this.storage.presets.find((J)=>J.id===z)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(z){return this.storage.presets.filter((J)=>!J.componentId||J.componentId===z)}getRecentPresets(){return this.storage.recentIds.map((z)=>this.getPreset(z)).filter((z)=>z!==void 0)}usePreset(z){let J=this.getPreset(z);if(!J)return;return J.lastUsed=Date.now(),J.usageCount++,this.storage.recentIds=[z,...this.storage.recentIds.filter((Z)=>Z!==z)].slice(0,Pz),this.dirty=!0,J}updatePreset(z,J){let Z=this.getPreset(z);if(!Z)return;return Object.assign(Z,J),this.dirty=!0,Z}deletePreset(z){let J=this.storage.presets.findIndex((Z)=>Z.id===z);if(J===-1)return!1;return this.storage.presets.splice(J,1),this.storage.recentIds=this.storage.recentIds.filter((Z)=>Z!==z),this.dirty=!0,!0}searchPresets(z){let J=z.toLowerCase();return this.storage.presets.filter((Z)=>{if(Z.name.toLowerCase().includes(J))return!0;if(Z.description?.toLowerCase().includes(J))return!0;if(Z.tags?.some((K)=>K.toLowerCase().includes(J)))return!0;return!1})}getMostUsedPresets(z=5){return[...this.storage.presets].sort((J,Z)=>Z.usageCount-J.usageCount).slice(0,z)}exportPresets(z){let J=z?this.storage.presets.filter((Z)=>z.includes(Z.id)):this.storage.presets;return JSON.stringify({presets:J},null,2)}importPresets(z,J=!1){let Z=JSON.parse(z),K=0;for(let $ of Z.presets){let X=this.storage.presets.find((B)=>B.id===$.id);if(X&&!J)continue;if(X)Object.assign(X,$);else this.storage.presets.push($);K++}if(K>0)this.dirty=!0;return K}}function Tz(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";var Qz=new Map;async function H(z,J,Z={}){let K=performance.now(),$=[];try{let X=await S.promises.stat(J),B=Qz.get(J),Y;if(B&&B.mtime===X.mtimeMs)Y=B.content;else Y=await S.promises.readFile(J,"utf-8"),Qz.set(J,{content:Y,mtime:X.mtimeMs,analyzed:null});let{processDirectives:W}=await import("./chunk-ccre21me.js"),j={},U=A(Y);if(U)try{await V(U,j,J)}catch(O){$.push(`Warning: Could not extract script variables: ${O instanceof Error?O.message:String(O)}`)}if(Z.props)Object.assign(j,Z.props);let Q=await W(Y,j,J,{},new Set),D=Wz(Y),L=A(Y);return Q=jz(Q),Q=Dz(Q,j),{html:Q,css:D,js:L,errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}async function qz(z){try{let J=await S.promises.readFile(z,"utf-8"),Z=A(J);if(!Z)return null;let K={};if(await V(Z,K,z),Array.isArray(K.variants))return K.variants;return null}catch{return null}}async function Bz(z,J,Z,K){let $=J.story?.variants;if(!$){let Y=await qz(J.path);if(Y)$=Y}if(!$&&Z==="default")return H(z,J.path,{props:K||{}});if(!$)return H(z,J.path,{props:K||{}});let X=$.find((Y)=>Y.id===Z);if(!X&&Z==="default")return H(z,J.path,{props:K||{}});if(!X)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Z}' not found`],duration:0};let B={...X.state,...K};if(X.source)return wz(z,X.source,B);return H(z,J.path,{props:B})}async function wz(z,J,Z={}){let K=performance.now(),$=[];try{let{processDirectives:X}=await import("./chunk-ccre21me.js"),B={...Z},Y=A(J);if(Y)try{await V(Y,B,"inline-template.stx")}catch{}let j=await X(J,B,"inline-template.stx",{},new Set);return j=jz(j),j=Dz(j,B),{html:j,css:Wz(J),js:A(J),errors:$,duration:performance.now()-K}}catch(X){return $.push(X instanceof Error?X.message:String(X)),{html:`<div class="stx-render-error">${Lz($[0])}</div>`,css:"",js:"",errors:$,duration:performance.now()-K}}}function Wz(z){let J=[],Z=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
560
560
|
`)}function jz(z){return z.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function A(z){let J=[],Z=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,K=Z.exec(z);while(K!==null)J.push(K[1].trim()),K=Z.exec(z);return J.join(`
|
|
561
561
|
`)}function Dz(z,J){let Z=`<script>window.__stxProps = ${JSON.stringify(J)};</script>`;return z+Z}function Lz(z){return z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function Oz(z,J){let Z=await I(z);f(z,Z);let K=v(z.config,Z);g(z,K),console.log(` Found ${Z.length} story files`);let $=typeof J.host==="string"?J.host:J.host===!0?"0.0.0.0":"localhost",X=new k(z.root),B=new T(z.root),Y=new M(z.root),W=s(),j=Bun.serve({port:J.port,hostname:$,fetch:async(Q,D)=>{let O=new URL(Q.url).pathname;if(O==="/__hmr"){if(D.upgrade(Q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(O.startsWith("/api/"))return Cz(z,O,Q,{presetsManager:X,bookmarksManager:B,analyticsTracker:Y});return kz(z,O,J.port)},websocket:{open(Q){W.open(Q)},close(Q){W.close(Q)},message(Q,D){W.message(Q,D)}}}),U=`http://${$}:${J.port}`,_=Uz(z,async(Q,D)=>{console.log(` [${Q}] ${D.relativePath}`);let L=await I(z);f(z,L);let O=v(z.config,L);if(g(z,O),Q==="add")a(D.id,{fileName:D.fileName});else if(Q==="unlink")o(D.id);else n(D.id,{fileName:D.fileName})});if(J.open){let Q=U;try{let{exec:D}=await import("child_process"),L=process.platform;D(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} ${Q}`)}catch{}}return{server:j,url:U,close:async()=>{_(),j.stop()}}}async function Cz(z,J,Z,K){let{presetsManager:$,bookmarksManager:X,analyticsTracker:B}=K;if(J==="/api/stories")return Response.json({files:z.storyFiles.map((Y)=>({id:Y.id,fileName:Y.fileName,relativePath:Y.relativePath,treePath:Y.treePath})),tree:z.tree});if(J.startsWith("/api/story/")){let Y=J.slice(11),W=z.storyFiles.find((j)=>j.id===Y);if(!W)return new Response("Story not found",{status:404});try{let j=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:j})}catch{return new Response("Error reading story",{status:500})}}if(J==="/api/config")return Response.json({theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets});if(J.startsWith("/api/render/")){let Y=new URL(Z.url),W=J.slice(12).split("/"),j=W[0],U=W[1]||"default",_,Q=Y.searchParams.get("props");if(Q)try{_=JSON.parse(Q)}catch{}let D=z.storyFiles.find((L)=>L.id===j);if(!D)return new Response("Story not found",{status:404});try{let L=await Bz(z,D,U,_);return Response.json({html:L.html,css:L.css,js:L.js,errors:L.errors,duration:L.duration})}catch(L){return Response.json({html:"",css:"",js:"",errors:[L instanceof Error?L.message:String(L)],duration:0},{status:500})}}if(J==="/api/presets"&&Z.method==="GET")return Response.json({presets:$.getAllPresets()});if(J==="/api/presets"&&Z.method==="POST")try{let Y=await Z.json(),W=$.createPreset(Y.name,Y.props,{componentId:Y.componentId,description:Y.description});return await $.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/presets/")&&!J.includes("/use")&&Z.method==="GET"){let Y=J.slice(13),W=$.getPreset(Y);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(J.endsWith("/use")&&Z.method==="POST"){let Y=J.slice(13,-4),W=$.usePreset(Y);if(!W)return new Response("Preset not found",{status:404});return await $.save(),Response.json(W)}if(J.startsWith("/api/presets/")&&Z.method==="DELETE"){let Y=J.slice(13);if(!$.deletePreset(Y))return new Response("Preset not found",{status:404});return await $.save(),Response.json({success:!0})}if(J==="/api/bookmarks"&&Z.method==="GET")return Response.json({bookmarks:X.getAllBookmarks()});if(J==="/api/bookmarks"&&Z.method==="POST")try{let Y=await Z.json(),W=X.addBookmark(Y.storyId,Y.variantId,Y.props,{name:Y.name,notes:Y.notes,color:Y.color});return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/bookmarks/toggle"&&Z.method==="POST")try{let Y=await Z.json(),W=X.toggleBookmark(Y.storyId,Y.variantId,Y.props);return await X.save(),Response.json(W)}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J.startsWith("/api/bookmarks/")&&J!=="/api/bookmarks/toggle"&&Z.method==="GET"){let Y=J.slice(15),W=X.getBookmark(Y);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(J.startsWith("/api/bookmarks/")&&Z.method==="DELETE"){let Y=J.slice(15);if(!X.deleteBookmark(Y))return new Response("Bookmark not found",{status:404});return await X.save(),Response.json({success:!0})}if(J==="/api/analytics/track"&&Z.method==="POST")try{let Y=await Z.json();if(Y.type==="view"&&Y.componentId)B.trackView(Y.componentId,Y.variantId);else if(Y.type==="prop_change"&&Y.componentId&&Y.propName)B.trackPropChange(Y.componentId,Y.propName,null);else if(Y.type==="variant_switch"&&Y.componentId&&Y.variantId)B.trackVariantSwitch(Y.componentId,Y.variantId);else if(Y.type==="search"&&Y.query)B.trackSearch(Y.query,0);return await B.save(),Response.json({success:!0})}catch(Y){return Response.json({error:String(Y)},{status:400})}if(J==="/api/analytics/summary"&&Z.method==="GET")return Response.json({mostViewed:B.getMostViewedComponents(10),mostChangedProps:B.getMostChangedProps(10),searchAnalytics:B.getSearchAnalytics()});if(J.startsWith("/api/analytics/component/")&&Z.method==="GET"){let Y=J.slice(25),W=z.storyFiles.find((U)=>U.id===Y),j=B.getComponentAnalytics(Y,W?.fileName||Y);return Response.json(j)}return new Response("Not found",{status:404})}function kz(z,J,Z){let K=Sz(z,Z);return new Response(K,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Sz(z,J){let{theme:Z}=z.config,K=Z.title||"STX Story",$=`ws://localhost:${J}/__hmr`,X=r($);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${Z.darkClass||"dark"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Gt as a,Ht as b}from"./chunk-
|
|
2
|
+
import{Gt as a,Ht as b}from"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-m8kem5ca.js";export{a as prepareRuntimeConfig,b as generateRuntimeConfigTypes};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ul as G}from"./chunk-qjvny3wf.js";import{nq as U,rq as B}from"./chunk-
|
|
2
|
+
import{ul as G}from"./chunk-qjvny3wf.js";import{nq as U,rq as B}from"./chunk-0vgexs1k.js";import{Ls as O}from"./chunk-243n8zxy.js";import{st as L}from"./chunk-w1asc0zd.js";import{Sw as y}from"./chunk-m8kem5ca.js";import X from"fs";import Z from"path";var H=new Map,$=new Map;async function p(j){let J;for(let V=0;V<3;V++)try{let q=(await X.promises.stat(j)).mtime.getTime(),W=$.get(j);if(W&&W.mtime===q)return W.content;let I=await Bun.file(j).text(),T=(await X.promises.stat(j)).mtime.getTime();if(T!==q)continue;return $.set(j,{content:I,mtime:T}),I}catch(Q){J=Q;break}throw $.delete(j),Error(`File not found: ${j}${J?` (${J.message})`:""}`)}function m(j){$.delete(j)}function f(j){for(let z of $.keys())if(z.startsWith(j))$.delete(z)}var M=null,v=null,b=null;function r(j){b=j}async function k(j=!1){let z=b??await import("./chunk-xcxa0grg.js");if(j)return z.generateSignalsRuntimeDev();if(M===null)M=z.generateSignalsRuntime();return M}var N=null;async function R(){if(N===null){let{getRouterScript:j}=await import("./chunk-t9m81dj8.js");N=j()}return N}var x={};async function d(j,z=!1){let J=j==="runtime"?await k(z):await R(),V=j==="runtime"&&z?"runtime-debug":j,Q=x[V];if(!Q||Q.content!==J)Q={content:J,hash:Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)},x[V]=Q;return{content:J,hash:Q.hash,url:`/_stx/${j}.${Q.hash}.js`}}var E=500,Y=new Map;function w(j){return L(process.cwd(),"module-bundles",`${j}.js`)}function c(j){let z=Bun.hash(j).toString(16).padStart(16,"0").slice(0,16),J=Y.has(z);if(J)Y.delete(z);Y.set(z,j);while(Y.size>E)Y.delete(Y.keys().next().value);if(!J)try{let V=w(z);if(!X.existsSync(V))X.mkdirSync(Z.dirname(V),{recursive:!0}),X.writeFileSync(V,j)}catch{}return`/_stx/modules.${z}.js`}function l(j){if(!/^[0-9a-f]{16}$/.test(j))return;let z=Y.get(j);if(z!==void 0)return z;try{return X.readFileSync(w(j),"utf8")}catch{return}}function o(){$.clear(),B(),O(),M=null,v=null,N=null}function A(j){let z={debug:j.debug===!0,middleware:(j.middleware??[]).map((J)=>({name:J.name,timing:J.timing,handler:String(J.handler)})),customDirectives:(j.customDirectives??[]).map((J)=>({name:J.name,hasEndTag:J.hasEndTag===!0,rawParams:J.rawParams===!0,handler:String(J.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(z)).digest("hex")}async function s(j,z){try{if(!z.cachePath)return null;let J=Z.resolve(z.cachePath),V=Z.join(J,`${D(j)}.html`),Q=Z.join(J,`${D(j)}.meta.json`);if(!await U(V)||!await U(Q))return null;let q=await Bun.file(Q).text(),W=JSON.parse(q);if(W.cacheVersion!==z.cacheVersion)return null;if(W.engine!==G())return null;if(W.optionsSignature!==A(z))return null;if((await X.promises.stat(j)).mtime.getTime()>W.mtime)return null;for(let K of W.dependencies)if(await U(K)){if((await X.promises.stat(K)).mtime.getTime()>W.mtime)return null}else return null;return await Bun.file(V).text()}catch(J){return console.warn(`Cache error for ${j}:`,J),null}}async function n(j,z,J,V){try{if(!V.cachePath)return;let Q=Z.resolve(V.cachePath);await X.promises.mkdir(Q,{recursive:!0});let q=Z.join(Q,`${D(j)}.html`),W=Z.join(Q,`${D(j)}.meta.json`),I=await X.promises.stat(j);await Bun.write(q,z);let K={sourcePath:j,mtime:I.mtime.getTime(),dependencies:Array.from(J),cacheVersion:V.cacheVersion,engine:G(),optionsSignature:A(V),generatedAt:Date.now()};await Bun.write(W,JSON.stringify(K,null,2)),H.set(j,{output:z,mtime:I.mtime.getTime(),dependencies:J})}catch(Q){console.warn(`Failed to cache template ${j}:`,Q)}}var F=16;function D(j){return new Bun.CryptoHasher("sha1").update(j).digest("hex").substring(0,F)}
|
|
3
3
|
export{H as Kj,p as Lj,m as Mj,f as Nj,r as Oj,k as Pj,R as Qj,d as Rj,c as Sj,l as Tj,o as Uj,s as Vj,n as Wj,D as Xj};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Hm as W,Lp as X}from"./chunk-
|
|
2
|
+
import{Hm as W,Lp as X}from"./chunk-0vgexs1k.js";import V from"fs";import M from"path";import*as Y from"readline";var j={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},Q={help:{description:"Show available commands",usage:"help [command]",handler:async(q,z)=>{if(q[0]&&Q[q[0]]){let A=Q[q[0]];console.log(`
|
|
3
3
|
${j.bold}${q[0]}${j.reset} - ${A.description}`),console.log(` Usage: ${j.cyan}${A.usage}${j.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${j.bold}Available Commands:${j.reset}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ve as a}from"./chunk-
|
|
2
|
+
import{Ve as a}from"./chunk-cf4191be.js";import"./chunk-0knxnyq6.js";import"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{a as buildApp};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bm as b}from"./chunk-
|
|
2
|
+
import{Bm as b}from"./chunk-0vgexs1k.js";import{pv as L,tv as R}from"./chunk-met6wtbk.js";function P(j,U){let Q=1,J=U,B="<template",z="</template";while(J<j.length&&Q>0){let G=j.indexOf("<",J);if(G===-1)break;if(J=G,j.startsWith(B,J)&&(J+B.length>=j.length||/[\s>\/]/.test(j[J+B.length]))){Q++,J+=B.length;continue}if(j.startsWith(z,J)){let W=j.indexOf(">",J+z.length);if(W!==-1){if(Q--,Q===0)return W+1;J=W+1;continue}}J++}return Q===0?J:-1}var F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function O(j,U){let Q=null;for(let J=U;J<j.length;J++){let B=j[J];if(Q){if(B==="\\"){J++;continue}if(B===Q)Q=null;continue}if(B==='"'||B==="'"){Q=B;continue}if(B===">")return J+1}return-1}function I(j,U,Q){let J=U.toLowerCase(),B=1,z=Q;while(z<j.length){let G=j.indexOf("<",z);if(G===-1)return-1;if(j.startsWith("<!--",G)){let $=j.indexOf("-->",G+4);z=$===-1?j.length:$+3;continue}let W=O(j,G+1);if(W===-1)return-1;let Z=j.slice(G,W),Y=Z.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(Y&&Y[2].toLowerCase()===J){if(Y[1]==="/"){if(B--,B===0)return W}else if(!/\/\s*>$/.test(Z))B++}z=W}return-1}function w(j){let U=[],Q=[],J=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[2].toLowerCase();if(Z[1]==="/"){let X=Q.lastIndexOf(Y);if(X!==-1)Q.splice(X);B=G;continue}let $=/\/\s*>$/.test(W),K=Q.length===0?W.match(J):null;if(K){let X=K[1]||K[2],H=W.replace(J,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),_=$||F.has(Y)?-1:I(j,Y,G);if(_===-1)U.push({start:z,end:G,slotName:X,element:H}),B=G;else U.push({start:z,end:_,slotName:X,element:H+j.slice(G,_)}),B=_;continue}if(!$&&!F.has(Y)){if(Q.push(Y),Y==="script"||Y==="style"){let X=j.toLowerCase().indexOf(`</${Y}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function D(j){let U=[],Q=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[1]==="/",$=Z[2].toLowerCase();if(Y){let X=Q.lastIndexOf($);if(X!==-1)Q.splice(X);B=G;continue}if($==="template"&&Q.length===0){let X=W.match(J);if(X){let H=P(j,G);if(H!==-1){let _=X[1]||X[2]||X[3];U.push({start:z,end:H,slotName:_,content:j.slice(G,H-11).trim(),propsBinding:X[4]||void 0}),B=H;continue}}}if(!/\/\s*>$/.test(W)&&!F.has($)){if(Q.push($),$==="script"||$==="style"){let X=j.toLowerCase().indexOf(`</${$}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function v(j){let U={default:"",named:new Map},Q=j,J=D(j);for(let z of J)U.named.set(z.slotName,{name:z.slotName,content:z.content,propsBinding:z.propsBinding});J.sort((z,G)=>G.start-z.start);for(let z of J)Q=Q.slice(0,z.start)+Q.slice(z.end);let B=w(Q);for(let z of B){let G=U.named.get(z.slotName);if(G)G.content+=z.element;else U.named.set(z.slotName,{name:z.slotName,content:z.element})}for(let z=B.length-1;z>=0;z--){let G=B[z];Q=Q.slice(0,G.start)+Q.slice(G.end)}return U.default=Q.trim(),U}function S(j){let U=j.match(/name\s*=\s*["']([^"']+)["']/),Q=U?U[1]:"",J={},B=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,z;while((z=B.exec(j))!==null)J[z[1]]=z[2];let G=j.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),W=G?G[1].trim():"";return{name:Q,props:J,defaultContent:W}}async function k(j,U,Q,J){if(!j)return Q;let B=j.content;if(j.propsBinding&&Object.keys(U).length>0){let z=j.propsBinding.trim(),G={...J};if(z.startsWith("{")&&z.endsWith("}")){let W=z.slice(1,-1).split(",").map((Z)=>Z.trim()).filter(Boolean);for(let Z of W){let[Y,$]=Z.split(":").map((X)=>X.trim()),K=$||Y;if(U[Y]!==void 0)G[K]=U[Y]}}else G[z]=U;B=N(B,G)}return B}function N(j,U){return j.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Q,J)=>{try{let B=J.trim(),z=y(B,U);return b(String(z??""))}catch{return`{{ ${J} }}`}})}function y(j,U){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(j)){let J=j.split("."),B=U;for(let z of J)if(B&&typeof B==="object"&&z in B)B=B[z];else return;return B}let Q=j.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Q){let[,J,B,z]=Q,G=U[J],W=parseInt(z,10);if(typeof G==="number")switch(B){case"+":return G+W;case"-":return G-W;case"*":return G*W;case"/":return G/W}}try{if(!L(j))return;return R(j,Object.keys(U))(...Object.values(U))}catch{return}}async function T(j,U,Q){let J=j;J=await C(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,W,Z,Y)=>{let $=U.named.get(W),K=Y?.trim()||"",X=Z||"",H={},_=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,q;while((q=_.exec(X))!==null){let A=q[1],V=q[2];H[A]=y(V,Q)}return await k($,H,K,Q)});let z=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(z,(G,W,Z)=>{if(/\bname\s*=/.test(W||""))return G;let Y=Z?.trim()||"";return U.default||Y}),J}async function C(j,U,Q){let J=[],B=[];j.replace(U,(W,...Z)=>{let Y=Z[Z.length-2];return B.push({match:W,index:Y}),J.push(Q(W,...Z.slice(0,-2))),W});let z=await Promise.all(J),G=j;for(let W=B.length-1;W>=0;W--){let{match:Z,index:Y}=B[W];G=G.slice(0,Y)+z[W]+G.slice(Y+Z.length)}return G}function E(j){let U=v(j);return{defaultSlot:U.default,namedSlots:U.named}}async function x(j,U,Q,J){return await T(j,{default:U,named:Q},J)}
|
|
3
3
|
export{v as Lg,S as Mg,k as Ng,T as Og,E as Pg,x as Qg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{fi as jH}from"./chunk-
|
|
2
|
+
import{fi as jH}from"./chunk-pkma79bf.js";import{Do as e,Mp as S,Np as zH,Op as qH,Rp as JH,Sp as WH,Tp as VH,Up as AH,Vp as GH,Wp as UH,Xp as FH,Yp as MH,Zp as XH,am as $H,xr as BH}from"./chunk-0vgexs1k.js";import{st as f}from"./chunk-w1asc0zd.js";import{Av as D}from"./chunk-7racewc5.js";import{existsSync as x,readFileSync as m}from"fs";import U from"path";var EH=new Set(["module","exports","require","$bool","window","document","console","confirm","alert","fetch"]),HH=e.filter((H)=>!EH.has(H)).sort(),KH=[...D].sort(),DH=[...new Set([...HH,...KH])].sort(),PH=new Set(HH),TH=new Set(KH),SH=new Set(DH),t=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function xH(H,K){if(K==="server")return`'${H}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${H}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${H}', so it is undefined in the browser.`}function QH(H,K){let Z=[];for(let q of K){if(q.offset===void 0)continue;let Y=q.kind==="server"?PH:TH;t.lastIndex=0;for(let z of q.code.matchAll(t)){let A=z.index+z[0].indexOf("{")+1;for(let G of z[1].matchAll(/[^,]+/g)){let X=G[0];if(/^\s*type\s/.test(X))continue;let M=/^\s*([A-Za-z_$][\w$]*)/.exec(X);if(!M)continue;let $=M[1];if(!SH.has($)||Y.has($))continue;let V=q.offset+A+G.index+M[0].length-$.length,J=H.slice(0,V),I=J.split(`
|
|
3
3
|
`).length;Z.push({line:I,column:V-(J.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:V,length:$.length,name:$,kind:q.kind,message:xH($,q.kind)})}}}return Z}import w from"path";var hH="@stacksjs/stx-typescript-plugin";function kH(H,K){let Z=w.resolve(H);for(;;){let q=w.join(Z,"tsconfig.json");if(K(q))return q;let Y=w.dirname(Z);if(Y===Z)return;Z=Y}}function YH(H,K,Z){let q=kH(H,Z);if(!q)return;let Y=new Set,z=(A)=>{if(Y.has(A))return;Y.add(A);let G=K(A);if(!G)return;let X=G.compilerOptions?.plugins;if(Array.isArray(X)){let $=X.find((J)=>J?.name===hH),V=Array.isArray($?.libs)?$.libs.filter((J)=>typeof J==="string"):[];return $?{configPath:A,libs:V.map((J)=>w.resolve(w.dirname(A),J))}:null}let M=typeof G.extends==="string"?[G.extends]:Array.isArray(G.extends)?G.extends:[];for(let $ of[...M].reverse()){if(typeof $!=="string"||!$.startsWith("."))continue;let V=w.resolve(w.dirname(A),$.endsWith(".json")?$:`${$}.json`),J=z(V);if(J!==void 0)return J}return};return z(q)??void 0}function gH(H,K="",Z=""){let q=H.startLine>1?`
|
|
5
5
|
`.repeat(H.startLine-1):"",Y=UH(H)+qH(zH(H.code)),z=H.kind==="client"||H.kind==="plain"?VH(K,H.code):"";return GH(`${q+Y}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{sk as m}from"./chunk-
|
|
2
|
+
import{sk as m}from"./chunk-rvmgbjbh.js";import{Sw as z}from"./chunk-m8kem5ca.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{So as a,To as b,Uo as c,Vo as d,Wo as e,Xo as f,Yo as g}from"./chunk-
|
|
2
|
+
import{So as a,To as b,Uo as c,Vo as d,Wo as e,Xo as f,Yo as g}from"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{a as resetUnscopedSignalWarnings,g as processStackReplacements,f as processStackPushDirectives,e as processIncludes,b as partialsCache,c as onceStore,d as clearOnceStore};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Xf as a}from"./chunk-
|
|
2
|
+
import{Xf as a}from"./chunk-qz8bkt99.js";import"./chunk-vs5zebkb.js";import"./chunk-0knxnyq6.js";import"./chunk-rnzwf3z2.js";import"./chunk-y32dbdta.js";import"./chunk-frp9fc7j.js";import"./chunk-q2jvq038.js";import"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{a as buildForProduction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ki as T,Li as u,Mi as A}from"./chunk-ra1s4s6b.js";import{_k as g,fl as h,ll as b}from"./chunk-
|
|
2
|
+
import{Ki as T,Li as u,Mi as A}from"./chunk-ra1s4s6b.js";import{_k as g,fl as h,ll as b}from"./chunk-17s5aghd.js";import{bm as k,fq as B,xr as I,zo as f}from"./chunk-0vgexs1k.js";import{vv as D,wv as S}from"./chunk-ta6z7k4p.js";import{Av as F}from"./chunk-7racewc5.js";import P from"path";var j=new Map,K=new Map,n=["composables","functions"];function p(z){let H=P.basename(z,".ts");return H==="index"||H==="types"||z.endsWith(".d.ts")}async function r(z){if(z)return P.resolve(z);let H=`<default>:${process.cwd()}`,Y=K.get(H);if(Y!==void 0)return Y;let J=await l();if(J!==null)K.set(H,J);return J}async function l(){let z=await I(),H=z.root||process.cwd(),Y=z.composablesDir;if(Y)return P.resolve(H,Y);for(let J of n){let V=P.resolve(H,J);try{let Z=new Bun.Glob("**/*.ts");for await(let W of Z.scan({cwd:V,absolute:!0}))if(!p(W))return V}catch{}}return null}async function m(z){let H=Array.isArray(z)?z:z?[P.resolve(z)]:(await I())._layerComposableDirs??[await r()].filter((J)=>!!J),Y=new Map;for(let J of H){let V=new Bun.Glob("**/*.ts");try{for await(let Z of V.scan({cwd:J,absolute:!0})){let W=P.relative(J,Z);if(!p(Z)&&!Y.has(W))Y.set(W,Z)}}catch{}}return{key:H.join("\x00"),files:[...Y.values()].sort()}}async function Wq(z){let{files:H}=await m(z),Y=B({loader:"ts",target:"browser",define:k()}),J=[];for(let V of H)try{let Z=await Bun.file(V).text(),W=Y.scan(Z).exports.filter((G)=>G!=="default");if(W.length>0)J.push({file:V,names:W})}catch{}return J}function c(z,H){return new RegExp(`\\b${H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(z)}function a(z,H,Y){let J=new Map;for(let{file:G,names:$}of z)for(let O of $)if(!J.has(O))J.set(O,G);let V=(G)=>{let $=[];for(let[O,w]of J)if(c(G,O))$.push(w);return $},Z=new Set,W=Y.flatMap(V);while(W.length>0){let G=[];for(let $ of W){if(Z.has($))continue;Z.add($);for(let O of V(H.get($)??""))if(!Z.has(O))G.push(O)}W=G}return Z}async function Yq(z,H,Y){let{key:J,files:V}=await m(z);if(!J)return null;let Z=()=>[...new Set([...V,...V.flatMap((q)=>g(q))])],W=T(Z());if(V.length===0)return A(j,J,W,""),null;V.sort();let G=B({loader:"ts",target:"browser",define:k()}),$=new Map,O=[];for(let q of V)try{let Q=await Bun.file(q).text();$.set(q,Q);let U=G.scan(Q).exports.filter((X)=>X!=="default");if(U.length>0)O.push({file:q,names:U})}catch{$.set(q,"")}let w=H===void 0?new Set(V):a(O,$,Y?[H,...Y]:[H]);if(w.size===0)return null;let _=V.filter((q)=>w.has(q)),M=`${J}\x00${_.join("\x00")}`,v=u(j,M,W);if(v!==void 0)return v||null;let R=[],L=new Set,C=new Set;for(let q of _)try{let Q=$.get(q)??await Bun.file(q).text(),U=P.basename(q,".ts");for(let X of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])C.add(X[1]);try{for(let X of G.scan(Q).exports)if(X!=="default")L.add(X)}catch{}if(Q=D(Q),h(Q))Q=await b(Q,q,{projectRoot:process.cwd(),externalizeUserModules:!1}),Q=f(Q);Q=S(Q),Q=Q.replace(/^export\s+(default\s+)?/gm,""),Q=G.transformSync(Q),R.push(`// Composable: ${U}
|
|
3
3
|
${Q.trim()}`)}catch(Q){console.warn(`[stx] Failed to load composable ${q}:`,Q)}if(R.length===0||L.size===0)return A(j,M,W,""),null;let t=[...L].map((q)=>` try { if (!(${JSON.stringify(q)} in __c)) __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
|
|
4
4
|
`),N=JSON.stringify([...L]),E=R.join(`
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ss as x}from"./chunk-4arms0am.js";import{st as A}from"./chunk-w1asc0zd.js";import{It as T,Mt as q}from"./chunk-xk402w4a.js";import{Iw as y,aw as C}from"./chunk-e03m4har.js";import{Sw as P}from"./chunk-m8kem5ca.js";y();import H from"fs";import $ from"path";import{pathToFileURL as b}from"url";var R=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],O=new Set;function N(J,Y={}){let K=$.resolve(J,Y.dir??"server/api"),Q=[],Z=new Map;if(!H.existsSync(K))return Q;let B=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:K})).sort();for(let z of B){if(z.endsWith(".d.ts"))continue;let W=z.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),I=W.pop(),X=I.lastIndexOf("."),_=X>=0?I.slice(X+1):"get",F=_.toUpperCase();if(!R.includes(F)||_!==_.toLowerCase())throw Error(`Unsupported API method suffix in ${z}; use ${R.map((k)=>k.toLowerCase()).join(", ")}`);if(X>=0)I=I.slice(0,X);if(I!=="index")W.push(I);let G=new Set,j=W.map((k,S)=>{let E=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(k);if(E){if(G.has(E[2])||E[1]&&S!==W.length-1)throw Error(`Invalid API parameter in ${z}`);return G.add(E[2]),`:${E[2]}${E[1]?"*":""}`}if(!/^[\w-]+$/.test(k))throw Error(`Unsupported API path segment ${k} in ${z}`);return k}),U=`/api${j.length?`/${j.join("/")}`:""}`,L=`${F} ${U.replace(/:\w+/g,":param")}`;if(Z.has(L))throw Error(`Ambiguous API route ${F} ${U}: ${Z.get(L)} and ${z}`);Z.set(L,z);let M=$.join(K,z);O.add($.resolve(M)),O.add(H.realpathSync(M)),Q.push({pattern:U,method:F,filePath:M})}return Q.sort((z,V)=>{let W=z.pattern.split("/"),I=V.pattern.split("/"),X=(_)=>_?.endsWith("*")?0:_?.startsWith(":")?1:2;for(let _=0;_<Math.max(W.length,I.length);_++){let F=X(I[_])-X(W[_]);if(F)return F}return z.pattern.localeCompare(V.pattern)||z.method.localeCompare(V.method)})}async function w(J,Y){let K=A(J,"api-types.d.ts"),Q=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let B of Y){let z=`./${$.relative($.dirname(K),B.filePath).replace(/\\/g,"/")}`,{params:V}=C(B.pattern);Q.push(` ${JSON.stringify(`${B.method} ${B.pattern}`)}: { params: { ${V.map((W)=>`${JSON.stringify(W)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(z)}).default>> }`)}Q.push(" }","}","export {}","");let Z=Q.join(`
|
|
3
3
|
`);if(!await Bun.file(K).exists()||await Bun.file(K).text()!==Z)await Bun.write(K,Z);return K}async function p(J,Y,K={}){let Q=N(J,K);await w(J,Q);let Z=[];for(let B of Q){let z=await Bun.build({entrypoints:[B.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!z.success)throw Error(`API build failed for ${B.filePath}: ${z.logs.join(`
|
|
4
|
-
`)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-
|
|
4
|
+
`)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-v8hhk3cd.js"),V=q((await z(J)).runtimeConfig);return await T(V,()=>D(B,async(W)=>{let I=await Bun.build({entrypoints:[W.filePath],target:"bun",format:"esm",splitting:!1});if(!I.success)throw Error(I.logs.join(`
|
|
5
5
|
`));let X=I.outputs.find((_)=>_.kind==="entry-point");if(!X||I.outputs.length!==1)throw Error(`Unsupported API bundle output: ${W.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await X.text()).toString("base64")}`)).default})(Z))}catch(B){return console.error("[stx] API discovery failed:",B),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function u(J,Y,K){if(x(J))return!0;let Q=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(Q.test($.basename(J)))return!0;try{if(Q.test($.basename(H.realpathSync(J))))return!0}catch{}if(O.has($.resolve(J)))return!0;if(!K)return!1;let Z=$.resolve(Y,typeof K==="object"?K.dir??"server/api":"server/api"),B=(V)=>{try{return H.realpathSync(V)}catch{return $.resolve(V)}},z=B(J);return[Z,$.resolve(Y,"server"),$.resolve(Y,".output/server")].some((V)=>{let W=B(V);return z===W||z.startsWith(`${W}${$.sep}`)})}
|
|
6
6
|
export{N as nl,w as ol,p as pl,D as ql,l as rl,s as sl,u as tl};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{jg as e,lg as kF,mg as UF,ng as wF,vg as EF}from"./chunk-
|
|
2
|
+
import{jg as e,lg as kF,mg as UF,ng as wF,vg as EF}from"./chunk-vs5zebkb.js";import{yg as BF}from"./chunk-0knxnyq6.js";import{oj as l,pj as d}from"./chunk-rnzwf3z2.js";import{Dk as HF,Ek as IF,Fk as KF}from"./chunk-frp9fc7j.js";import{nl as YF,pl as ZF}from"./chunk-q2jvq038.js";import{Hp as VF,Lp as r,Qp as o,Xm as s,jo as zF,kp as $F,om as p,qm as i,vr as t,xr as M,zp as GF}from"./chunk-0vgexs1k.js";import{xs as XF}from"./chunk-4arms0am.js";import{nt as qF}from"./chunk-243n8zxy.js";import{Ht as WF}from"./chunk-w54m70rf.js";import{Mt as QF}from"./chunk-xk402w4a.js";import{Fw as h,Iw as _F}from"./chunk-e03m4har.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>o(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...t,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=e(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
|
|
3
3
|
[stx build] Done in ${D}ms \u2014 ${R.length} pages compiled`),{pageCount:R.length,assets:S,outputDir:X,duration:D}}
|
|
4
4
|
export{u as Sf,c as Tf,a as Uf,bF as Vf,FF as Wf,qJ as Xf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Lg as a,Mg as b,Ng as c,Og as d,Pg as e,Qg as f}from"./chunk-
|
|
2
|
+
import{Lg as a,Mg as b,Ng as c,Og as d,Pg as e,Qg as f}from"./chunk-k8gb8b8h.js";import"./chunk-0vgexs1k.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-243n8zxy.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-w54m70rf.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{c as renderSlot,d as processSlots,a as parseSlots,b as parseSlotElement,e as extractSlotContent,f as applySlots};
|