@remotex-labs/xbuild 2.2.0 → 2.2.1

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/bash.js CHANGED
@@ -21,7 +21,7 @@ __ _| |_/ /_ _ _| | __| |
21
21
  /_/\\_\\____/ \\__,_|_|_|\\__,_|
22
22
  `;function Dt(){return`
23
23
  \r${ot.burntOrange(pi)}
24
- \rVersion: ${ot.brightPink("2.2.0")}
24
+ \rVersion: ${ot.brightPink("2.2.1")}
25
25
  \r`}function O(){return ot.lightCoral("[xBuild]")}import{readdir as ui,stat as di,readFile as mi}from"fs/promises";import{xterm as Pe}from"@remotex-labs/xansi/xterm.component";var Ee=class{constructor(e,t){this.config=e;this.rootDir=C(t),this.config.port||=0,this.config.host||="localhost"}server;rootDir;framework=u(S);async start(){if(this.config.https)return await this.startHttpsServer();await this.startHttpServer()}async stop(){if(!this.server){console.log(O(),Pe.gray("No server is currently running."));return}await new Promise((e,t)=>{this.server.close(i=>{i?t(i):e()})}),console.log(O(),Pe.dim("Server stopped.")),this.server=void 0}async restart(){console.log(O(),Pe.burntOrange("Restarting server...")),await this.stop(),await this.start()}setActualPort(){if(this.config.port===0){let e=this.server.address();e&&typeof e=="object"&&e.port&&(this.config.port=e.port)}}startHttpServer(){return new Promise(e=>{this.server=Ht.createServer((t,i)=>{this.handleRequest(t,i,()=>this.defaultResponse(t,i))}),this.server.listen(this.config.port,this.config.host,()=>{this.setActualPort(),this.config.onStart?.({host:this.config.host,port:this.config.port,url:`http://${this.config.host}:${this.config.port}`}),e()})})}startHttpsServer(){return new Promise(e=>{let t={key:Lt(this.config.key??x(this.framework.distPath,"..","certs","server.key")),cert:Lt(this.config.cert??x(this.framework.distPath,"..","certs","server.crt"))};this.server=_t.createServer(t,(i,o)=>{this.handleRequest(i,o,()=>this.defaultResponse(i,o))}),this.server.listen(this.config.port,this.config.host,()=>{this.setActualPort(),this.config.onStart?.({host:this.config.host,port:this.config.port,url:`https://${this.config.host}:${this.config.port}`}),e()})})}handleRequest(e,t,i){try{this.config.verbose&&console.log(`${O()} Request ${Pe.lightCoral(e.url?.toString()??"")}`),this.config.onRequest?this.config.onRequest(e,t,i):i()}catch(o){this.sendError(t,o)}}getContentType(e){return{html:"text/html",css:"text/css",js:"application/javascript",cjs:"application/javascript",mjs:"application/javascript",ts:"text/plain",map:"application/json",json:"application/json",png:"image/png",jpg:"image/jpeg",gif:"image/gif",txt:"text/plain"}[e]||"application/octet-stream"}async defaultResponse(e,t){let i=e.url==="/"?"":e.url?.replace(/^\/+/,"")||"",o=x(this.rootDir,i);if(!o.startsWith(this.rootDir)){t.statusCode=403,t.end();return}try{let n=await di(o);n.isDirectory()?await this.handleDirectory(o,i,t):n.isFile()&&await this.handleFile(o,t)}catch(n){let s=n.message;s.includes("favicon")||console.log(O(),s),this.sendNotFound(t)}}async handleDirectory(e,t,i){let n=(await ui(e)).map(l=>{let p=x(t,l),f=jt(l).slice(1)||"folder";return f==="folder"?`
26
26
  <a href="/${p}" class="folder-row">
27
27
  <div class="icon"><i class="fa-solid fa-folder"></i></div>
@@ -60,12 +60,12 @@ ${t}
60
60
  ${e}
61
61
 
62
62
  ${A}Enhanced Stack Trace:
