@remotex-labs/xbuild 2.3.1 → 2.3.2
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 +2 -2
- package/dist/bash.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/bash.js
CHANGED
|
@@ -21,7 +21,7 @@ __ _| |_/ /_ _ _| | __| |
|
|
|
21
21
|
/_/\\_\\____/ \\__,_|_|_|\\__,_|
|
|
22
22
|
`;function Pt(){return`
|
|
23
23
|
\r${Qe.burntOrange(ti)}
|
|
24
|
-
\rVersion: ${Qe.brightPink("2.3.
|
|
24
|
+
\rVersion: ${Qe.brightPink("2.3.2")}
|
|
25
25
|
\r`}function I(){return Qe.lightCoral("[xBuild]")}import{readdir as ii,stat as oi,readFile as ni}from"fs/promises";import{xterm as Ie}from"@remotex-labs/xansi/xterm.component";var ge=class{constructor(e,t){this.config=e;this.rootDir=ri(t),this.config.port||=0,this.config.host||="localhost"}server;rootDir;framework=u(b);async start(){if(this.config.https)return await this.startHttpsServer();await this.startHttpServer()}async stop(){if(!this.server){console.log(I(),Ie.gray("No server is currently running."));return}await new Promise((e,t)=>{this.server.close(i=>{i?t(i):e()})}),console.log(I(),Ie.dim("Server stopped.")),this.server=void 0}async restart(){console.log(I(),Ie.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=$t.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:Mt(this.config.key??Ce(this.framework.distPath,"..","certs","server.key")),cert:Mt(this.config.cert??Ce(this.framework.distPath,"..","certs","server.crt"))};this.server=Bt.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(`${I()} Request ${Ie.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=Ce(this.rootDir,i);if(!o.startsWith(this.rootDir)){t.statusCode=403,t.end();return}try{let n=await oi(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(I(),s),this.sendNotFound(t)}}async handleDirectory(e,t,i){let n=(await ii(e)).map(l=>{let p=Ce(t,l),f=Rt(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>
|
|
@@ -49,7 +49,7 @@ __ _| |_/ /_ _ _| | __| |
|
|
|
49
49
|
`),e.join(`
|
|
50
50
|
`)}function at(){let r=Math.max(0,st.rows-2);r>0&&console.log(`
|
|
51
51
|
`.repeat(r)),ct.cursorTo(st,0,0),ct.clearScreenDown(st)}function ho(r){let e=fr[uo]??"xdg-open";po(`${e} ${r}`)}function yo(r,e,t,i,o){if(e?.name)switch((e.sequence===w.QUIT||r===nt.SIGINT||r===nt.SIGQUIT)&&(console.log(`
|
|
52
|
-
\u{1F44B} Exiting...`),mo(
|
|
52
|
+
\u{1F44B} Exiting...`),mo(0)),e.name){case w.CLEAR:at();break;case w.VERBOSE:let n=u(x).getValue(s=>s.verbose);console.log(`\u{1F41E} Debug mode: ${n?"DISABLED":"ENABLED"}`),lr({verbose:!n});break;case w.RELOAD:at(),t();break;case w.HELP:at(),console.log(i);break;case w.SHOW_URL:o&&console.log(`${I()} ${Be.canaryYellow(o)}`);break;case w.OPEN_BROWSER:o&&ho(o);break}}function pr(r,e){if(!$e.isTTY)return;let t=go(!!e);console.log(t),$e.setRawMode(!0),ct.emitKeypressEvents($e),$e.on("keypress",(i,o)=>{yo(i,o,r,t,e)})}import{existsSync as vo}from"fs";import{runInThisContext as xo}from"vm";import{createRequire as bo}from"module";import{resolve as So}from"@remotex-labs/xmap";var Eo={minify:!1,format:"cjs",platform:"node",logLevel:"silent",packages:"external",minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1};async function lt(r){if(!r||!vo(r))return{};u(v).touchFile(r);let[e,t]=(await Ut([r],{...Eo,outdir:"tmp"})).outputFiles;u(b).setSource(e.text,r),globalThis.module={exports:{}},globalThis.require=bo(So(r)),await xo(t.text,{filename:r});let i=module.exports.config??module.exports.default;return i||{}}import{relative as wo}from"@remotex-labs/xmap";var Ne=class r extends y{constructor(t,i){if(t instanceof y)return t;super(t.message,"VMRuntimeError");this.originalError=t;this.originalError instanceof AggregateError&&Array.isArray(this.originalError.errors)&&(this.errors=this.originalError.errors.map(o=>new r(o,i))),this.stack=this.originalError.stack,this.message=this.originalError.message,this.reformatStack(this.originalError,i)}errors=[];[Symbol.for("nodejs.util.inspect.custom")](){if(this.errors&&this.errors.length>0){let t=this.errors.map(i=>`${i.formattedStack??i.stack}`).join("");return`VMRuntimeError Contains ${this.errors.length} nested errors:
|
|
53
53
|
${t}
|
|
54
54
|
`}return this.formattedStack||this.stack}};import{xterm as pt}from"@remotex-labs/xansi/xterm.component";import{xterm as q}from"@remotex-labs/xansi/xterm.component";var ur=q.hex("#80a36b"),ve=q.hex("#dcdfe4"),ie=q.hex("#5798cd"),M=q.hex("#e5c07b"),oe=q.hex("#56b6c2"),$=q.hex("#e06c75"),ne=q.hex("#c678dd"),se=q.hex("#a5a7ab");var T=" ",ft=1024,dr=ft*1024,gr="\u2014",Q="\u2192",Y="\xD7",Co="\u2022";function Z(r,e=ie.dim(Q)){return`${I()} ${e} ${ie(r)}`}function Io(r){return r<ft?`${r} B`:r<dr?`${(r/ft).toFixed(2)} KB`:`${(r/dr).toFixed(2)} MB`}function hr(r){let e=r.file?wo(process.cwd(),r.file):"(unknown)",t=M(String((r.line??0)+1)),i=M(String((r.column??0)+1));return`${oe(e)}:${t}:${i}`}function To(r,e){if(!e.metadata?.formatCode)return;let t=e.metadata.formatCode.split(`
|
|
55
55
|
`),i=e.metadata.stack.map(o=>o.format).join(`
|