@remotex-labs/xbuild 2.5.0 → 2.5.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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- var wr=Object.create;var Ve=Object.defineProperty;var Cr=Object.getOwnPropertyDescriptor;var yt=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),fe=r=>{throw TypeError(r)};var Ir=(r,e,t)=>e in r?Ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var mt=(r,e)=>Ve(r,"name",{value:e,configurable:!0});var F=r=>[,,,wr(r?.[yt("metadata")]??null)],vt=["class","method","getter","setter","accessor","field","value","get","set"],le=r=>r!==void 0&&typeof r!="function"?fe("Function expected"):r,Tr=(r,e,t,i,o)=>({kind:vt[r],name:e,metadata:i,addInitializer:n=>t._?fe("Already initialized"):o.push(le(n||null))}),Or=(r,e)=>Ir(e,yt("metadata"),r[3]),k=(r,e,t,i)=>{for(var o=0,n=r[e>>1],s=n&&n.length;o<s;o++)e&1?n[o].call(t):i=n[o].call(t,i);return i},A=(r,e,t,i,o,n)=>{var s,a,c,l,p,f=e&7,d=!!(e&8),m=!!(e&16),$=f>3?r.length+1:f?d?1:2:0,_=vt[f+5],j=f>3&&(r[$-1]=[]),Le=r[$]||(r[$]=[]),E=f&&(!m&&!d&&(o=o.prototype),f<5&&(f>3||!m)&&Cr(f<4?o:{get[t](){return gt(this,n)},set[t](C){return ht(this,n,C)}},t));f?m&&f<4&&mt(n,(f>2?"set ":f>1?"get ":"")+t):mt(o,t);for(var ce=i.length-1;ce>=0;ce--)l=Tr(f,t,c={},r[3],Le),f&&(l.static=d,l.private=m,p=l.access={has:m?C=>Fr(o,C):C=>t in C},f^3&&(p.get=m?C=>(f^1?gt:kr)(C,o,f^4?n:E.get):C=>C[t]),f>2&&(p.set=m?(C,He)=>ht(C,o,He,f^4?n:E.set):(C,He)=>C[t]=He)),a=(0,i[ce])(f?f<4?m?n:E[_]:f>4?void 0:{get:E.get,set:E.set}:o,l),c._=1,f^4||a===void 0?le(a)&&(f>4?j.unshift(a):f?m?n=a:E[_]=a:o=a):typeof a!="object"||a===null?fe("Object expected"):(le(s=a.get)&&(E.get=s),le(s=a.set)&&(E.set=s),le(s=a.init)&&j.unshift(s));return f||Or(r,o),E&&Ve(o,t,E),m?f^4?n:E:o};var _e=(r,e,t)=>e.has(r)||fe("Cannot "+t),Fr=(r,e)=>Object(e)!==e?fe('Cannot use the "in" operator on this value'):r.has(e),gt=(r,e,t)=>(_e(r,e,"read from private field"),t?t.call(r):e.get(r));var ht=(r,e,t,i)=>(_e(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),kr=(r,e,t)=>(_e(r,e,"access private method"),t);import{rmSync as jo}from"fs";import{cwd as Lo}from"process";import Se from"node:process";import{resolveError as Ur}from"@remotex-labs/xmap";var Ue=new Map,xt=new Map;function Ar(r){return typeof r=="object"&&r!==null&&"useClass"in r}function Pr(r){return typeof r=="object"&&r!==null&&"useFactory"in r}function Rr(r){return typeof r=="object"&&r!==null&&"useValue"in r}function P(r){return function(e){xt.set(e,r||{})}}function ze(r,e=[]){if(!r)return e;let t=e;for(let i of r.slice(t.length))if(Ar(i))t.push(u(i.useClass,...ze(i.providers)));else if(Pr(i))t.push(i.useFactory(...ze(i.providers)));else if(Rr(i))t.push(i.useValue);else if(typeof i=="function")t.push(u(i));else throw new Error(`Unknown provider type: ${typeof i}`);return t}function u(r,...e){if(Ue.has(r))return Ue.get(r);let t=xt.get(r);if(!t)throw new Error(`Cannot inject ${r.name} \u2013 not marked @Injectable`);let i=ze(t.providers,e),o=t.factory?t.factory(...i):new r(...i);return t?.scope==="singleton"&&Ue.set(r,o),o}import{xterm as Ye}from"@remotex-labs/xansi/xterm.component";import $r from"typescript";import{resolve as Mr}from"@remotex-labs/xmap";import{closeSync as Br,fstatSync as Nr,openSync as Dr,readFileSync as jr}from"fs";var bt,We;bt=[P({scope:"singleton"})];var v=class{resolvedPathCache=new Map;snapshotsByPath=new Map;clear(){this.snapshotsByPath.clear(),this.resolvedPathCache.clear()}getSnapshot(e){return this.snapshotsByPath.get(this.resolve(e))}getOrTouchFile(e){return this.snapshotsByPath.get(this.resolve(e))??this.touchFile(e)}getTrackedFilePaths(){return[...this.snapshotsByPath.keys()]}touchFile(e){let t=this.resolve(e),i=this.snapshotsByPath.get(t)??this.createEntry(t);try{this.syncEntry(t,i)}catch{(i.contentSnapshot!==void 0||i.version>0)&&(i.version++,i.mtimeMs=0,i.contentSnapshot=void 0)}return{...i}}resolve(e){let t=this.resolvedPathCache.get(e);if(t)return t;let i=Mr(e);return this.resolvedPathCache.set(e,i),i}createEntry(e){let t={version:0,mtimeMs:0,contentSnapshot:void 0};return this.snapshotsByPath.set(e,t),t}syncEntry(e,t){let i=Dr(e,"r");try{let{mtimeMs:o}=Nr(i);if(o===t.mtimeMs)return;let n=jr(i,"utf-8");t.version++,t.mtimeMs=o,t.contentSnapshot=n?$r.ScriptSnapshot.fromString(n):void 0}finally{Br(i)}}};We=F(null),v=A(We,0,"FilesModel",bt,v),k(We,1,v);import{readFileSync as Lr}from"fs";import{SourceService as Hr}from"@remotex-labs/xmap";import{resolve as Ge,toPosix as St}from"@remotex-labs/xmap";var Et,Ke;Et=[P({scope:"singleton"})];var b=class{filePath;distPath;rootPath;sourceMaps=new Map;constructor(){this.filePath=import.meta.filename,this.setSourceFile(this.filePath),this.rootPath=this.getRootDir(),this.distPath=this.getDistDir()}isFrameworkFile(e){let{source:t,sourceRoot:i}=e,o=t?.toLowerCase();return!!(t&&o.includes("xbuild")&&!o.includes("xbuild.config")||i&&i.includes("xBuild"))}getSourceMap(e){if(e=Ge(e),this.sourceMaps.has(e))return this.sourceMaps.get(e)}setSource(e,t){let i=Ge(t);try{return this.initializeSourceMap(e,i)}catch(o){throw new Error(`Failed to initialize SourceService: ${i}
2
+ var Er=Object.create;var Ve=Object.defineProperty;var Cr=Object.getOwnPropertyDescriptor;var yt=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),fe=r=>{throw TypeError(r)};var Ir=(r,e,t)=>e in r?Ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var mt=(r,e)=>Ve(r,"name",{value:e,configurable:!0});var F=r=>[,,,Er(r?.[yt("metadata")]??null)],vt=["class","method","getter","setter","accessor","field","value","get","set"],le=r=>r!==void 0&&typeof r!="function"?fe("Function expected"):r,Tr=(r,e,t,i,o)=>({kind:vt[r],name:e,metadata:i,addInitializer:n=>t._?fe("Already initialized"):o.push(le(n||null))}),Or=(r,e)=>Ir(e,yt("metadata"),r[3]),k=(r,e,t,i)=>{for(var o=0,n=r[e>>1],s=n&&n.length;o<s;o++)e&1?n[o].call(t):i=n[o].call(t,i);return i},A=(r,e,t,i,o,n)=>{var s,a,c,l,p,f=e&7,d=!!(e&8),m=!!(e&16),$=f>3?r.length+1:f?d?1:2:0,_=vt[f+5],j=f>3&&(r[$-1]=[]),Le=r[$]||(r[$]=[]),w=f&&(!m&&!d&&(o=o.prototype),f<5&&(f>3||!m)&&Cr(f<4?o:{get[t](){return gt(this,n)},set[t](C){return ht(this,n,C)}},t));f?m&&f<4&&mt(n,(f>2?"set ":f>1?"get ":"")+t):mt(o,t);for(var ce=i.length-1;ce>=0;ce--)l=Tr(f,t,c={},r[3],Le),f&&(l.static=d,l.private=m,p=l.access={has:m?C=>Fr(o,C):C=>t in C},f^3&&(p.get=m?C=>(f^1?gt:kr)(C,o,f^4?n:w.get):C=>C[t]),f>2&&(p.set=m?(C,He)=>ht(C,o,He,f^4?n:w.set):(C,He)=>C[t]=He)),a=(0,i[ce])(f?f<4?m?n:w[_]:f>4?void 0:{get:w.get,set:w.set}:o,l),c._=1,f^4||a===void 0?le(a)&&(f>4?j.unshift(a):f?m?n=a:w[_]=a:o=a):typeof a!="object"||a===null?fe("Object expected"):(le(s=a.get)&&(w.get=s),le(s=a.set)&&(w.set=s),le(s=a.init)&&j.unshift(s));return f||Or(r,o),w&&Ve(o,t,w),m?f^4?n:w:o};var _e=(r,e,t)=>e.has(r)||fe("Cannot "+t),Fr=(r,e)=>Object(e)!==e?fe('Cannot use the "in" operator on this value'):r.has(e),gt=(r,e,t)=>(_e(r,e,"read from private field"),t?t.call(r):e.get(r));var ht=(r,e,t,i)=>(_e(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),kr=(r,e,t)=>(_e(r,e,"access private method"),t);import{rmSync as jo}from"fs";import{cwd as Lo}from"process";import Se from"node:process";import{resolveError as Ur}from"@remotex-labs/xmap";var Ue=new Map,xt=new Map;function Ar(r){return typeof r=="object"&&r!==null&&"useClass"in r}function Pr(r){return typeof r=="object"&&r!==null&&"useFactory"in r}function Rr(r){return typeof r=="object"&&r!==null&&"useValue"in r}function P(r){return function(e){xt.set(e,r||{})}}function ze(r,e=[]){if(!r)return e;let t=e;for(let i of r.slice(t.length))if(Ar(i))t.push(u(i.useClass,...ze(i.providers)));else if(Pr(i))t.push(i.useFactory(...ze(i.providers)));else if(Rr(i))t.push(i.useValue);else if(typeof i=="function")t.push(u(i));else throw new Error(`Unknown provider type: ${typeof i}`);return t}function u(r,...e){if(Ue.has(r))return Ue.get(r);let t=xt.get(r);if(!t)throw new Error(`Cannot inject ${r.name} \u2013 not marked @Injectable`);let i=ze(t.providers,e),o=t.factory?t.factory(...i):new r(...i);return t?.scope==="singleton"&&Ue.set(r,o),o}import{xterm as Ye}from"@remotex-labs/xansi/xterm.component";import $r from"typescript";import{resolve as Mr}from"@remotex-labs/xmap";import{closeSync as Br,fstatSync as Nr,openSync as Dr,readFileSync as jr}from"fs";var bt,We;bt=[P({scope:"singleton"})];var v=class{resolvedPathCache=new Map;snapshotsByPath=new Map;clear(){this.snapshotsByPath.clear(),this.resolvedPathCache.clear()}getSnapshot(e){return this.snapshotsByPath.get(this.resolve(e))}getOrTouchFile(e){return this.snapshotsByPath.get(this.resolve(e))??this.touchFile(e)}getTrackedFilePaths(){return[...this.snapshotsByPath.keys()]}touchFile(e){let t=this.resolve(e),i=this.snapshotsByPath.get(t)??this.createEntry(t);try{this.syncEntry(t,i)}catch{(i.contentSnapshot!==void 0||i.version>0)&&(i.version++,i.mtimeMs=0,i.contentSnapshot=void 0)}return{...i}}resolve(e){let t=this.resolvedPathCache.get(e);if(t)return t;let i=Mr(e);return this.resolvedPathCache.set(e,i),i}createEntry(e){let t={version:0,mtimeMs:0,contentSnapshot:void 0};return this.snapshotsByPath.set(e,t),t}syncEntry(e,t){let i=Dr(e,"r");try{let{mtimeMs:o}=Nr(i);if(o===t.mtimeMs)return;let n=jr(i,"utf-8");t.version++,t.mtimeMs=o,t.contentSnapshot=n?$r.ScriptSnapshot.fromString(n):void 0}finally{Br(i)}}};We=F(null),v=A(We,0,"FilesModel",bt,v),k(We,1,v);import{readFileSync as Lr}from"fs";import{SourceService as Hr}from"@remotex-labs/xmap";import{resolve as Ge,toPosix as St}from"@remotex-labs/xmap";var wt,Ke;wt=[P({scope:"singleton"})];var b=class{filePath;distPath;rootPath;sourceMaps=new Map;constructor(){this.filePath=import.meta.filename,this.setSourceFile(this.filePath),this.rootPath=this.getRootDir(),this.distPath=this.getDistDir()}isFrameworkFile(e){let{source:t,sourceRoot:i}=e,o=t?.toLowerCase();return!!(t&&o.includes("xbuild")&&!o.includes("xbuild.config")||i&&i.includes("xBuild"))}getSourceMap(e){if(e=Ge(e),this.sourceMaps.has(e))return this.sourceMaps.get(e)}setSource(e,t){let i=Ge(t);try{return this.initializeSourceMap(e,i)}catch(o){throw new Error(`Failed to initialize SourceService: ${i}
3
3
  ${o instanceof Error?o.message:String(o)}`)}}setSourceFile(e){if(!e)return;let t=Ge(e),i=`${e}.map`;if(!this.sourceMaps.has(t))try{let o=Lr(i,"utf-8");return this.initializeSourceMap(o,t)}catch(o){throw new Error(`Failed to initialize SourceService: ${t}
4
- ${o instanceof Error?o.message:String(o)}`)}}getRootDir(){return St(process.cwd())}getDistDir(){return St(import.meta.dirname)}initializeSourceMap(e,t){if(e?.includes('"mappings": ""'))return;let i=new Hr(e,t);this.sourceMaps.set(t,i)}};Ke=F(null),b=A(Ke,0,"FrameworkService",Et,b),k(Ke,1,b);import{parseErrorStack as Ot}from"@remotex-labs/xmap/parser.component";function wt(r){return e=>new U(t=>e.subscribe({next:i=>{try{let o=r(i);t.next?.(o)}catch(o){t.error?.(o)}},error:i=>t.error?.(i),complete:()=>t.complete?.()}))}function Ct(r=(e,t)=>e===t){return e=>new U(t=>{let i=!1,o;return e.subscribe({next:n=>{try{if(!i){o=n,i=!0,t.next?.(n);return}r(o,n)||(o=n,t.next?.(n))}catch(s){t.error?.(s)}},error:n=>t.error?.(n),complete:()=>t.complete?.()})})}var U=class{constructor(e){this.handler=e}handler;subscribe(e,t,i){let o=this.createSafeObserver(e,t,i),n;try{n=this.handler(o)}catch(s){return o.error?.(s),()=>{}}return()=>{try{n?.()}catch(s){o.error?.(s)}}}pipe(...e){return e.length===0?this:e.reduce((t,i)=>i(t),this)}createSafeObserver(e,t,i){return typeof e=="function"?{next:e,error:t,complete:i}:e||{}}};var pe=class extends U{isCompleted=!1;observers=new Set;constructor(){super(e=>{if(this.isCompleted){e.complete?.();return}return this.observers.add(e),()=>this.observers.delete(e)})}next(e){if(this.isCompleted)return;let t=[];for(let i of[...this.observers])try{i.next?.(e)}catch(o){t.push(o);try{i.error?.(o)}catch{}}if(t.length>0)throw new AggregateError(t,`${t.length} observer(s) failed in next()`)}error(e){if(this.isCompleted)return;let t=[];for(let i of[...this.observers])try{i.error?.(e)}catch(o){t.push(o)}if(t.length>0)throw new AggregateError(t,`${t.length} observer(s) failed in error()`)}complete(){if(this.isCompleted)return;let e=[];for(let t of[...this.observers])try{t.complete?.()}catch(i){e.push(i)}if(this.observers.clear(),this.isCompleted=!0,e.length>0)throw new AggregateError(e,`${e.length} observer(s) failed in complete()`)}};var ue=class extends pe{lastValue;constructor(e){super(),this.lastValue=typeof e=="function"?e():e}get value(){return this.lastValue}subscribe(e,t,i){if(this.isCompleted)return()=>{};let o=this.createSafeObserver(e,t,i),n=super.subscribe(o);return o.next?.(this.lastValue),n}next(e){this.isCompleted||(this.lastValue=e,super.next(e))}};function xe(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function z(r,...e){if(!e.length)return r;let t=e.shift();if(xe(r)&&xe(t)){for(let i in t){let o=t[i],n=r[i];Array.isArray(o)&&Array.isArray(n)?Object.assign(r,{[i]:[...n,...o]}):xe(o)?Object.assign(r,{[i]:z(xe(n)?n:{},o)}):Object.assign(r,{[i]:o})}return z(r,...e)}return r}function be(r,e,t=!0){return r===e||Object.is(r,e)?!0:r===null||e===null?!1:r instanceof Date&&e instanceof Date?r.getTime()===e.getTime():r instanceof RegExp&&e instanceof RegExp?r.source===e.source&&r.flags===e.flags:URL&&r instanceof URL&&e instanceof URL?r.href===e.href:typeof r=="object"&&typeof e=="object"?_r(r,e,t):!1}function Vr(r,e){return r==null||typeof r!="object"&&typeof r!="function"?!1:e in r||Object.prototype.hasOwnProperty.call(r,e)}function _r(r,e,t=!0){if(Array.isArray(r)&&Array.isArray(e))return t&&r.length!==e.length?!1:r.every((n,s)=>be(n,e[s],t));let i=Object.keys(r),o=Object.keys(e);if(t&&i.length!==o.length)return!1;for(let n of i)if(!Vr(e,n)||!be(r[n],e[n],t))return!1;return!0}var It=Object.freeze({verbose:!1,common:Object.freeze({types:!0,declaration:!0,esbuild:Object.freeze({write:!0,bundle:!0,minify:!0,format:"cjs",outdir:"dist",platform:"browser",absWorkingDir:process.cwd()})})});var Tt,qe;Tt=[P({scope:"singleton"})];var x=class{constructor(e=It){this.initialConfig=e;this.config$=new ue(z({},e))}initialConfig;config$;getValue(e){return e?e(this.config$.value):this.config$.value}subscribe(e){return this.config$.subscribe(e)}select(e){return this.config$.pipe(wt(e),Ct((t,i)=>be(t,i)))}patch(e){let t=z({},this.config$.value,e);this.config$.next(t)}reload(e){this.config$.next(z({},this.initialConfig,e))}};qe=F(null),x=A(qe,0,"ConfigurationService",Tt,x),k(qe,1,x);import{formatErrorCode as zr}from"@remotex-labs/xmap/formatter.component";import{highlightCode as Wr}from"@remotex-labs/xmap/highlighter.component";function Gr(r=""){let t=u(b).getSourceMap(r);if(t)return t;let i=u(v).getOrTouchFile(r),o=i?.contentSnapshot?.text;if(!i||!o)return null;let n=o.split(`
4
+ ${o instanceof Error?o.message:String(o)}`)}}getRootDir(){return St(process.cwd())}getDistDir(){return St(import.meta.dirname)}initializeSourceMap(e,t){if(e?.includes('"mappings": ""'))return;let i=new Hr(e,t);this.sourceMaps.set(t,i)}};Ke=F(null),b=A(Ke,0,"FrameworkService",wt,b),k(Ke,1,b);import{parseErrorStack as Ot}from"@remotex-labs/xmap/parser.component";function Et(r){return e=>new U(t=>e.subscribe({next:i=>{try{let o=r(i);t.next?.(o)}catch(o){t.error?.(o)}},error:i=>t.error?.(i),complete:()=>t.complete?.()}))}function Ct(r=(e,t)=>e===t){return e=>new U(t=>{let i=!1,o;return e.subscribe({next:n=>{try{if(!i){o=n,i=!0,t.next?.(n);return}r(o,n)||(o=n,t.next?.(n))}catch(s){t.error?.(s)}},error:n=>t.error?.(n),complete:()=>t.complete?.()})})}var U=class{constructor(e){this.handler=e}handler;subscribe(e,t,i){let o=this.createSafeObserver(e,t,i),n;try{n=this.handler(o)}catch(s){return o.error?.(s),()=>{}}return()=>{try{n?.()}catch(s){o.error?.(s)}}}pipe(...e){return e.length===0?this:e.reduce((t,i)=>i(t),this)}createSafeObserver(e,t,i){return typeof e=="function"?{next:e,error:t,complete:i}:e||{}}};var pe=class extends U{isCompleted=!1;observers=new Set;constructor(){super(e=>{if(this.isCompleted){e.complete?.();return}return this.observers.add(e),()=>this.observers.delete(e)})}next(e){if(this.isCompleted)return;let t=[];for(let i of[...this.observers])try{i.next?.(e)}catch(o){t.push(o);try{i.error?.(o)}catch{}}if(t.length>0)throw new AggregateError(t,`${t.length} observer(s) failed in next()`)}error(e){if(this.isCompleted)return;let t=[];for(let i of[...this.observers])try{i.error?.(e)}catch(o){t.push(o)}if(t.length>0)throw new AggregateError(t,`${t.length} observer(s) failed in error()`)}complete(){if(this.isCompleted)return;let e=[];for(let t of[...this.observers])try{t.complete?.()}catch(i){e.push(i)}if(this.observers.clear(),this.isCompleted=!0,e.length>0)throw new AggregateError(e,`${e.length} observer(s) failed in complete()`)}};var ue=class extends pe{lastValue;constructor(e){super(),this.lastValue=typeof e=="function"?e():e}get value(){return this.lastValue}subscribe(e,t,i){if(this.isCompleted)return()=>{};let o=this.createSafeObserver(e,t,i),n=super.subscribe(o);return o.next?.(this.lastValue),n}next(e){this.isCompleted||(this.lastValue=e,super.next(e))}};function xe(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function z(r,...e){if(!e.length)return r;let t=e.shift();if(xe(r)&&xe(t)){for(let i in t){let o=t[i],n=r[i];Array.isArray(o)&&Array.isArray(n)?Object.assign(r,{[i]:[...n,...o]}):xe(o)?Object.assign(r,{[i]:z(xe(n)?n:{},o)}):Object.assign(r,{[i]:o})}return z(r,...e)}return r}function be(r,e,t=!0){return r===e||Object.is(r,e)?!0:r===null||e===null?!1:r instanceof Date&&e instanceof Date?r.getTime()===e.getTime():r instanceof RegExp&&e instanceof RegExp?r.source===e.source&&r.flags===e.flags:URL&&r instanceof URL&&e instanceof URL?r.href===e.href:typeof r=="object"&&typeof e=="object"?_r(r,e,t):!1}function Vr(r,e){return r==null||typeof r!="object"&&typeof r!="function"?!1:e in r||Object.prototype.hasOwnProperty.call(r,e)}function _r(r,e,t=!0){if(Array.isArray(r)&&Array.isArray(e))return t&&r.length!==e.length?!1:r.every((n,s)=>be(n,e[s],t));let i=Object.keys(r),o=Object.keys(e);if(t&&i.length!==o.length)return!1;for(let n of i)if(!Vr(e,n)||!be(r[n],e[n],t))return!1;return!0}var It=Object.freeze({verbose:!1,common:Object.freeze({types:!0,declaration:!0,esbuild:Object.freeze({write:!0,bundle:!0,minify:!0,format:"cjs",outdir:"dist",platform:"browser",absWorkingDir:process.cwd()})})});var Tt,qe;Tt=[P({scope:"singleton"})];var x=class{constructor(e=It){this.initialConfig=e;this.config$=new ue(z({},e))}initialConfig;config$;getValue(e){return e?e(this.config$.value):this.config$.value}subscribe(e){return this.config$.subscribe(e)}select(e){return this.config$.pipe(Et(e),Ct((t,i)=>be(t,i)))}patch(e){let t=z({},this.config$.value,e);this.config$.next(t)}reload(e){this.config$.next(z({},this.initialConfig,e))}};qe=F(null),x=A(qe,0,"ConfigurationService",Tt,x),k(qe,1,x);import{formatErrorCode as zr}from"@remotex-labs/xmap/formatter.component";import{highlightCode as Wr}from"@remotex-labs/xmap/highlighter.component";function Gr(r=""){let t=u(b).getSourceMap(r);if(t)return t;let i=u(v).getOrTouchFile(r),o=i?.contentSnapshot?.text;if(!i||!o)return null;let n=o.split(`
5
5
  `);return{getPositionWithCode:(s,a,c,l)=>{let p=l?.linesBefore??3,f=l?.linesAfter??3,d=Math.max(s-p,0),m=Math.min(s+f,n.length);return{line:s,column:a+1,code:n.slice(d,m).join(`
6
6
  `),source:r,name:null,startLine:d,endLine:m,sourceRoot:null,sourceIndex:-1,generatedLine:-1,generatedColumn:-1}}}}function Kr(r){return r instanceof Error?Ot(r):r.detail instanceof Error?Ot(r.detail):r.location?{name:"esBuildMessage",message:r.text??"",rawStack:"",stack:[{source:`@${r.location.file}`,line:r.location.line,column:r.location.column,fileName:r.location.file,eval:!1,async:!1,native:!1,constructor:!1}]}:{stack:[],name:"esBuildMessage",message:r.text??"",rawStack:""}}function L(r,e){let t=u(b),i=u(x).getValue(s=>s.verbose)??!1,o=Kr(r),n=Ur(o,{...e,withNativeFrames:i||(e?.withFrameworkFrames??!1),getSource(s){return Gr(s)}});return n.stack.filter(s=>{if(!(e?.withFrameworkFrames??!1)&&t.isFrameworkFile(s))return!1;!n.formatCode&&s.code&&(n.formatCode=zr({code:Wr(s.code),line:s.line??0,column:s.column??0,startLine:s.stratLine??0},{color:Ye.brightPink}))}),n}function H(r,e,t,i=[]){let o=[`
7
7
  ${e}: ${Ye.lightCoral(t)}`];for(let n of i??[])n.text&&o.push(`
@@ -12,7 +12,7 @@ ${r.formatCode}`),r.stack.length&&o.push(`
12
12
  Enhanced Stack Trace:
13
13
  ${r.stack.map(n=>n.format).join(`
14
14
  `)}
15
- `),o.join("")}var y=class extends Error{errorMetadata;formattedStack;constructor(e,t="xBuildBaseError"){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get metadata(){return this.errorMetadata}[Symbol.for("nodejs.util.inspect.custom")](){return this.formattedStack||this.stack}reformatStack(e,t){this.errorMetadata=L(e,t),this.formattedStack=H(this.errorMetadata,e.name,e.message)}};function Ft(r){if(r instanceof AggregateError){console.error("AggregateError:",r.message);for(let e of r.errors)if(e instanceof Error&&!(e instanceof y)){let t=L(e,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(H(t,e.name,e.message))}else console.error(e);return}if(r instanceof Error&&!(r instanceof y)){let e=L(r,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(H(e,r.name,r.message))}else console.error(r)}Se.on("uncaughtException",r=>{Ft(r),Se.exit(2)});Se.on("unhandledRejection",r=>{Ft(r),Se.exit(2)});import{join as Ho}from"@remotex-labs/xmap";import Xe from"yargs";import{hideBin as Yr}from"yargs/helpers";var qr="config.xbuild.ts",Ee={entryPoints:{describe:"Source files to build (supports glob patterns)",type:"string",array:!0},typeCheck:{describe:"Perform type checking without building output",alias:"tc",type:"boolean"},platform:{describe:"Target platform for the build output",alias:"p",type:"string",choices:["browser","node","neutral"]},serve:{describe:"Start server to the <folder>",alias:"s",type:"string"},outdir:{describe:"Directory for build output files",alias:"o",type:"string"},declaration:{describe:"Generate TypeScript declaration files (.d.ts)",alias:"de",type:"boolean"},watch:{describe:"Watch mode - rebuild on file changes",alias:"w",type:"boolean"},config:{describe:"Path to build configuration file",alias:"c",type:"string",default:qr},tsconfig:{describe:"Path to TypeScript configuration file",alias:"tsc",type:"string"},minify:{describe:"Minify the build output",alias:"m",type:"boolean"},bundle:{describe:"Bundle dependencies into output files",alias:"b",type:"boolean"},types:{describe:"Enable type checking during build process",alias:"btc",type:"boolean"},failOnError:{describe:"Fail build when TypeScript errors are detected",alias:"foe",type:"boolean"},format:{describe:"Output module format",alias:"f",type:"string",choices:["cjs","esm","iife"]},verbose:{describe:"Verbose error stack traces",alias:"v",type:"boolean"},build:{describe:"Select an build configuration variant by names (as defined in your config file)",alias:"xb",type:"string",array:!0}},kt=[["xBuild src/index.ts","Build a single file with default settings"],["xBuild src/**/*.ts --bundle --minify","Bundle and minify all TypeScript files"],["xBuild src/app.ts -s","Development mode with watch and dev server"],["xBuild src/app.ts -s dist","Development mode with watch and dev server from dist folder"],["xBuild src/lib.ts --format esm --declaration","Build ESM library with type definitions"],["xBuild src/server.ts --platform node --outdir dist","Build Node.js application to dist folder"],["xBuild --typeCheck","Type check only without generating output"],["xBuild --config custom.xbuild.ts","Use custom configuration file"]];var At,Je;At=[P({scope:"singleton"})];var Q=class{parseConfigFile(e){return Xe(e).help(!1).version(!1).options({config:Ee.config}).parseSync()}parseUserArgv(e,t){return t?Xe(e).help(!1).version(!1).options(t).parseSync():{}}enhancedParse(e,t={}){let i=Xe(Yr(e)).locale("en"),o=i.showHelp;return i.showHelp=function(n){return this.group(Object.keys(Ee),"xBuild Options:"),this.group(Object.keys(t),"user Options:"),o.call(this,n)},i.usage("Usage: xBuild [files..] [options]").command("* [entryPoints..]","Specific files to build (supports glob patterns)",n=>n.positional("entryPoints",{describe:"Specific files to build (supports glob patterns)",type:"string",array:!0})).options(t).options(Ee).epilogue("For more information, check the documentation https://remotex-labs.github.io/xBuild/").help().alias("help","h").strict().version(),kt.forEach(([n,s])=>{i.example(n,s)}),i.parseSync()}};Je=F(null),Q=A(Je,0,"ArgvModule",At,Q),k(Je,1,Q);import lt from"readline";import{exec as ho}from"child_process";import{cwd as Xr}from"process";import{readdirSync as Jr}from"fs";import{matchesGlob as Qe}from"path";import{join as Qr}from"@remotex-labs/xmap";function Zr(r){let e=[],t=[];for(let i of r)i.startsWith("!")?t.push(i.slice(1)):e.push(i);return{include:e,exclude:t}}function Pt(r,e){for(let t of e)if(t.endsWith(r)||Qe(r,t))return!0;return!1}function ei(r,e){let t=r+"/**";for(let i of e)if(Qe(r,i)||Qe(t,i))return!0;return!1}function we(r,e){let{include:t,exclude:i}=Zr(e),o=Object.create(null),s=Xr().length+1,a=r.length+1,c=i.length>0;function l(p){let f;try{f=Jr(p,{withFileTypes:!0})}catch{return}let d=f.length;for(let m=0;m<d;m++){let $=f[m],_=Qr(p,$.name),j=_.slice(a);if($.isDirectory()){(!c||!ei(j,i))&&l(_);continue}if(!(c&&Pt(j,i))&&Pt(j,t)){let Le=_.slice(s),E=j.lastIndexOf("."),ce=E>0?j.slice(0,E):j;o[ce]=Le}}}return l(r),o}var M=class r extends Error{diagnostics;constructor(e,t=[]){super(e),this.name="TypesError",this.diagnostics=t,Object.setPrototypeOf(this,r.prototype)}};var S=class extends y{constructor(e,t={withFrameworkFrames:!0}){super(e),this.reformatStack(this,t)}};var W=class extends y{id;constructor(e,t){super(e.text??"","esBuildError"),this.id=e.id??"",e.detail instanceof Error?(this.stack=e.detail.stack,this.message=e.detail.message,this.reformatStack(e.detail,t)):(this.errorMetadata=L(e,{withFrameworkFrames:!0}),this.stack=H(this.errorMetadata,this.name,this.message,e.notes))}};function ti(r){if(r instanceof y)return r;if(r.detail instanceof y||r.detail instanceof M)return r.detail;if(r.detail instanceof Error)return new W(r,{withFrameworkFrames:!0});if(r.location)return new W(r);if(r.text)return new S(r.text)}function de(r=[],e){for(let t of r){let i=ti(t);i&&e.push(i)}}function me(r){let e={errors:[],warnings:[],metafile:r.metafile,outputFiles:r.outputFiles,mangleCache:r.mangleCache};return de(r.errors,e.errors),de(r.warnings,e.warnings),e}function V(r){return typeof r=="object"&&r!==null&&"errors"in r}import*as Nt from"http";import*as Dt from"https";import{extname as Mt}from"path";import{readFileSync as Bt}from"fs";var Rt=`<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Dark File Browser \u2014 FTP-like</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" /><style>:root{--bg:#0b0f14;--panel:#0f1720;--muted:#9aa4b2;--accent:#E5C07B;--glass:rgba(255,255,255,0.03);--card:#0c1116;--radius:12px;--gap:12px;--shadow:0 6px 18px rgba(0,0,0,0.4);--file-icon-size:40px;font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial}*{box-sizing:border-box;font-style:normal !important}html,body{height:100%;margin:0;font-size:14px;color:#dce7ef;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:radial-gradient(1200px 600px at 10% 10%,rgba(110,231,183,0.04),transparent 8%),linear-gradient(180deg,rgba(255,255,255,0.01),transparent 20%),var(--bg);padding:28px;display:flex;gap:20px;align-items:flex-start;justify-content:center}.app{width:1100px;max-width:98vw;display:flex;gap:18px;padding:18px;border-radius:16px;box-shadow:var(--shadow);border:1px solid rgba(255,255,255,0.03);background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0));overflow:hidden}.sidebar{width:260px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border-radius:var(--radius);padding:14px}.brand{display:flex;gap:12px;align-items:center;margin-bottom:10px}.logo{width:46px;height:46px;border-radius:10px;background:linear-gradient(135deg,#b65b9f 0%,#804b8f 100%);display:flex;align-items:center;justify-content:center;font-weight:700}.brand h1{font-size:16px;margin:0}.muted{color:var(--muted);font-size:13px}.search{margin:12px 0}.search input{width:100%;padding:10px 12px;border-radius:10px;border:1px solid rgba(255,255,255,0.03);background:var(--glass);color:inherit}.quick-list{margin-top:12px}.quick-list a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;background:transparent;color:var(--muted);text-decoration:none;cursor:pointer;transition:color 0.15s ease}.quick-list a:hover{color:var(--accent)}.main{flex:1;display:flex;flex-direction:column}.topbar{display:flex;align-items:center;gap:12px;padding-bottom:12px}.breadcrumbs{list-style:none;display:flex;gap:8px;align-items:center;background:var(--glass);padding:8px 12px;border-radius:var(--radius);margin:0}.breadcrumbs li{display:flex;align-items:center}.breadcrumbs li:not(:last-child)::after{content:'>';margin-left:8px;color:var(--muted)}.breadcrumbs a{color:var(--muted);text-decoration:none;transition:color 0.15s ease}.breadcrumbs a:hover{color:var(--accent)}.list{margin-top:14px;display:grid;grid-template-columns:1fr;gap:10px}.list a{display:flex;text-decoration:none;color:inherit}.folder-row,.file-row{display:flex;gap:12px;align-items:center;padding:10px;border-radius:10px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border:1px solid rgba(255,255,255,0.02);transition:color 0.25s ease}.icon{width:var(--file-icon-size);height:var(--file-icon-size);border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.02);flex-shrink:0;transition:background 0.25s ease,color 0.25s ease}.folder-row:hover,.file-row:hover{color:var(--accent)}.folder-row:hover .icon{background:rgba(152,195,121,0.2)}.file-row:hover .icon{background:rgba(224,108,117,0.2)}.folder-row:hover .icon i{color:#98C379}.file-row:hover .icon i{color:#e09c6c}.meta{display:flex;flex-direction:column}.name{font-weight:600}.sub{color:var(--muted);font-size:13px}.empty{padding:40px;text-align:center;color:var(--muted)}@media (max-width:880px){.app{flex-direction:column;padding:12px}.sidebar,.main{width:100%}}</style></head><body><div class="app"><aside class="sidebar"><div class="brand"><div class="logo">F</div><div><h1>xBuildFTP</h1><div class="muted">Browse & serve files</div></div></div><div class="search"><input placeholder="Search files & folders..."/></div><div class="quick-list"><a href="/">\u{1F3E0} Home</a><a href="\${ up }">\u2B06\uFE0F Up</a></div></aside><main class="main"><div class="topbar"><div class="topbar"><ul class="breadcrumbs"> \${ paths } </ul></div></div> \${ fileList } </main></div></body><script> const searchInput = document.querySelector('.search input'); const listItems = document.querySelectorAll('.list > .folder-row, .list > .file-row'); const emptyMessage = document.querySelector('.empty'); searchInput.addEventListener('input', () => { const query = searchInput.value.toLowerCase(); let anyVisible = false; listItems.forEach(item => { const name = item.querySelector('.name').textContent.toLowerCase(); if (name.includes(query)) { item.style.display = 'flex'; anyVisible = true; } else { item.style.display = 'none'; } }); emptyMessage.style.display = anyVisible ? 'none' : 'block'; }); </script></html>`;import{resolve as oi,join as Ce}from"@remotex-labs/xmap";import{xterm as Ze}from"@remotex-labs/xansi/xterm.component";var ii=`
15
+ `),o.join("")}var y=class extends Error{errorMetadata;formattedStack;constructor(e,t="xBuildBaseError"){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get metadata(){return this.errorMetadata}[Symbol.for("nodejs.util.inspect.custom")](){return this.formattedStack||this.stack}reformatStack(e,t){this.errorMetadata=L(e,t),this.formattedStack=H(this.errorMetadata,e.name,e.message)}};function Ft(r){if(r instanceof AggregateError){console.error("AggregateError:",r.message);for(let e of r.errors)if(e instanceof Error&&!(e instanceof y)){let t=L(e,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(H(t,e.name,e.message))}else console.error(e);return}if(r instanceof Error&&!(r instanceof y)){let e=L(r,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(H(e,r.name,r.message))}else console.error(r)}Se.on("uncaughtException",r=>{Ft(r),Se.exit(2)});Se.on("unhandledRejection",r=>{Ft(r),Se.exit(2)});import{join as Ho}from"@remotex-labs/xmap";import Xe from"yargs";import{hideBin as Yr}from"yargs/helpers";var qr="config.xbuild.ts",we={entryPoints:{describe:"Source files to build (supports glob patterns)",type:"string",array:!0},typeCheck:{describe:"Perform type checking without building output",alias:"tc",type:"boolean"},platform:{describe:"Target platform for the build output",alias:"p",type:"string",choices:["browser","node","neutral"]},serve:{describe:"Start server to the <folder>",alias:"s",type:"string"},outdir:{describe:"Directory for build output files",alias:"o",type:"string"},declaration:{describe:"Generate TypeScript declaration files (.d.ts)",alias:"de",type:"boolean"},watch:{describe:"Watch mode - rebuild on file changes",alias:"w",type:"boolean"},config:{describe:"Path to build configuration file",alias:"c",type:"string",default:qr},tsconfig:{describe:"Path to TypeScript configuration file",alias:"tsc",type:"string"},minify:{describe:"Minify the build output",alias:"m",type:"boolean"},bundle:{describe:"Bundle dependencies into output files",alias:"b",type:"boolean"},types:{describe:"Enable type checking during build process",alias:"btc",type:"boolean"},failOnError:{describe:"Fail build when TypeScript errors are detected",alias:"foe",type:"boolean"},format:{describe:"Output module format",alias:"f",type:"string",choices:["cjs","esm","iife"]},verbose:{describe:"Verbose error stack traces",alias:"v",type:"boolean"},build:{describe:"Select an build configuration variant by names (as defined in your config file)",alias:"xb",type:"string",array:!0}},kt=[["xBuild src/index.ts","Build a single file with default settings"],["xBuild src/**/*.ts --bundle --minify","Bundle and minify all TypeScript files"],["xBuild src/app.ts -s","Development mode with watch and dev server"],["xBuild src/app.ts -s dist","Development mode with watch and dev server from dist folder"],["xBuild src/lib.ts --format esm --declaration","Build ESM library with type definitions"],["xBuild src/server.ts --platform node --outdir dist","Build Node.js application to dist folder"],["xBuild --typeCheck","Type check only without generating output"],["xBuild --config custom.xbuild.ts","Use custom configuration file"]];var At,Je;At=[P({scope:"singleton"})];var Q=class{parseConfigFile(e){return Xe(e).help(!1).version(!1).options({config:we.config}).parseSync()}parseUserArgv(e,t){return t?Xe(e).help(!1).version(!1).options(t).parseSync():{}}enhancedParse(e,t={}){let i=Xe(Yr(e)).locale("en"),o=i.showHelp;return i.showHelp=function(n){return this.group(Object.keys(we),"xBuild Options:"),this.group(Object.keys(t),"user Options:"),o.call(this,n)},i.usage("Usage: xBuild [files..] [options]").command("* [entryPoints..]","Specific files to build (supports glob patterns)",n=>n.positional("entryPoints",{describe:"Specific files to build (supports glob patterns)",type:"string",array:!0})).options(t).options(we).epilogue("For more information, check the documentation https://remotex-labs.github.io/xBuild/").help().alias("help","h").strict().version(),kt.forEach(([n,s])=>{i.example(n,s)}),i.parseSync()}};Je=F(null),Q=A(Je,0,"ArgvModule",At,Q),k(Je,1,Q);import lt from"readline";import{exec as ho}from"child_process";import{cwd as Xr}from"process";import{readdirSync as Jr}from"fs";import{matchesGlob as Qe}from"path";import{join as Qr}from"@remotex-labs/xmap";function Zr(r){let e=[],t=[];for(let i of r)i.startsWith("!")?t.push(i.slice(1)):e.push(i);return{include:e,exclude:t}}function Pt(r,e){for(let t of e)if(t.endsWith(r)||Qe(r,t))return!0;return!1}function ei(r,e){let t=r+"/**";for(let i of e)if(Qe(r,i)||Qe(t,i))return!0;return!1}function Ee(r,e){let{include:t,exclude:i}=Zr(e),o=Object.create(null),s=Xr().length+1,a=r.length+1,c=i.length>0;function l(p){let f;try{f=Jr(p,{withFileTypes:!0})}catch{return}let d=f.length;for(let m=0;m<d;m++){let $=f[m],_=Qr(p,$.name),j=_.slice(a);if($.isDirectory()){(!c||!ei(j,i))&&l(_);continue}if(!(c&&Pt(j,i))&&Pt(j,t)){let Le=_.slice(s),w=j.lastIndexOf("."),ce=w>0?j.slice(0,w):j;o[ce]=Le}}}return l(r),o}var M=class r extends Error{diagnostics;constructor(e,t=[]){super(e),this.name="TypesError",this.diagnostics=t,Object.setPrototypeOf(this,r.prototype)}};var S=class extends y{constructor(e,t={withFrameworkFrames:!0}){super(e),this.reformatStack(this,t)}};var W=class extends y{id;constructor(e,t){super(e.text??"","esBuildError"),this.id=e.id??"",e.detail instanceof Error?(this.stack=e.detail.stack,this.message=e.detail.message,this.reformatStack(e.detail,t)):(this.errorMetadata=L(e,{withFrameworkFrames:!0}),this.stack=H(this.errorMetadata,this.name,this.message,e.notes))}};function ti(r){if(r instanceof y)return r;if(r.detail instanceof y||r.detail instanceof M)return r.detail;if(r.detail instanceof Error)return new W(r,{withFrameworkFrames:!0});if(r.location)return new W(r);if(r.text)return new S(r.text)}function de(r=[],e){for(let t of r){let i=ti(t);i&&e.push(i)}}function me(r){let e={errors:[],warnings:[],metafile:r.metafile,outputFiles:r.outputFiles,mangleCache:r.mangleCache};return de(r.errors,e.errors),de(r.warnings,e.warnings),e}function V(r){return typeof r=="object"&&r!==null&&"errors"in r}import*as Nt from"http";import*as Dt from"https";import{extname as Mt}from"path";import{readFileSync as Bt}from"fs";var Rt=`<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Dark File Browser \u2014 FTP-like</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" /><style>:root{--bg:#0b0f14;--panel:#0f1720;--muted:#9aa4b2;--accent:#E5C07B;--glass:rgba(255,255,255,0.03);--card:#0c1116;--radius:12px;--gap:12px;--shadow:0 6px 18px rgba(0,0,0,0.4);--file-icon-size:40px;font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial}*{box-sizing:border-box;font-style:normal !important}html,body{height:100%;margin:0;font-size:14px;color:#dce7ef;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:radial-gradient(1200px 600px at 10% 10%,rgba(110,231,183,0.04),transparent 8%),linear-gradient(180deg,rgba(255,255,255,0.01),transparent 20%),var(--bg);padding:28px;display:flex;gap:20px;align-items:flex-start;justify-content:center}.app{width:1100px;max-width:98vw;display:flex;gap:18px;padding:18px;border-radius:16px;box-shadow:var(--shadow);border:1px solid rgba(255,255,255,0.03);background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0));overflow:hidden}.sidebar{width:260px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border-radius:var(--radius);padding:14px}.brand{display:flex;gap:12px;align-items:center;margin-bottom:10px}.logo{width:46px;height:46px;border-radius:10px;background:linear-gradient(135deg,#b65b9f 0%,#804b8f 100%);display:flex;align-items:center;justify-content:center;font-weight:700}.brand h1{font-size:16px;margin:0}.muted{color:var(--muted);font-size:13px}.search{margin:12px 0}.search input{width:100%;padding:10px 12px;border-radius:10px;border:1px solid rgba(255,255,255,0.03);background:var(--glass);color:inherit}.quick-list{margin-top:12px}.quick-list a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;background:transparent;color:var(--muted);text-decoration:none;cursor:pointer;transition:color 0.15s ease}.quick-list a:hover{color:var(--accent)}.main{flex:1;display:flex;flex-direction:column}.topbar{display:flex;align-items:center;gap:12px;padding-bottom:12px}.breadcrumbs{list-style:none;display:flex;gap:8px;align-items:center;background:var(--glass);padding:8px 12px;border-radius:var(--radius);margin:0}.breadcrumbs li{display:flex;align-items:center}.breadcrumbs li:not(:last-child)::after{content:'>';margin-left:8px;color:var(--muted)}.breadcrumbs a{color:var(--muted);text-decoration:none;transition:color 0.15s ease}.breadcrumbs a:hover{color:var(--accent)}.list{margin-top:14px;display:grid;grid-template-columns:1fr;gap:10px}.list a{display:flex;text-decoration:none;color:inherit}.folder-row,.file-row{display:flex;gap:12px;align-items:center;padding:10px;border-radius:10px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border:1px solid rgba(255,255,255,0.02);transition:color 0.25s ease}.icon{width:var(--file-icon-size);height:var(--file-icon-size);border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.02);flex-shrink:0;transition:background 0.25s ease,color 0.25s ease}.folder-row:hover,.file-row:hover{color:var(--accent)}.folder-row:hover .icon{background:rgba(152,195,121,0.2)}.file-row:hover .icon{background:rgba(224,108,117,0.2)}.folder-row:hover .icon i{color:#98C379}.file-row:hover .icon i{color:#e09c6c}.meta{display:flex;flex-direction:column}.name{font-weight:600}.sub{color:var(--muted);font-size:13px}.empty{padding:40px;text-align:center;color:var(--muted)}@media (max-width:880px){.app{flex-direction:column;padding:12px}.sidebar,.main{width:100%}}</style></head><body><div class="app"><aside class="sidebar"><div class="brand"><div class="logo">F</div><div><h1>xBuildFTP</h1><div class="muted">Browse & serve files</div></div></div><div class="search"><input placeholder="Search files & folders..."/></div><div class="quick-list"><a href="/">\u{1F3E0} Home</a><a href="\${ up }">\u2B06\uFE0F Up</a></div></aside><main class="main"><div class="topbar"><div class="topbar"><ul class="breadcrumbs"> \${ paths } </ul></div></div> \${ fileList } </main></div></body><script> const searchInput = document.querySelector('.search input'); const listItems = document.querySelectorAll('.list > .folder-row, .list > .file-row'); const emptyMessage = document.querySelector('.empty'); searchInput.addEventListener('input', () => { const query = searchInput.value.toLowerCase(); let anyVisible = false; listItems.forEach(item => { const name = item.querySelector('.name').textContent.toLowerCase(); if (name.includes(query)) { item.style.display = 'flex'; anyVisible = true; } else { item.style.display = 'none'; } }); emptyMessage.style.display = anyVisible ? 'none' : 'block'; }); </script></html>`;import{resolve as oi,join as Ce}from"@remotex-labs/xmap";import{xterm as Ze}from"@remotex-labs/xansi/xterm.component";var ii=`
16
16
  ______ _ _ _
17
17
  | ___ \\ (_) | | |
18
18
  __ _| |_/ /_ _ _| | __| |
@@ -21,7 +21,7 @@ __ _| |_/ /_ _ _| | __| |
21
21
  /_/\\_\\____/ \\__,_|_|_|\\__,_|
22
22
  `;function $t(){return`
23
23
  \r${Ze.burntOrange(ii)}
24
- \rVersion: ${Ze.brightPink("2.5.0")}
24
+ \rVersion: ${Ze.brightPink("2.5.1")}
25
25
  \r`}function I(){return Ze.lightCoral("[xBuild]")}import{readdir as ni,stat as si,readFile as ai}from"fs/promises";import{xterm as Ie}from"@remotex-labs/xansi/xterm.component";var ge=class{constructor(e,t){this.config=e;this.rootDir=oi(t),this.config.port||=0,this.config.host||="localhost"}config;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=Nt.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:Bt(this.config.key??Ce(this.framework.distPath,"..","certs","server.key")),cert:Bt(this.config.cert??Ce(this.framework.distPath,"..","certs","server.crt"))};this.server=Dt.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 si(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 ni(e)).map(l=>{let p=Ce(t,l),f=Mt(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>
@@ -32,7 +32,7 @@ __ _| |_/ /_ _ _| | __| |
32
32
  <div class="icon"><i class="fa-solid fa-file-code"></i></div>
33
33
  <div class="meta"><div class="name">${l}</div><div class="sub">${f}</div></div>
34
34
  </a>
35
- `}).join("");n?n=`<div class="list">${n}</div>`:n='<div class="empty">No files or folders here.</div>';let s="/",a=t.split("/").map(l=>(s+=`${l}/`,`<li><a href="${s}">${l}</a></li>`)).join(""),c=Rt.replace("${ fileList }",n).replace("${ paths }",'<li><a href="/">root</a></li>'+a).replace("${ up }","/"+t.split("/").slice(0,-1).join("/"));i.writeHead(200,{"Content-Type":"text/html"}),i.end(c)}async handleFile(e,t){let i=Mt(e).slice(1)||"txt",o=this.getContentType(i),n=await ai(e);t.writeHead(200,{"Content-Type":o}),t.end(n)}sendNotFound(e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not Found")}sendError(e,t){console.error(I(),t.toString()),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{matchesGlob as jt}from"path";import{stat as ci,watch as li}from"fs/promises";import{normalize as fi,join as pi}from"@remotex-labs/xmap";var he=class{excludes;include;debounceTimer=null;framework=u(b);constructor(e=[],t=["**/*"]){this.include=t,this.excludes=e}async start(e){let t=new Set,i=li(this.framework.rootPath,{recursive:!0});for await(let{filename:o}of i){if(!o)continue;let n=fi(o);if(n.endsWith("~")||!this.include.some(a=>jt(n,a))||this.excludes.some(a=>jt(n,a)))continue;let s=pi(this.framework.rootPath,n);try{if(!(await ci(s)).isFile())continue}catch{}t.add(n),this.debounce(()=>this.handleChangedFiles(e,t))}}async handleChangedFiles(e,t){e?.([...t]),t.clear()}debounce(e,t=150){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}};import Ni from"typescript";import{build as Di}from"esbuild";import{writeFile as Yt,mkdir as ji,readFile as Li}from"fs/promises";import g from"typescript";import ui from"typescript";import{dirname as Lt,relative as di,toPosix as mi}from"@remotex-labs/xmap";var gi=/^#!.*(\r?\n)?/,hi=/export {};\n?/g,yi=/(?:\/\*\*[\s\S]*?\*\/\s*)+(\/\*\*[\s\S]*?\*\/)/g,vi=/^export\s+(?:default\s+)?/gm,xi=/(?<=[:;,{}\[\]()\w"'`])[ \t]*\/\*\*[^\r\n]*?\*\/[ \t]*$/gm;function bi(r){return r.charCodeAt(0)===35&&r.charCodeAt(1)===33?r.replace(gi,""):r}function Si(r){return r.includes("export {}")?r.replace(hi,""):r}function Ei(r){return r=r.replace(xi,""),r.replace(yi,"$1")}function Ht(r){return r.replace(vi,"")}function wi(r){return r.charCodeAt(0)===35||r.includes("export {}")||r.includes("/**")}function Te(r){return wi(r)&&(r=bi(r),r=Si(r),r=Ei(r)),r}function et(r,e){let{outDir:t,rootDir:i,declarationDir:o}=e,n=o||t||Lt(r),s=i||Lt(r),c=di(s,r).replace(/\.tsx?$/,".d.ts"),l=ui.sys.resolvePath(`${n}/${c}`);return mi(l)}var Vt,tt;Vt=[P({scope:"singleton"})];var Z=class{languageService;languageHostService;printer;nodesCache=new Map;filesCache=u(v);constructor(){this.printer=g.createPrinter({newLine:g.NewLineKind.LineFeed})}clear(){this.nodesCache.clear()}get(e){let t=this.filesCache.resolve(e);return this.nodesCache.get(t)}scan(e,t,i){let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this,{languageService:t,languageHostService:i}),n=this.filesCache.getSnapshot(e.fileName).version.toString(),s=this.nodesCache.get(e.fileName);if(s?.version===n)return s;let a=this.initDeclaration(e.fileName,n),c=this.emitDeclaration.call(o,e);return a.content=this.stripImportsExports.call(o,c,a),this.nodesCache.set(e.fileName,a),a}initDeclaration(e,t){return{version:t,fileName:e,content:"",internalDeps:new Set,externalImports:{named:Object.create(null),default:Object.create(null),namespace:Object.create(null)},internalExports:{star:[],exports:[],namespace:Object.create(null)},externalExports:{star:[],exports:Object.create(null),namespace:Object.create(null)}}}resolveModule(e,t){if(!g.isStringLiteral(e))return null;let i=e.text,o=this.languageHostService.resolveModuleName(i,t).resolvedModule?.resolvedFileName;return!o||o.includes("node_modules")?{fileName:i,isExternal:!0}:{fileName:o,isExternal:!1}}addNamedElements(e,t){for(let i of t){let o=i.propertyName?`${i.propertyName.text} as ${i.name.text}`:i.name.text;e.push(o)}}hasExportModifier(e){return g.canHaveModifiers(e)?g.getModifiers(e)?.some(i=>i.kind===g.SyntaxKind.ExportKeyword)??!1:!1}emitDeclaration(e){let i=this.languageService.getEmitOutput(e.fileName,!0,!0).outputFiles[0]?.text;if(!i)throw new Error(`Failed to emit declaration: ${e.fileName}`);return g.createSourceFile(e.fileName.replace(/\.tsx?$/,".d.ts"),i,g.ScriptTarget.Latest,!0)}stripImportsExports(e,t){let i=[],o=[];for(let c of e.statements){if(g.isImportDeclaration(c)){this.handleImport(c,t,i);continue}if(g.isExportDeclaration(c)){this.handleExport(c,t);continue}this.hasExportModifier(c)&&this.extractExportName(c,t),o.push(c)}let n=g.factory.createNodeArray(o),s=this.printer.printList(g.ListFormat.MultiLine,n,e),a=Ht(Te(s));for(let c of i)if(c.includes(" as ")){let[l,p]=c.split(" as ");a=a.replace(new RegExp(`\\b${p}\\b`,"g"),l)}else a=a.replace(new RegExp(`\\b${c}\\.`,"g"),"");return a}handleImport(e,t,i){let{importClause:o,moduleSpecifier:n}=e;if(!o||!n)return;let s=this.resolveModule(n,t.fileName);if(!s)return;let{fileName:a,isExternal:c}=s;if(!c){t.internalDeps.add(a);let{namedBindings:p}=o;if(!p)return;g.isNamespaceImport(p)?i.push(p.name.text):g.isNamedImports(p)&&this.addNamedElements(i,p.elements);return}if(!o){t.externalImports.namespace[a]="";return}o.name&&(t.externalImports.default[a]=o.name.text);let{namedBindings:l}=o;l&&(g.isNamespaceImport(l)?t.externalImports.namespace[l.name.text]=a:g.isNamedImports(l)&&this.addNamedElements(t.externalImports.named[a]??=[],l.elements))}handleExport(e,t){let{moduleSpecifier:i,exportClause:o}=e;if(!i)return;let n=this.resolveModule(i,t.fileName);if(!n)return;let{fileName:s,isExternal:a}=n;if(a||t.internalDeps.add(s),!o){a?t.externalExports.star.push(s):t.internalExports.star.push(s);return}if(g.isNamespaceExport(o)){a?t.externalExports.namespace[o.name.text]=s:t.internalExports.namespace[o.name.text]=s;return}g.isNamedExports(o)&&(a?this.addNamedElements(t.externalExports.exports[s]??=[],o.elements):this.addNamedElements(t.internalExports.exports,o.elements))}extractExportName(e,t){if(g.isVariableStatement(e)){for(let i of e.declarationList.declarations)g.isIdentifier(i.name)&&t.internalExports.exports.push(i.name.text);return}(g.isEnumDeclaration(e)||g.isClassDeclaration(e)||g.isFunctionDeclaration(e)||g.isInterfaceDeclaration(e)||g.isTypeAliasDeclaration(e))&&e.name&&g.isIdentifier(e.name)&&t.internalExports.exports.push(e.name.text)}};tt=F(null),Z=A(tt,0,"GraphModel",Vt,Z),k(tt,1,Z);import G from"typescript";import{matchesGlob as Mi}from"path";import{relative as Bi}from"@remotex-labs/xmap";import{mkdir as Ci,writeFile as Ii}from"fs/promises";import{join as Ti,dirname as Oi}from"@remotex-labs/xmap";var _t=`/**
35
+ `}).join("");n?n=`<div class="list">${n}</div>`:n='<div class="empty">No files or folders here.</div>';let s="/",a=t.split("/").map(l=>(s+=`${l}/`,`<li><a href="${s}">${l}</a></li>`)).join(""),c=Rt.replace("${ fileList }",n).replace("${ paths }",'<li><a href="/">root</a></li>'+a).replace("${ up }","/"+t.split("/").slice(0,-1).join("/"));i.writeHead(200,{"Content-Type":"text/html"}),i.end(c)}async handleFile(e,t){let i=Mt(e).slice(1)||"txt",o=this.getContentType(i),n=await ai(e);t.writeHead(200,{"Content-Type":o}),t.end(n)}sendNotFound(e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not Found")}sendError(e,t){console.error(I(),t.toString()),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{matchesGlob as jt}from"path";import{stat as ci,watch as li}from"fs/promises";import{normalize as fi,join as pi}from"@remotex-labs/xmap";var he=class{excludes;include;debounceTimer=null;framework=u(b);constructor(e=[],t=["**/*"]){this.include=t,this.excludes=e}async start(e){let t=new Set,i=li(this.framework.rootPath,{recursive:!0});for await(let{filename:o}of i){if(!o)continue;let n=fi(o);if(n.endsWith("~")||!this.include.some(a=>jt(n,a))||this.excludes.some(a=>jt(n,a)))continue;let s=pi(this.framework.rootPath,n);try{if(!(await ci(s)).isFile())continue}catch{}t.add(n),this.debounce(()=>this.handleChangedFiles(e,t))}}async handleChangedFiles(e,t){e?.([...t]),t.clear()}debounce(e,t=150){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}};import Ni from"typescript";import{build as Di}from"esbuild";import{writeFile as Yt,mkdir as ji,readFile as Li}from"fs/promises";import g from"typescript";import ui from"typescript";import{dirname as Lt,relative as di,toPosix as mi}from"@remotex-labs/xmap";var gi=/^#!.*(\r?\n)?/,hi=/export {};\n?/g,yi=/(?:\/\*\*[\s\S]*?\*\/\s*)+(\/\*\*[\s\S]*?\*\/)/g,vi=/^export\s+(?:default\s+)?/gm,xi=/(?<=[:;,{}\[\]()\w"'`])[ \t]*\/\*\*[^\r\n]*?\*\/[ \t]*$/gm;function bi(r){return r.charCodeAt(0)===35&&r.charCodeAt(1)===33?r.replace(gi,""):r}function Si(r){return r.includes("export {}")?r.replace(hi,""):r}function wi(r){return r=r.replace(xi,""),r.replace(yi,"$1")}function Ht(r){return r.replace(vi,"")}function Ei(r){return r.charCodeAt(0)===35||r.includes("export {}")||r.includes("/**")}function Te(r){return Ei(r)&&(r=bi(r),r=Si(r),r=wi(r)),r}function et(r,e){let{outDir:t,rootDir:i,declarationDir:o}=e,n=o||t||Lt(r),s=i||Lt(r),c=di(s,r).replace(/\.tsx?$/,".d.ts"),l=ui.sys.resolvePath(`${n}/${c}`);return mi(l)}var Vt,tt;Vt=[P({scope:"singleton"})];var Z=class{languageService;languageHostService;printer;nodesCache=new Map;filesCache=u(v);constructor(){this.printer=g.createPrinter({newLine:g.NewLineKind.LineFeed})}clear(){this.nodesCache.clear()}get(e){let t=this.filesCache.resolve(e);return this.nodesCache.get(t)}scan(e,t,i){let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this,{languageService:t,languageHostService:i}),n=this.filesCache.getSnapshot(e.fileName).version.toString(),s=this.nodesCache.get(e.fileName);if(s?.version===n)return s;let a=this.initDeclaration(e.fileName,n),c=this.emitDeclaration.call(o,e);return a.content=this.stripImportsExports.call(o,c,a),this.nodesCache.set(e.fileName,a),a}initDeclaration(e,t){return{version:t,fileName:e,content:"",internalDeps:new Set,externalImports:{named:Object.create(null),default:Object.create(null),namespace:Object.create(null)},internalExports:{star:[],exports:[],namespace:Object.create(null)},externalExports:{star:[],exports:Object.create(null),namespace:Object.create(null)}}}resolveModule(e,t){if(!g.isStringLiteral(e))return null;let i=e.text,o=this.languageHostService.resolveModuleName(i,t).resolvedModule?.resolvedFileName;return!o||o.includes("node_modules")?{fileName:i,isExternal:!0}:{fileName:o,isExternal:!1}}addNamedElements(e,t){for(let i of t){let o=i.propertyName?`${i.propertyName.text} as ${i.name.text}`:i.name.text;e.push(o)}}hasExportModifier(e){return g.canHaveModifiers(e)?g.getModifiers(e)?.some(i=>i.kind===g.SyntaxKind.ExportKeyword)??!1:!1}emitDeclaration(e){let i=this.languageService.getEmitOutput(e.fileName,!0,!0).outputFiles[0]?.text;if(!i)throw new Error(`Failed to emit declaration: ${e.fileName}`);return g.createSourceFile(e.fileName.replace(/\.tsx?$/,".d.ts"),i,g.ScriptTarget.Latest,!0)}stripImportsExports(e,t){let i=[],o=[],n=[];for(let l of e.statements){if(g.isImportDeclaration(l)){this.handleImport(l,t,i,o);continue}if(g.isExportDeclaration(l)){this.handleExport(l,t);continue}this.hasExportModifier(l)&&this.extractExportName(l,t),n.push(l)}let s=g.factory.createNodeArray(n),a=this.printer.printList(g.ListFormat.MultiLine,s,e),c=Ht(Te(a));for(let[l,p]of o)c=c.replace(new RegExp(`\\b${p}\\b`,"g"),l);for(let l of i)c=c.replace(new RegExp(`\\b${l}\\.`,"g"),"");return c}handleImport(e,t,i,o){let{importClause:n,moduleSpecifier:s}=e;if(!n||!s)return;let a=this.resolveModule(s,t.fileName);if(!a)return;let{fileName:c,isExternal:l}=a;if(!l){t.internalDeps.add(c);let{namedBindings:f}=n;if(!f)return;if(g.isNamespaceImport(f))i.push(f.name.text);else if(g.isNamedImports(f))for(let d of f.elements)d.propertyName&&o.push([d.propertyName.text,d.name.text]);return}if(!n){t.externalImports.namespace[c]="";return}n.name&&(t.externalImports.default[c]=n.name.text);let{namedBindings:p}=n;p&&(g.isNamespaceImport(p)?t.externalImports.namespace[p.name.text]=c:g.isNamedImports(p)&&this.addNamedElements(t.externalImports.named[c]??=[],p.elements))}handleExport(e,t){let{moduleSpecifier:i,exportClause:o}=e;if(!i)return;let n=this.resolveModule(i,t.fileName);if(!n)return;let{fileName:s,isExternal:a}=n;if(a||t.internalDeps.add(s),!o){a?t.externalExports.star.push(s):t.internalExports.star.push(s);return}if(g.isNamespaceExport(o)){a?t.externalExports.namespace[o.name.text]=s:t.internalExports.namespace[o.name.text]=s;return}g.isNamedExports(o)&&(a?this.addNamedElements(t.externalExports.exports[s]??=[],o.elements):this.addNamedElements(t.internalExports.exports,o.elements))}extractExportName(e,t){if(g.isVariableStatement(e)){for(let i of e.declarationList.declarations)g.isIdentifier(i.name)&&t.internalExports.exports.push(i.name.text);return}(g.isEnumDeclaration(e)||g.isClassDeclaration(e)||g.isFunctionDeclaration(e)||g.isInterfaceDeclaration(e)||g.isTypeAliasDeclaration(e))&&e.name&&g.isIdentifier(e.name)&&t.internalExports.exports.push(e.name.text)}};tt=F(null),Z=A(tt,0,"GraphModel",Vt,Z),k(tt,1,Z);import G from"typescript";import{matchesGlob as Mi}from"path";import{relative as Bi}from"@remotex-labs/xmap";import{mkdir as Ci,writeFile as Ii}from"fs/promises";import{join as Ti,dirname as Oi}from"@remotex-labs/xmap";var _t=`/**
36
36
  * This file was automatically generated by xBuild.
37
37
  * DO NOT EDIT MANUALLY.
38
38
  */
@@ -42,14 +42,14 @@ __ _| |_/ /_ _ _| | __| |
42
42
  `)}
43
43
  };`)}return l.length>0&&o.push(...l),o.join(`
44
44
  `)}};import{dirname as Fi}from"@remotex-labs/xmap";import{mkdir as ki,writeFile as Ai}from"fs/promises";import{xterm as Pi}from"@remotex-labs/xansi/xterm.component";var Fe=class r{constructor(e,t){this.languageService=e;this.languageHostService=t}languageService;languageHostService;static emittedVersions=new Map;static clearCache(){this.emittedVersions.clear()}async emit(e){let t=this.languageService.getProgram();if(!t)throw new Error(`${Pi.deepOrange("[TS]")} Language service program is not available`);let i=this.languageHostService.getCompilationSettings();e&&(i={...i,outDir:e});let o=[],n=t.getSourceFiles();for(let s=0;s<n.length;s++){let a=n[s];this.shouldEmitFile(a,t,i)&&o.push(a)}o.length!==0&&await Promise.all(o.map(s=>this.emitSingleDeclaration(s,i)))}shouldEmitFile(e,t,i){if(e.isDeclarationFile||t.isSourceFileFromExternalLibrary(e))return!1;let o=et(e.fileName,i),n=r.emittedVersions.get(o),s=this.languageHostService.getScriptVersion(e.fileName);return!n||n!==s?(r.emittedVersions.set(o,s),!0):!1}async emitSingleDeclaration(e,t){let i=this.languageService.getEmitOutput(e.fileName,!0);if(i.emitSkipped)return;let o=i.outputFiles[0].text,n=et(e.fileName,t);o=Te(o),o=this.languageHostService.resolveAliases(o,e.fileName,".d.ts"),await ki(Fi(n),{recursive:!0}),await Ai(n,o,"utf8")}};import te from"typescript";import{relative as Ri,dirname as $i}from"@remotex-labs/xmap";var re=class r{constructor(e={}){this.compilerOptions=e;this.alias=r.generateAliasRegex(e),this.moduleResolutionCache=te.createModuleResolutionCache(process.cwd(),t=>t,this.compilerOptions)}compilerOptions;static sys=te.sys;alias;aliasCache=new Map;moduleResolutionCache;trackFiles=new Set;filesCache=u(v);get aliasRegex(){return this.alias}set options(e){this.compilerOptions=e,this.alias=r.generateAliasRegex(e),this.moduleResolutionCache=te.createModuleResolutionCache(process.cwd(),t=>t,this.compilerOptions)}static reload(){let e=u(v);e.getTrackedFilePaths().map(t=>{e.touchFile(t)})}touchFile(e){return this.trackFiles.add(this.filesCache.resolve(e)),this.filesCache.touchFile(e)}touchFiles(e){for(let t of e)this.touchFile(t)}getCompilationSettings(){return this.compilerOptions}fileExists(e){return r.sys.fileExists(e)}readFile(e,t){return r.sys.readFile(e,t)}readDirectory(e,t,i,o,n){return r.sys.readDirectory(e,t,i,o,n)}getDirectories(e){return r.sys.getDirectories(e)}directoryExists(e){return r.sys.directoryExists(e)}getCurrentDirectory(){return r.sys.getCurrentDirectory()}getScriptFileNames(){return[...this.trackFiles]}getDefaultLibFileName(e){return te.getDefaultLibFilePath(e)}getScriptVersion(e){let t=this.filesCache.getSnapshot(e);return this.trackFiles.add(this.filesCache.resolve(e)),t?t.version.toString():"0"}hasScriptSnapshot(e){return this.trackFiles.has(this.filesCache.resolve(e))}getScriptSnapshot(e){let t=this.filesCache.getSnapshot(e);return this.trackFiles.add(this.filesCache.resolve(e)),t?t.contentSnapshot:this.touchFile(e).contentSnapshot}resolveModuleName(e,t){return te.resolveModuleName(e,t,this.compilerOptions,te.sys,this.moduleResolutionCache)}resolveModuleFileName(e,t){if(this.aliasCache.has(e))return this.aliasCache.get(e);let o=this.resolveModuleName(e,t).resolvedModule?.resolvedFileName;return this.aliasCache.set(e,o),o}resolveAliases(e,t,i=""){return this.alias?e.replace(this.alias,(o,n)=>{let s=this.resolveModuleFileName(n,t);if(!s)return o;let a=s.replace(/\.tsx?$/,i),c=Ri($i(t),a);return o.replace(n,c.startsWith(".")?c:"./"+c)}):e}static generateAliasRegex(e){let t=e.paths;if(!t||Object.keys(t).length<1)return;let i=Object.keys(t).map(o=>o.replace("/*","").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`(?:^|\\s)(?:import|export)\\s+(?:type\\s+)?(?:[^'"]*from\\s+)?['"]((${i})[^'"]*)['"];?`,"gm")}};var Ut,rt;Ut=[P({providers:[{useValue:"tsconfig.json"}]})];var N=class N{constructor(e="tsconfig.json"){this.configPath=e;let{config:t,host:i,service:o}=this.acquireLanguageService();this.config=t,this.languageService=o,this.languageHostService=i,this.languageHostService.touchFiles(this.config.fileNames),this.emitterService=new Fe(o,i),this.bundlerService=new Oe(o,i)}configPath;config;languageService;languageHostService;static serviceCache=new Map;emitterService;bundlerService;check(e){let t=this.languageService.getProgram();if(!t)return[];let i=e&&e.length>0?e.map(o=>t.getSourceFile(o)):this.languageService.getProgram()?.getSourceFiles();return i?i.filter(o=>this.shouldCheckFile(o)).flatMap(o=>this.collectDiagnostics(o)):[]}touchFiles(e){for(let t of e)if(this.languageHostService.hasScriptSnapshot(t)&&this.languageHostService.touchFile(t),t.includes(this.configPath)){let i=N.serviceCache.get(this.configPath);i.config=this.parseConfig(),i.host.options=i.config.options}}async emitBundle(e,t){await this.bundlerService.emit(e,t)}async emit(e){await this.emitterService.emit(e)}dispose(e){let t=N.serviceCache.get(e);t&&(t.refCount--,N.cleanupUnusedServices())}static cleanupUnusedServices(){for(let[e,t]of this.serviceCache)t.refCount<1&&(t.service.dispose(),this.serviceCache.delete(e))}shouldCheckFile(e){if(!e||e.fileName.includes("node_modules"))return!1;if(this.config.raw?.exclude){for(let t of this.config.raw.exclude)if(Mi(Bi(this.config.options.rootDir,e.fileName),t))return!1}return!e.isDeclarationFile}collectDiagnostics(e){return[...this.languageService.getSemanticDiagnostics(e.fileName),...this.languageService.getSyntacticDiagnostics(e.fileName),...this.languageService.getSuggestionDiagnostics(e.fileName)].map(t=>this.formatDiagnostic(t))}acquireLanguageService(){let e=N.serviceCache.get(this.configPath);return e?(e.refCount++,e):this.createLanguageService()}createLanguageService(){let e=this.parseConfig(),t=new re(e.options),i=G.createLanguageService(t,G.createDocumentRegistry()),o={config:e,host:t,service:i,refCount:1};return N.serviceCache.set(this.configPath,o),o}parseConfig(){let e=G.getParsedCommandLineOfConfigFile(this.configPath,{sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0},{...G.sys,onUnRecoverableConfigFileDiagnostic:()=>{}});return e||(e={options:{strict:!0,target:G.ScriptTarget.ESNext,module:G.ModuleKind.NodeNext,sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:G.ModuleResolutionKind.NodeNext},errors:[],fileNames:[],projectReferences:void 0}),e.options={...e.options,rootDir:e.options?.rootDir??process.cwd()},e}formatDiagnostic(e){let t={message:G.flattenDiagnosticMessageText(e.messageText,`
45
- `),category:e.category};if(e.file&&e.start!==void 0){let{line:i,character:o}=e.file.getLineAndCharacterOfPosition(e.start);t.file=e.file.fileName,t.line=i+1,t.column=o+1,t.code=e.code}return t}};rt=F(null),N=A(rt,0,"TypescriptService",Ut,N),k(rt,1,N);var ie=N;import{cwd as ke}from"process";import{build as it}from"esbuild";var zt={write:!1,bundle:!0,minify:!0,outdir:`${ke()}`,format:"esm",target:"esnext",platform:"browser",sourcemap:"external",mangleQuoted:!0,sourcesContent:!0,preserveSymlinks:!0};async function Wt(r,e={}){try{return await it({absWorkingDir:ke(),...zt,...e,metafile:!0,entryPoints:r})}catch(t){if(V(t)){let i=new AggregateError([],"Failed to build entryPoints");throw de(t.errors,i.errors),i}throw t}}async function Gt(r,e,t={}){return await it({absWorkingDir:ke(),...zt,...t,stdin:{loader:"ts",contents:r,resolveDir:ke(),sourcefile:e},write:!1,metafile:!0,logLevel:"silent",sourcemap:"external"})}async function Kt(r,e={}){try{return await it({...e,outdir:"tmp",write:!1,bundle:!0,outfile:void 0,metafile:!0,packages:"external",logLevel:"silent",entryPoints:r})}catch(t){if(V(t)){let i=new AggregateError([],"Failed to analyze entryPoint");throw de(t.errors,i.errors),i}throw t}}import{relative as Hi,resolve as Vi,join as Xt,dirname as _i}from"@remotex-labs/xmap";function qt(r,e){if(Array.isArray(e)){let t={};return e.length>0&&typeof e[0]=="object"?e.forEach(i=>{t[i.out]=i.in}):typeof e[0]=="string"&&(t=we(r,e)),t}else{if(e&&typeof e=="object")return e;if(e===void 0)return}throw new S("Unsupported entry points format")}var Ae=class{constructor(e,t,i,o={}){this.name=e;this.lifecycle=t;this.buildConfig=i;this.argv=o;if(!this.buildConfig?.esbuild)throw new S(`Variant '${this.name}' not found configuration`);this.tsConfigPath=this.buildConfig.esbuild.tsconfig??"tsconfig.json",this.typescriptModule=new ie(this.tsConfigPath),this.buildConfig=this.initializeConfig(this.getConfig(this.buildConfig,this.configService.getValue().common)),this.lifecycle.onEnd(this.end.bind(this),`${this.name}-core`),this.lifecycle.onStart(this.start.bind(this),`${this.name}-core`),this.configUnsubscribe=this.configService.select(n=>({variantConfig:n.variants?.[this.name],commonConfig:n.common})).subscribe(this.handleConfigChange.bind(this),n=>{throw n})}name;lifecycle;buildConfig;argv;dependenciesFile;active=!0;tsConfigPath;typescriptModule;configUnsubscribe;configService=u(x);get typescript(){return this.typescriptModule}get config(){return this.buildConfig}get dependencies(){return this.dependenciesFile??{}}dispose(){this.configUnsubscribe(),this.typescriptModule.dispose(this.tsConfigPath)}touchFiles(e){this.typescriptModule.touchFiles(e)}async check(){return this.dependenciesFile||(this.dependenciesFile=await this.buildDependencyMap()),this.typescriptModule.check(Object.values(this.dependenciesFile))}async build(){if(!this.active)return;this.applyInjections();let e=Object.assign({},this.buildConfig.esbuild);if(this.dependenciesFile=await this.buildDependencyMap(),this.buildConfig.esbuild.bundle===!1&&Object.assign(e,{entryPoints:this.dependenciesFile}),this.config.define&&e.define)for(let[t,i]of Object.entries(this.config.define))typeof i=="function"&&(e.define[t]=JSON.stringify(i()));try{let t=await Di(e);return await this.packageTypeComponent(),t}catch(t){if(V(t)){if(t.errors.filter(o=>o.location).length>0)throw t;return{errors:t?.errors??[],warnings:t?.warnings??[]}}}}getConfig(e,t={}){return e?z({},t,e):null}async start(){let e={errors:[],warnings:[]};if(!this.buildConfig.types)return e;let t=this.typescriptModule.check(Object.values(this.dependenciesFile??{}));if(t.length===0)return e;if(typeof this.buildConfig.types=="object"&&!this.buildConfig.types.failOnError){let o=new M("Type checking failed",t);e.warnings?.push({detail:o,location:void 0})}else{let o=[],n=[],s=new M("Type checking failed",o),a=new M("Type checking failed",n);for(let c of t)(c.category===Ni.DiagnosticCategory.Error?o:n).push(c);o.length&&e.errors?.push({detail:s,location:void 0}),n.length&&e.warnings?.push({detail:a,location:void 0})}return e}async end(e){if(e.buildResult.errors?.length>0)return;let t={errors:[],warnings:[]};if(typeof e.buildResult.metafile?.outputs=="object"){let s=Object.keys(e.buildResult.metafile?.outputs);for(let a of s){if(!a.endsWith(".map"))continue;let c=_i(a),l=await Li(a,"utf8"),p=JSON.parse(l);p.sources=p.sources.map(f=>f.startsWith("http")?f:Xt(c,f)),await Yt(a,JSON.stringify(p),"utf8")}}if(!this.buildConfig.declaration)return;let i=this.buildConfig.declaration,o=typeof i=="object"?i.bundle!==!1:!0,n=typeof i=="object"?i.outDir:void 0;try{o?await this.typescriptModule.emitBundle(this.buildConfig.esbuild.entryPoints,n):await this.typescriptModule.emit(n)}catch(s){t.warnings?.push({detail:s,location:void 0})}return t}registerConfigHooks(e){if(!e)return;let{onStart:t,onResolve:i,onLoad:o,onEnd:n,onSuccess:s}=e;t&&this.lifecycle.onStart(t),i&&this.lifecycle.onResolve(i),o&&this.lifecycle.onLoad(o),n&&this.lifecycle.onEnd(n),s&&this.lifecycle.onSuccess(s)}async packageTypeComponent(){let e=this.buildConfig.esbuild.outdir??"dist",t=this.buildConfig.esbuild.format==="esm"?"module":"commonjs";await ji(e,{recursive:!0}),await Yt(Xt(e,"package.json"),`{"type": "${t}"}`)}initializeConfig(e){if(!e)throw new S(`Variant '${this.name}' not found configuration`);if(!e.esbuild.entryPoints&&!e.esbuild.stdin)throw new S("Entry points are required in esbuild configuration");let t=e.define,i=t?Object.fromEntries(Object.entries(t).flatMap(([o,n])=>typeof n=="function"?[]:[[o,JSON.stringify(n)]])):void 0;return this.registerConfigHooks(e.lifecycle),e.esbuild.entryPoints=qt(this.typescriptModule.config.options.rootDir??process.cwd(),e.esbuild.entryPoints),e.esbuild=Object.assign({},e.esbuild,{define:i,logLevel:"silent",plugins:[this.lifecycle.create()]}),e}async handleConfigChange({variantConfig:e,commonConfig:t}){this.active=!1;let i=this.getConfig(e,t);i&&(this.active=!0,this.buildConfig=this.initializeConfig(i),i.esbuild.outdir&&i.esbuild.outfile&&(this.buildConfig.esbuild.outdir=void 0),i.esbuild.tsconfig&&i.esbuild.tsconfig!==this.tsConfigPath&&(this.typescriptModule.dispose(this.tsConfigPath),this.tsConfigPath=i.esbuild.tsconfig,this.typescriptModule=new ie(this.tsConfigPath)))}stripExtension(e){let t=e.lastIndexOf(".");return t>0?e.substring(0,t):e}async buildDependencyMap(){let{esbuild:e}=this.buildConfig,t={...e,plugins:void 0},{metafile:i}=await Kt(e.entryPoints,t),o={};for(let n of Object.keys(i.inputs)){let s=Hi(this.typescriptModule.config.options.rootDir,Vi(n)),a=this.stripExtension(s);o[a]=n}return o}injectTextBlock(e){let t=this.buildConfig[e];if(!t)return;let i=this.buildConfig.esbuild;i[e]??={};for(let[o,n]of Object.entries(t))i[e][o]=typeof n=="function"?n(this.name,this.argv):n}applyInjections(){this.injectTextBlock("banner"),this.injectTextBlock("footer")}};import{readFile as Ui}from"fs/promises";import{resolve as zi}from"@remotex-labs/xmap";var Pe=class{constructor(e,t){this.variantName=e;this.argv=t}variantName;argv;filesModel=u(v);endHooks=new Map;loadHooks=new Map;startHooks=new Map;successHooks=new Map;resolveHooks=new Map;onStart(e,t=this.variantName){e&&this.startHooks.set(t,e)}onEnd(e,t=this.variantName){e&&this.endHooks.set(t,e)}onSuccess(e,t=this.variantName){e&&this.successHooks.set(t,e)}onResolve(e,t=this.variantName){e&&this.resolveHooks.set(t,e)}onLoad(e,t=this.variantName){e&&this.loadHooks.set(t,e)}clearAll(){this.endHooks.clear(),this.loadHooks.clear(),this.startHooks.clear(),this.successHooks.clear(),this.resolveHooks.clear()}create(){return{name:this.variantName,setup:e=>{let t={argv:this.argv,options:e.initialOptions,variantName:this.variantName,stage:{startTime:new Date}};e.initialOptions.metafile=!0,this.startHooks.size>0&&e.onStart(this.executeStartHooks.bind(this,t,e)),(this.endHooks.size>0||this.successHooks.size>0)&&e.onEnd(this.executeEndHooks.bind(this,t)),this.resolveHooks.size>0&&e.onResolve({filter:/.*/},this.executeResolveHooks.bind(this,t)),this.loadHooks.size>0&&e.onLoad({filter:/.*/},this.executeLoadHooks.bind(this,t))}}}pushError(e,t,i,o=this.variantName){e.push({id:t,detail:i,location:null,pluginName:o})}async executeStartHooks(e,t){e.stage.startTime=new Date;let i=[],o=[],n={build:t,...e};for(let[s,a]of this.startHooks.entries())try{let c=await a(n);c?.errors&&i.push(...c.errors),c?.warnings&&o.push(...c.warnings)}catch(c){this.pushError(i,"startHook",c,s)}return{errors:i,warnings:o}}async executeEndHooks(e,t){let{errors:i,warnings:o}=t,n=Date.now()-e.stage.startTime.getTime(),s={buildResult:t,duration:n,...e};for(let[a,c]of this.endHooks.entries())try{let l=await c(s);l?.errors&&i.push(...l.errors),l?.warnings&&o.push(...l.warnings)}catch(l){this.pushError(i,"endHook",l,a)}if(t.errors.length===0)for(let[a,c]of this.successHooks.entries())try{await c(s)}catch(l){this.pushError(i,"endHook",l,a)}}async executeResolveHooks(e,t){let i={errors:[]},o={args:t,...e};for(let[n,s]of this.resolveHooks.entries())try{let a=await s(o);if(!a)continue;i={...i,...a}}catch(a){this.pushError(i.errors,"endResolve",a,n)}return i}async executeLoadHooks(e,t){let i=[],o=[],n="default",s=zi(t.path),a=this.filesModel.getOrTouchFile(s),c;try{c=a?.contentSnapshot?a.contentSnapshot.text:await Ui(s,"utf8")}catch{return e.options.logOverride?.["lifecycle-file-ignored"]!=="silent"&&o.push({id:"",text:`${t.path} ignored`,pluginName:"lifecycle"}),{warnings:o,errors:i,loader:n}}for(let[l,p]of this.loadHooks.entries())try{let f=await p({contents:c,loader:n,args:t,...e});if(!f)continue;f.contents!==void 0&&(c=f.contents),f.loader&&(n=f.loader),f.errors&&i.push(...f.errors),f.warnings&&o.push(...f.warnings)}catch(f){this.pushError(i,"loadHook",f,l)}return{contents:c,loader:n,errors:i,warnings:o}}};import h from"typescript";import{createSourceFile as co}from"typescript";import{highlightCode as or}from"@remotex-labs/xmap/highlighter.component";import D from"typescript";var Wi="$$ifdef";function Gi(r,e,t,i=!1){let o=i?"export function ":"function ";return D.isArrowFunction(e)||D.isFunctionExpression(e)?Ki(r,e,t,o):`${i?"export const ":"const "}${r} = ${e.getText(t)};`}function Ki(r,e,t,i){let n=e.modifiers?.some(l=>l.kind===D.SyntaxKind.AsyncKeyword)??!1?"async ":"",s=e.parameters.map(l=>l.getText(t)).join(", "),a=e.type?`: ${e.type.getText(t)}`:"",c=qi(e,t);return`${n}${i}${r}(${s})${a} ${c}`}function qi(r,e){let t=r.body.getText(e);return D.isArrowFunction(r)&&!D.isBlock(r.body)?`{ return ${t}; }`:t}function Yi(r,e,t="",i="();"){return D.isArrowFunction(r)||D.isFunctionExpression(r)?`${r.modifiers?.some(s=>s.kind===D.SyntaxKind.AsyncKeyword)??!1?"async ":""}${t}(${r.getText(e)})${i}`:t?`${t}${r.getText(e)}`:`(() => { return ${r.getText(e)}; })${i}`}function Jt(r,e,t){let i=r in t&&!!t[r];return e===Wi===i}function Qt(r,e,t,i){let[o,n]=e.arguments;if(!D.isStringLiteral(o))return!1;let s=e.expression.text,a=o.text;if(!Jt(a,s,i.defines))return"undefined";let c=r.name.getText(i.sourceFile);return Gi(c,n,i.sourceFile,t)}function Re(r,e,t,i=!1,o){let[n,s]=r.arguments;if(!D.isStringLiteral(n))return!1;let a=n.text,c=r.expression.text;if(!Jt(a,c,e.defines))return"";let l="",p=t?.name.getText(e.sourceFile);return p&&(l=i?`export const ${p} = `:`const ${p} = `),Yi(s,e.sourceFile,l,o)}import B from"typescript";import{createRequire as Qi}from"module";var $e=class extends y{constructor(e,t=0){super(e.message,"InlineError"),this.errorMetadata=L(e,{lineOffset:t}),this.stack=H(this.errorMetadata,this.name,this.message)}};import{Script as Xi,createContext as Ji}from"vm";async function Zt(r,e={},t={}){let i=new Xi(r,t),o=Ji(e);return await i.runInContext(o,{breakOnSigint:!0,displayErrors:!1})}import{dirname as Zi,relative as eo}from"@remotex-labs/xmap";async function er(r,e,t){let[i,o]=(await Gt(r,e.sourceFile.fileName,{bundle:!0,format:"cjs",platform:"node",packages:"external"})).outputFiles;try{let n={exports:{}},s=Qi(e.sourceFile.fileName),a=to(e.sourceFile.fileName,n,s);a.context=e.context;let c=await Zt(o.text,a,{filename:e.sourceFile.fileName});return c===null?"undefined":typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}catch(n){ro(n,e,i.text,t)}return"undefined"}function to(r,e,t){return{...globalThis,Error,RegExp,process,Buffer,module:e,require:t,console,setTimeout,setInterval,clearTimeout,clearInterval,ReferenceError,__dirname:Zi(r),__filename:r}}function ro(r,e,t,i){(!r||typeof r!="object"||!("stack"in r))&&(r=new Error(String(r)));let o=i.getStart(e.sourceFile),{line:n}=e.sourceFile.getLineAndCharacterOfPosition(o);u(b).setSource(t,e.sourceFile.fileName);let s=new $e(r,n);e.errors.push({text:s.message,detail:s})}function io(r,e){let t=null,i=o=>{if(!t){if(B.isFunctionDeclaration(o)&&o.name?.text===r){t=o;return}B.isVariableStatement(o)&&(t=oo(o,r),t)||B.forEachChild(o,i)}};return i(e),t}function oo(r,e){for(let t of r.declarationList.declarations)if(B.isIdentifier(t.name)&&t.name.text===e&&t.initializer&&(B.isArrowFunction(t.initializer)||B.isFunctionExpression(t.initializer)))return t.initializer;return null}function tr(r){return`module.exports = (${r})();`}function no(r){return r&B.NodeFlags.Const?"const":r&B.NodeFlags.Let?"let":"var"}function rr(r,e){return r?B.isIdentifier(r)?so(r,e):B.isArrowFunction(r)||B.isFunctionExpression(r)?{node:r,data:tr(r.getText(e.sourceFile))}:{node:r,data:r.getText(e.sourceFile)}:null}function so(r,e){let t=io(r.text,e.sourceFile);return t?{node:t,data:tr(t.getText(e.sourceFile))}:(ao(r.text,e,r),{data:"",node:r})}function ao(r,e,t){let i=t.getStart(e.sourceFile),{line:o,character:n}=e.sourceFile.getLineAndCharacterOfPosition(i),s=eo(".",e.sourceFile.fileName);e.warnings.push({text:`Function $$inline(${r}); not found in ${s}`,location:{line:o+1,column:n,file:e.sourceFile.fileName,lineText:"asd"}})}async function ir(r,e,t,i,o){let n=t.arguments[0],s=rr(n,o);if(!s)return!1;let a=await er(s.data,o,s.node),c=no(e.declarationList.flags),l=i?"export ":"",p=r.name.getText(o.sourceFile);return`${l}${c} ${p} = ${a};`}async function ot(r,e){let t=r[0],i=rr(t,e);return i?er(i.data,e,i.node):!1}var K=["$$ifdef","$$ifndef","$$inline"];function nt(r,e){return K.some(t=>r.getText(e).includes(t))}function nr(r){return r===K[2]?1:2}async function lo(r,e,t){let i=!1;for(let o of r.declarationList.declarations){let n="",s,a=o.initializer;if(!a||(h.isCallExpression(a)&&h.isIdentifier(a.expression)?s=a:h.isCallExpression(a)&&h.isCallExpression(a.expression)&&h.isIdentifier(a.expression.expression)?(s=a.expression,n=`(${a.arguments.map(f=>f.getText(t.sourceFile)).join(", ")})`):h.isAsExpression(a)&&h.isCallExpression(a.expression)&&h.isIdentifier(a.expression.expression)&&(s=a.expression),!s))continue;let c=s.expression.text;if(!K.includes(c))continue;if(s.arguments.length!==nr(c)){let{line:p,character:f}=t.sourceFile.getLineAndCharacterOfPosition(s.getStart(t.sourceFile));throw new W({text:`Invalid macro call: ${c} with ${s.arguments.length} arguments`,location:{file:t.sourceFile.fileName,line:p+1,column:f}})}let l=r.modifiers?.some(p=>p.kind===h.SyntaxKind.ExportKeyword)??!1;c===K[2]?i=await ir(o,r,s,l,t):n?i=Re(s,t,o,l,n):i=Qt(o,s,l,t),i!==!1&&e.add({replacement:i,end:r.getEnd(),start:r.getStart(t.sourceFile)})}return i!==!1}async function fo(r,e,t){let i=r.expression;if(!i.expression||!h.isIdentifier(i.expression))return!1;let o=i.expression.text;if(!K.includes(o))return!1;if(i.arguments.length!==nr(o)){let{line:s,character:a}=t.sourceFile.getLineAndCharacterOfPosition(r.getStart(t.sourceFile));throw new W({text:`Invalid macro call: ${o} with ${i.arguments.length} arguments`,location:{file:t.sourceFile.fileName,line:s+1,column:a}})}let n=!1;return o==K[2]?(await ot(i.arguments,t),n="undefined"):n=Re(i,t),n!==!1&&e.add({replacement:n,end:i.getEnd(),start:i.getStart(t.sourceFile)}),n!==!1}async function po(r,e,t){if(!h.isCallExpression(r)||!nt(r,t.sourceFile))return!1;let i=r;if(!h.isIdentifier(i.expression))return!1;if(i.expression.text===K[2]){let s=await ot(i.arguments,t);return s===!1?!1:(e.add({start:r.getStart(t.sourceFile),end:r.getEnd(),replacement:s}),!0)}let n=Re(i,t);return n===!1?!1:(e.add({start:r.getStart(t.sourceFile),end:r.getEnd(),replacement:n}),!0)}async function uo(r,e="unknow"){let t=r.stage.defineMetadata.disabledMacroNames,i=r.stage.defineMetadata.filesWithMacros.has(r.sourceFile.fileName);if(!i&&t.size===0)return r.contents;let o=[r.sourceFile],n=new Set;for(;o.length>0;){let c=o.pop(),l=c?.kind;if(!c||!l||i&&(l===h.SyntaxKind.VariableStatement&&await lo(c,n,r)||l===h.SyntaxKind.ExpressionStatement&&nt(c,r.sourceFile)&&await fo(c,n,r)||l===h.SyntaxKind.CallExpression&&nt(c,r.sourceFile)&&await po(c,n,r)))continue;if(t.size>0){if(l===h.SyntaxKind.CallExpression){let f=c;h.isIdentifier(f.expression)&&t.has(f.expression.text)&&n.add({start:c.getStart(r.sourceFile),end:c.getEnd(),replacement:"undefined"})}else if(l===h.SyntaxKind.Identifier){let f=c;if(t.has(f.text)){let d=c.parent??c;if(d&&!h.isImportSpecifier(d)&&!h.isExportSpecifier(d)){let m=d?.getText(r.sourceFile);(!h.isCallExpression(d)||d.expression!==c)&&(!m||K.every($=>!m.includes($)))&&n.add({start:c.getStart(r.sourceFile),end:c.getEnd(),replacement:"undefined"})}}}}let p=c.getChildren(r.sourceFile);for(let f=p.length-1;f>=0;f--)o.push(p[f])}if(n.size===0)return r.contents;let s=Array.from(n);s.sort((c,l)=>l.start-c.start),r.stage.replacementInfo??={},r.stage.replacementInfo[e]??=[];let a=r.stage.replacementInfo[e];for(let{start:c,end:l,replacement:p}of s)a.push({source:or(r.contents.slice(c,l)),replacement:or(p)}),r.contents=r.contents.slice(0,c)+p+r.contents.slice(l);return r.contents}async function sr(r,e){let{args:t,loader:i,stage:o,contents:n,variantName:s,options:a,argv:c}=e;if(t.path.includes("node_modules")||n.length<1)return;let l=t.path.slice(t.path.lastIndexOf("."));if(![".js",".ts"].includes(l))return;let p=r.typescript.languageHostService.getCompilationSettings(),f=co(t.path,n.toString(),p.target??h.ScriptTarget.Latest,!0),d={stage:o,errors:[],contents:n.toString(),warnings:[],defines:r.config.define??{},sourceFile:f,context:{argv:c,options:a,variantName:s}},m=await uo(d,r.name);return r.config.esbuild.bundle||r.typescript.languageHostService.aliasRegex&&(m=r.typescript.languageHostService.resolveAliases(m,t.path,".js")),{loader:i,contents:m,warnings:d.warnings,errors:d.errors}}var ar="$$",cr=/(?:(?:export\s+)?(?:const|let|var)\s+([\w$]+)\s*=\s*)?\$\$(ifdef|ifndef|inline)\s*\(\s*(?:['"]([^'"]+)['"])?/g;function mo(r,e,t,i){let o=1;for(let s=0;s<i;s++)r[s]===`
45
+ `),category:e.category};if(e.file&&e.start!==void 0){let{line:i,character:o}=e.file.getLineAndCharacterOfPosition(e.start);t.file=e.file.fileName,t.line=i+1,t.column=o+1,t.code=e.code}return t}};rt=F(null),N=A(rt,0,"TypescriptService",Ut,N),k(rt,1,N);var ie=N;import{cwd as ke}from"process";import{build as it}from"esbuild";var zt={write:!1,bundle:!0,minify:!0,outdir:`${ke()}`,format:"esm",target:"esnext",platform:"browser",sourcemap:"external",mangleQuoted:!0,sourcesContent:!0,preserveSymlinks:!0};async function Wt(r,e={}){try{return await it({absWorkingDir:ke(),...zt,...e,metafile:!0,entryPoints:r})}catch(t){if(V(t)){let i=new AggregateError([],"Failed to build entryPoints");throw de(t.errors,i.errors),i}throw t}}async function Gt(r,e,t={}){return await it({absWorkingDir:ke(),...zt,...t,stdin:{loader:"ts",contents:r,resolveDir:ke(),sourcefile:e},write:!1,metafile:!0,logLevel:"silent",sourcemap:"external"})}async function Kt(r,e={}){try{return await it({...e,outdir:"tmp",write:!1,bundle:!0,outfile:void 0,metafile:!0,packages:"external",logLevel:"silent",entryPoints:r})}catch(t){if(V(t)){let i=new AggregateError([],"Failed to analyze entryPoint");throw de(t.errors,i.errors),i}throw t}}import{relative as Hi,resolve as Vi,join as Xt,dirname as _i}from"@remotex-labs/xmap";function qt(r,e){if(Array.isArray(e)){let t={};return e.length>0&&typeof e[0]=="object"?e.forEach(i=>{t[i.out]=i.in}):typeof e[0]=="string"&&(t=Ee(r,e)),t}else{if(e&&typeof e=="object")return e;if(e===void 0)return}throw new S("Unsupported entry points format")}var Ae=class{constructor(e,t,i,o={}){this.name=e;this.lifecycle=t;this.buildConfig=i;this.argv=o;if(!this.buildConfig?.esbuild)throw new S(`Variant '${this.name}' not found configuration`);this.tsConfigPath=this.buildConfig.esbuild.tsconfig??"tsconfig.json",this.typescriptModule=new ie(this.tsConfigPath),this.buildConfig=this.initializeConfig(this.getConfig(this.buildConfig,this.configService.getValue().common)),this.lifecycle.onEnd(this.end.bind(this),`${this.name}-core`),this.lifecycle.onStart(this.start.bind(this),`${this.name}-core`),this.configUnsubscribe=this.configService.select(n=>({variantConfig:n.variants?.[this.name],commonConfig:n.common})).subscribe(this.handleConfigChange.bind(this),n=>{throw n})}name;lifecycle;buildConfig;argv;dependenciesFile;active=!0;tsConfigPath;typescriptModule;configUnsubscribe;configService=u(x);get typescript(){return this.typescriptModule}get config(){return this.buildConfig}get dependencies(){return this.dependenciesFile??{}}dispose(){this.configUnsubscribe(),this.typescriptModule.dispose(this.tsConfigPath)}touchFiles(e){this.typescriptModule.touchFiles(e)}async check(){return this.dependenciesFile||(this.dependenciesFile=await this.buildDependencyMap()),this.typescriptModule.check(Object.values(this.dependenciesFile))}async build(){if(!this.active)return;this.applyInjections();let e=Object.assign({},this.buildConfig.esbuild);if(this.dependenciesFile=await this.buildDependencyMap(),this.buildConfig.esbuild.bundle===!1&&Object.assign(e,{entryPoints:this.dependenciesFile}),this.config.define&&e.define)for(let[t,i]of Object.entries(this.config.define))typeof i=="function"&&(e.define[t]=JSON.stringify(i()));try{let t=await Di(e);return await this.packageTypeComponent(),t}catch(t){if(V(t)){if(t.errors.filter(o=>o.location).length>0)throw t;return{errors:t?.errors??[],warnings:t?.warnings??[]}}}}getConfig(e,t={}){return e?z({},t,e):null}async start(){let e={errors:[],warnings:[]};if(!this.buildConfig.types)return e;let t=this.typescriptModule.check(Object.values(this.dependenciesFile??{}));if(t.length===0)return e;if(typeof this.buildConfig.types=="object"&&!this.buildConfig.types.failOnError){let o=new M("Type checking failed",t);e.warnings?.push({detail:o,location:void 0})}else{let o=[],n=[],s=new M("Type checking failed",o),a=new M("Type checking failed",n);for(let c of t)(c.category===Ni.DiagnosticCategory.Error?o:n).push(c);o.length&&e.errors?.push({detail:s,location:void 0}),n.length&&e.warnings?.push({detail:a,location:void 0})}return e}async end(e){if(e.buildResult.errors?.length>0)return;let t={errors:[],warnings:[]};if(typeof e.buildResult.metafile?.outputs=="object"){let s=Object.keys(e.buildResult.metafile?.outputs);for(let a of s){if(!a.endsWith(".map"))continue;let c=_i(a),l=await Li(a,"utf8"),p=JSON.parse(l);p.sources=p.sources.map(f=>f.startsWith("http")?f:Xt(c,f)),await Yt(a,JSON.stringify(p),"utf8")}}if(!this.buildConfig.declaration)return;let i=this.buildConfig.declaration,o=typeof i=="object"?i.bundle!==!1:!0,n=typeof i=="object"?i.outDir:void 0;try{o?await this.typescriptModule.emitBundle(this.buildConfig.esbuild.entryPoints,n):await this.typescriptModule.emit(n)}catch(s){t.warnings?.push({detail:s,location:void 0})}return t}registerConfigHooks(e){if(!e)return;let{onStart:t,onResolve:i,onLoad:o,onEnd:n,onSuccess:s}=e;t&&this.lifecycle.onStart(t),i&&this.lifecycle.onResolve(i),o&&this.lifecycle.onLoad(o),n&&this.lifecycle.onEnd(n),s&&this.lifecycle.onSuccess(s)}async packageTypeComponent(){let e=this.buildConfig.esbuild.outdir??"dist",t=this.buildConfig.esbuild.format==="esm"?"module":"commonjs";await ji(e,{recursive:!0}),await Yt(Xt(e,"package.json"),`{"type": "${t}"}`)}initializeConfig(e){if(!e)throw new S(`Variant '${this.name}' not found configuration`);if(!e.esbuild.entryPoints&&!e.esbuild.stdin)throw new S("Entry points are required in esbuild configuration");let t=e.define,i=t?Object.fromEntries(Object.entries(t).flatMap(([o,n])=>typeof n=="function"?[]:[[o,JSON.stringify(n)]])):void 0;return this.registerConfigHooks(e.lifecycle),e.esbuild.entryPoints=qt(this.typescriptModule.config.options.rootDir??process.cwd(),e.esbuild.entryPoints),e.esbuild=Object.assign({},e.esbuild,{define:i,logLevel:"silent",plugins:[this.lifecycle.create()]}),e}async handleConfigChange({variantConfig:e,commonConfig:t}){this.active=!1;let i=this.getConfig(e,t);i&&(this.active=!0,this.buildConfig=this.initializeConfig(i),i.esbuild.outdir&&i.esbuild.outfile&&(this.buildConfig.esbuild.outdir=void 0),i.esbuild.tsconfig&&i.esbuild.tsconfig!==this.tsConfigPath&&(this.typescriptModule.dispose(this.tsConfigPath),this.tsConfigPath=i.esbuild.tsconfig,this.typescriptModule=new ie(this.tsConfigPath)))}stripExtension(e){let t=e.lastIndexOf(".");return t>0?e.substring(0,t):e}async buildDependencyMap(){let{esbuild:e}=this.buildConfig,t={...e,plugins:void 0},{metafile:i}=await Kt(e.entryPoints,t),o={};for(let n of Object.keys(i.inputs)){let s=Hi(this.typescriptModule.config.options.rootDir,Vi(n)),a=this.stripExtension(s);o[a]=n}return o}injectTextBlock(e){let t=this.buildConfig[e];if(!t)return;let i=this.buildConfig.esbuild;i[e]??={};for(let[o,n]of Object.entries(t))i[e][o]=typeof n=="function"?n(this.name,this.argv):n}applyInjections(){this.injectTextBlock("banner"),this.injectTextBlock("footer")}};import{readFile as Ui}from"fs/promises";import{resolve as zi}from"@remotex-labs/xmap";var Pe=class{constructor(e,t){this.variantName=e;this.argv=t}variantName;argv;filesModel=u(v);endHooks=new Map;loadHooks=new Map;startHooks=new Map;successHooks=new Map;resolveHooks=new Map;onStart(e,t=this.variantName){e&&this.startHooks.set(t,e)}onEnd(e,t=this.variantName){e&&this.endHooks.set(t,e)}onSuccess(e,t=this.variantName){e&&this.successHooks.set(t,e)}onResolve(e,t=this.variantName){e&&this.resolveHooks.set(t,e)}onLoad(e,t=this.variantName){e&&this.loadHooks.set(t,e)}clearAll(){this.endHooks.clear(),this.loadHooks.clear(),this.startHooks.clear(),this.successHooks.clear(),this.resolveHooks.clear()}create(){return{name:this.variantName,setup:e=>{let t={argv:this.argv,options:e.initialOptions,variantName:this.variantName,stage:{startTime:new Date}};e.initialOptions.metafile=!0,this.startHooks.size>0&&e.onStart(this.executeStartHooks.bind(this,t,e)),(this.endHooks.size>0||this.successHooks.size>0)&&e.onEnd(this.executeEndHooks.bind(this,t)),this.resolveHooks.size>0&&e.onResolve({filter:/.*/},this.executeResolveHooks.bind(this,t)),this.loadHooks.size>0&&e.onLoad({filter:/.*/},this.executeLoadHooks.bind(this,t))}}}pushError(e,t,i,o=this.variantName){e.push({id:t,detail:i,location:null,pluginName:o})}async executeStartHooks(e,t){e.stage.startTime=new Date;let i=[],o=[],n={build:t,...e};for(let[s,a]of this.startHooks.entries())try{let c=await a(n);c?.errors&&i.push(...c.errors),c?.warnings&&o.push(...c.warnings)}catch(c){this.pushError(i,"startHook",c,s)}return{errors:i,warnings:o}}async executeEndHooks(e,t){let{errors:i,warnings:o}=t,n=Date.now()-e.stage.startTime.getTime(),s={buildResult:t,duration:n,...e};for(let[a,c]of this.endHooks.entries())try{let l=await c(s);l?.errors&&i.push(...l.errors),l?.warnings&&o.push(...l.warnings)}catch(l){this.pushError(i,"endHook",l,a)}if(t.errors.length===0)for(let[a,c]of this.successHooks.entries())try{await c(s)}catch(l){this.pushError(i,"endHook",l,a)}}async executeResolveHooks(e,t){let i={errors:[]},o={args:t,...e};for(let[n,s]of this.resolveHooks.entries())try{let a=await s(o);if(!a)continue;i={...i,...a}}catch(a){this.pushError(i.errors,"endResolve",a,n)}return i}async executeLoadHooks(e,t){let i=[],o=[],n="default",s=zi(t.path),a=this.filesModel.getOrTouchFile(s),c;try{c=a?.contentSnapshot?a.contentSnapshot.text:await Ui(s,"utf8")}catch{return e.options.logOverride?.["lifecycle-file-ignored"]!=="silent"&&o.push({id:"",text:`${t.path} ignored`,pluginName:"lifecycle"}),{warnings:o,errors:i,loader:n}}for(let[l,p]of this.loadHooks.entries())try{let f=await p({contents:c,loader:n,args:t,...e});if(!f)continue;f.contents!==void 0&&(c=f.contents),f.loader&&(n=f.loader),f.errors&&i.push(...f.errors),f.warnings&&o.push(...f.warnings)}catch(f){this.pushError(i,"loadHook",f,l)}return{contents:c,loader:n,errors:i,warnings:o}}};import h from"typescript";import{createSourceFile as co}from"typescript";import{highlightCode as or}from"@remotex-labs/xmap/highlighter.component";import D from"typescript";var Wi="$$ifdef";function Gi(r,e,t,i=!1){let o=i?"export function ":"function ";return D.isArrowFunction(e)||D.isFunctionExpression(e)?Ki(r,e,t,o):`${i?"export const ":"const "}${r} = ${e.getText(t)};`}function Ki(r,e,t,i){let n=e.modifiers?.some(l=>l.kind===D.SyntaxKind.AsyncKeyword)??!1?"async ":"",s=e.parameters.map(l=>l.getText(t)).join(", "),a=e.type?`: ${e.type.getText(t)}`:"",c=qi(e,t);return`${n}${i}${r}(${s})${a} ${c}`}function qi(r,e){let t=r.body.getText(e);return D.isArrowFunction(r)&&!D.isBlock(r.body)?`{ return ${t}; }`:t}function Yi(r,e,t="",i="();"){return D.isArrowFunction(r)||D.isFunctionExpression(r)?`${r.modifiers?.some(s=>s.kind===D.SyntaxKind.AsyncKeyword)??!1?"async ":""}${t}(${r.getText(e)})${i}`:t?`${t}${r.getText(e)}`:`(() => { return ${r.getText(e)}; })${i}`}function Jt(r,e,t){let i=r in t&&!!t[r];return e===Wi===i}function Qt(r,e,t,i){let[o,n]=e.arguments;if(!D.isStringLiteral(o))return!1;let s=e.expression.text,a=o.text;if(!Jt(a,s,i.defines))return"undefined";let c=r.name.getText(i.sourceFile);return Gi(c,n,i.sourceFile,t)}function Re(r,e,t,i=!1,o){let[n,s]=r.arguments;if(!D.isStringLiteral(n))return!1;let a=n.text,c=r.expression.text;if(!Jt(a,c,e.defines))return"";let l="",p=t?.name.getText(e.sourceFile);return p&&(l=i?`export const ${p} = `:`const ${p} = `),Yi(s,e.sourceFile,l,o)}import B from"typescript";import{createRequire as Qi}from"module";var $e=class extends y{constructor(e,t=0){super(e.message,"InlineError"),this.errorMetadata=L(e,{lineOffset:t}),this.stack=H(this.errorMetadata,this.name,this.message)}};import{Script as Xi,createContext as Ji}from"vm";async function Zt(r,e={},t={}){let i=new Xi(r,t),o=Ji(e);return await i.runInContext(o,{breakOnSigint:!0,displayErrors:!1})}import{dirname as Zi,relative as eo}from"@remotex-labs/xmap";async function er(r,e,t){let[i,o]=(await Gt(r,e.sourceFile.fileName,{bundle:!0,format:"cjs",platform:"node",packages:"external"})).outputFiles;try{let n={exports:{}},s=Qi(e.sourceFile.fileName),a=to(e.sourceFile.fileName,n,s);a.context=e.context;let c=await Zt(o.text,a,{filename:e.sourceFile.fileName});return c===null?"undefined":typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}catch(n){ro(n,e,i.text,t)}return"undefined"}function to(r,e,t){return{...globalThis,Error,RegExp,process,Buffer,module:e,require:t,console,setTimeout,setInterval,clearTimeout,clearInterval,ReferenceError,__dirname:Zi(r),__filename:r}}function ro(r,e,t,i){(!r||typeof r!="object"||!("stack"in r))&&(r=new Error(String(r)));let o=i.getStart(e.sourceFile),{line:n}=e.sourceFile.getLineAndCharacterOfPosition(o);u(b).setSource(t,e.sourceFile.fileName);let s=new $e(r,n);e.errors.push({text:s.message,detail:s})}function io(r,e){let t=null,i=o=>{if(!t){if(B.isFunctionDeclaration(o)&&o.name?.text===r){t=o;return}B.isVariableStatement(o)&&(t=oo(o,r),t)||B.forEachChild(o,i)}};return i(e),t}function oo(r,e){for(let t of r.declarationList.declarations)if(B.isIdentifier(t.name)&&t.name.text===e&&t.initializer&&(B.isArrowFunction(t.initializer)||B.isFunctionExpression(t.initializer)))return t.initializer;return null}function tr(r){return`module.exports = (${r})();`}function no(r){return r&B.NodeFlags.Const?"const":r&B.NodeFlags.Let?"let":"var"}function rr(r,e){return r?B.isIdentifier(r)?so(r,e):B.isArrowFunction(r)||B.isFunctionExpression(r)?{node:r,data:tr(r.getText(e.sourceFile))}:{node:r,data:r.getText(e.sourceFile)}:null}function so(r,e){let t=io(r.text,e.sourceFile);return t?{node:t,data:tr(t.getText(e.sourceFile))}:(ao(r.text,e,r),{data:"",node:r})}function ao(r,e,t){let i=t.getStart(e.sourceFile),{line:o,character:n}=e.sourceFile.getLineAndCharacterOfPosition(i),s=eo(".",e.sourceFile.fileName);e.warnings.push({text:`Function $$inline(${r}); not found in ${s}`,location:{line:o+1,column:n,file:e.sourceFile.fileName,lineText:"asd"}})}async function ir(r,e,t,i,o){let n=t.arguments[0],s=rr(n,o);if(!s)return!1;let a=await er(s.data,o,s.node),c=no(e.declarationList.flags),l=i?"export ":"",p=r.name.getText(o.sourceFile);return`${l}${c} ${p} = ${a};`}async function ot(r,e){let t=r[0],i=rr(t,e);return i?er(i.data,e,i.node):!1}var K=["$$ifdef","$$ifndef","$$inline"];function nt(r,e){return K.some(t=>r.getText(e).includes(t))}function nr(r){return r===K[2]?1:2}async function lo(r,e,t){let i=!1;for(let o of r.declarationList.declarations){let n="",s,a=o.initializer;if(!a||(h.isCallExpression(a)&&h.isIdentifier(a.expression)?s=a:h.isCallExpression(a)&&h.isCallExpression(a.expression)&&h.isIdentifier(a.expression.expression)?(s=a.expression,n=`(${a.arguments.map(f=>f.getText(t.sourceFile)).join(", ")})`):h.isAsExpression(a)&&h.isCallExpression(a.expression)&&h.isIdentifier(a.expression.expression)&&(s=a.expression),!s))continue;let c=s.expression.text;if(!K.includes(c))continue;if(s.arguments.length!==nr(c)){let{line:p,character:f}=t.sourceFile.getLineAndCharacterOfPosition(s.getStart(t.sourceFile));throw new W({text:`Invalid macro call: ${c} with ${s.arguments.length} arguments`,location:{file:t.sourceFile.fileName,line:p+1,column:f}})}let l=r.modifiers?.some(p=>p.kind===h.SyntaxKind.ExportKeyword)??!1;c===K[2]?i=await ir(o,r,s,l,t):n?i=Re(s,t,o,l,n):i=Qt(o,s,l,t),i!==!1&&e.add({replacement:i,end:r.getEnd(),start:r.getStart(t.sourceFile)})}return i!==!1}async function fo(r,e,t){let i=r.expression;if(!i.expression||!h.isIdentifier(i.expression))return!1;let o=i.expression.text;if(!K.includes(o))return!1;if(i.arguments.length!==nr(o)){let{line:s,character:a}=t.sourceFile.getLineAndCharacterOfPosition(r.getStart(t.sourceFile));throw new W({text:`Invalid macro call: ${o} with ${i.arguments.length} arguments`,location:{file:t.sourceFile.fileName,line:s+1,column:a}})}let n=!1;return o==K[2]?(await ot(i.arguments,t),n="undefined"):n=Re(i,t),n!==!1&&e.add({replacement:n,end:i.getEnd(),start:i.getStart(t.sourceFile)}),n!==!1}async function po(r,e,t){if(!h.isCallExpression(r)||!nt(r,t.sourceFile))return!1;let i=r;if(!h.isIdentifier(i.expression))return!1;if(i.expression.text===K[2]){let s=await ot(i.arguments,t);return s===!1?!1:(e.add({start:r.getStart(t.sourceFile),end:r.getEnd(),replacement:s}),!0)}let n=Re(i,t);return n===!1?!1:(e.add({start:r.getStart(t.sourceFile),end:r.getEnd(),replacement:n}),!0)}async function uo(r,e="unknow"){let t=r.stage.defineMetadata.disabledMacroNames,i=r.stage.defineMetadata.filesWithMacros.has(r.sourceFile.fileName);if(!i&&t.size===0)return r.contents;let o=[r.sourceFile],n=new Set;for(;o.length>0;){let c=o.pop(),l=c?.kind;if(!c||!l||i&&(l===h.SyntaxKind.VariableStatement&&await lo(c,n,r)||l===h.SyntaxKind.ExpressionStatement&&nt(c,r.sourceFile)&&await fo(c,n,r)||l===h.SyntaxKind.CallExpression&&nt(c,r.sourceFile)&&await po(c,n,r)))continue;if(t.size>0){if(l===h.SyntaxKind.CallExpression){let f=c;h.isIdentifier(f.expression)&&t.has(f.expression.text)&&n.add({start:c.getStart(r.sourceFile),end:c.getEnd(),replacement:"undefined"})}else if(l===h.SyntaxKind.Identifier){let f=c;if(t.has(f.text)){let d=c.parent??c;if(d&&!h.isImportSpecifier(d)&&!h.isExportSpecifier(d)){let m=d?.getText(r.sourceFile);(!h.isCallExpression(d)||d.expression!==c)&&(!m||K.every($=>!m.includes($)))&&n.add({start:c.getStart(r.sourceFile),end:c.getEnd(),replacement:"undefined"})}}}}let p=c.getChildren(r.sourceFile);for(let f=p.length-1;f>=0;f--)o.push(p[f])}if(n.size===0)return r.contents;let s=Array.from(n);s.sort((c,l)=>l.start-c.start),r.stage.replacementInfo??={},r.stage.replacementInfo[e]??=[];let a=r.stage.replacementInfo[e];for(let{start:c,end:l,replacement:p}of s)a.push({source:or(r.contents.slice(c,l)),replacement:or(p)}),r.contents=r.contents.slice(0,c)+p+r.contents.slice(l);return r.contents}async function sr(r,e){let{args:t,loader:i,stage:o,contents:n,variantName:s,options:a,argv:c}=e;if(t.path.includes("node_modules")||n.length<1)return;let l=t.path.slice(t.path.lastIndexOf("."));if(![".js",".ts"].includes(l))return;let p=r.typescript.languageHostService.getCompilationSettings(),f=co(t.path,n.toString(),p.target??h.ScriptTarget.Latest,!0),d={stage:o,errors:[],contents:n.toString(),warnings:[],defines:r.config.define??{},sourceFile:f,context:{argv:c,options:a,variantName:s}},m=await uo(d,r.name);return r.config.esbuild.bundle||r.typescript.languageHostService.aliasRegex&&(m=r.typescript.languageHostService.resolveAliases(m,t.path,".js")),{loader:i,contents:m,warnings:d.warnings,errors:d.errors}}var ar="$$",cr=/(?:(?:export\s+)?(?:const|let|var)\s+([\w$]+)\s*=\s*)?\$\$(ifdef|ifndef|inline)\s*\(\s*(?:['"]([^'"]+)['"])?/g;function mo(r,e,t,i){let o=1;for(let s=0;s<i;s++)r[s]===`
46
46
  `&&o++;let n=r.lastIndexOf(`
47
47
  `,i-1)+1;return{file:t,line:o,column:r.indexOf(e,n)-n}}function go(r,e){let t=r.lastIndexOf(`
48
- `,e-1)+1;for(;t<e&&(r[t]===" "||r[t]===" ");)t++;if(t>=e)return!1;let i=r[t],o=r[t+1];return i==="/"&&(o==="/"||o==="*")||i==="*"}async function lr(r,e){let t={disabledMacroNames:new Set,filesWithMacros:new Set};e.stage.defineMetadata=t;let i=[],o=u(v),n=r.config.define??{},s=Object.values(r.dependencies??{});for(let a of s){let c=o.getOrTouchFile(a)?.contentSnapshot?.text;if(!c)continue;let l=o.resolve(a);cr.lastIndex=0;for(let p of c.matchAll(cr)){let f=p.index;if(go(c,f))continue;let[,d,m,$]=p;if(t.filesWithMacros.add(l),!d||(d.startsWith(ar)||i.push({text:`Macro function '${d}' not start with '${ar}' prefix to avoid conflicts`,location:mo(c,d,a,f)}),m==="inline"))continue;let _=!!n[$];m==="ifndef"===_&&t.disabledMacroNames.add(d)}}return{warnings:i}}var ye=class{constructor(e={}){this.argv=e;this.configuration.subscribe(this.parseVariants.bind(this))}argv;onEndCallback;onStartCallback;variants={};configuration=u(x);get config(){return this.configuration.getValue()}set onEnd(e){this.onEndCallback=e}set onStart(e){this.onStartCallback=e}reload({config:e,clearCache:t=!1}={}){t&&re.reload(),e&&this.configuration.reload(e),this.disposeVariants(this.compareKeys(this.config.variants,this.variants)),this.parseVariants()}touchFiles(e){for(let t of Object.values(this.variants))t.touchFiles(e)}setConfiguration(e){this.configuration.patch(e)}async typeChack(){let e={};for(let t of Object.values(this.variants))e[t.name]=await t.check();return e}async build(e){let t={cache:new Map,errors:[],results:{}};this.validateDependencies(e);let i=e??Object.keys(this.variants);if(await Promise.all(i.map(o=>this.buildVariant(o,t))),t.errors.length)throw new AggregateError(t.errors,"Build failed");return t.results}onEndTrigger(e){this.onEndCallback&&this.onEndCallback(e)}async onStartTrigger(e){try{let t=await lr(this.variants[e.variantName],e);return this.onStartCallback&&this.onStartCallback(e),t}catch(t){let i=[];if(t instanceof AggregateError){for(let o of t.errors)i.push({detail:o,text:o.message});return{errors:i}}throw t}}disposeVariants(e){if(e.length)for(let t of e)this.variants[t].dispose(),delete this.variants[t]}compareKeys(e,t){return[...Object.keys(t).filter(n=>!(n in e))]}parseVariants(){if(!this.config.variants)throw new S("Variants are not defined in the configuration");for(let e of Object.keys(this.config.variants)){if(this.variants[e])continue;let t=new Pe(e,this.argv);t.onEnd(this.onEndTrigger.bind(this),"build-service"),t.onStart(this.onStartTrigger.bind(this),"build-service"),this.variants[e]=new Ae(e,t,this.config.variants[e],this.argv),t.onLoad(sr.bind({},this.variants[e]),"build-service")}}getDependOn(e){let{dependOn:t}=this.config.variants?.[e]??{};return t?Array.isArray(t)?t:[t]:[]}validateDependencies(e){let t=new Set,i=new Set,o=(n,s)=>{if(i.has(n))throw new S(`Circular dependency detected: ${[...s,n].join(" \u2192 ")}`);if(!t.has(n)){i.add(n);for(let a of this.getDependOn(n))this.variants[a]&&o(a,[...s,n]);i.delete(n),t.add(n)}};for(let n of e??Object.keys(this.variants))o(n,[])}async executeBuild(e,t){let i=this.getDependOn(e).filter(n=>this.variants[n]);await Promise.all(i.map(n=>this.buildVariant(n,t)));let o=this.variants[e];if(o)try{let n=await o.build();n&&(t.results[e]=me(n))}catch(n){V(n)||n instanceof AggregateError?t.errors.push(...me({errors:n.errors}).errors):t.errors.push(n instanceof Error?n:new Error(String(n)))}}buildVariant(e,t){let i=t.cache.get(e);if(i)return i;let o=this.executeBuild(e,t);return t.cache.set(e,o),o}};function fr(r){u(x).reload(r)}function pr(r){u(x).patch(r)}import{platform as yo,exit as vo,stdin as Me,stdout as at}from"process";import{xterm as Be}from"@remotex-labs/xansi/xterm.component";var st={SIGINT:"",SIGQUIT:""},w={HELP:"h",QUIT:"q",CLEAR:"c",RELOAD:"r",VERBOSE:"v",SHOW_URL:"u",OPEN_BROWSER:"o"},ur={win32:"start",darwin:"open",linux:"xdg-open"};function xo(r=!1){let e=["\u{1F680} Shortcuts"],t=Be.dim(" press "),i=(o,n)=>{e.push(`${t}${Be.bold(o)}${Be.dim(n)}`)};return r&&(i(w.SHOW_URL," to show server url"),i(w.OPEN_BROWSER," to open in browser")),i(w.VERBOSE," to enable / disable verbose mode"),i(w.RELOAD," to reload"),i(w.CLEAR," to clear console"),i(w.QUIT,` to quit
48
+ `,e-1)+1;for(;t<e&&(r[t]===" "||r[t]===" ");)t++;if(t>=e)return!1;let i=r[t],o=r[t+1];return i==="/"&&(o==="/"||o==="*")||i==="*"}async function lr(r,e){let t={disabledMacroNames:new Set,filesWithMacros:new Set};e.stage.defineMetadata=t;let i=[],o=u(v),n=r.config.define??{},s=Object.values(r.dependencies??{});for(let a of s){let c=o.getOrTouchFile(a)?.contentSnapshot?.text;if(!c)continue;let l=o.resolve(a);cr.lastIndex=0;for(let p of c.matchAll(cr)){let f=p.index;if(go(c,f))continue;let[,d,m,$]=p;if(t.filesWithMacros.add(l),!d||(d.startsWith(ar)||i.push({text:`Macro function '${d}' not start with '${ar}' prefix to avoid conflicts`,location:mo(c,d,a,f)}),m==="inline"))continue;let _=!!n[$];m==="ifndef"===_&&t.disabledMacroNames.add(d)}}return{warnings:i}}var ye=class{constructor(e={}){this.argv=e;this.configuration.subscribe(this.parseVariants.bind(this))}argv;onEndCallback;onStartCallback;variants={};configuration=u(x);get config(){return this.configuration.getValue()}set onEnd(e){this.onEndCallback=e}set onStart(e){this.onStartCallback=e}reload({config:e,clearCache:t=!1}={}){t&&re.reload(),e&&this.configuration.reload(e),this.disposeVariants(this.compareKeys(this.config.variants,this.variants)),this.parseVariants()}touchFiles(e){for(let t of Object.values(this.variants))t.touchFiles(e)}setConfiguration(e){this.configuration.patch(e)}async typeChack(){let e={};for(let t of Object.values(this.variants))e[t.name]=await t.check();return e}async build(e){let t={cache:new Map,errors:[],results:{}};this.validateDependencies(e);let i=e??Object.keys(this.variants);if(await Promise.all(i.map(o=>this.buildVariant(o,t))),t.errors.length)throw new AggregateError(t.errors,"Build failed");return t.results}onEndTrigger(e){this.onEndCallback&&this.onEndCallback(e)}async onStartTrigger(e){try{let t=await lr(this.variants[e.variantName],e);return this.onStartCallback&&this.onStartCallback(e),t}catch(t){let i=[];if(t instanceof AggregateError){for(let o of t.errors)i.push({detail:o,text:o.message});return{errors:i}}throw t}}disposeVariants(e){if(e.length)for(let t of e)this.variants[t].dispose(),delete this.variants[t]}compareKeys(e,t){return[...Object.keys(t).filter(n=>!(n in e))]}parseVariants(){if(!this.config.variants)throw new S("Variants are not defined in the configuration");for(let e of Object.keys(this.config.variants)){if(this.variants[e])continue;let t=new Pe(e,this.argv);t.onEnd(this.onEndTrigger.bind(this),"build-service"),t.onStart(this.onStartTrigger.bind(this),"build-service"),this.variants[e]=new Ae(e,t,this.config.variants[e],this.argv),t.onLoad(sr.bind({},this.variants[e]),"build-service")}}getDependOn(e){let{dependOn:t}=this.config.variants?.[e]??{};return t?Array.isArray(t)?t:[t]:[]}validateDependencies(e){let t=new Set,i=new Set,o=(n,s)=>{if(i.has(n))throw new S(`Circular dependency detected: ${[...s,n].join(" \u2192 ")}`);if(!t.has(n)){i.add(n);for(let a of this.getDependOn(n))this.variants[a]&&o(a,[...s,n]);i.delete(n),t.add(n)}};for(let n of e??Object.keys(this.variants))o(n,[])}async executeBuild(e,t){let i=this.getDependOn(e).filter(n=>this.variants[n]);await Promise.all(i.map(n=>this.buildVariant(n,t)));let o=this.variants[e];if(o)try{let n=await o.build();n&&(t.results[e]=me(n))}catch(n){V(n)||n instanceof AggregateError?t.errors.push(...me({errors:n.errors}).errors):t.errors.push(n instanceof Error?n:new Error(String(n)))}}buildVariant(e,t){let i=t.cache.get(e);if(i)return i;let o=this.executeBuild(e,t);return t.cache.set(e,o),o}};function fr(r){u(x).reload(r)}function pr(r){u(x).patch(r)}import{platform as yo,exit as vo,stdin as Me,stdout as at}from"process";import{xterm as Be}from"@remotex-labs/xansi/xterm.component";var st={SIGINT:"",SIGQUIT:""},E={HELP:"h",QUIT:"q",CLEAR:"c",RELOAD:"r",VERBOSE:"v",SHOW_URL:"u",OPEN_BROWSER:"o"},ur={win32:"start",darwin:"open",linux:"xdg-open"};function xo(r=!1){let e=["\u{1F680} Shortcuts"],t=Be.dim(" press "),i=(o,n)=>{e.push(`${t}${Be.bold(o)}${Be.dim(n)}`)};return r&&(i(E.SHOW_URL," to show server url"),i(E.OPEN_BROWSER," to open in browser")),i(E.VERBOSE," to enable / disable verbose mode"),i(E.RELOAD," to reload"),i(E.CLEAR," to clear console"),i(E.QUIT,` to quit
49
49
  `),e.join(`
50
50
  `)}function ct(){let r=Math.max(0,at.rows-2);r>0&&console.log(`
51
- `.repeat(r)),lt.cursorTo(at,0,0),lt.clearScreenDown(at)}function bo(r){let e=ur[yo]??"xdg-open";ho(`${e} ${r}`)}function So(r,e,t,i,o){if(e?.name)switch((e.sequence===w.QUIT||r===st.SIGINT||r===st.SIGQUIT)&&(console.log(`
52
- \u{1F44B} Exiting...`),vo(0)),e.name){case w.CLEAR:ct();break;case w.VERBOSE:let n=u(x).getValue(s=>s.verbose);console.log(`\u{1F41E} Debug mode: ${n?"DISABLED":"ENABLED"}`),pr({verbose:!n});break;case w.RELOAD:ct(),t();break;case w.HELP:ct(),console.log(i);break;case w.SHOW_URL:o&&console.log(`${I()} ${Be.canaryYellow(o)}`);break;case w.OPEN_BROWSER:o&&bo(o);break}}function dr(r,e){if(!Me.isTTY)return;let t=xo(!!e);console.log(t),Me.setRawMode(!0),lt.emitKeypressEvents(Me),Me.on("keypress",(i,o)=>{So(i,o,r,t,e)})}import{existsSync as Eo}from"fs";import{runInThisContext as wo}from"vm";import{createRequire as Co}from"module";import{resolve as Io}from"@remotex-labs/xmap";var To={minify:!1,format:"cjs",platform:"node",logLevel:"silent",packages:"external",minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1};async function ft(r){if(!r||!Eo(r))return{};u(v).touchFile(r);let[e,t]=(await Wt([r],{...To,outdir:"tmp"})).outputFiles;u(b).setSource(e.text,r),globalThis.module={exports:{}},globalThis.require=Co(Io(r)),await wo(t.text,{filename:r});let i=module.exports.config??module.exports.default;return i||{}}import{relative as Oo}from"@remotex-labs/xmap";import{DiagnosticCategory as pt}from"typescript";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)}originalError;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:
51
+ `.repeat(r)),lt.cursorTo(at,0,0),lt.clearScreenDown(at)}function bo(r){let e=ur[yo]??"xdg-open";ho(`${e} ${r}`)}function So(r,e,t,i,o){if(e?.name)switch((e.sequence===E.QUIT||r===st.SIGINT||r===st.SIGQUIT)&&(console.log(`
52
+ \u{1F44B} Exiting...`),vo(0)),e.name){case E.CLEAR:ct();break;case E.VERBOSE:let n=u(x).getValue(s=>s.verbose);console.log(`\u{1F41E} Debug mode: ${n?"DISABLED":"ENABLED"}`),pr({verbose:!n});break;case E.RELOAD:ct(),t();break;case E.HELP:ct(),console.log(i);break;case E.SHOW_URL:o&&console.log(`${I()} ${Be.canaryYellow(o)}`);break;case E.OPEN_BROWSER:o&&bo(o);break}}function dr(r,e){if(!Me.isTTY)return;let t=xo(!!e);console.log(t),Me.setRawMode(!0),lt.emitKeypressEvents(Me),Me.on("keypress",(i,o)=>{So(i,o,r,t,e)})}import{existsSync as wo}from"fs";import{runInThisContext as Eo}from"vm";import{createRequire as Co}from"module";import{resolve as Io}from"@remotex-labs/xmap";var To={minify:!1,format:"cjs",platform:"node",logLevel:"silent",packages:"external",minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1};async function ft(r){if(!r||!wo(r))return{};u(v).touchFile(r);let[e,t]=(await Wt([r],{...To,outdir:"tmp"})).outputFiles;u(b).setSource(e.text,r),globalThis.module={exports:{}},globalThis.require=Co(Io(r)),await Eo(t.text,{filename:r});let i=module.exports.config??module.exports.default;return i||{}}import{relative as Oo}from"@remotex-labs/xmap";import{DiagnosticCategory as pt}from"typescript";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)}originalError;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 dt}from"@remotex-labs/xansi/xterm.component";import{xterm as q}from"@remotex-labs/xansi/xterm.component";var mr=q.hex("#80a36b"),ve=q.hex("#dcdfe4"),oe=q.hex("#5798cd"),T=q.hex("#e5c07b"),Y=q.hex("#56b6c2"),R=q.hex("#e06c75"),ne=q.hex("#c678dd"),se=q.hex("#a5a7ab");var O=" ",ut=1024,gr=ut*1024,yr="\u2014",X="\u2192",J="\xD7",vr="\u2022";function ee(r,e=oe.dim(X)){return`${I()} ${e} ${oe(r)}`}function Fo(r){return r<ut?`${r} B`:r<gr?`${(r/ut).toFixed(2)} KB`:`${(r/gr).toFixed(2)} MB`}function xr(r){let e=r.file?Oo(process.cwd(),r.file):"(unknown)",t=T(String((r.line??0)+1)),i=T(String((r.column??0)+1));return`${Y(e)}:${t}:${i}`}function ko(r,e){if(!e.metadata?.formatCode)return;let t=e.metadata.formatCode.split(`
55
55
  `),i=e.metadata.stack.map(o=>o.format).join(`