63
- ${t}`)}function bo(r,e,t){let i=xr(r),o=t(`TS${r.code}`),n=pe(r.message);return`${A}${e} ${i} ${we(ie)} ${o} ${we(vr)} ${n}`}function br(r,e,t=L){let i=xr(r),o=t(`TS${r.code}`),n=pe(r.message);console.log(`${A}${e} ${i}`,we(ie),`${o} ${we(vr)} ${n}`)}function So(r,e,t){let i=e.diagnostics.length;if(i===0)return r.push(`${A}${j(t)} ${j("TypesError")}: ${pe(e.message||"Type checking warning")}`),1;r.push("");for(let o of e.diagnostics)r.push(bo(o,j(t),yt.deepOrange));return i}function Eo(r,e,t,i){let o=`${i(e.name)}: ${e.message.slice(e.name.length+1)}`;r.push(`
63
+ ${t}`)}function bo(r,e,t){let i=xr(r),o=t(`TS${r.code}`),n=pe(r.message);return`${A}${e} ${i} ${we(ie)} ${o} ${we(vr)} ${n}`}function br(r,e,t=L){let i=xr(r),o=t(`TS${r.code}`),n=pe(r.message);console.log(`${A}${e} ${i}`,we(ie),`${o} ${we(vr)} ${n}`)}function So(r,e,t){let i=e.diagnostics.length;if(i===0)return r.push(`${A}${j(t)} ${j("TypesError")}: ${pe(e.message||"Type checking warning")}`),1;r.push("");for(let o of e.diagnostics)r.push(bo(o,j(t),yt.deepOrange));return i}function Eo(r,e,t,i){let o=`${i(e.name)}: ${e.message}`;r.push(`
64
64
  ${A}${i(t)} ${o}`),e instanceof y&&vo(r,e)}function Co(r,e,t,i){return e instanceof N?So(r,e,t):(Eo(r,e,t,i),1)}function yr(r,e){if(r.length===0)return;let t=e==="Errors",i=t?ee:ho,o=t?L:j,n=0,s=[""];for(let a of r)n+=Co(s,a,i,o);s[0]=`
65
65
  ${o(e)} (${n})`,console.log(s.join(`
66
66
  `))}function Io(r){let e=Object.entries(r.outputs),t=e.length,i=[];i.push(`
67
67
  ${gr("Outputs")} (${t})`);for(let[o,n]of e){let s=j.dim(yo(n.bytes));i.push(`${A}${ce(ie)} ${le(o)}: ${s}`)}i.push(""),console.log(i.join(`
68
- `))}function ue(r){if(r instanceof y){let e=`${L(r.name)}: ${r.message.slice(r.name.length+1)}`;console.log(`
68
+ `))}function ue(r){if(r instanceof y){let e=`${L(r.name)}: ${r.message}`;console.log(`
69
69
  ${A}${L(ee)} ${e}`),xo(r)}else if(G(r))for(let e of r.errors)ue(e);else if(r instanceof N)for(let e of r.diagnostics)br(e,L(ee));else r instanceof Error?ue(new Ue(r)):ue(new I(String(r)))}function wo(r,e){let t=e.length>0,i=t?j(r):fe(r),o=t?L(ee):ce.dim(ie),n=oe("completed",o);if(console.log(`${n} ${i}`),t){console.log("");for(let s of e)br(s,L(ee));console.log("")}}function Sr(r){for(let[e,t]of Object.entries(r))wo(e,t)}function Er({variantName:r}){console.log(`${oe("build")} ${fe(r)}`)}function To(r,e){if(!u(v).getValue().verbose)return;let t=e?.replacementInfo?.[r];if(!t||!Array.isArray(t)||t.length===0)return;let i=A+le(ie),o=[oe(`macro ${j("replacement")}`)];for(let{source:n,replacement:s}of t){let a=yt.dim("// "+n).replaceAll(`
70
70
  `,`
71
71
  ${A}`);if(s&&s!=="undefined"){let c=s.replaceAll(`