@remotex-labs/xbuild 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bash.js +26 -26
- package/dist/bash.js.map +3 -3
- package/dist/index.js +12 -12
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/bash.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Sr=Object.create;var
|
|
2
|
+
var Sr=Object.create;var qe=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var xt=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),fe=r=>{throw TypeError(r)};var Cr=(r,e,t)=>e in r?qe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ht=(r,e)=>qe(r,"name",{value:e,configurable:!0});var F=r=>[,,,Sr(r?.[xt("metadata")]??null)],bt=["class","method","getter","setter","accessor","field","value","get","set"],pe=r=>r!==void 0&&typeof r!="function"?fe("Function expected"):r,Er=(r,e,t,i,o)=>({kind:bt[r],name:e,metadata:i,addInitializer:n=>t._?fe("Already initialized"):o.push(pe(n||null))}),Ir=(r,e)=>Cr(e,xt("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},P=(r,e,t,i,o,n)=>{var s,a,c,l,u,p=e&7,x=!!(e&8),m=!!(e&16),W=p>3?r.length+1:p?x?1:2:0,te=bt[p+5],L=p>3&&(r[W-1]=[]),We=r[W]||(r[W]=[]),w=p&&(!m&&!x&&(o=o.prototype),p<5&&(p>3||!m)&&wr(p<4?o:{get[t](){return vt(this,n)},set[t](I){return yt(this,n,I)}},t));p?m&&p<4&&ht(n,(p>2?"set ":p>1?"get ":"")+t):ht(o,t);for(var le=i.length-1;le>=0;le--)l=Er(p,t,c={},r[3],We),p&&(l.static=x,l.private=m,u=l.access={has:m?I=>Tr(o,I):I=>t in I},p^3&&(u.get=m?I=>(p^1?vt:Or)(I,o,p^4?n:w.get):I=>I[t]),p>2&&(u.set=m?(I,Ge)=>yt(I,o,Ge,p^4?n:w.set):(I,Ge)=>I[t]=Ge)),a=(0,i[le])(p?p<4?m?n:w[te]:p>4?void 0:{get:w.get,set:w.set}:o,l),c._=1,p^4||a===void 0?pe(a)&&(p>4?L.unshift(a):p?m?n=a:w[te]=a:o=a):typeof a!="object"||a===null?fe("Object expected"):(pe(s=a.get)&&(w.get=s),pe(s=a.set)&&(w.set=s),pe(s=a.init)&&L.unshift(s));return p||Ir(r,o),w&&qe(o,t,w),m?p^4?n:w:o};var Ke=(r,e,t)=>e.has(r)||fe("Cannot "+t),Tr=(r,e)=>Object(e)!==e?fe('Cannot use the "in" operator on this value'):r.has(e),vt=(r,e,t)=>(Ke(r,e,"read from private field"),t?t.call(r):e.get(r));var yt=(r,e,t,i)=>(Ke(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Or=(r,e,t)=>(Ke(r,e,"access private method"),t);import{rmSync as So}from"fs";import{cwd as wo}from"process";import Oe from"node:process";var Xe=new Map,St=new Map;function Fr(r){return typeof r=="object"&&r!==null&&"useClass"in r}function kr(r){return typeof r=="object"&&r!==null&&"useFactory"in r}function Pr(r){return typeof r=="object"&&r!==null&&"useValue"in r}function A(r){return function(e){St.set(e,r||{})}}function Ye(r,e=[]){if(!r)return e;let t=e;for(let i of r.slice(t.length))if(Fr(i))t.push(f(i.useClass,...Ye(i.providers)));else if(kr(i))t.push(i.useFactory(...Ye(i.providers)));else if(Pr(i))t.push(i.useValue);else if(typeof i=="function")t.push(f(i));else throw new Error(`Unknown provider type: ${typeof i}`);return t}function f(r,...e){if(Xe.has(r))return Xe.get(r);let t=St.get(r);if(!t)throw new Error(`Cannot inject ${r.name} \u2013 not marked @Injectable`);let i=Ye(t.providers,e),o=t.factory?t.factory(...i):new r(...i);return t?.scope==="singleton"&&Xe.set(r,o),o}import{xterm as ge}from"@remotex-labs/xansi/xterm.component";import $r from"typescript";import{readFileSync as Br,statSync as Mr}from"fs";import*as ue from"path";import*as re from"path/posix";var Ar=/\\/g,Rr=/\/+/g;function R(r){if(!r)return"";let e=String(r);return e=e.replace(Ar,"/"),e=e.replace(Rr,"/"),e}function wt(r){return re.normalize(R(r))}function h(...r){return re.join(...r.map(R))}function C(...r){return R(ue.resolve(...r))}function $(r){return R(ue.dirname(r))}function T(r,e){return re.relative(R(r),R(e))||"."}var Ct,Je;Ct=[A({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);i||(i={version:0,mtimeMs:0,contentSnapshot:void 0},this.snapshotsByPath.set(t,i));try{let n=Mr(t).mtimeMs;if(n===i.mtimeMs)return{...i};let s=Br(t,"utf-8"),a=s?$r.ScriptSnapshot.fromString(s):void 0;i.version++,i.mtimeMs=n,i.contentSnapshot=a}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=C(e);return this.resolvedPathCache.set(e,i),i}};Je=F(null),v=P(Je,0,"FilesModel",Ct,v),k(Je,1,v);import{readFileSync as Nr}from"fs";import{SourceService as Dr}from"@remotex-labs/xmap";var Et,Qe;Et=[A({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=C(e),this.sourceMaps.has(e))return this.sourceMaps.get(e)}setSource(e,t){let i=C(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=C(e),i=`${e}.map`;if(!this.sourceMaps.has(t))try{let o=Nr(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 R(process.cwd())}getDistDir(){return R(import.meta.dirname)}initializeSourceMap(e,t){if(e?.includes('"mappings": ""'))return;let i=new Dr(e,t);this.sourceMaps.set(t,i)}};
|
|
5
|
-
`);return{getPositionWithCode:(s,a,c,l)=>{let u=l?.linesBefore??3,p=l?.linesAfter??3,
|
|
6
|
-
`),source:e,name:null,startLine:
|
|
4
|
+
${o instanceof Error?o.message:String(o)}`)}}getRootDir(){return R(process.cwd())}getDistDir(){return R(import.meta.dirname)}initializeSourceMap(e,t){if(e?.includes('"mappings": ""'))return;let i=new Dr(e,t);this.sourceMaps.set(t,i)}};Qe=F(null),b=P(Qe,0,"FrameworkService",Et,b),k(Qe,1,b);import{parseErrorStack as kt}from"@remotex-labs/xmap/parser.component";function It(r){return e=>new G(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 Tt(r=(e,t)=>e===t){return e=>new G(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 G=class{constructor(e){this.handler=e}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 de=class extends G{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 me=class extends de{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 Ie(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function q(r,...e){if(!e.length)return r;let t=e.shift();if(Ie(r)&&Ie(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]}):Ie(o)?Object.assign(r,{[i]:q(Ie(n)?n:{},o)}):Object.assign(r,{[i]:o})}return q(r,...e)}return r}function Te(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"?Lr(r,e,t):!1}function jr(r,e){return r==null||typeof r!="object"&&typeof r!="function"?!1:e in r||Object.prototype.hasOwnProperty.call(r,e)}function Lr(r,e,t=!0){if(Array.isArray(r)&&Array.isArray(e))return t&&r.length!==e.length?!1:r.every((n,s)=>Te(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(!jr(e,n)||!Te(r[n],e[n],t))return!1;return!0}var Hr="tsconfig.json",Ot=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",tsconfig:Hr,absWorkingDir:process.cwd()})})});var Ft,Ze;Ft=[A({scope:"singleton"})];var y=class{constructor(e=Ot){this.initialConfig=e;this.config$=new me(q({},e))}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(It(e),Tt((t,i)=>Te(t,i)))}patch(e){let t=q({},this.config$.value,e);this.config$.next(t)}reload(e){this.config$.next(q({},this.initialConfig,e))}};Ze=F(null),y=P(Ze,0,"ConfigurationService",Ft,y),k(Ze,1,y);import{highlightCode as _r}from"@remotex-labs/xmap/highlighter.component";import{Bias as Vr}from"@remotex-labs/xmap";import{formatErrorCode as Ur}from"@remotex-labs/xmap/formatter.component";var zr=/\s{2,}/g,Wr=/^https?:\/\//,Gr=/^file:\/\//;function qr(r){return r instanceof Error?kt(r):r.detail instanceof Error?kt(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 Kr(r){let e=r.fileName??"",t=this.framework.getSourceMap(e);if(t)return t;let i=this.files.getOrTouchFile(e),o=i?.contentSnapshot?.text;if(!i||!o)return null;let n=o.split(`
|
|
5
|
+
`);return{getPositionWithCode:(s,a,c,l)=>{let u=l?.linesBefore??3,p=l?.linesAfter??3,x=Math.max(s-u,0),m=Math.min(s+p,n.length);return{line:s,column:a+1,code:n.slice(x,m).join(`
|
|
6
|
+
`),source:e,name:null,startLine:x,endLine:m,sourceRoot:null,sourceIndex:-1,generatedLine:-1,generatedColumn:-1}}}}function Xr(r){return Ur({...r,code:_r(r.code)},{color:ge.brightPink})}function et(r){let e=r.fileName;if(e?.includes(this.framework.rootPath)&&(e=T(this.framework.rootPath,e)),!e)return r.source??"";let t=r.line&&r.column?ge.gray(`[${r.line}:${r.column}]`):"";return`at ${r.functionName??""} ${ge.darkGray(e)} ${t}`.replace(zr," ").trim()}function Yr(r,e){let{source:t,sourceRoot:i,line:o}=e;if(!t)return r.fileName?r.fileName.replace(Gr,""):"";let n=Math.max(t.lastIndexOf("http://"),t.lastIndexOf("https://"));if(n>0)return`${t.substring(n)}#L${o}`;if(Wr.test(t))return`${t}#L${o}`;if(i){let s=T($(this.framework.distPath),h(this.framework.distPath,t));return`${i}${s}#L${o}`}return`${t}#L${o}`}function Jr(r,e){return this.code||(this.code=e.code,this.source=e.source,this.formatCode=Xr(e)),et.call(this,{...r,line:e.line,column:e.column,functionName:e.name??r.functionName,fileName:Yr.call(this,r,e)})}function Qr(r,e){if(!this.withNativeFrames&&r.native||!r.line&&!r.column&&!r.fileName&&!r.functionName)return"";let t=Kr.call(this,r);if(!t)return et.call(this,r);let i=t.getPositionWithCode(r.line??0,r.column??0,Vr.LOWER_BOUND,e);return i?!this.withFrameworkFrames&&this.framework.isFrameworkFile(i)?"":(this.lineOffset&&(i.line+=this.lineOffset,i.startLine+=this.lineOffset,i.endLine+=this.lineOffset),this.line=i.line,this.column=i.column,Jr.call(this,r,i)):et.call(this,r)}function H(r,e,t=0){let i=f(y).getValue(a=>a.verbose)??!1,o={code:"",line:0,column:0,source:"",formatCode:"",lineOffset:t,files:f(v),framework:f(b),withNativeFrames:i,withFrameworkFrames:i,...e};return{stacks:qr(r).stack.map(a=>Qr.call(o,a,e)).filter(Boolean),code:o.code,line:o.line??0,column:o.column??0,source:o.source,formatCode:o.formatCode}}function _(r,e,t,i=[]){let o=[`
|
|
7
7
|
${e}: ${ge.lightCoral(t)}`];for(let n of i??[])n.text&&o.push(`
|
|
8
8
|
`+ge.gray(n.text));return r.formatCode&&o.push(`
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ ${r.formatCode}`),r.stacks.length&&o.push(`
|
|
|
12
12
|
Enhanced Stack Trace:
|
|
13
13
|
${r.stacks.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`),o.join("")}var
|
|
15
|
+
`),o.join("")}var g=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=H(e,t),this.formattedStack=_(this.errorMetadata,e.name,e.message)}};function Pt(r){if(r instanceof AggregateError){console.error("AggregateError:",r.message);for(let e of r.errors)if(e instanceof Error&&!(e instanceof g)){let t=H(e,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(_(t,e.name,e.message))}else console.error(e);return}if(r instanceof Error&&!(r instanceof g)){let e=H(r,{withFrameworkFrames:!0,withNativeFrames:!0});console.error(_(e,r.name,r.message))}else console.error(r)}Oe.on("uncaughtException",r=>{Pt(r),Oe.exit(2)});Oe.on("unhandledRejection",r=>{Pt(r),Oe.exit(2)});import rt from"yargs";import{hideBin as ri}from"yargs/helpers";import{xterm as tt}from"@remotex-labs/xansi/xterm.component";var Zr=`
|
|
16
16
|
______ _ _ _
|
|
17
17
|
| ___ \\ (_) | | |
|
|
18
18
|
__ _| |_/ /_ _ _| | __| |
|
|
@@ -20,11 +20,11 @@ __ _| |_/ /_ _ _| | __| |
|
|
|
20
20
|
> <| |_/ / |_| | | | (_| |
|
|
21
21
|
/_/\\_\\____/ \\__,_|_|_|\\__,_|
|
|
22
22
|
`;function Fe(){return`
|
|
23
|
-
\r${
|
|
24
|
-
\rVersion: ${
|
|
25
|
-
\r`}function O(){return
|
|
23
|
+
\r${tt.burntOrange(Zr)}
|
|
24
|
+
\rVersion: ${tt.brightPink("1.0.0-local")}
|
|
25
|
+
\r`}function O(){return tt.lightCoral("[xBuild]")}var ei="tsconfig.json",ti="config.xbuild.ts",ke={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:ti},tsconfig:{describe:"Path to TypeScript configuration file",alias:"tsc",type:"string",default:ei},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}},At=[["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 Rt,it;Rt=[A({scope:"singleton"})];var Q=class{parseConfigFile(e){return rt(e).help(!1).version(!1).options({config:ke.config}).parseSync()}parseUserArgv(e,t){return t?rt(e).help(!1).version(!1).options(t).parseSync():{}}enhancedParse(e,t={}){let i=rt(ri(e)).locale("en"),o=i.showHelp;return i.showHelp=function(n){return console.log(Fe()),this.group(Object.keys(ke),"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(ke).epilogue("For more information, check the documentation https://remotex-labs.github.io/xBuild/").help().alias("help","h").strict().version(),At.forEach(([n,s])=>{i.example(n,s)}),i.parseSync()}};it=F(null),Q=P(it,0,"ArgvModule",Rt,Q),k(it,1,Q);import dt from"readline";import{exec as eo}from"child_process";import{cwd as ii}from"process";import{readdirSync as oi}from"fs";import{matchesGlob as ot}from"path";function ni(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 $t(r,e){for(let t of e)if(ot(r,t))return!0;return!1}function si(r,e){let t=r+"/**";for(let i of e)if(ot(r,i)||ot(t,i))return!0;return!1}function Pe(r,e){let{include:t,exclude:i}=ni(e),o=Object.create(null),s=ii().length+1,a=r.length+1,c=i.length>0;function l(u){let p;try{p=oi(u,{withFileTypes:!0})}catch{return}let x=p.length;for(let m=0;m<x;m++){let W=p[m],te=h(u,W.name),L=te.slice(a);if(W.isDirectory()){(!c||!si(L,i))&&l(te);continue}if(!(c&&$t(L,i))&&$t(L,t)){let We=te.slice(s),w=L.lastIndexOf("."),le=w>0?L.slice(0,w):L;o[le]=We}}}return l(r),o}var V=class r extends Error{diagnostics;constructor(e,t=[]){super(e),this.name="TypesError",this.diagnostics=t,Object.setPrototypeOf(this,r.prototype)}};var Ae=class extends g{constructor(e){super(e.text,"esBuildError"),this.errorMetadata=H(e,{withFrameworkFrames:!0}),this.stack=_(this.errorMetadata,this.name,this.message,e.notes)}};var U=class r extends g{constructor(t,i){if(t instanceof g)return t;super(t.message,"VMRuntimeError");this.originalError=t;t instanceof AggregateError&&Array.isArray(t.errors)&&(this.errors=t.errors.map(o=>new r(o,i))),this.stack=t.stack,this.message=t.message,this.reformatStack(t,i)}errors=[];[Symbol.for("nodejs.util.inspect.custom")](){if(this.errors&&this.errors.length>0){let t=this.errors.map(i=>`${i.formattedStack??i.stack}`).join("");return`VMRuntimeError Contains ${this.errors.length} nested errors:
|
|
26
26
|
${t}
|
|
27
|
-
`}return this.formattedStack||this.stack}};function ai(r){return r instanceof
|
|
27
|
+
`}return this.formattedStack||this.stack}};function ai(r){return r instanceof g?r:r.detail instanceof g||r.detail instanceof V?r.detail:r.detail&&("errors"in r.detail||r.detail instanceof AggregateError)?new U(r.detail,{withFrameworkFrames:!0}):r.detail instanceof Error?new U(r.detail,{withFrameworkFrames:!0}):r.location?new Ae(r):new U(new Error(r.text))}function he(r=[],e){for(let t of r)e.push(ai(t))}function ve(r){let e={errors:[],warnings:[],metafile:r.metafile,outputFiles:r.outputFiles,mangleCache:r.mangleCache};return he(r.errors,e.errors),he(r.warnings,e.warnings),e}function Z(r){return typeof r=="object"&&r!==null&&"errors"in r}import*as Dt from"http";import*as jt from"https";import{extname as Mt}from"path";import{readFileSync as Nt}from"fs";var Bt=`<!doctype html>
|
|
28
28
|
<html lang="en">
|
|
29
29
|
<head>
|
|
30
30
|
<meta charset="utf-8"/>
|
|
@@ -342,7 +342,7 @@ ${t}
|
|
|
342
342
|
});
|
|
343
343
|
</script>
|
|
344
344
|
</html>
|
|
345
|
-
`;import{readdir as li,stat as pi,readFile as fi}from"fs/promises";import{xterm as Re}from"@remotex-labs/xansi/xterm.component";var ye=class{constructor(e,t){this.config=e;this.rootDir=C(t),this.config.port||=0,this.config.host||="localhost"}server;rootDir;framework=f(b);async start(){if(this.config.https)return await this.startHttpsServer();await this.startHttpServer()}async stop(){if(!this.server){console.log(O(),Re.gray("No server is currently running."));return}await new Promise((e,t)=>{this.server.close(i=>{i?t(i):e()})}),console.log(O(),Re.dim("Server stopped.")),this.server=void 0}async restart(){console.log(O(),Re.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=
|
|
345
|
+
`;import{readdir as li,stat as pi,readFile as fi}from"fs/promises";import{xterm as Re}from"@remotex-labs/xansi/xterm.component";var ye=class{constructor(e,t){this.config=e;this.rootDir=C(t),this.config.port||=0,this.config.host||="localhost"}server;rootDir;framework=f(b);async start(){if(this.config.https)return await this.startHttpsServer();await this.startHttpServer()}async stop(){if(!this.server){console.log(O(),Re.gray("No server is currently running."));return}await new Promise((e,t)=>{this.server.close(i=>{i?t(i):e()})}),console.log(O(),Re.dim("Server stopped.")),this.server=void 0}async restart(){console.log(O(),Re.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=Dt.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:Nt(this.config.key??h(this.framework.distPath,"..","certs","server.key")),cert:Nt(this.config.cert??h(this.framework.distPath,"..","certs","server.crt"))};this.server=jt.createServer(t,(i,o)=>{this.handleRequest(i,o,()=>this.defaultResponse(i,o))}),this.server.listen(this.config.port,this.config.host,()=>{this.setActualPort(),this.config.onStart?.({host:this.config.host,port:this.config.port,url:`https://${this.config.host}:${this.config.port}`}),e()})})}handleRequest(e,t,i){try{this.config.verbose&&console.log(`${O()} Request ${Re.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=h(this.rootDir,i);if(!o.startsWith(this.rootDir)){t.statusCode=403,t.end();return}try{let n=await pi(o);n.isDirectory()?await this.handleDirectory(o,i,t):n.isFile()&&await this.handleFile(o,t)}catch(n){let s=n.message;s.includes("favicon")||console.log(O(),s),this.sendNotFound(t)}}async handleDirectory(e,t,i){let n=(await li(e)).map(l=>{let u=h(t,l),p=Mt(l).slice(1)||"folder";return p==="folder"?`
|
|
346
346
|
<a href="/${u}" class="folder-row">
|
|
347
347
|
<div class="icon"><i class="fa-solid fa-folder"></i></div>
|
|
348
348
|
<div class="meta"><div class="name">${l}</div><div class="sub">Folder</div></div>
|
|
@@ -352,23 +352,23 @@ ${t}
|
|
|
352
352
|
<div class="icon"><i class="fa-solid fa-file-code"></i></div>
|
|
353
353
|
<div class="meta"><div class="name">${l}</div><div class="sub">${p}</div></div>
|
|
354
354
|
</a>
|
|
355
|
-
`}).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
|
|
355
|
+
`}).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=Bt.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 fi(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(O(),t.toString()),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{matchesGlob as Lt}from"path";import{stat as ui,watch as di}from"fs/promises";var xe=class{excludes;include;debounceTimer=null;framework=f(b);constructor(e=[],t=["**/*"]){this.include=t,this.excludes=e}async start(e){let t=new Set,i=di(this.framework.rootPath,{recursive:!0});for await(let{filename:o}of i){if(!o)continue;let n=wt(o);if(n.endsWith("~")||!this.include.some(a=>Lt(n,a))||this.excludes.some(a=>Lt(n,a)))continue;let s=h(this.framework.rootPath,n);try{if(!(await ui(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)}};var M=class extends g{constructor(e,t={withFrameworkFrames:!0}){super(e),this.reformatStack(this,t)}};import{build as ki}from"esbuild";import{writeFile as Pi,mkdir as Ai}from"fs/promises";import d from"typescript";import mi from"typescript";var gi=/^#!.*(\r?\n)?/,hi=/export {};\n?/g,vi=/(?:\/\*\*[\s\S]*?\*\/\s*)+(\/\*\*[\s\S]*?\*\/)/g,yi=/^export\s+(?:default\s+)?/gm,xi=/\s*\/\*\*[\s\S]*?\*\/\s*$/g;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(vi,"$1")}function Ht(r){return r.replace(yi,"")}function Ci(r){return r.charCodeAt(0)===35||r.includes("export {}")||r.includes("/**")}function $e(r){return Ci(r)&&(r=bi(r),r=Si(r),r=wi(r)),r}function nt(r,e){let{outDir:t,rootDir:i,declarationDir:o}=e,n=o||t||$(r),s=i||$(r),c=T(s,r).replace(/\.tsx?$/,".d.ts"),l=mi.sys.resolvePath(`${n}/${c}`);return R(l)}var _t,st;_t=[A({scope:"singleton"})];var ee=class{languageService;languageHostService;printer;nodesCache=new Map;filesCache=f(v);constructor(){this.printer=d.createPrinter({newLine:d.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(!d.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 d.canHaveModifiers(e)?d.getModifiers(e)?.some(i=>i.kind===d.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 d.createSourceFile(e.fileName.replace(/\.tsx?$/,".d.ts"),i,d.ScriptTarget.Latest,!0)}stripImportsExports(e,t){let i=[],o=[];for(let c of e.statements){if(d.isImportDeclaration(c)){this.handleImport(c,t,i);continue}if(d.isExportDeclaration(c)){this.handleExport(c,t);continue}this.hasExportModifier(c)&&this.extractExportName(c,t),o.push(c)}let n=d.factory.createNodeArray(o),s=this.printer.printList(d.ListFormat.MultiLine,n,e),a=Ht($e(s));for(let c of i)if(c.includes(" as ")){let[l,u]=c.split(" as ");a=a.replace(new RegExp(`\\b${u}\\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:u}=o;if(!u)return;d.isNamespaceImport(u)?i.push(u.name.text):d.isNamedImports(u)&&this.addNamedElements(i,u.elements);return}if(!o){t.externalImports.namespace[a]="";return}o.name&&(t.externalImports.default[a]=o.name.text);let{namedBindings:l}=o;l&&(d.isNamespaceImport(l)?t.externalImports.namespace[l.name.text]=a:d.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(d.isNamespaceExport(o)){a?t.externalExports.namespace[o.name.text]=s:t.internalExports.namespace[o.name.text]=s;return}d.isNamedExports(o)&&(a?this.addNamedElements(t.externalExports.exports[s]??=[],o.elements):this.addNamedElements(t.internalExports.exports,o.elements))}extractExportName(e,t){if(d.isVariableStatement(e)){for(let i of e.declarationList.declarations)d.isIdentifier(i.name)&&t.internalExports.exports.push(i.name.text);return}(d.isEnumDeclaration(e)||d.isClassDeclaration(e)||d.isFunctionDeclaration(e)||d.isInterfaceDeclaration(e)||d.isTypeAliasDeclaration(e))&&e.name&&d.isIdentifier(e.name)&&t.internalExports.exports.push(e.name.text)}};st=F(null),ee=P(st,0,"GraphModel",_t,ee),k(st,1,ee);import K from"typescript";import{mkdir as Ei,writeFile as Ii}from"fs/promises";var Vt=`/**
|
|
356
356
|
* This file was automatically generated by xBuild.
|
|
357
357
|
* DO NOT EDIT MANUALLY.
|
|
358
358
|
*/
|
|
359
|
-
`;var
|
|
360
|
-
`)} } from '${s}';`)}return{exports:t,declarations:i,externalExports:o}}parseContent(e,t,i){let o=[
|
|
359
|
+
`;var Be=class{constructor(e,t){this.languageService=e;this.languageHostService=t}graphModel=f(ee);async emit(e,t){let i=this.languageService?.getProgram();if(!i)throw new Error("Language service program not available");let o=this.languageHostService.getCompilationSettings();t&&(o={...o,outDir:t}),await Promise.all(Object.entries(e).map(async([n,s])=>{let a=i.getSourceFile(s);if(!a)return;let c=h(o.outDir,`${n}.d.ts`);await this.bundleCollectDeclarations(a,i,c)}))}generateRandomName(e){let t="abcdefghijklmnopqrstuvwxyz",i;do i=Array.from({length:3},()=>t[Math.floor(Math.random()*t.length)]).join("");while(e.has(i));return e.add(i),i}async bundleCollectDeclarations(e,t,i){let o=this.graphModel.scan(e,this.languageService,this.languageHostService),n=await this.getBundleContent(o,t);await Ei($(i),{recursive:!0}),await Ii(i,n,"utf-8")}async getBundleContent(e,t){let i=new Set,o=new Set([e]),n=new Set([e]),s=[...e.internalDeps],a=new Set(e.internalExports.star),c="";for(;s.length>0;){let l=s.pop();if(i.has(l))continue;i.add(l);let u=t.getSourceFile(l);if(!u)continue;let p=this.graphModel.scan(u,this.languageService,this.languageHostService);if(n.add(p),a.has(l)){o.add(p);for(let x of p.internalExports.star)a.add(x)}for(let x of p.internalDeps)i.has(x)||s.push(x);c+=p.content}return c+=e.content,this.parseContent(c,n,o)}collectExternalImports(e){let t=new Map;for(let i of e){for(let[o,n]of Object.entries(i.externalImports.default)){t.has(o)||t.set(o,{named:new Set,namespace:new Map});let s=t.get(o);s.default||(s.default=n)}for(let[o,n]of Object.entries(i.externalImports.named)){t.has(o)||t.set(o,{named:new Set,namespace:new Map});for(let s of n)t.get(o).named.add(s)}for(let[o,n]of Object.entries(i.externalImports.namespace))t.has(n)||t.set(n,{named:new Set,namespace:new Map}),t.get(n).namespace.set(o,n)}return t}generateImportStatements(e){let t=[];for(let[i,{default:o,named:n,namespace:s}]of e){let a=[];if(o&&a.push(o),n.size>0&&a.push(`{ ${Array.from(n).sort().join(", ")} }`),s.size>0)for(let[c]of s)t.push(`import * as ${c} from '${i}';`);a.length>0&&t.push(`import ${a.join(", ")} from '${i}';`)}return t}collectNamespaceExports(e,t=new Set){if(t.has(e))return{exports:[],declarations:[]};t.add(e);let i=this.graphModel.get(e);if(!i)return{exports:[],declarations:[]};let o=[...i.internalExports.exports],n=[];for(let[s,a]of Object.entries(i.internalExports.namespace)){let c=this.collectNamespaceExports(a,t);c.exports.length>0&&(n.push(...c.declarations),n.push(`const ${s} = { ${c.exports.join(", ")} };`),o.push(s))}for(let s of i.externalExports.star){let a=this.collectNamespaceExports(s,t);o.push(...a.exports),n.push(...a.declarations)}return{exports:o,declarations:n}}collectBundleExports(e){let t=[],i=[],o=[];for(let n of e){t.push(...n.internalExports.exports);for(let[s,a]of Object.entries(n.internalExports.namespace)){let c=this.collectNamespaceExports(a);c.exports.length>0&&(i.push(...c.declarations),i.push(`const ${s} = { ${c.exports.join(", ")} };`),t.push(s))}for(let s of n.externalExports.star)i.push(`export * from '${s}';`);for(let[s,a]of Object.entries(n.externalExports.namespace))o.push(`export * as ${s} from '${a}';`);for(let[s,a]of Object.entries(n.externalExports.exports))o.push(`export { ${a.join(`,
|
|
360
|
+
`)} } from '${s}';`)}return{exports:t,declarations:i,externalExports:o}}parseContent(e,t,i){let o=[Vt],n=this.collectExternalImports(t),s=this.generateImportStatements(n);o.push(...s),s.length>0&&o.push("");let{exports:a,declarations:c,externalExports:l}=this.collectBundleExports(i);if(c.length>0&&(o.push(...c),o.push("")),o.push(e),a.length>0){let u=Array.from(new Set(a)).sort();o.push(`export {
|
|
361
361
|
${u.join(`,
|
|
362
362
|
`)}
|
|
363
363
|
};`)}return l.length>0&&o.push(...l),o.join(`
|
|
364
|
-
`)}};import{mkdir as Ti,writeFile as Oi}from"fs/promises";import{xterm as Fi}from"@remotex-labs/xansi/xterm.component";var
|
|
365
|
-
`)};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}};ct=F(null),N=P(ct,0,"TypescriptService",zt,N),k(ct,1,N);var oe=N;import{cwd as De}from"process";import{build as lt}from"esbuild";var Wt={write:!1,bundle:!0,minify:!0,outdir:`${De()}`,format:"esm",target:"esnext",platform:"browser",sourcemap:"external",mangleQuoted:!0,sourcesContent:!0,preserveSymlinks:!0};async function Gt(r,e={}){try{return await lt({absWorkingDir:De(),...Wt,...e,metafile:!0,entryPoints:r})}catch(t){if(ee(t)){let i=new AggregateError([],"Failed to build entryPoints");throw he(t.errors,i.errors),i}throw t}}async function qt(r,e,t={}){return await lt({absWorkingDir:De(),...Wt,...t,stdin:{loader:"js",contents:r,resolveDir:De(),sourcefile:e},write:!1,metafile:!0,logLevel:"silent",sourcemap:"external"})}async function je(r,e={}){try{return await lt({...e,outdir:"tmp",write:!1,bundle:!0,metafile:!0,packages:"external",logLevel:"silent",entryPoints:r})}catch(t){if(ee(t)){let i=new AggregateError([],"Failed to analyze entryPoint");throw he(t.errors,i.errors),i}throw t}}function Kt(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=Pe(r,e)),t}else if(e&&typeof e=="object")return e;throw new $("Unsupported entry points format")}var Le=class{constructor(e,t,i,o={}){this.name=e;this.lifecycle=t;this.buildConfig=i;this.argv=o;if(!this.buildConfig?.esbuild)throw new $(`Variant '${this.name}' not found configuration`);this.tsConfigPath=this.buildConfig.esbuild.tsconfig??"tsconfig.json",this.typescriptModule=new oe(this.tsConfigPath),this.buildConfig=this.initializeConfig(this.getConfig(this.buildConfig,this.configService.getValue().common)),this.typescriptModule.languageHostService.touchFiles(Object.values(this.buildConfig.esbuild.entryPoints)),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})}dependenciesFile;active=!0;tsConfigPath;typescriptModule;configUnsubscribe;configService=f(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){this.applyInjections(),this.dependenciesFile=await this.buildDependencyMap(),this.buildConfig.esbuild.bundle===!1&&(this.buildConfig.esbuild.entryPoints=this.dependenciesFile);try{let e=await ki(this.buildConfig.esbuild);return await this.packageTypeComponent(),e}catch(e){if(ee(e)){if(e.errors.filter(i=>i.pluginName==="").length>0)throw e;return{errors:e.errors,warnings:e.warnings}}throw e}}}getConfig(e,t={}){return e?K({},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;let i=new U("Type checking failed",t);return typeof this.buildConfig.types=="object"&&!this.buildConfig.types.failOnError?e.warnings?.push({detail:i,location:void 0}):e.errors?.push({detail:i,location:void 0}),e}async end(e){if(e.buildResult.errors?.length>0)return;let t={errors:[],warnings:[]};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 Ai(e,{recursive:!0}),await Pi(v(e,"package.json"),`{"type": "${t}"}`)}initializeConfig(e){if(!e)throw new $(`Variant '${this.name}' not found configuration`);if(!e.esbuild.entryPoints)throw new $("Entry points are required in esbuild configuration");let t=e.define,i=t?Object.fromEntries(Object.entries(t).map(([o,n])=>[o,JSON.stringify(n)])):void 0;return this.registerConfigHooks(e.lifecycle),e.esbuild.tsconfig??="tsconfig.json",e.esbuild.entryPoints=Kt(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.tsconfig&&i.esbuild.tsconfig!==this.tsConfigPath&&(this.typescriptModule.dispose(this.tsConfigPath),this.tsConfigPath=i.esbuild.tsconfig,this.typescriptModule=new oe(this.tsConfigPath)))}stripExtension(e){let t=e.lastIndexOf(".");return t>0?e.substring(0,t):e}async buildDependencyMap(){let{esbuild:e}=this.buildConfig,{metafile:t}=await je(e.entryPoints,{platform:e.platform}),i={};for(let o of Object.keys(t.inputs)){let n=T(this.typescriptModule.config.options.rootDir,C(o)),s=this.stripExtension(n);i[s]=o}return i}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 Ri}from"fs/promises";var He=class{constructor(e,t){this.variantName=e;this.argv=t}filesModel=f(y);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,variantName:this.variantName,stage:{startTime:new Date}};e.initialOptions.metafile=!0,this.startHooks.size>0&&e.onStart(async()=>this.executeStartHooks(e,t)),(this.endHooks.size>0||this.successHooks.size>0)&&e.onEnd(async i=>this.executeEndHooks(i,t)),this.resolveHooks.size>0&&e.onResolve({filter:/.*/},async i=>this.executeResolveHooks(i,t)),this.loadHooks.size>0&&e.onLoad({filter:/.*/},async i=>this.executeLoadHooks(i,t))}}}async executeStartHooks(e,t){t.stage.startTime=new Date;let i={errors:[],warnings:[]};for(let o of this.startHooks.values()){let n=await o({build:e,...t});n&&(n.errors&&i.errors.push(...n.errors),n.warnings&&i.warnings.push(...n.warnings))}return i}async executeEndHooks(e,t){let i={errors:[],warnings:[]},o=Date.now()-t.stage.startTime.getTime();for(let n of this.endHooks.values()){let s=await n({buildResult:e,duration:o,...t});s&&(s.errors&&i.errors.push(...s.errors),s.warnings&&i.warnings.push(...s.warnings))}if(e.errors.length===0)for(let n of this.successHooks.values())await n({buildResult:e,duration:o,...t});return i}async executeResolveHooks(e,t){let i;for(let o of this.resolveHooks.values()){let n=await o({args:e,...t});n&&(i?i={...i,...n}:i=n)}return i??null}async executeLoadHooks(e,t){let i,o="default",n={errors:[],warnings:[]},s=C(e.path),a=this.filesModel.getSnapshot(s);a&&a.contentSnapshot?i=a.contentSnapshot.text:i=await Ri(s,"utf8");for(let c of this.loadHooks.values()){let l=await c({contents:i,loader:o,args:e,...t});l&&(l.contents!==void 0&&(i=l.contents),l.loader&&(o=l.loader),l.errors&&n.errors.push(...l.errors),l.warnings&&n.warnings.push(...l.warnings))}return{contents:i,loader:o,...n}}};import S from"typescript";import Y from"typescript";var Bi="$$ifdef";function Mi(r,e,t,i=!1){let o=i?"export function ":"function ";return Y.isArrowFunction(e)||Y.isFunctionExpression(e)?$i(r,e,t,o):`${i?"export const ":"const "}${r} = ${e.getText(t)};`}function $i(r,e,t,i){let o=e.parameters.map(a=>a.getText(t)).join(", "),n=e.type?`: ${e.type.getText(t)}`:"",s=Ni(e,t);return`${i}${r}(${o})${n} ${s}`}function Ni(r,e){let t=r.body.getText(e);return Y.isArrowFunction(r)&&!Y.isBlock(r.body)?`{ return ${t}; }`:t}function Di(r,e){return Y.isArrowFunction(r)||Y.isFunctionExpression(r)?`(${r.getText(e)})()`:`(() => { return ${r.getText(e)}; })()`}function Xt(r,e,t){let i=r in t&&!!t[r];return e===Bi===i}function Yt(r,e,t,i){let[o,n]=e.arguments;if(!Y.isStringLiteral(o))return!1;let s=e.expression.text,a=o.text;if(!Xt(a,s,i.defines))return"";let c=r.name.getText(i.sourceFile);return Mi(c,n,i.sourceFile,t)}function Jt(r,e,t){let[i,o]=r;if(!Y.isStringLiteral(i))return!1;let n=i.text;return Xt(n,e,t.defines)?Di(o,t.sourceFile):""}import M from"typescript";import{createRequire as Hi}from"module";var _e=class extends m{constructor(e,t=0){super(e.message,"InlineError"),this.errorMetadata=_(e,{},t),this.stack=V(this.errorMetadata,this.name,this.message)}};import{Script as ji,createContext as Li}from"vm";async function Qt(r,e={},t={}){let i=new ji(r,t),o=Li(e);return await i.runInContext(o,{breakOnSigint:!0,displayErrors:!1})}async function Zt(r,e,t){let[i,o]=(await qt(r,e.sourceFile.fileName,{bundle:!0,format:"cjs",platform:"node",packages:"external"})).outputFiles;try{let n={exports:{}},s=Hi(e.sourceFile.fileName),a=await Qt(o.text,_i(e.sourceFile.fileName,n,s),{filename:e.sourceFile.fileName});if(a==null)return"undefined";if(typeof a=="string")return JSON.stringify(a);if(typeof a=="number"||typeof a=="boolean")return String(a)}catch(n){Vi(n,e,i.text,t)}return"undefined"}function _i(r,e,t){return{...globalThis,Error,RegExp,process,Buffer,module:e,require:t,console,setTimeout,setInterval,clearTimeout,clearInterval,ReferenceError,__dirname:B(r),__filename:r}}function Vi(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);f(b).setSource(t,e.sourceFile.fileName);let s=new _e(r,n);e.errors.push({text:s.message,detail:s})}function Ui(r,e){let t=null,i=o=>{if(!t){if(M.isFunctionDeclaration(o)&&o.name?.text===r){t=o;return}M.isVariableStatement(o)&&(t=zi(o,r),t)||M.forEachChild(o,i)}};return i(e),t}function zi(r,e){for(let t of r.declarationList.declarations)if(M.isIdentifier(t.name)&&t.name.text===e&&t.initializer&&(M.isArrowFunction(t.initializer)||M.isFunctionExpression(t.initializer)))return t.initializer;return null}function er(r){return`module.exports = (${r})();`}function Wi(r){return r&M.NodeFlags.Const?"const":r&M.NodeFlags.Let?"let":"var"}function tr(r,e){return r?M.isIdentifier(r)?Gi(r,e):M.isArrowFunction(r)||M.isFunctionExpression(r)?{node:r,data:er(r.getText(e.sourceFile))}:{node:r,data:r.getText(e.sourceFile)}:null}function Gi(r,e){let t=Ui(r.text,e.sourceFile);return t?{node:t,data:er(t.getText(e.sourceFile))}:(qi(r.text,e,r),{data:"",node:r})}function qi(r,e,t){let i=t.getStart(e.sourceFile),{line:o,character:n}=e.sourceFile.getLineAndCharacterOfPosition(i),s=T(".",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 rr(r,e,t,i,o){let n=t.arguments[0],s=tr(n,o);if(!s)return!1;let a=await Zt(s.data,o,s.node),c=Wi(e.declarationList.flags),l=i?"export ":"",u=r.name.getText(o.sourceFile);return`${l}${c} ${u} = ${a};`}async function pt(r,e){let t=r[0],i=tr(t,e);return i?Zt(i.data,e,i.node):!1}var Ki=/\.(ts|js)$/,W=["$$ifdef","$$ifndef","$$inline"];async function Xi(r,e,t){for(let i of r.declarationList.declarations){let o=i.initializer;if(!o||!S.isCallExpression(o)||!S.isIdentifier(o.expression))continue;let n=o.expression.text;if(!W.includes(n))continue;let s=n==W[2]?1:2;if(!W.includes(n)||o.arguments.length<s){e.add({replacement:"undefined",end:r.getEnd(),start:r.getStart(t.sourceFile)});return}let a=r.modifiers?.some(l=>l.kind===S.SyntaxKind.ExportKeyword)??!1,c=!1;n===W[2]?c=await rr(i,r,o,a,t):c=Yt(i,o,a,t),c!==!1&&e.add({replacement:c,end:r.getEnd(),start:r.getStart(t.sourceFile)})}}async function Yi(r,e,t){let i=r.expression;if(!S.isIdentifier(i.expression))return;let o=i.expression.text,n=o==W[2]?1:2;if(!W.includes(o)||i.arguments.length<n){e.add({replacement:"undefined",end:r.getEnd(),start:r.getStart(t.sourceFile)});return}let s=!1;o==W[2]?s=await pt(i.arguments,t):s=Jt(i.arguments,o,t),s!==!1&&e.add({replacement:s,end:r.getEnd(),start:r.getStart(t.sourceFile)})}async function Ji(r){let e=new Set,t=r.stage.defineMetadata.disabledMacroNames,i=async n=>{if(S.isVariableStatement(n))await Xi(n,e,r);else if(S.isExpressionStatement(n)&&S.isCallExpression(n.expression))await Yi(n,e,r);else if(S.isCallExpression(n)&&S.isIdentifier(n.expression)&&n.expression.text===W[2]){let a=n.parent;if(!a||!S.isVariableDeclaration(a)&&!S.isExpressionStatement(a)){let c=await pt(n.arguments,r);c!==!1&&e.add({replacement:c,end:n.getEnd(),start:n.getStart(r.sourceFile)})}}else if(S.isCallExpression(n)&&S.isIdentifier(n.expression)&&t.has(n.expression.text))e.add({start:n.getStart(r.sourceFile),end:n.getEnd(),replacement:"undefined"});else if(S.isIdentifier(n)&&t.has(n.text)){let a=n.parent,c=a?.getText(r.sourceFile);(!a||!S.isCallExpression(a)||a.expression!==n)&&(!c||W.every(l=>!c.includes(l)))&&e.add({start:n.getStart(r.sourceFile),end:n.getEnd(),replacement:"undefined"})}let s=n.getChildren(r.sourceFile);for(let a of s)await i(a)};if(await i(r.sourceFile),e.size===0)return r.contents;let o=Array.from(e);o.sort((n,s)=>s.start-n.start);for(let{start:n,end:s,replacement:a}of o)r.contents=r.contents.slice(0,n)+a+r.contents.slice(s);return r.contents}async function ir(r,e){let{args:t,loader:i,stage:o,contents:n}=e;if(t.path.includes("node_modules")||n.length<1||!Ki.test(t.path))return;let a=r.typescript.languageService.getProgram()?.getSourceFile(t.path);if(!a)return;let c=n.toString(),l={stage:o,errors:[],contents:c,warnings:[],defines:r.config.define??{},sourceFile:a};return a&&(c=await Ji(l)),r.config.esbuild.bundle||r.typescript.languageHostService.aliasRegex&&(c=r.typescript.languageHostService.resolveAliases(c,t.path,".js")),{loader:i,contents:c,warnings:l.warnings,errors:l.errors}}var or="$$",nr=/(?:(?:export\s+)?(?:const|let|var)\s+([\w$]+)\s*=\s*)?\$\$(ifdef|ifndef)\s*\(\s*['"]([^'"]+)['"]/g;function Qi(r,e,t,i){let o=1;for(let n=0;n<i;n++)r[n]===`
|
|
364
|
+
`)}};import{mkdir as Ti,writeFile as Oi}from"fs/promises";import{xterm as Fi}from"@remotex-labs/xansi/xterm.component";var Me=class r{constructor(e,t){this.languageService=e;this.languageHostService=t}static emittedVersions=new Map;static clearCache(){this.emittedVersions.clear()}async emit(e){let t=this.languageService.getProgram();if(!t)throw new Error(`${Fi.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=nt(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=nt(e.fileName,t);o=$e(o),o=this.languageHostService.resolveAliases(o,e.fileName,".d.ts"),await Ti($(n),{recursive:!0}),await Oi(n,o,"utf8")}};import ie from"typescript";var Ne=class r{constructor(e={}){this.compilerOptions=e;this.alias=r.generateAliasRegex(e),this.moduleResolutionCache=ie.createModuleResolutionCache(process.cwd(),t=>t,this.compilerOptions)}static sys=ie.sys;alias;aliasCache=new Map;moduleResolutionCache;trackFiles=new Set;filesCache=f(v);get aliasRegex(){return this.alias}set options(e){this.compilerOptions=e,this.alias=r.generateAliasRegex(e),this.moduleResolutionCache=ie.createModuleResolutionCache(process.cwd(),t=>t,this.compilerOptions)}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 ie.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 ie.resolveModuleName(e,t,this.compilerOptions,ie.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=T(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,at;Ut=[A({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 Me(o,i),this.bundlerService=new Be(o,i)}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){return e&&!e.fileName.includes("node_modules")&&!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 Ne(e.options),i=K.createLanguageService(t,K.createDocumentRegistry()),o={config:e,host:t,service:i,refCount:1};return N.serviceCache.set(this.configPath,o),o}parseConfig(){let e=K.getParsedCommandLineOfConfigFile(this.configPath,{skipLibCheck:!0,stripInternal:!0,emitDeclarationOnly:!0},{...K.sys,onUnRecoverableConfigFileDiagnostic:()=>{}});return e||(e={options:{strict:!0,target:K.ScriptTarget.ESNext,module:K.ModuleKind.NodeNext,declaration:!0,skipLibCheck:!0,moduleResolution:K.ModuleResolutionKind.NodeNext},errors:[],fileNames:[],projectReferences:void 0}),e.options={...e.options,rootDir:e.options?.rootDir??process.cwd()},e}formatDiagnostic(e){let t={message:K.flattenDiagnosticMessageText(e.messageText,`
|
|
365
|
+
`)};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}};at=F(null),N=P(at,0,"TypescriptService",Ut,N),k(at,1,N);var oe=N;import{cwd as De}from"process";import{build as ct}from"esbuild";var zt={write:!1,bundle:!0,minify:!0,outdir:`${De()}`,format:"esm",target:"esnext",platform:"browser",sourcemap:"external",mangleQuoted:!0,sourcesContent:!0,preserveSymlinks:!0};async function Wt(r,e={}){try{return await ct({absWorkingDir:De(),...zt,...e,metafile:!0,entryPoints:r})}catch(t){if(Z(t)){let i=new AggregateError([],"Failed to build entryPoints");throw he(t.errors,i.errors),i}throw t}}async function Gt(r,e,t={}){return await ct({absWorkingDir:De(),...zt,...t,stdin:{loader:"js",contents:r,resolveDir:De(),sourcefile:e},write:!1,metafile:!0,logLevel:"silent",sourcemap:"external"})}async function qt(r,e={}){try{return await ct({...e,outdir:"tmp",write:!1,bundle:!0,metafile:!0,packages:"external",logLevel:"silent",entryPoints:r})}catch(t){if(Z(t)){let i=new AggregateError([],"Failed to analyze entryPoint");throw he(t.errors,i.errors),i}throw t}}function Kt(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=Pe(r,e)),t}else if(e&&typeof e=="object")return e;throw new M("Unsupported entry points format")}var je=class{constructor(e,t,i,o={}){this.name=e;this.lifecycle=t;this.buildConfig=i;this.argv=o;if(!this.buildConfig?.esbuild)throw new M(`Variant '${this.name}' not found configuration`);this.tsConfigPath=this.buildConfig.esbuild.tsconfig??"tsconfig.json",this.typescriptModule=new oe(this.tsConfigPath),this.buildConfig=this.initializeConfig(this.getConfig(this.buildConfig,this.configService.getValue().common)),this.typescriptModule.languageHostService.touchFiles(Object.values(this.buildConfig.esbuild.entryPoints)),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})}dependenciesFile;active=!0;tsConfigPath;typescriptModule;configUnsubscribe;configService=f(y);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){this.applyInjections(),this.dependenciesFile=await this.buildDependencyMap(),this.buildConfig.esbuild.bundle===!1&&(this.buildConfig.esbuild.entryPoints=this.dependenciesFile);try{let e=await ki(this.buildConfig.esbuild);return await this.packageTypeComponent(),e}catch(e){if(Z(e)){if(e.errors.filter(i=>i.pluginName==="").length>0)throw e;return{errors:e.errors,warnings:e.warnings}}throw e}}}getConfig(e,t={}){return e?q({},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;let i=new V("Type checking failed",t);return typeof this.buildConfig.types=="object"&&!this.buildConfig.types.failOnError?e.warnings?.push({detail:i,location:void 0}):e.errors?.push({detail:i,location:void 0}),e}async end(e){if(e.buildResult.errors?.length>0)return;let t={errors:[],warnings:[]};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 Ai(e,{recursive:!0}),await Pi(h(e,"package.json"),`{"type": "${t}"}`)}initializeConfig(e){if(!e)throw new M(`Variant '${this.name}' not found configuration`);if(!e.esbuild.entryPoints)throw new M("Entry points are required in esbuild configuration");let t=e.define,i=t?Object.fromEntries(Object.entries(t).map(([o,n])=>[o,JSON.stringify(n)])):void 0;return this.registerConfigHooks(e.lifecycle),e.esbuild.tsconfig??="tsconfig.json",e.esbuild.entryPoints=Kt(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.tsconfig&&i.esbuild.tsconfig!==this.tsConfigPath&&(this.typescriptModule.dispose(this.tsConfigPath),this.tsConfigPath=i.esbuild.tsconfig,this.typescriptModule=new oe(this.tsConfigPath)))}stripExtension(e){let t=e.lastIndexOf(".");return t>0?e.substring(0,t):e}async buildDependencyMap(){let{esbuild:e}=this.buildConfig,{metafile:t}=await qt(e.entryPoints,{loader:e.loader,platform:e.platform}),i={};for(let o of Object.keys(t.inputs)){let n=T(this.typescriptModule.config.options.rootDir,C(o)),s=this.stripExtension(n);i[s]=o}return i}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 Ri}from"fs/promises";var Le=class{constructor(e,t){this.variantName=e;this.argv=t}filesModel=f(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,variantName:this.variantName,stage:{startTime:new Date}};e.initialOptions.metafile=!0,this.startHooks.size>0&&e.onStart(async()=>this.executeStartHooks(e,t)),(this.endHooks.size>0||this.successHooks.size>0)&&e.onEnd(async i=>this.executeEndHooks(i,t)),this.resolveHooks.size>0&&e.onResolve({filter:/.*/},async i=>this.executeResolveHooks(i,t)),this.loadHooks.size>0&&e.onLoad({filter:/.*/},async i=>this.executeLoadHooks(i,t))}}}async executeStartHooks(e,t){t.stage.startTime=new Date;let i={errors:[],warnings:[]};for(let o of this.startHooks.values()){let n=await o({build:e,...t});n&&(n.errors&&i.errors.push(...n.errors),n.warnings&&i.warnings.push(...n.warnings))}return i}async executeEndHooks(e,t){let i={errors:[],warnings:[]},o=Date.now()-t.stage.startTime.getTime();for(let n of this.endHooks.values()){let s=await n({buildResult:e,duration:o,...t});s&&(s.errors&&i.errors.push(...s.errors),s.warnings&&i.warnings.push(...s.warnings))}if(e.errors.length===0)for(let n of this.successHooks.values())await n({buildResult:e,duration:o,...t});return i}async executeResolveHooks(e,t){let i;for(let o of this.resolveHooks.values()){let n=await o({args:e,...t});n&&(i?i={...i,...n}:i=n)}return i??null}async executeLoadHooks(e,t){let i,o="default",n={errors:[],warnings:[]},s=C(e.path),a=this.filesModel.getSnapshot(s);a&&a.contentSnapshot?i=a.contentSnapshot.text:i=await Ri(s,"utf8");for(let c of this.loadHooks.values()){let l=await c({contents:i,loader:o,args:e,...t});l&&(l.contents!==void 0&&(i=l.contents),l.loader&&(o=l.loader),l.errors&&n.errors.push(...l.errors),l.warnings&&n.warnings.push(...l.warnings))}return{contents:i,loader:o,...n}}};import S from"typescript";import X from"typescript";var $i="$$ifdef";function Bi(r,e,t,i=!1){let o=i?"export function ":"function ";return X.isArrowFunction(e)||X.isFunctionExpression(e)?Mi(r,e,t,o):`${i?"export const ":"const "}${r} = ${e.getText(t)};`}function Mi(r,e,t,i){let o=e.parameters.map(a=>a.getText(t)).join(", "),n=e.type?`: ${e.type.getText(t)}`:"",s=Ni(e,t);return`${i}${r}(${o})${n} ${s}`}function Ni(r,e){let t=r.body.getText(e);return X.isArrowFunction(r)&&!X.isBlock(r.body)?`{ return ${t}; }`:t}function Di(r,e){return X.isArrowFunction(r)||X.isFunctionExpression(r)?`(${r.getText(e)})()`:`(() => { return ${r.getText(e)}; })()`}function Xt(r,e,t){let i=r in t&&!!t[r];return e===$i===i}function Yt(r,e,t,i){let[o,n]=e.arguments;if(!X.isStringLiteral(o))return!1;let s=e.expression.text,a=o.text;if(!Xt(a,s,i.defines))return"";let c=r.name.getText(i.sourceFile);return Bi(c,n,i.sourceFile,t)}function Jt(r,e,t){let[i,o]=r;if(!X.isStringLiteral(i))return!1;let n=i.text;return Xt(n,e,t.defines)?Di(o,t.sourceFile):""}import B from"typescript";import{createRequire as Hi}from"module";var He=class extends g{constructor(e,t=0){super(e.message,"InlineError"),this.errorMetadata=H(e,{},t),this.stack=_(this.errorMetadata,this.name,this.message)}};import{Script as ji,createContext as Li}from"vm";async function Qt(r,e={},t={}){let i=new ji(r,t),o=Li(e);return await i.runInContext(o,{breakOnSigint:!0,displayErrors:!1})}async function Zt(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=Hi(e.sourceFile.fileName),a=await Qt(o.text,_i(e.sourceFile.fileName,n,s),{filename:e.sourceFile.fileName});if(a==null)return"undefined";if(typeof a=="string")return JSON.stringify(a);if(typeof a=="number"||typeof a=="boolean")return String(a)}catch(n){Vi(n,e,i.text,t)}return"undefined"}function _i(r,e,t){return{...globalThis,Error,RegExp,process,Buffer,module:e,require:t,console,setTimeout,setInterval,clearTimeout,clearInterval,ReferenceError,__dirname:$(r),__filename:r}}function Vi(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);f(b).setSource(t,e.sourceFile.fileName);let s=new He(r,n);e.errors.push({text:s.message,detail:s})}function Ui(r,e){let t=null,i=o=>{if(!t){if(B.isFunctionDeclaration(o)&&o.name?.text===r){t=o;return}B.isVariableStatement(o)&&(t=zi(o,r),t)||B.forEachChild(o,i)}};return i(e),t}function zi(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 er(r){return`module.exports = (${r})();`}function Wi(r){return r&B.NodeFlags.Const?"const":r&B.NodeFlags.Let?"let":"var"}function tr(r,e){return r?B.isIdentifier(r)?Gi(r,e):B.isArrowFunction(r)||B.isFunctionExpression(r)?{node:r,data:er(r.getText(e.sourceFile))}:{node:r,data:r.getText(e.sourceFile)}:null}function Gi(r,e){let t=Ui(r.text,e.sourceFile);return t?{node:t,data:er(t.getText(e.sourceFile))}:(qi(r.text,e,r),{data:"",node:r})}function qi(r,e,t){let i=t.getStart(e.sourceFile),{line:o,character:n}=e.sourceFile.getLineAndCharacterOfPosition(i),s=T(".",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 rr(r,e,t,i,o){let n=t.arguments[0],s=tr(n,o);if(!s)return!1;let a=await Zt(s.data,o,s.node),c=Wi(e.declarationList.flags),l=i?"export ":"",u=r.name.getText(o.sourceFile);return`${l}${c} ${u} = ${a};`}async function lt(r,e){let t=r[0],i=tr(t,e);return i?Zt(i.data,e,i.node):!1}var Ki=/\.(ts|js)$/,z=["$$ifdef","$$ifndef","$$inline"];async function Xi(r,e,t){for(let i of r.declarationList.declarations){let o=i.initializer;if(!o||!S.isCallExpression(o)||!S.isIdentifier(o.expression))continue;let n=o.expression.text;if(!z.includes(n))continue;let s=n==z[2]?1:2;if(!z.includes(n))return;if(o.arguments.length<s)throw new Error(`Invalid macro call: ${n} with ${o.arguments.length} arguments`);let a=r.modifiers?.some(l=>l.kind===S.SyntaxKind.ExportKeyword)??!1,c=!1;n===z[2]?c=await rr(i,r,o,a,t):c=Yt(i,o,a,t),c!==!1&&e.add({replacement:c,end:r.getEnd(),start:r.getStart(t.sourceFile)})}}async function Yi(r,e,t){let i=r.expression;if(!S.isIdentifier(i.expression))return;let o=i.expression.text,n=o==z[2]?1:2;if(!z.includes(o))return;if(i.arguments.length<n)throw new Error(`Invalid macro call: ${o} with ${i.arguments.length} arguments`);let s=!1;o==z[2]?s=await lt(i.arguments,t):s=Jt(i.arguments,o,t),s!==!1&&e.add({replacement:s,end:r.getEnd(),start:r.getStart(t.sourceFile)})}async function Ji(r){let e=new Set,t=r.stage.defineMetadata.disabledMacroNames,i=async n=>{if(S.isVariableStatement(n))await Xi(n,e,r);else if(S.isExpressionStatement(n)&&S.isCallExpression(n.expression))await Yi(n,e,r);else if(S.isCallExpression(n)&&S.isIdentifier(n.expression)&&n.expression.text===z[2]){let a=n.parent;if(!a||!S.isVariableDeclaration(a)&&!S.isExpressionStatement(a)){let c=await lt(n.arguments,r);c!==!1&&e.add({replacement:c,end:n.getEnd(),start:n.getStart(r.sourceFile)})}}else if(S.isCallExpression(n)&&S.isIdentifier(n.expression)&&t.has(n.expression.text))e.add({start:n.getStart(r.sourceFile),end:n.getEnd(),replacement:"undefined"});else if(S.isIdentifier(n)&&t.has(n.text)){let a=n.parent,c=a?.getText(r.sourceFile);(!a||!S.isCallExpression(a)||a.expression!==n)&&(!c||z.every(l=>!c.includes(l)))&&e.add({start:n.getStart(r.sourceFile),end:n.getEnd(),replacement:"undefined"})}let s=n.getChildren(r.sourceFile);for(let a of s)await i(a)};if(await i(r.sourceFile),e.size===0)return r.contents;let o=Array.from(e);o.sort((n,s)=>s.start-n.start);for(let{start:n,end:s,replacement:a}of o)r.contents=r.contents.slice(0,n)+a+r.contents.slice(s);return r.contents}async function ir(r,e){let{args:t,loader:i,stage:o,contents:n}=e;if(t.path.includes("node_modules")||n.length<1||!Ki.test(t.path))return;let a=r.typescript.languageService.getProgram()?.getSourceFile(t.path);if(!a)return;let c=n.toString(),l={stage:o,errors:[],contents:c,warnings:[],defines:r.config.define??{},sourceFile:a};return a&&(c=await Ji(l)),r.config.esbuild.bundle||r.typescript.languageHostService.aliasRegex&&(c=r.typescript.languageHostService.resolveAliases(c,t.path,".js")),{loader:i,contents:c,warnings:l.warnings,errors:l.errors}}var or="$$",nr=/(?:(?:export\s+)?(?:const|let|var)\s+([\w$]+)\s*=\s*)?\$\$(ifdef|ifndef)\s*\(\s*['"]([^'"]+)['"]/g;function Qi(r,e,t,i){let o=1;for(let n=0;n<i;n++)r[n]===`
|
|
366
366
|
`&&o++;return{file:t,line:o,column:r.indexOf(e,i)-i}}function Zi(r,e){let t=r.lastIndexOf(`
|
|
367
|
-
`,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 sr(r,e){let t={disabledMacroNames:new Set,filesWithMacros:new Set};e.stage.defineMetadata=t;let i=[],o=
|
|
367
|
+
`,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 sr(r,e){let t={disabledMacroNames:new Set,filesWithMacros:new Set};e.stage.defineMetadata=t;let i=[],o=f(v),n=r.config.define??{},s=Object.keys(r.dependencies);if(!s)return Promise.resolve({warnings:i});for(let a of s){let l=(o.getSnapshot(a)??o.touchFile(a))?.contentSnapshot?.text;if(l){nr.lastIndex=0;for(let u of l.matchAll(nr)){if(Zi(l,u.index))continue;t.filesWithMacros.add(o.resolve(a));let[,p,x,m]=u;if(!p)continue;let W=m in n&&!!n[m];x==="ifndef"===W&&t.disabledMacroNames.add(p),p.startsWith(or)||i.push({text:`Macro function '${p}' not start with '${or}' prefix to avoid conflicts`,location:Qi(l,p,a,u.index)})}}}return{warnings:i}}var be=class{constructor(e={}){this.argv=e;this.configuration.subscribe(this.parseVariants.bind(this))}onEndCallback;onStartCallback;variants={};configuration=f(y);get config(){return this.configuration.getValue()}set onEnd(e){this.onEndCallback=e}set onStart(e){this.onStartCallback=e}reload(e){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=[],i={},o=Object.entries(this.variants).map(async([n,s])=>{if(!(e&&!e.includes(n)))try{let a=await s.build();a&&(i[n]=ve(a))}catch(a){if(Z(a)||a instanceof AggregateError){let c=ve({errors:a.errors});t.push(...c.errors)}else a instanceof Error?t.push(a):t.push(new Error(String(a)))}});if(await Promise.allSettled(o),t.length)throw new AggregateError(t,"Build failed");return i}onEndTrigger(e){this.onEndCallback&&this.onEndCallback(e)}async onStartTrigger(e){try{let t=await sr(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 M("Variants are not defined in the configuration");for(let e of Object.keys(this.config.variants)){if(this.variants[e])continue;let t=new Le(e,this.argv);t.onEnd(this.onEndTrigger.bind(this),"build-service"),t.onStart(this.onStartTrigger.bind(this),"build-service"),this.variants[e]=new je(e,t,this.config.variants[e],this.argv),t.onLoad(ir.bind({},this.variants[e]),"build-service")}}};function ar(r){f(y).reload(r)}function cr(r){f(y).patch(r)}import{platform as to,exit as ro,stdin as _e,stdout as ft}from"process";import{xterm as Ve}from"@remotex-labs/xansi/xterm.component";var pt={SIGINT:"",SIGQUIT:""},E={HELP:"h",QUIT:"q",CLEAR:"c",RELOAD:"r",VERBOSE:"v",SHOW_URL:"u",OPEN_BROWSER:"o"},lr={win32:"start",darwin:"open",linux:"xdg-open"};function io(r=!1){let e=["\u{1F680} Shortcuts"],t=Ve.dim(" press "),i=(o,n)=>{e.push(`${t}${Ve.bold(o)}${Ve.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
|
|
368
368
|
`),e.join(`
|
|
369
|
-
`)}function
|
|
370
|
-
`.repeat(r)),
|
|
371
|
-
\u{1F44B} Exiting...`),ro(1)),e.name){case E.CLEAR:
|
|
369
|
+
`)}function ut(){let r=Math.max(0,ft.rows-2);r>0&&console.log(`
|
|
370
|
+
`.repeat(r)),dt.cursorTo(ft,0,0),dt.clearScreenDown(ft)}function oo(r){let e=lr[to]??"xdg-open";eo(`${e} ${r}`)}function no(r,e,t,i,o){if(e?.name)switch((e.sequence===E.QUIT||r===pt.SIGINT||r===pt.SIGQUIT)&&(console.log(`
|
|
371
|
+
\u{1F44B} Exiting...`),ro(1)),e.name){case E.CLEAR:ut();break;case E.VERBOSE:let n=f(y).getValue(s=>s.verbose);console.log(`\u{1F41E} Debug mode: ${n?"DISABLED":"ENABLED"}`),cr({verbose:!n});break;case E.RELOAD:ut(),t();break;case E.HELP:ut(),console.log(i);break;case E.SHOW_URL:o&&console.log(`${O()} ${Ve.canaryYellow(o)}`);break;case E.OPEN_BROWSER:o&&oo(o);break}}function pr(r,e){if(!_e.isTTY)return;let t=io(!!e);console.log(t),_e.setRawMode(!0),dt.emitKeypressEvents(_e),_e.on("keypress",(i,o)=>{no(i,o,r,t,e)})}import{existsSync as so}from"fs";import{runInThisContext as ao}from"vm";import{createRequire as co}from"module";var lo={minify:!1,format:"cjs",platform:"node",logLevel:"silent",packages:"external",minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1};async function mt(r){if(!r||!so(r))return{};f(v).touchFile(r);let[e,t]=(await Wt([r],{...lo,outdir:"tmp"})).outputFiles;f(b).setSource(e.text,r),globalThis.module={exports:{}},globalThis.require=co(C(r)),await ao(t.text,{filename:r});let i=module.exports.config??module.exports.default;return i||{}}import{xterm as Y}from"@remotex-labs/xansi/xterm.component";var fr=Y.hex("#80a36b"),Se=Y.hex("#dcdfe4"),ne=Y.hex("#5798cd"),D=Y.hex("#e5c07b"),we=Y.hex("#56b6c2"),J=Y.hex("#e06c75"),se=Y.hex("#c678dd"),Ue=Y.hex("#a5a7ab");import{xterm as mr}from"@remotex-labs/xansi/xterm.component";var j=" ",gt=1024,ur=gt*1024,gr="\u2014",ce="\u2192",ae="\xD7",po="\u2022";function Ee(r,e=ne.dim(ce)){return`${O()} ${e} ${ne(r)}`}function fo(r){return r<gt?`${r} B`:r<ur?`${(r/gt).toFixed(2)} KB`:`${(r/ur).toFixed(2)} MB`}function hr(r){let e=r.file?T(process.cwd(),r.file):"(unknown)",t=D(String((r.line??0)+1)),i=D(String((r.column??0)+1));return`${we(e)}:${t}:${i}`}function uo(r,e){if(!e.metadata?.formatCode)return;let t=e.metadata.formatCode.split(`
|
|
372
372
|
`),i=e.metadata.stacks.join(`
|
|
373
373
|
`);r.push("");for(let o of t)r.push(`${j}${o}`);r.push(""),r.push(`${j}Enhanced Stack Trace:`),r.push(` ${i}`)}function mo(r){if(!r.metadata?.formatCode)return;let e=r.metadata.formatCode.split(`
|
|
374
374
|
`).map(i=>`${j}${i}`).join(`
|
|
@@ -377,14 +377,14 @@ ${t}
|
|
|
377
377
|
${e}
|
|
378
378
|
|
|
379
379
|
${j}Enhanced Stack Trace:
|
|
380
|
-
${t}`)}function go(r,e,t){let i=hr(r),o=t(`TS${r.code}`),n=
|
|
381
|
-
${j}${D(t)} ${D("TypesError")}: ${
|
|
382
|
-
${j}${i(t)} ${e}`),e instanceof
|
|
380
|
+
${t}`)}function go(r,e,t){let i=hr(r),o=t(`TS${r.code}`),n=Ue(r.message);return`${j}${e} ${i} ${Se(ce)} ${o} ${Se(gr)} ${n}`}function vr(r,e,t=J){let i=hr(r),o=t(`TS${r.code}`),n=Ue(r.message);console.log(`${j}${e} ${i}`,Se(ce),`${o} ${Se(gr)} ${n}`)}function ho(r,e,t){let i=e.diagnostics.length;if(i===0)return r.push(`
|
|
381
|
+
${j}${D(t)} ${D("TypesError")}: ${Ue(e.message||"Type checking warning")}`),1;for(let o of e.diagnostics)r.push(go(o,D(t),mr.deepOrange));return i}function vo(r,e,t,i){r.push(`
|
|
382
|
+
${j}${i(t)} ${e}`),e instanceof g&&uo(r,e)}function yo(r,e,t,i){return e instanceof V?ho(r,e,t):(vo(r,e,t,i),1)}function dr(r,e){if(r.length===0)return;let t=e==="Errors",i=t?ae:po,o=t?J:D,n=0,s=[""];for(let a of r)n+=yo(s,a,i,o);s.push(""),s[0]=`
|
|
383
383
|
${o(e)} (${n})`,console.log(s.join(`
|
|
384
384
|
`))}function xo(r){let e=Object.entries(r.outputs),t=e.length,i=[];i.push(`
|
|
385
385
|
${fr("Outputs")} (${t})`);for(let[o,n]of e){let s=D.dim(fo(n.bytes));i.push(`${j}${ne(ce)} ${we(o)}: ${s}`)}i.push(""),console.log(i.join(`
|
|
386
|
-
`))}function Ce(r){if(r instanceof AggregateError)for(let e of r.errors)Ce(e);else if(r instanceof
|
|
387
|
-
${j}${
|
|
388
|
-
`),r.serve?.onStart?.({host:a,port:c,url:l})}};return await new ye(n,o).start(),i}async function
|
|
389
|
-
${O()} Rebuilding: files (${a.length})`),await
|
|
386
|
+
`))}function Ce(r){if(r instanceof AggregateError)for(let e of r.errors)Ce(e);else if(r instanceof V)for(let e of r.diagnostics)vr(e,J(ae));else r instanceof g?(console.log(`
|
|
387
|
+
${j}${J(ae)} ${r}`),mo(r)):r instanceof Error?Ce(new U(r)):Ce(new U(new Error(String(r))))}function bo(r,e){let t=e.length>0,i=t?D(r):se(r),o=t?J(ae):ne.dim(ce),n=Ee("completed",o);if(console.log(`${n} ${i}`),t){console.log("");for(let s of e)vr(s,J(ae));console.log("")}}function yr(r){for(let[e,t]of Object.entries(r))bo(e,t)}function xr({variantName:r}){console.log(`${Ee("build")} ${se(r)}`)}function br({variantName:r,duration:e,buildResult:t}){let{errors:i,warnings:o,metafile:n}=ve(t),s=!!n,a=s?se(r):D(r),c=s?ne.dim(ce):J(ae),l=Ee("completed",c),u=mr.dim(`in ${e} ms`);console.log(`${l} ${a} ${u}`),dr(i,"Errors"),dr(o,"Warnings"),s&&xo(n)}var Co=["!node_modules/**","!dist/**","!bundle/**","!**/*.d.ts"],Eo=["dist","dist/**",".git/**",".idea/**","node_modules/**"];function Io(r,e){if(!e.entryPoints)return;let t=[...e.entryPoints,...Co];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:Pe(wo(),t)}}}}function To(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 Oo(r){let e=[...Eo];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 Fo(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")} ${se(o)} ${we(l)}
|
|
388
|
+
`),r.serve?.onStart?.({host:a,port:c,url:l})}};return await new ye(n,o).start(),i}async function ze(r,e){try{let t=h(process.cwd(),"dist");if(So(t,{recursive:!0,force:!0}),e.typeCheck){let i=await r.typeChack();yr(i)}else await r.build(e.build)}catch(t){Ce(t)}}async function ko(r,e,t,i){if(!(t.watch||t.serve!==void 0||e.serve?.start))return;let n=Oo(e),s=new xe(n);pr(async()=>{await ze(r,t)},i),await ze(r,t),await s.start(async a=>{if(r.touchFiles(a),a.includes(t.config)){let c=await mt(t.config);r.reload(c)}console.log(`
|
|
389
|
+
${O()} Rebuilding: files (${a.length})`),await ze(r,t)})}async function Po(){console.log(Fe());let r=f(Q),e=r.parseConfigFile(process.argv),t=await mt(e.config),i=r.enhancedParse(process.argv,t.userArgv),o=r.parseUserArgv(process.argv,t.userArgv);Io(t,i),To(t,i),ar(t);let n=new be(o);n.onEnd=br,n.onStart=xr;let s=await Fo(t,i);await ko(n,t,i,s),await ze(n,i)}Po();
|
|
390
390
|
//# sourceMappingURL=bash.js.map
|