@@ -76,8 +76,8 @@ ${O}`);if(s&&s!=="undefined"){let c=s.replaceAll(`
76
76
  ${O}`);o.push(`
77
77
  ${i} ${c} ${a}`)}else o.push(`
78
78
  ${i} ${a}`)}console.log(o.join(`
79
- `))}function Er({variantName:r,duration:e,buildResult:t,stage:i}){let{errors:o,warnings:n,metafile:s}=me(t),a=!!s,c=a?ne(r):T(r),l=a?oe.dim(X):R(J),p=ee("completed",l);console.log(`${p} ${c} ${dt.dim(`in ${e} ms`)}`),hr(o,"Errors"),hr(n,"Warnings"),(o.length||n.length)&&console.log(""),Do(r,i),a?Bo(s):console.log("")}var Vo=["!node_modules/**","!dist/**","!bundle/**","!**/*.d.ts"],_o=["dist","dist/**",".git/**",".idea/**","node_modules/**"];function Uo(r,e){if(!e.entryPoints)return;let t=[...e.entryPoints,...Vo];e.outdir&&t.push(`!${e.outdir}/**`,`!${e.outdir}`),r.common?.esbuild?.outdir&&t.push(`!${r.common.esbuild.outdir}/**`,`!${r.common.esbuild.outdir}`),r.variants={argv:{esbuild:{entryPoints:we(Lo(),t)}}}}function zo(r,e){e.verbose!==void 0&&(r.verbose=e.verbose);let t=Object.values(r.variants??{});for(let i of t)e.types!==void 0&&(i.types=e.types),e.outdir!==void 0&&(i.esbuild.outdir=e.outdir),e.bundle!==void 0&&(i.esbuild.minify=e.bundle),e.minify!==void 0&&(i.esbuild.minify=e.minify),e.tsconfig!==void 0&&(i.esbuild.tsconfig=e.tsconfig),e.platform!==void 0&&(i.esbuild.platform=e.platform),e.declaration!==void 0&&(i.declaration=e.declaration),e.failOnError!==void 0&&(i.types={failOnError:e.failOnError})}function Wo(r){let e=[..._o];r.common?.esbuild?.outdir&&e.push(r.common.esbuild.outdir,`${r.common.esbuild.outdir}/**`);let t=Object.values(r.variants??{});for(let i of t)i.esbuild.outdir&&e.push(i.esbuild.outdir,`${i.esbuild.outdir}/**`);return e}async function Go(r,e){if(!((e.serve??!1)!==!1||r.serve?.start))return;let i,o=r.serve?.dir||e.serve||"dist",n={...r.serve,onStart({host:a,port:c,url:l}){i=l,console.log(`${ee("serve")} ${ne(o)} ${Y(l)}
79
+ `))}function wr({variantName:r,duration:e,buildResult:t,stage:i}){let{errors:o,warnings:n,metafile:s}=me(t),a=!!s,c=a?ne(r):T(r),l=a?oe.dim(X):R(J),p=ee("completed",l);console.log(`${p} ${c} ${dt.dim(`in ${e} ms`)}`),hr(o,"Errors"),hr(n,"Warnings"),(o.length||n.length)&&console.log(""),Do(r,i),a?Bo(s):console.log("")}var Vo=["!node_modules/**","!dist/**","!bundle/**","!**/*.d.ts"],_o=["dist","dist/**",".git/**",".idea/**","node_modules/**"];function Uo(r,e){if(!e.entryPoints)return;let t=[...e.entryPoints,...Vo];e.outdir&&t.push(`!${e.outdir}/**`,`!${e.outdir}`),r.common?.esbuild?.outdir&&t.push(`!${r.common.esbuild.outdir}/**`,`!${r.common.esbuild.outdir}`),r.variants={argv:{esbuild:{entryPoints:Ee(Lo(),t)}}}}function zo(r,e){e.verbose!==void 0&&(r.verbose=e.verbose);let t=Object.values(r.variants??{});for(let i of t)e.types!==void 0&&(i.types=e.types),e.outdir!==void 0&&(i.esbuild.outdir=e.outdir),e.bundle!==void 0&&(i.esbuild.minify=e.bundle),e.minify!==void 0&&(i.esbuild.minify=e.minify),e.tsconfig!==void 0&&(i.esbuild.tsconfig=e.tsconfig),e.platform!==void 0&&(i.esbuild.platform=e.platform),e.declaration!==void 0&&(i.declaration=e.declaration),e.failOnError!==void 0&&(i.types={failOnError:e.failOnError})}function Wo(r){let e=[..._o];r.common?.esbuild?.outdir&&e.push(r.common.esbuild.outdir,`${r.common.esbuild.outdir}/**`);let t=Object.values(r.variants??{});for(let i of t)i.esbuild.outdir&&e.push(i.esbuild.outdir,`${i.esbuild.outdir}/**`);return e}async function Go(r,e){if(!((e.serve??!1)!==!1||r.serve?.start))return;let i,o=r.serve?.dir||e.serve||"dist",n={...r.serve,onStart({host:a,port:c,url:l}){i=l,console.log(`${ee("serve")} ${ne(o)} ${Y(l)}
80
80
  `),r.serve?.onStart?.({host:a,port:c,url:l})}};return await new ge(n,o).start(),i}async function je(r,e){try{let t=Ho(process.cwd(),"dist");if(jo(t,{recursive:!0,force:!0}),e.typeCheck){let i=await r.typeChack();br(i)}else{let i=await r.build(e.build);Object.entries(i).forEach(([o,n])=>{let s=n.errors.filter(c=>c?.id==="endHook");if(!s.length)return;let a=ee("onEnd-hook",R(J));console.log(a,o),s.forEach(c=>ae(c)),console.log("")})}}catch(t){ae(t),process.exitCode=1}}async function Ko(r,e,t,i){if(!(t.watch||t.serve!==void 0||e.serve?.start))return;let n=Wo(e),s=new he(n);dr(async()=>{r.reload({clearCache:!0}),await je(r,t)},i),await je(r,t),await s.start(async a=>{if(r.touchFiles(a),a.includes(t.config)){let c=await ft(t.config);r.reload({config:c})}console.log(`
81
81
  ${I()} ${se("Rebuilding")}: files (${a.length})
82
- `),await je(r,t)})}async function qo(){console.log($t());let r=u(Q),e=r.parseConfigFile(process.argv);globalThis.$argv=e;let t=await ft(e.config),i=r.enhancedParse(process.argv,t.userArgv),o=r.parseUserArgv(process.argv,t.userArgv);Uo(t,i),zo(t,i),fr(t);let n=new ye(o);n.onEnd=Er,n.onStart=Sr;let s=await Go(t,i);await Ko(n,t,i,s),await je(n,i)}qo();
82
+ `),await je(r,t)})}async function qo(){console.log($t());let r=u(Q),e=r.parseConfigFile(process.argv);globalThis.$argv=e;let t=await ft(e.config),i=r.enhancedParse(process.argv,t.userArgv),o=r.parseUserArgv(process.argv,t.userArgv);Uo(t,i),zo(t,i),fr(t);let n=new ye(o);n.onEnd=wr,n.onStart=Sr;let s=await Go(t,i);await Ko(n,t,i,s),await je(n,i)}qo();
83
83
  //# sourceMappingURL=bash.js.map