@stacksjs/stx 0.2.246 → 0.2.248
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-qpmas4vz.js → chunk-7e3dks04.js} +4 -4
- package/dist/{chunk-aqcca4mj.js → chunk-7v2v2z4f.js} +1 -1
- package/dist/{chunk-j5h418q6.js → chunk-8qax49p0.js} +1 -1
- package/dist/{chunk-wekcdsz0.js → chunk-8vz7gc9b.js} +1 -1
- package/dist/{chunk-hrf61g6t.js → chunk-axvmngpm.js} +1 -1
- package/dist/{chunk-ahzq2gdh.js → chunk-ccma7ay5.js} +1 -1
- package/dist/{chunk-qbj89n8d.js → chunk-pzxytzqw.js} +1 -1
- package/dist/{chunk-10s4pe0a.js → chunk-s2hzefvz.js} +45 -45
- package/dist/{chunk-2z5077ce.js → chunk-stepbjtr.js} +1 -1
- package/dist/{chunk-zp1qrw61.js → chunk-xp5935a3.js} +1 -1
- package/dist/cli.js +3 -3
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Rf as p}from"./chunk-vhnnryps.js";import{Hg as a,Jg as JF,Kg as ZF,Lg as qF}from"./chunk-
|
|
2
|
+
import{Rf as p}from"./chunk-vhnnryps.js";import{Hg as a,Jg as JF,Kg as ZF,Lg as qF}from"./chunk-8qax49p0.js";import{sj as C,tj as D}from"./chunk-7bemc914.js";import{Ek as QF,Fk as XF,Gk as YF}from"./chunk-58f0mthg.js";import{$o as o,Bq as FF,Fq as c,Nm as u,as as n,cs as N,em as l,gm as d,gq as e,uq as t}from"./chunk-h7aynn48.js";import{_s as r}from"./chunk-v0y3drpw.js";import{Du as S,Fu as WF}from"./chunk-5ec3m8hk.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=o(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=FF(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=e(F.html,W);if(k.htmlAttrs)F.html=t(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
|
|
3
3
|
[stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
|
|
4
4
|
export{g as Hf,f as If,m as Jf,UF as Kf,i as Lf,lF as Mf};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ag as t,Bg as e,Dg as b,Mg as JJ}from"./chunk-j5h418q6.js";import{Qm as u,Rm as l,bp as o,im as y,jm as P,sm as x,tp as g,zm as v}from"./chunk-h7aynn48.js";import{Bu as s,Fu as OJ,_t as a}from"./chunk-5ec3m8hk.js";import{Pu as R}from"./chunk-p3kn55v4.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,$)=>{let G=Q[Z];if(G===void 0)Q[Z]=$;else if(Array.isArray(G))G.push($);else Q[Z]=[G,$]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[$,G]of Z.entries())if(typeof G==="string")X($,G);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,$]of new URLSearchParams(await J.text()).entries())X(Z,$);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let $=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if($&&typeof $==="object"){let G=$,W=QJ(G.cookies),I=G.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:N,...U}=G;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function m(J,K=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let Z of K)X.append("Set-Cookie",Z);for(let[Z,$]of Object.entries(Q??{}))if(Z.toLowerCase()!=="location")X.set(Z,$);return new Response(null,{status:303,headers:X})}async function wJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:$}=await c(J,K),G=u(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:$,status:G,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-qh4bhceg.js"),_=I(X),N=J.streamTemplates;if(N&&Object.keys(N).length>0){let{processDirectives:U}=await import("./chunk-1vd6bg7v.js"),{defaultConfig:z}=await import("./chunk-3mm46ez1.js"),O=X.streamBoundaries||{},w={...z,autoShell:!1},D=Object.keys(N).map((V)=>({id:V,render:async()=>{let F=typeof O[V]==="function"?await O[V]():void 0;return U(N[V],{...X,$boundary:F},J.sourceFile,w,new Set)}})),E=new Set(D.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...D]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:$,status:G,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let $ of J.serverScriptContent)try{await g($,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[$,G]of Object.entries(J.placeholders))if(G.expression)try{let W=v(G.expression,Q);if(G.type==="raw")Z.set($,W!==void 0&&W!==null?String(W):"");else Z.set($,W!==void 0&&W!==null?x(String(W)):"")}catch{Z.set($,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function AJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,$]of Object.entries(J.placeholders))if($.expression)try{let G=v($.expression,Q);if($.type==="raw")X.set(Z,G!==void 0&&G!==null?String(G):"");else X.set(Z,G!==void 0&&G!==null?x(String(G)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function jJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),$=X.trim().toLowerCase();if(!$)continue;let G=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))G=_}K.set($,G)}return K}function YJ(J){if(!J)return null;let K=jJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=YJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let $=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return $();try{let G=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if(G.length>=Z.length)return $();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String(G.length)),new Response(G,{status:K.status,statusText:K.statusText,headers:W})}catch{return $()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".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 mJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,$=new Map,G=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),G.set(U.pattern,s(O.html)),W.set(U.pattern,o(O.html));let w=B.join(K,U.fragmentPath);if(await Bun.file(w).exists())$.set(U.pattern,await Bun.file(w).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let N=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let j=await J.onRequest(U);if(j)return j}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let j=B.resolve(K,"public"),Y;try{Y=decodeURIComponent(O)}catch{Y=O}if(!Y.includes("\x00")){let L=B.resolve(j,`.${Y}`);if(L===j||L.startsWith(`${j}${B.sep}`))try{if(r.existsSync(L)&&r.statSync(L).isFile()){let M=B.extname(L).toLowerCase(),S=_J[M]||"application/octet-stream",H=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(L),{headers:{"Content-Type":S,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let w=e(U),D=null,E={};if(D=I.get(O)||null,!D)for(let{regex:j,route:Y,paramNames:L}of _){let A=O.match(j);if(A){D=Y,L.forEach((M,S)=>{E[M]=A[S+1]});break}}if(!D){let j=I.get("/404")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(w){let j=$.get(D.pattern);if(j){let Y=G.get(D.pattern);return new Response(j,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(D.pattern)?{"X-STX-Runtime":W.get(D.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},...b(),"Cache-Control":t}})}}let V=f(U.method),F=Z.get(D.pattern);if(!F){let j=I.get("/500")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!F.hasServerScripts&&Object.keys(F.placeholders).length===0)return new Response(F.html,{status:F.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:j,boundaries:Y,redirect:L,cookies:A,status:M,headers:S}=await d(F,{params:E,request:U,method:U.method});if(L)return m(L,A,S);if(Y&&Y.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-qh4bhceg.js");return k(T(j,Y,{timeoutMs:30000}),{status:M??F.status??200,headers:{"Cache-Control":"no-cache",...S}})}let H=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of A??[])H.append("Set-Cookie",T);for(let[T,k]of Object.entries(S??{}))H.set(T,k);return new Response(j,{status:M??F.status??200,headers:H})}catch(j){return console.error(`[stx] Hydration error for ${O}:`,j),new Response(F.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>N.stop()}}
|
|
2
|
+
import{Ag as t,Bg as e,Dg as b,Mg as JJ}from"./chunk-8qax49p0.js";import{Qm as u,Rm as l,bp as o,im as y,jm as P,sm as x,tp as g,zm as v}from"./chunk-h7aynn48.js";import{Bu as s,Fu as OJ,_t as a}from"./chunk-5ec3m8hk.js";import{Pu as R}from"./chunk-p3kn55v4.js";import r from"fs";import B from"path";var{serve:IJ}=globalThis.Bun;function q(J,K,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(K)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function KJ(J){let K=J.headers.get("content-type")||"",Q={},X=(Z,$)=>{let G=Q[Z];if(G===void 0)Q[Z]=$;else if(Array.isArray(G))G.push($);else Q[Z]=[G,$]};if(K.includes("multipart/form-data")){let Z=await J.formData();for(let[$,G]of Z.entries())if(typeof G==="string")X($,G);return Q}if(K.includes("application/x-www-form-urlencoded")){for(let[Z,$]of new URLSearchParams(await J.text()).entries())X(Z,$);return Q}return Q}function f(J){if(!J)return!1;let K=J.toUpperCase();return K!=="GET"&&K!=="HEAD"}async function h(J,K={}){let Q=K.request,X=K.method??Q?.method;if(!Q||!f(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let Z={};try{Z=await KJ(Q)}catch{}let $=await J.action({request:Q,form:Z,params:K.params??{},query:J.query??{},cookies:K.cookies??{}});if($&&typeof $==="object"){let G=$,W=QJ(G.cookies),I=G.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:_,redirect:N,...U}=G;if(Object.assign(J,U),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function QJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let K=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){K.push(q(Q,X));continue}if(X&&typeof X==="object"){let Z=X;if(typeof Z.value!=="string")continue;K.push(q(Q,Z.value,Z))}}return K}function m(J,K=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let Z of K)X.append("Set-Cookie",Z);for(let[Z,$]of Object.entries(Q??{}))if(Z.toLowerCase()!=="location")X.set(Z,$);return new Response(null,{status:303,headers:X})}async function wJ(J,K={}){return(await c(J,K)).html}async function d(J,K={}){let{html:Q,context:X,redirect:Z,cookies:$}=await c(J,K),G=u(X),W=l(X);if(Z)return{html:Q,redirect:Z,cookies:$,status:G,headers:W};let{extractStreamBoundaries:I}=await import("./chunk-qh4bhceg.js"),_=I(X),N=J.streamTemplates;if(N&&Object.keys(N).length>0){let{processDirectives:U}=await import("./chunk-1vd6bg7v.js"),{defaultConfig:z}=await import("./chunk-3mm46ez1.js"),O=X.streamBoundaries||{},w={...z,autoShell:!1},D=Object.keys(N).map((V)=>({id:V,render:async()=>{let F=typeof O[V]==="function"?await O[V]():void 0;return U(N[V],{...X,$boundary:F},J.sourceFile,w,new Set)}})),E=new Set(D.map((V)=>V.id));_=[...(_||[]).filter((V)=>!E.has(V.id)),...D]}return{html:Q,boundaries:_&&_.length>0?_:void 0,cookies:$,status:G,headers:W}}async function c(J,K){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};if(!J.hasServerScripts&&!P(J.html))return{html:J.html,context:Q};for(let $ of J.serverScriptContent)try{await g($,Q,J.sourceFile)}catch(G){console.warn(`[stx] Server script error in ${J.sourceFile}:`,G)}let X=await h(Q,{request:K.request,method:K.method,params:K.params??{},cookies:K.cookies??{}});if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!P(J.html))return{html:J.html,context:Q,cookies:X.cookies};let Z=new Map;for(let[$,G]of Object.entries(J.placeholders))if(G.expression)try{let W=v(G.expression,Q);if(G.type==="raw")Z.set($,W!==void 0&&W!==null?String(W):"");else Z.set($,W!==void 0&&W!==null?x(String(W)):"")}catch{Z.set($,"")}return{html:y(J.html,Z),context:Q,cookies:X.cookies}}async function AJ(J,K={}){if(!J.hasServerScripts&&!P(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...K};for(let Z of J.serverScriptContent)try{await g(Z,Q,J.sourceFile)}catch($){console.warn(`[stx] Server script error in ${J.sourceFile}:`,$)}if(!P(J.fragment))return J.fragment;let X=new Map;for(let[Z,$]of Object.entries(J.placeholders))if($.expression)try{let G=v($.expression,Q);if($.type==="raw")X.set(Z,G!==void 0&&G!==null?String(G):"");else X.set(Z,G!==void 0&&G!==null?x(String(G)):"")}catch{X.set(Z,"")}return y(J.fragment,X)}OJ();import C from"zlib";import{promisify as n}from"util";var XJ=n(C.brotliCompress),ZJ=n(C.gzip),$J=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],GJ=["text/event-stream","multipart/x-mixed-replace"],UJ=1024;function WJ(J){if(!J)return!1;let K=J.toLowerCase();if(GJ.some((Q)=>K.startsWith(Q)))return!1;return $J.some((Q)=>K.startsWith(Q))}function jJ(J){let K=new Map;for(let Q of J.split(",")){let[X,...Z]=Q.trim().split(";"),$=X.trim().toLowerCase();if(!$)continue;let G=1;for(let W of Z){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(W);if(!I)continue;let _=Number.parseFloat(I[1]);if(Number.isFinite(_))G=_}K.set($,G)}return K}function YJ(J){if(!J)return null;let K=jJ(J),Q=K.get("*"),X=(Z)=>K.get(Z)??Q??0;if(X("br")>0)return"br";if(X("gzip")>0)return"gzip";return null}async function i(J,K,Q={}){if(K.headers.get("content-encoding"))return K;if(K.status===204||K.status===304||!K.body)return K;if(!WJ(K.headers.get("content-type")))return K;let X=YJ(J.headers.get("accept-encoding"));if(!X)return K;let Z;try{Z=new Uint8Array(await K.arrayBuffer())}catch{return K}let $=()=>new Response(Z,{status:K.status,statusText:K.statusText,headers:p(K.headers)});if(Z.length<(Q.threshold??UJ))return $();try{let G=X==="br"?await XJ(Z,{params:{[C.constants.BROTLI_PARAM_QUALITY]:Q.quality??5,[C.constants.BROTLI_PARAM_SIZE_HINT]:Z.length}}):await ZJ(Z);if(G.length>=Z.length)return $();let W=p(K.headers);return W.set("Content-Encoding",X),W.set("Content-Length",String(G.length)),new Response(G,{status:K.status,statusText:K.statusText,headers:W})}catch{return $()}}function p(J){let K=new Headers(J),Q=K.get("Vary");if(!Q)return K.set("Vary","Accept-Encoding"),K;if(!Q.split(",").some((Z)=>Z.trim().toLowerCase()==="accept-encoding"))K.set("Vary",`${Q}, Accept-Encoding`);return K}var _J={".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 mJ(J={}){let K=B.resolve(J.outputDir||".output"),Q=J.port||3000,X=JJ(K);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let Z=new Map,$=new Map,G=new Map,W=new Map;for(let U of X.routes)try{let z=B.join(K,U.compiledPath),O=JSON.parse(await Bun.file(z).text());Z.set(U.pattern,O),G.set(U.pattern,s(O.html)),W.set(U.pattern,o(O.html));let w=B.join(K,U.fragmentPath);if(await Bun.file(w).exists())$.set(U.pattern,await Bun.file(w).text())}catch(z){console.warn(`[stx] Failed to load route ${U.pattern}:`,z)}let I=new Map,_=[];for(let U of X.routes)if(U.hasParams){let{regex:z,params:O}=a(U.pattern);_.push({regex:z,route:U,paramNames:O})}else I.set(U.pattern,U);let N=IJ({port:Q,async fetch(U){return i(U,await(async()=>{let O=new URL(U.url).pathname;if(J.onRequest){let j=await J.onRequest(U);if(j)return j}if(J.apiRoutes?.[O])return J.apiRoutes[O](U);if((U.method==="GET"||U.method==="HEAD")&&O!=="/"){let j=B.resolve(K,"public"),Y;try{Y=decodeURIComponent(O)}catch{Y=O}if(!Y.includes("\x00")){let L=B.resolve(j,`.${Y}`);if(L===j||L.startsWith(`${j}${B.sep}`))try{if(r.existsSync(L)&&r.statSync(L).isFile()){let M=B.extname(L).toLowerCase(),S=_J[M]||"application/octet-stream",H=O.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(O);return new Response(Bun.file(L),{headers:{"Content-Type":S,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let w=e(U),D=null,E={};if(D=I.get(O)||null,!D)for(let{regex:j,route:Y,paramNames:L}of _){let A=O.match(j);if(A){D=Y,L.forEach((M,S)=>{E[M]=A[S+1]});break}}if(!D){let j=I.get("/404")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(w){let j=$.get(D.pattern);if(j){let Y=G.get(D.pattern);return new Response(j,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...W.has(D.pattern)?{"X-STX-Runtime":W.get(D.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},...b(),"Cache-Control":t}})}}let V=f(U.method),F=Z.get(D.pattern);if(!F){let j=I.get("/500")||null;if(j){let Y=Z.get(j.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!V&&!F.hasServerScripts&&Object.keys(F.placeholders).length===0)return new Response(F.html,{status:F.status??200,headers:{"Content-Type":"text/html",...b(),"Cache-Control":"public, max-age=60"}});try{let{html:j,boundaries:Y,redirect:L,cookies:A,status:M,headers:S}=await d(F,{params:E,request:U,method:U.method});if(L)return m(L,A,S);if(Y&&Y.length>0){let{renderStreamingPage:T,streamToResponse:k}=await import("./chunk-qh4bhceg.js");return k(T(j,Y,{timeoutMs:30000}),{status:M??F.status??200,headers:{"Cache-Control":"no-cache",...S}})}let H=new Headers({"Content-Type":"text/html",...b(),"Cache-Control":"no-cache"});for(let T of A??[])H.append("Set-Cookie",T);for(let[T,k]of Object.entries(S??{}))H.set(T,k);return new Response(j,{status:M??F.status??200,headers:H})}catch(j){return console.error(`[stx] Hydration error for ${O}:`,j),new Response(F.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${Q}`),console.log(`[stx] Serving ${X.routes.length} routes (${Z.size} pre-loaded)`),{port:Q,stop:()=>N.stop()}}
|
|
3
3
|
export{WJ as lg,YJ as mg,i as ng,q as og,KJ as pg,f as qg,h as rg,m as sg,wJ as tg,d as ug,AJ as vg,mJ as wg};
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{Ha as a,Ve as F,Xa as r,Xe as v,Ye as P,o as m,oa as l,pb as n,qb as p,re as s,sb as i,se as t,xb as e}from"./chunk-
|
|
3
|
+
import{Ha as a,Ve as F,Xa as r,Xe as v,Ye as P,o as m,oa as l,pb as n,qb as p,re as s,sb as i,se as t,xb as e}from"./chunk-7e3dks04.js";import"./chunk-ym3r8ktq.js";import"./chunk-dgg8a6c8.js";import"./chunk-r1p9hha3.js";import"./chunk-pbsfbgx7.js";import"./chunk-z1yd16w1.js";import"./chunk-stepbjtr.js";import"./chunk-vhnnryps.js";import"./chunk-0j9hrzjj.js";import"./chunk-91e3916g.js";import"./chunk-8vz7gc9b.js";import"./chunk-xp5935a3.js";import"./chunk-8qax49p0.js";import"./chunk-temdqamx.js";import"./chunk-f5v2qf95.js";import"./chunk-6twytnbh.js";import"./chunk-49kk0s96.js";import"./chunk-w3ycm4na.js";import"./chunk-w8cdwh41.js";import"./chunk-gpmpcrww.js";import"./chunk-74cv4ta1.js";import"./chunk-wcm80anz.js";import"./chunk-y7m2dpd3.js";import"./chunk-9y0g8kzt.js";import"./chunk-t6nseeb9.js";import"./chunk-xttsqmkm.js";import"./chunk-54st8g2j.js";import"./chunk-6nxf4pb0.js";import"./chunk-qhcwqxsr.js";import"./chunk-9n0gvfrg.js";import"./chunk-7q9mwh4v.js";import"./chunk-refwkt87.js";import"./chunk-1e0kazb9.js";import"./chunk-7bemc914.js";import"./chunk-w95sp0k9.js";import"./chunk-4fybwpba.js";import"./chunk-bmfnxh4y.js";import"./chunk-gh1vsaa0.js";import"./chunk-58f0mthg.js";import{al as u,bl as c}from"./chunk-e2nzn35y.js";import"./chunk-d8y85xdy.js";import{Bm as A}from"./chunk-h7aynn48.js";import{qs as f}from"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-v0y3drpw.js";import"./chunk-0pdrnxg2.js";import"./chunk-j26v67km.js";import"./chunk-3gjrq8m7.js";import"./chunk-mh4hd2wt.js";import"./chunk-fa3pamx8.js";import"./chunk-5ec3m8hk.js";import"./chunk-snh1ahqp.js";import{Pu as B}from"./chunk-p3kn55v4.js";import{spawn as o}from"child_process";import L from"fs";import zb from"os";import $ from"path";import w from"process";import{CLI as wb}from"@stacksjs/clapp";var N="0.2.248";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",E=new wb("stx");function h(J){let Z=typeof J==="string"?Number.parseInt(J,10):J;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function d(J){try{if(!L.existsSync(J)){let K=$.dirname(J),x=$.basename(J);if(L.existsSync(K)){let z=L.readdirSync(K).filter((j)=>j.toLowerCase().includes(x.toLowerCase().substring(0,3))||j.endsWith(".stx")||j.endsWith(".md")),k=z.length>0?`File not found. Similar files in ${K}: ${z.slice(0,3).join(", ")}`:`File not found. Directory ${K} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${J}`,suggestion:k}}return{isValid:!1,error:`File does not exist: ${J}`,suggestion:"Check the file path and try again"}}if(L.statSync(J).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${J}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${J}`,suggestion:"Check file permissions and path"}}}function y(J){let Z=typeof J==="string"?Number.parseInt(J,10):J;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var V=(J)=>J.includes("*")||J.includes("?")||J.includes("{")||J.includes("["),jb=(J)=>J.endsWith(".stx")||J.endsWith(".md");function S(J,Z=1){if(console.error(`\u274C ${J.error}`),J.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${J.suggestion}`);w.exit(Z)}function kb(J){if(!J)return;let Z;try{Z=JSON.parse(J)}catch(K){console.error(`\u274C --info-plist is not valid JSON: ${K.message}`),w.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),w.exit(1);for(let[K,x]of Object.entries(Z))if(typeof x!=="string"&&typeof x!=="number"&&typeof x!=="boolean")console.error(`\u274C --info-plist value for "${K}" must be a string, number or boolean`),w.exit(1);return Z}async function Hb(J,Z){try{let K=["test"],x=[];if(J&&J.length>0)for(let W of J)if(V(W))try{let H=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(H.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(x.push(...H),Z.verbose)console.log(`Found ${H.length} file(s) matching pattern: ${W}`)}catch(H){return console.error(`Error expanding glob pattern ${W}:`,H),!1}else x.push(W);if(x.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(K.push(...x),Z.filter)K.push("--pattern",Z.filter);if(Z.timeout)K.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=$.join(zb.tmpdir(),`stx-test-report-${Date.now()}.xml`);K.push("--reporter",Z.reporter),K.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)K.push("--coverage");if(Z.watch)K.push("--watch");K.push("--preload",$.join(__dirname,"../../../test-utils/happy-dom.ts"));let b={...w.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},z="bun";if(Z.verbose)console.log(`Running: ${z} ${K.join(" ")}`);let k=performance.now(),j=o(z,K,{stdio:"inherit",shell:!1,env:b});return new Promise((W)=>{j.on("close",(H)=>{let Y=((performance.now()-k)/1000).toFixed(2);if(H===0)W(!0);else W(!1)}),w.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),j.kill("SIGINT"),w.exit(1)})})}catch(K){return console.error("Error running tests:",K instanceof Error?K.message:String(K)),!1}}var Qb=w.argv.length>=3&&(jb(w.argv[2])&&L.existsSync(w.argv[2])||V(w.argv[2]));if(Qb){let J=w.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let K=3;K<w.argv.length;K++){let x=w.argv[K];if(x==="--port"&&K+1<w.argv.length){let b=h(w.argv[++K]);if(!b.isValid)S(b);Z.port=Number.parseInt(w.argv[K],10)}else if(x==="--no-watch")Z.watch=!1;else if(x==="--highlight-theme"&&K+1<w.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=w.argv[++K]}else if(x==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(x==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(x==="--no-cache")Z.cache=!1;else if(x==="--native")Z.native=!0}if(V(J))try{let K=await Array.fromAsync(new Bun.Glob(J).scan({onlyFiles:!0,absolute:!0})),x=J.endsWith(".stx")?K.filter((j)=>j.endsWith(".stx")):J.endsWith(".md")?K.filter((j)=>j.endsWith(".md")):K.filter((j)=>j.endsWith(".stx")||j.endsWith(".md")),b=J.split("*")[0].replace(/\/$/,"")||".",z=$.resolve(b);try{let j=new Bun.Glob("**/*.stx"),H=(await Array.fromAsync(j.scan({cwd:z,onlyFiles:!0,absolute:!0}))).filter((U)=>/\[.+\]/.test($.basename(U)));for(let U of H)if(!x.includes(U))x.push(U)}catch{}if(x.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${J}`),w.exit(1);if(!await v(x,Z))w.exit(1)}catch(K){console.error("Failed to process files:",K),w.exit(1)}else F(J,Z).catch((K)=>{console.error("Failed to start dev server:",K),w.exit(1)})}else{let J=function(x,b){let z=[];for(let k=0;k<=b.length;k++)z[k]=[k];for(let k=0;k<=x.length;k++)z[0][k]=k;for(let k=1;k<=b.length;k++)for(let j=1;j<=x.length;j++)if(b.charAt(k-1)===x.charAt(j-1))z[k][j]=z[k-1][j-1];else z[k][j]=Math.min(z[k-1][j-1]+1,z[k][j-1]+1,z[k-1][j]+1);return z[b.length][x.length]};E.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(x)=>{try{if(await r(x))console.log("Documentation generated successfully."),w.exit(0);else console.error("Documentation generation failed."),w.exit(1)}catch(b){console.error("Error generating documentation:",b),w.exit(1)}}),E.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(x,b)=>{try{let{fetchCollections:z,generatePackage:k}=await import("./chunk-absrtcb0.js");if(x==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let j=await z(),W=Object.entries(j).sort((H,U)=>U[1].total-H[1].total);console.log(`Available collections:
|
|
@@ -69,7 +69,7 @@ Total: ${H} issues in ${W} files`),b.output){let U=`
|
|
|
69
69
|
File not found: ${x}`),w.exit(1);if(!x.endsWith(".stx"))console.error(`
|
|
70
70
|
File must have .stx extension: ${x}`),w.exit(1)}let k=$.resolve(b.pages),j=$.resolve(b.out);if(!x&&!L.existsSync(k))console.error(`
|
|
71
71
|
Pages directory not found: ${k}`),console.log(`
|
|
72
|
-
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),w.exit(1);let{buildApp:W}=await import("./chunk-
|
|
72
|
+
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),w.exit(1);let{buildApp:W}=await import("./chunk-ccma7ay5.js");c();let H=await W({root:x?$.dirname(x):void 0,debug:b.verbose,ssg:{pagesDir:b.pages,outputDir:b.out,domain:b.domain,baseUrl:b.base,sitemap:b.sitemap,rss:b.rss,minify:b.minify,cache:b.cache!==!1,cleanOutput:b.clean,concurrency:Number.parseInt(b.concurrency,10)||10,publicDir:b.public,trailingSlash:b.trailingSlash,generate404:!0,hooks:b.verbose?{onPageStart:(Y)=>console.log(` Generating: ${Y}`),onPageEnd:(Y,Q)=>console.log(` Generated: ${Y} (${Q.length} bytes)`),onError:(Y,Q)=>console.error(` Error in ${Q}: ${Y.message}`)}:void 0},ssr:{outputDir:b.out==="dist"?".output":b.out,debug:b.verbose}}),U=((performance.now()-z)/1000).toFixed(2);if(H.mode==="ssr"&&H.ssr)console.log(`
|
|
73
73
|
Build complete! (SSR)
|
|
74
74
|
`),console.log(` Pages compiled: ${H.ssr.pageCount}`),console.log(` Output: ${H.ssr.outputDir}`),console.log(` Duration: ${U}s
|
|
75
75
|
`);else if(H.ssg){if(console.log(`
|
|
@@ -84,7 +84,7 @@ Total: ${H} issues in ${W} files`),b.output){let U=`
|
|
|
84
84
|
Build completed with ${H.ssg.failedCount} error(s). Fix the issues above and try again.
|
|
85
85
|
`),w.exit(1);console.log(" To preview locally:"),console.log(` cd ${b.out||"dist"} && npx serve
|
|
86
86
|
`)}}catch(z){console.error(`
|
|
87
|
-
Build failed:`,z instanceof Error?z.message:String(z)),w.exit(1)}}),E.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(x)=>{try{let b=$.resolve(x.output);if(!L.existsSync($.join(b,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),w.exit(1);let{startProductionServer:z}=await import("./chunk-
|
|
87
|
+
Build failed:`,z instanceof Error?z.message:String(z)),w.exit(1)}}),E.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(x)=>{try{let b=$.resolve(x.output);if(!L.existsSync($.join(b,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),w.exit(1);let{startProductionServer:z}=await import("./chunk-axvmngpm.js");await z({outputDir:b,port:Number.parseInt(x.port,10)||3000})}catch(b){console.error(`
|
|
88
88
|
Failed to start production server:`,b instanceof Error?b.message:String(b)),w.exit(1)}}),E.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(x,b)=>{try{let{deploy:z,initNetlify:k,DeployError:j}=await import("./chunk-3p4txpk9.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${N}\x1B[0m`),b.init){console.log(`
|
|
89
89
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
90
90
|
`);let H=await k({directory:x||w.cwd(),siteId:b.siteId});if(console.log(`\u2713 Created ${H.configPath}`),H.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.248",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.19",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.14",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.248",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.248",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.248",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.248",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.11",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|