@remotex-labs/xbuild 1.5.3 → 1.5.5
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/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/configuration/interfaces/configuration.interface.d.ts +4 -0
- package/dist/index.js +16 -15
- package/dist/index.js.map +5 -5
- package/dist/providers/interfaces/typescript-provider.interface.d.ts +20 -0
- package/dist/providers/typescript.provider.d.ts +238 -6
- package/package.json +8 -8
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,6 @@ __ _| |_/ /_ _ _| | __| |
|
|
|
8
8
|
/_/\\_\\____/ \\__,_|_|_|\\__,_|
|
|
9
9
|
`;function t(r=!0){return`
|
|
10
10
|
\r${e("\x1B[38;5;208m",i,r)}
|
|
11
|
-
\rVersion: ${e("\x1B[38;5;197m","1.5.
|
|
11
|
+
\rVersion: ${e("\x1B[38;5;197m","1.5.5",r)}
|
|
12
12
|
\r`}console.log(t());o(process.argv).catch(r=>{console.error(r.stack),process.exit(1)});
|
|
13
13
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts", "../src/components/colors.component.ts", "../src/components/banner.component.ts"],
|
|
4
|
-
"sourceRoot": "https://github.com/remotex-lab/xBuild/tree/v1.5.
|
|
4
|
+
"sourceRoot": "https://github.com/remotex-lab/xBuild/tree/v1.5.5/",
|
|
5
5
|
"sourcesContent": ["#!/usr/bin/env node\n/**\n * Import will remove at compile time\n */\nimport type { xBuildError } from '@errors/xbuild.error';\nimport type { VMRuntimeError } from '@errors/vm-runtime.error';\n/**\n * Imports\n */\nimport { buildWithArgv } from './index.js';\nimport { bannerComponent } from '@components/banner.component';\n/**\n * Banner\n */\nconsole.log(bannerComponent());\n/**\n * Run entrypoint of xBuild\n */\nbuildWithArgv(process.argv).catch((error: VMRuntimeError & xBuildError) => {\n console.error(error.stack);\n process.exit(1);\n});\n", "/**\n * An enumeration of ANSI color codes used for text formatting in the terminal.\n *\n * These colors can be used to format terminal output with various text colors,\n * including different shades of gray, yellow, and orange, among others.\n *\n * Each color code starts with an ANSI escape sequence (`\\u001B`), followed by the color code.\n * The `Reset` option can be used to reset the terminal's text formatting back to the default.\n *\n * @example\n * ```ts\n * console.log(Color.BrightPink, 'This is bright pink text', Color.Reset);\n * ```\n */\nexport const enum Colors {\n Reset = '\\u001B[0m',\n Red = '\\u001B[38;5;9m',\n Gray = '\\u001B[38;5;243m',\n Cyan = '\\u001B[38;5;81m',\n DarkGray = '\\u001B[38;5;238m',\n LightCoral = '\\u001B[38;5;203m',\n LightOrange = '\\u001B[38;5;215m',\n OliveGreen = '\\u001B[38;5;149m',\n BurntOrange = '\\u001B[38;5;208m',\n LightGoldenrodYellow = '\\u001B[38;5;221m',\n LightYellow = '\\u001B[38;5;230m',\n CanaryYellow = '\\u001B[38;5;227m',\n DeepOrange = '\\u001B[38;5;166m',\n LightGray = '\\u001B[38;5;252m',\n BrightPink = '\\u001B[38;5;197m'\n}\n/**\n * Formats a message string with the specified ANSI color and optionally resets it after the message.\n *\n * This function applies an ANSI color code to the provided message,\n * and then appends the reset code to ensure that the color formatting doesn't extend beyond the message.\n * It's useful for outputting colored text in a terminal. If color formatting is not desired,\n * the function can return the message unformatted.\n *\n * @param color - The ANSI color code to apply. This is used only if `activeColor` is true.\n * @param msg - The message to be formatted with the specified color.\n * @param activeColor - A boolean flag indicating whether color formatting should be applied. Default is `__ACTIVE_COLOR`.\n *\n * @returns A string with the specified color applied to the message,\n * followed by a reset sequence if `activeColor` is true.\n *\n * @example\n * ```ts\n * const coloredMessage = setColor(Colors.LightOrange, 'This is a light orange message');\n * console.log(coloredMessage);\n * ```\n *\n * @example\n * ```ts\n * const plainMessage = setColor(Colors.LightOrange, 'This is a light orange message', false);\n * console.log(plainMessage); // Output will be without color formatting\n * ```\n */\nexport function setColor(color: Colors, msg: string, activeColor: boolean = __ACTIVE_COLOR): string {\n if (!activeColor)\n return msg;\n return `${color}${msg}${Colors.Reset}`;\n}\n", "/**\n * Imports\n */\nimport { Colors, setColor } from '@components/colors.component';\n/**\n * ASCII Logo and Version Information\n *\n * @remarks\n * The `asciiLogo` constant stores an ASCII representation of the project logo\n * that will be displayed in the banner. This banner is rendered in a formatted\n * string in the `bannerComponent` function.\n *\n * The `cleanScreen` constant contains an ANSI escape code to clear the terminal screen.\n */\nexport const asciiLogo = `\n ______ _ _ _\n | ___ \\\\ (_) | | |\n__ _| |_/ /_ _ _| | __| |\n\\\\ \\\\/ / ___ \\\\ | | | | |/ _\\` |\n > <| |_/ / |_| | | | (_| |\n/_/\\\\_\\\\____/ \\\\__,_|_|_|\\\\__,_|\n`;\n// ANSI escape codes for colors\nexport const cleanScreen = '\\x1Bc';\n/**\n * Renders the banner with the ASCII logo and version information.\n *\n * This function constructs and returns a formatted banner string that includes an ASCII logo and the version number.\n * The colors used for the ASCII logo and version number can be enabled or disabled based on the `activeColor` parameter.\n * If color formatting is enabled, the ASCII logo will be rendered in burnt orange, and the version number will be in bright pink.\n *\n * @param activeColor - A boolean flag indicating whether ANSI color formatting should be applied. Default is `__ACTIVE_COLOR`.\n *\n * @returns A formatted string containing the ASCII logo, version number, and ANSI color codes if `activeColor` is `true`.\n *\n * @remarks\n * The `bannerComponent` function clears the terminal screen, applies color formatting if enabled, and displays\n * the ASCII logo and version number. The version number is retrieved from the global `__VERSION` variable, and\n * the colors are reset after the text is rendered.\n *\n * @example\n * ```ts\n * console.log(bannerComponent());\n * ```\n *\n * This will output the banner to the console with the ASCII logo, version, and colors.\n *\n * @example\n * ```ts\n * console.log(bannerComponent(false));\n * ```\n *\n * This will output the banner to the console with the ASCII logo and version number without color formatting.\n *\n * @public\n */\n// Todo \\r${ activeColor ? cleanScreen : '' }\nexport function bannerComponent(activeColor: boolean = true): string {\n return `\n \\r${setColor(Colors.BurntOrange, asciiLogo, activeColor)}\n \\rVersion: ${setColor(Colors.BrightPink, __VERSION, activeColor)}\n \\r`;\n}\n/**\n * A formatted string prefix used for logging build-related messages.\n * // todo optimize this\n */\nexport function prefix() {\n return setColor(Colors.LightCoral, '[xBuild]');\n}\n"],
|
|
6
6
|
"mappings": ";AASA,OAAS,iBAAAA,MAAqB,aCiDvB,SAASC,EAASC,EAAeC,EAAaC,EAAuB,eAAwB,CAChG,OAAKA,EAEE,GAAGF,CAAK,GAAGC,CAAG,UADVA,CAEf,CChDO,IAAME,EAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EA2ClB,SAASC,EAAgBC,EAAuB,GAAc,CACjE,MAAO;AAAA,YACCC,mBAA6BC,EAAWF,CAAW,CAAC;AAAA,qBAC3CC,mBAA4B,QAAWD,CAAW,CAAC;AAAA,OAExE,CFhDA,QAAQ,IAAIG,EAAgB,CAAC,EAI7BC,EAAc,QAAQ,IAAI,EAAE,MAAOC,GAAwC,CACvE,QAAQ,MAAMA,EAAM,KAAK,EACzB,QAAQ,KAAK,CAAC,CAClB,CAAC",
|
|
7
7
|
"names": ["buildWithArgv", "setColor", "color", "msg", "activeColor", "asciiLogo", "bannerComponent", "activeColor", "setColor", "asciiLogo", "bannerComponent", "buildWithArgv", "error"]
|
|
@@ -279,6 +279,10 @@ export interface ConfigurationInterface {
|
|
|
279
279
|
* Generates TypeScript declaration files.
|
|
280
280
|
*/
|
|
281
281
|
declaration: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Bundle declaration file
|
|
284
|
+
*/
|
|
285
|
+
bundleDeclaration: boolean;
|
|
282
286
|
/**
|
|
283
287
|
* Overrides the output directory for TypeScript declaration files (.d.ts).
|
|
284
288
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{cwd as
|
|
2
|
-
${
|
|
3
|
-
${f("\x1B[38;5;203m",
|
|
1
|
+
import{cwd as ue}from"process";import{readFileSync as pe}from"fs";import{fileURLToPath as de}from"url";import{dirname as W,join as me,resolve as $}from"path";import{SourceService as ge}from"@remotex-labs/xmap";function f(i,e,t=__ACTIVE_COLOR){return t?`${i}${e}\x1B[0m`:e}import{highlightCode as he}from"@remotex-labs/xmap/highlighter.component";import{formatErrorCode as ye}from"@remotex-labs/xmap/formatter.component";var F=ue(),L=W(de(import.meta.url)),ve=W(L),_=(()=>{let i;return{get service(){if(!i){let e=pe(me(L,"index.js.map"));i=new ge(e.toString(),import.meta.url)}return i}}})();global.__ACTIVE_COLOR||(global.__ACTIVE_COLOR=!0);function Se(i,e,t,r){return`${i.replace(`${r}\\`,e).replace(/\\/g,"/")}#L${t}`}function A(i,e,t,r,o){if(o.isPromiseAll())return`at async Promise.all (index: ${o.getPromiseIndex()})`;let n=o.isAsync()?"async":"",a=i?`${n} ${i}`:n,c=t>=0&&r>=0?f("\x1B[38;5;243m",`[${t}:${r}]`):"";return`at ${a} ${f("\x1B[38;5;238m",e)} ${c}`.replace(/\s{2,}/g," ").trim()}function xe(i){let e=i.getLineNumber()||-1,t=i.getColumnNumber()||-1,r=i.getFileName()||"<anonymous>",o=i.getTypeName()||"",n=i.getFunctionName()||"",a=i.isNative()?"<native>":n;return o&&(a=`${o}.${a}`),{functionName:a,source:r,line:e,column:t}}function be(i,e){let t=__ACTIVE_COLOR?he(i.code):i.code;return i.name&&e.name=="TypeError"&&(e.message=e.message.replace(/^\S+/,i.name)),ye({...i,code:t},{color:__ACTIVE_COLOR?"\x1B[38;5;197m":"",reset:__ACTIVE_COLOR?"\x1B[0m":""})}function Ce(i,e){let{functionName:t,source:r,line:o,column:n}=xe(i);if(i.isPromiseAll()||i.isEval()||i.isNative())return A(t,r,o,n,i);let a=null,c=r===_.service.file;if(c?a=_.service.getPositionWithCode(o,n):e.error.sourceMap&&(a=e.error.sourceMap.getPositionWithCode(o,n)),a){let l=c?L:F,{line:p,column:v,name:B}=a,N=$(l,a.source);return e.blockCode||(e.blockCode=be(a,e.error)),a.sourceRoot&&(N=Se($(l,a.source),a.sourceRoot,a.line,c?ve:F)),A(B||t,N,p,v,i)}return r==="evalmachine.<anonymous>"?"":A(t,r,o,n,i)}function Ee(i,e){return e.map(t=>Ce(t,i)).filter(Boolean)}function H(i,e){let t={error:i,blockCode:null,formattedError:global.__ACTIVE_COLOR?"\x1B[0m":""},r=Ee(t,e);return t.formattedError+=`
|
|
2
|
+
${i.name}:
|
|
3
|
+
${f("\x1B[38;5;203m",i.message)}
|
|
4
4
|
|
|
5
5
|
`,t.blockCode&&(t.formattedError+=`${t.blockCode}
|
|
6
6
|
|
|
7
7
|
`),r.length>0&&(t.formattedError+=`Enhanced Stack Trace:
|
|
8
8
|
${r.join(`
|
|
9
9
|
`)}
|
|
10
|
-
`),t.formattedError}var
|
|
10
|
+
`),t.formattedError}var j=Error.prepareStackTrace;Error.prepareStackTrace=(i,e)=>(i.callStacks=e,j?j(i,e):"");process.on("uncaughtException",i=>{console.error(i.stack),process.exit(1)});process.on("unhandledRejection",i=>{console.error(i.stack),process.exit(1)});import{existsSync as yt}from"fs";import we from"yargs";import{hideBin as Te}from"yargs/helpers";function K(i){let e=we(Te(i)).command("$0 [file]","A versatile JavaScript and TypeScript toolchain build system.",t=>{t.positional("entryPoints",{describe:"The file entryPoints to build",type:"string"}).option("typeCheck",{describe:"Perform type checking",alias:"tc",type:"boolean"}).option("node",{alias:"n",describe:"Build for node platform",type:"boolean"}).option("dev",{alias:"d",describe:"Array entryPoints to run as development in Node.js",type:"array"}).option("debug",{alias:"db",describe:"Array entryPoints to run in Node.js with debug state",type:"array"}).option("serve",{alias:"s",describe:"Serve the build folder over HTTP",type:"boolean"}).option("outdir",{alias:"o",describe:"Output directory",type:"string"}).option("declaration",{alias:"de",describe:"Add TypeScript declarations",type:"boolean"}).option("watch",{alias:"w",describe:"Watch for file changes",type:"boolean"}).option("config",{alias:"c",describe:"Build configuration file (js/ts)",type:"string",default:"xbuild.config.ts"}).option("tsconfig",{alias:"tsc",describe:"Set TypeScript configuration file to use",type:"string",default:"tsconfig.json"}).option("minify",{alias:"m",describe:"Minify the code",type:"boolean"}).option("bundle",{alias:"b",describe:"Bundle the code",type:"boolean"}).option("noTypeChecker",{alias:"ntc",describe:"Skip TypeScript type checking",type:"boolean"}).option("buildOnError",{alias:"boe",describe:"Continue building even if there are TypeScript type errors",type:"boolean"}).option("format",{alias:"f",describe:"Defines the format for the build output ('cjs' | 'esm' | 'iif').",type:"string"}).option("version",{alias:"v",describe:"Show version number",type:"boolean",default:!1,conflicts:"help"})}).help().alias("help","h").version(!1).middleware(t=>{t.version&&process.exit(0)});return e.showHelp(t=>{(process.argv.includes("--help")||process.argv.includes("-h"))&&(console.log(t+`
|
|
11
11
|
|
|
12
|
-
`),process.exit(0))}),e}import*as
|
|
12
|
+
`),process.exit(0))}),e}import*as fe from"node:process";import{dirname as mt,resolve as b}from"path";import{build as gt,context as ht}from"esbuild";import{spawn as ke}from"child_process";function V(i,e=!1){let t=["--enable-source-maps",i];e&&t.unshift("--inspect-brk=0.0.0.0:0");let r=ke("node",t);return r.stdout.on("data",o=>{console.log(o.toString())}),r.stderr.on("data",o=>{console.error(o.toString())}),r}import u from"typescript";import{promises as Re}from"fs";import{cwd as Pe}from"process";import{build as U}from"esbuild";var h=class i extends Error{constructor(t,r){super(t);this.sourceMap=r;Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="xBuildBaseError"}callStacks=[];reformatStack(t){return t.callStacks?H(this,t.callStacks):t.stack??""}};var m=class i extends h{originalErrorStack;constructor(e,t){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,i),t&&Object.assign(this,t),this.name="xBuildError",this.originalErrorStack=this.stack,this.stack=this.reformatStack(this)}};var Oe={write:!1,bundle:!0,minify:!0,format:"cjs",target:"esnext",platform:"node",sourcemap:!0,sourcesContent:!0,preserveSymlinks:!0};function De(i){let e=/\/\/# sourceMappingURL=data:application\/json;base64,([^'"\s]+)/,t=i.match(e);if(!t||!t[1])throw new m("Source map URL not found in the output.");let r=t[1];return{code:i.replace(e,""),sourceMap:r}}async function J(i,e={}){let t={absWorkingDir:Pe(),...Oe,...e,entryPoints:[i]},o=(await U(t)).outputFiles?.pop()?.text??"";return De(o)}async function C(i,e="browser"){return await U({outdir:"tmp",write:!1,bundle:!0,metafile:!0,platform:e,packages:"external",logLevel:"silent",entryPoints:i,loader:{".html":"text"}})}function Me(i,e){let t=u.createSourceFile("temp.ts",i,u.ScriptTarget.Latest,!0),r=o=>{if(u.isFunctionDeclaration(o)&&o.name&&o.name.text.startsWith("$$")){e.removeFunctions.add(o.name.text);return}if(u.isVariableStatement(o)&&o.declarationList.declarations.length>0){o.declarationList.declarations.forEach(n=>{u.isIdentifier(n.name)&&n.name.text.startsWith("$$")&&n.initializer&&(u.isArrowFunction(n.initializer)||u.isFunctionExpression(n.initializer))&&e.removeFunctions.add(n.name.text)});return}if(u.isIdentifier(o)&&u.isExpression(o)&&o.escapedText&&o.escapedText.startsWith("$$")){e.removeFunctions.add(o.escapedText);return}u.forEachChild(o,r)};r(t)}async function Be(i,e,t){let r=Object.keys(i.inputs);for(let o of r){let n=await Re.readFile(o,"utf8"),a=/\/\/\s?ifdef\s?(\w+)([\s\S]*?)\/\/\s?endif/g,c;for(;(c=a.exec(n))!==null;){let[,l,p]=c;e.define[l]||Me(p,t)}}}function Ae(i,e){let t=[];function r(n){if(u.isCallExpression(n)){let a=n.expression.getText(),c=a.endsWith("!")?a.slice(0,-1):a;c.startsWith("$$")&&e.removeFunctions.has(c)&&t.push({start:n.getStart(),end:n.getEnd(),replacement:"undefined"});let l=n.expression;if(u.isPropertyAccessExpression(l)){let p=l.name;u.isIdentifier(p)&&p.text.startsWith("$$")&&t.push({start:n.getStart(),end:n.getEnd(),replacement:"undefined"})}}u.forEachChild(n,r)}r(i),t.sort((n,a)=>a.start-n.start);let o=i.getFullText();for(let{start:n,end:a,replacement:c}of t)o=o.substring(0,n)+c+o.substring(a);return o}async function G(i,e,t,r,o){if(!t.path.endsWith(".ts")&&!t.path.endsWith(".js"))return{loader:e,contents:i};if(!r.macros){let c={removeFunctions:new Set},l=await C([t.path]);await Be(l.metafile,o,c),r.macros=c}let n=i.toString(),a=u.createSourceFile(t.path,n,u.ScriptTarget.Latest,!0);return{loader:e??"ts",contents:Ae(a,r.macros)}}import{join as Le}from"path";import{cwd as Ie}from"process";import{existsSync as Ne,readFileSync as $e}from"fs";import{highlightCode as Fe}from"@remotex-labs/xmap/highlighter.component";import{formatErrorCode as _e}from"@remotex-labs/xmap/formatter.component";var E=class i extends h{originalErrorStack;constructor(e){super(e.text),this.name="esBuildError",Error.captureStackTrace&&Error.captureStackTrace(this,i),e.location?this.stack=this.generateFormattedError(e):(this.originalErrorStack=this.stack,this.stack=this.reformatStack(this))}generateFormattedError(e){let{text:t,location:r,notes:o}=e,n=this.applyColor("\x1B[0m",`
|
|
13
13
|
${this.name}: ${this.applyColor("\x1B[38;5;243m",r?.file??"")}
|
|
14
14
|
`);if(n+=this.applyColor("\x1B[38;5;203m",`${t}
|
|
15
15
|
|
|
16
|
-
`),
|
|
16
|
+
`),o.forEach(a=>{n+=this.applyColor("\x1B[38;5;243m",`${a.text}
|
|
17
17
|
|
|
18
|
-
`)}),r){let
|
|
19
|
-
`)}return n}readCode(e){try{return
|
|
20
|
-
`):null}catch{return null}}formatCodeSnippet(e,t){let{line:r=1,column:
|
|
21
|
-
`));return
|
|
18
|
+
`)}),r){let a=this.readCode(r.file);a&&(n+=`${this.formatCodeSnippet(a,r)}
|
|
19
|
+
`)}return n}readCode(e){try{return Ne(e)?$e(Le(Ie(),e),"utf-8").split(`
|
|
20
|
+
`):null}catch{return null}}formatCodeSnippet(e,t){let{line:r=1,column:o=0,file:n}=t,a=Math.max(r-3,0),c=Math.min(r+3,e.length),l=Fe(e.slice(a,c).join(`
|
|
21
|
+
`));return _e({line:r,name:null,code:l,source:n,endLine:c,startLine:a,column:o+1,sourceRoot:null,sourceIndex:-1,generatedLine:-1,generatedColumn:-1},{color:global.__ACTIVE_COLOR?"\x1B[38;5;197m":"",reset:global.__ACTIVE_COLOR?"\x1B[0m":""})}applyColor(e,t){return global.__ACTIVE_COLOR?f(e,t):t}};function d(){return f("\x1B[38;5;203m","[xBuild]")}var y=class i extends h{originalError;originalErrorStack;constructor(e,t){super(e.message,t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.originalError=e,this.originalErrorStack=e.stack,this.name="VMRuntimeError",this.stack=this.reformatStack(e)}};import*as ee from"http";import*as te from"https";var z=`<!DOCTYPE html>
|
|
22
22
|
<html>
|
|
23
23
|
<head>
|
|
24
24
|
<meta charset="UTF-8">
|
|
@@ -75,10 +75,11 @@ ${this.name}: ${this.applyColor("\x1B[38;5;243m",r?.file??"")}
|
|
|
75
75
|
<ul>\${ fileList }</ul>
|
|
76
76
|
</body>
|
|
77
77
|
</html>
|
|
78
|
-
`;import{extname as q,join as Y,resolve as
|
|
79
|
-
`),a=
|
|
78
|
+
`;import{extname as q,join as Y,resolve as We}from"path";import{existsSync as Z,readdir as He,readFile as Ke,readFileSync as X,stat as Ve}from"fs";var Q={html:{icon:"fa-file-code",color:"#d1a65f"},css:{icon:"fa-file-css",color:"#264de4"},js:{icon:"fa-file-code",color:"#f7df1e"},json:{icon:"fa-file-json",color:"#b41717"},png:{icon:"fa-file-image",color:"#53a8e4"},jpg:{icon:"fa-file-image",color:"#53a8e4"},jpeg:{icon:"fa-file-image",color:"#53a8e4"},gif:{icon:"fa-file-image",color:"#53a8e4"},txt:{icon:"fa-file-alt",color:"#8e8e8e"},folder:{icon:"fa-folder",color:"#ffb800"}},w=class{rootDir;isHttps;config;constructor(e,t){this.rootDir=We(t),this.config=e,this.isHttps=this.config.keyfile&&this.config.certfile?Z(this.config.keyfile)&&Z(this.config.certfile):!1}start(){if(this.config.onStart&&this.config.onStart(),this.isHttps)return this.startHttpsServer();this.startHttpServer()}startHttpServer(){ee.createServer((t,r)=>{this.handleRequest(t,r,()=>this.defaultResponse(t,r))}).listen(this.config.port,this.config.host,()=>{console.log(`${d()} HTTP/S server is running at http://${this.config.host}:${this.config.port}`)})}startHttpsServer(){let e={key:X(this.config.keyfile),cert:X(this.config.certfile)};te.createServer(e,(r,o)=>{this.handleRequest(r,o,()=>this.defaultResponse(r,o))}).listen(this.config.port,this.config.host,()=>{let r=f("\x1B[38;5;227m",`https://${this.config.host}:${this.config.port}`);console.log(`${d()} HTTPS server is running at ${r}`)})}handleRequest(e,t,r){try{this.config.onRequest?this.config.onRequest(e,t,r):r()}catch(o){this.sendError(t,o)}}getContentType(e){return{html:"text/html",css:"text/css",js:"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 r=e.url==="/"?"":e.url?.replace(/^\/+/,"")||"",o=Y(this.rootDir,r);if(!o.startsWith(this.rootDir)){t.statusCode=403,t.end();return}try{let n=await this.promisifyStat(o);n.isDirectory()?this.handleDirectory(o,r,t):n.isFile()&&this.handleFile(o,t)}catch(n){let a=n.message;a.includes("favicon")||console.log(d(),a),this.sendNotFound(t)}}promisifyStat(e){return new Promise((t,r)=>{Ve(e,(o,n)=>o?r(o):t(n))})}handleDirectory(e,t,r){He(e,(o,n)=>{if(o)return this.sendError(r,o);let a=n.map(c=>{if(c.match(/[^A-Za-z0-9_\/\\.-]/))return;let l=Y(t,c);if(l.match(/[^A-Za-z0-9_\/\\.-]/))return;let p=q(c).slice(1)||"folder",{icon:v,color:B}=Q[p]||Q.folder;return`<li><i class="fas ${v}" style="color: ${B};"></i> <a href="/${l}">${c}</a></li>`}).join("");r.writeHead(200,{"Content-Type":"text/html"}),r.end(z.replace("${ fileList }",a))})}handleFile(e,t){let r=q(e).slice(1)||"txt",o=this.getContentType(r);Ke(e,(n,a)=>{if(n)return this.sendError(t,n);t.writeHead(200,{"Content-Type":o}),t.end(a)})}sendNotFound(e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not Found")}sendError(e,t){console.error(`${d()}`,t.toString()),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{promises as Ue}from"fs";import{resolve as Je}from"path";var T=class{buildState={};onEndHooks=[];onSuccess=[];onLoadHooks=[];onStartHooks=[];onResolveHooks=[];registerOnStart(e){e&&this.onStartHooks.push(e)}registerOnEnd(e){e&&this.onEndHooks.push(e)}registerOnSuccess(e){e&&this.onSuccess.push(e)}registerOnResolve(e){e&&this.onResolveHooks.push(e)}registerOnLoad(e){e&&this.onLoadHooks.push(e)}setup(){return{name:"middleware-plugin",setup:e=>{e.initialOptions.metafile=!0,e.onEnd(this.handleOnEnd.bind(this)),e.onStart(this.handleOnStart.bind(this,e)),e.onLoad({filter:/.*/},this.handleOnLoad.bind(this)),e.onResolve({filter:/.*/},this.handleOnResolve.bind(this))}}}async handleOnStart(e){this.buildState={};let t={errors:[],warnings:[]};for(let r of this.onStartHooks){let o=await r(e,this.buildState);o&&(o.errors?.length&&t.errors.push(...o.errors),o.warnings?.length&&t.warnings.push(...o.warnings))}return t}async handleOnEnd(e){let t={errors:e.errors??[],warnings:e.warnings??[]};for(let r of this.onEndHooks){e.errors=t.errors,e.warnings=t.warnings;let o=await r(e,this.buildState);o&&(o.errors?.length&&t.errors.push(...o.errors),o.warnings?.length&&t.warnings.push(...o.warnings))}if(t.errors.length<1)for(let r of this.onSuccess)await r(e,this.buildState);return t}async handleOnResolve(e){let t={};for(let r of this.onResolveHooks){let o=await r(e,this.buildState);o&&(t={...t,...o,path:o.path||t.path})}return t.path?t:null}async handleOnLoad(e){let t={contents:void 0,loader:"default"},r=Je(e.path);t.contents||(t.contents=await Ue.readFile(r,"utf8"));for(let o of this.onLoadHooks){let n=await o(t.contents??"",t.loader,e,this.buildState);n&&(t={...t,...n,contents:n.contents||t.contents,loader:n.loader||t.loader})}return t.contents?t:null}};function re(i,e){return i.replace(/\/\/\s?ifdef\s?(\w+)([\s\S]*?)\/\/\s?endif/g,(t,r,o)=>e[r]?o:`
|
|
79
|
+
`.repeat((o.match(/\n/g)||[]).length))}import{relative as Ge}from"path";function ie(i,e,t,r){let o=/(?:import|export)\s.*?\sfrom\s+['"]([^'"]+)['"]/g;for(let n in t){let a=Ge(e,t[n]).replace(/\\/g,"/");a.startsWith("..")||(a=`./${a}`),i=i.replaceAll(n,`${a}/`),r&&(i=i.replace(o,(c,l)=>(l.startsWith("../")||l.startsWith("./"))&&!l.endsWith(".js")?c.replace(l,`${l}.js`):c))}return i}import*as s from"typescript";var k=class i extends Error{constructor(e,t){super(e),this.name="TypesError",Object.setPrototypeOf(this,i.prototype),t?.cause&&(this.cause=t.cause)}};import{resolve as P,relative as ze,dirname as qe,parse as Ye,join as Ze}from"path";var Xe={ClassDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateClassDeclaration(i,r,i.name,i.typeParameters,i.heritageClauses,i.members)},InterfaceDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateInterfaceDeclaration(i,r,i.name,i.typeParameters,i.heritageClauses,i.members)},EnumDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateEnumDeclaration(i,r,i.name,i.members)},FunctionDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateFunctionDeclaration(i,r,i.asteriskToken,i.name,i.typeParameters,i.parameters,i.type,i.body)},TypeAliasDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateTypeAliasDeclaration(i,r,i.name,i.typeParameters,i.type)},VariableStatement:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateVariableStatement(i,r,i.declarationList)},ModuleDeclaration:(i,e)=>{let t=s.factory.createModifier(s.SyntaxKind.ExportKeyword),r=e?[t,...e]:[t];return s.factory.updateModuleDeclaration(i,r,i.name,i.body)}},O=class{constructor(e,t,r=!0){this.tsConfig=e;this.outDir=t;this.activeColor=r;this.options={...this.tsConfig.options,outDir:this.outDir}}options;typeCheck(e=!1){let t=s.createProgram(this.tsConfig.fileNames,{...this.options,noEmit:!0,skipLibCheck:!0,emitDeclarationOnly:!0});this.handleDiagnostics(s.getPreEmitDiagnostics(t),e)}generateBundleDeclarations(e,t=!1,r=!1){let o={...this.options,rootDir:this.options.baseUrl,declaration:!0,skipLibCheck:!0,emitDeclarationOnly:!0};Object.entries(e).forEach(([n,a])=>{o.outFile=Ze(this.outDir,n);let c=s.createProgram([a],o),l={afterDeclarations:[this.cleanupDeclarations()]},p=s.getPreEmitDiagnostics(c);!t&&p.some(v=>v.category===s.DiagnosticCategory.Error)&&this.handleDiagnostics(p,r),c.emit(void 0,void 0,void 0,void 0,l)})}generateDeclarations(e=!1,t=!1){let r=s.createProgram(this.tsConfig.fileNames,{...this.options,rootDir:this.options.baseUrl,declaration:!0,skipLibCheck:!0,emitDeclarationOnly:!0}),o=s.getPreEmitDiagnostics(r);!e&&o.some(n=>n.category===s.DiagnosticCategory.Error)&&this.handleDiagnostics(o,t),r.emit(void 0,void 0,void 0,!0,{afterDeclarations:[this.createTransformerFactory()]})}isImportOrExportDeclaration(e){return s.isImportDeclaration(e)||s.isExportDeclaration(e)}hasStringLiteralModuleSpecifier(e){return e.moduleSpecifier&&s.isStringLiteral(e.moduleSpecifier)}resolveModuleFileName(e,t){let r,o=s.resolveModuleName(e,t.baseUrl,t,s.sys);if(o.resolvedModule&&t.baseUrl){if(o.resolvedModule.resolvedFileName.includes("node_modules"))return r;r=P(o.resolvedModule.resolvedFileName).replace(P(t.baseUrl),".")}return r}getRelativePathToOutDir(e,t){e=P(e).replace(P(this.options.baseUrl??""),".");let r=ze(qe(e),t).replace(/\\/g,"/"),o=Ye(r);return o.dir.startsWith("..")||(o.dir=`./${o.dir}`),`${o.dir}/${o.name}`}updateModuleSpecifier(e,t){let r=s.factory.createStringLiteral(t);return s.isImportDeclaration(e)?s.factory.updateImportDeclaration(e,e.modifiers,e.importClause,r,void 0):s.isExportDeclaration(e)?s.factory.updateExportDeclaration(e,e.modifiers,e.isTypeOnly,e.exportClause,r,void 0):e}createVisitor(e,t){let r=o=>{if(this.isImportOrExportDeclaration(o)&&this.hasStringLiteralModuleSpecifier(o)){let n=o.moduleSpecifier.text,a=this.resolveModuleFileName(n,this.options);if(a){let c=this.getRelativePathToOutDir(e.fileName,a);return this.updateModuleSpecifier(o,c)}}return s.visitEachChild(o,r,t)};return r}createTransformerFactory(){return e=>({transformSourceFile:t=>s.visitEachChild(t,this.createVisitor(t,e),e),transformBundle:t=>t})}handleDiagnostics(e,t=!1){if(e.length!==0&&(e.forEach(r=>{if(r.file&&r.start!==void 0){let{line:o,character:n}=r.file.getLineAndCharacterOfPosition(r.start),a=s.flattenDiagnosticMessageText(r.messageText,`
|
|
80
|
+
`),c=f("\x1B[38;5;81m",r.file.fileName,this.activeColor),l=f("\x1B[38;5;230m",`${o+1}:${n+1}`,this.activeColor),p=f("\x1B[38;5;9m","error",this.activeColor),v=f("\x1B[38;5;243m",`TS${r.code}`,this.activeColor);console.error(`${d()} ${c}:${l} - ${p} ${v}:${a}`)}else console.error(s.flattenDiagnosticMessageText(r.messageText,`
|
|
80
81
|
`))}),console.log(`
|
|
81
|
-
`),!t))throw new
|
|
82
|
-
${
|
|
83
|
-
`),this.config.dev&&this.spawnDev(e.metafile,this.config.dev)}async processEntryPoints(){let e=this.config.esbuild,t=await
|
|
82
|
+
`),!t))throw new k("Type checking failed due to errors.")}isNodeWithModifiers(e){return s.isClassDeclaration(e)||s.isInterfaceDeclaration(e)||s.isEnumDeclaration(e)||s.isFunctionDeclaration(e)||s.isTypeAliasDeclaration(e)||s.isVariableStatement(e)||s.isModuleDeclaration(e)}removeExportModifiers(e){if(!e)return;let t=e.filter(r=>r.kind!==s.SyntaxKind.ExportKeyword&&r.kind!==s.SyntaxKind.DefaultKeyword);return t.length?t:void 0}updateNodeWithoutExports(e){let t=this.removeExportModifiers(e.modifiers);for(let[r,o]of Object.entries(Xe)){let n=s[`is${r}`];if(typeof n=="function"&&n(e))return o(e,t)}return e}visitNode(e,t){return this.isNodeWithModifiers(t)&&t.modifiers&&t.modifiers.some(o=>o.kind===s.SyntaxKind.ExportKeyword||o.kind===s.SyntaxKind.DefaultKeyword)?this.updateNodeWithoutExports(t):s.visitEachChild(t,r=>this.visitNode(e,r),e)}arrayContainsStringWithSubstring(e,t){return e.some(r=>r.includes(t))}visitTopLevelStatement(e,t,r){if(s.isImportDeclaration(e)){if(e.moduleSpecifier&&s.isStringLiteral(e.moduleSpecifier)){let o=e.moduleSpecifier.text;if(!this.arrayContainsStringWithSubstring(this.tsConfig.fileNames,`${o}.ts`)){let n=s.factory.createImportDeclaration(e.modifiers,e.importClause,s.factory.createStringLiteral(o));t.push(n)}}return[]}return s.isImportEqualsDeclaration(e)?[]:s.isExportDeclaration(e)?[]:s.isModuleDeclaration(e)?e.modifiers?.some(o=>o.kind===s.SyntaxKind.DeclareKeyword)?e.body&&s.isModuleBlock(e.body)?e.body.statements.flatMap(o=>this.visitTopLevelStatement(o,t,r)):[]:[this.visitNode(r,e)]:[this.visitNode(r,e)]}visitSourceFile(e,t,r){let o=e.statements.flatMap(n=>this.visitTopLevelStatement(n,t,r));return s.factory.updateSourceFile(e,o,e.isDeclarationFile,e.referencedFiles,e.typeReferenceDirectives,e.hasNoDefaultLib,e.libReferenceDirectives)}cleanupDeclarations(){return e=>t=>{if(!s.isBundle(t))throw new Error("Cannot process a single file, expected a bundle");let r=[],o=t.sourceFiles.map(a=>this.visitSourceFile(a,r,e)),n=s.factory.createSourceFile(r,s.factory.createToken(s.SyntaxKind.EndOfFileToken),s.NodeFlags.None);return s.factory.createBundle([n,...o])}}};import g from"typescript";import{dirname as st}from"path";import{existsSync as se,readFileSync as at}from"fs";import{cwd as Qe}from"process";var D={dev:!1,watch:!1,declaration:!1,buildOnError:!1,noTypeChecker:!1,bundleDeclaration:!1,define:{},esbuild:{write:!0,bundle:!0,minify:!0,format:"cjs",outdir:"dist",platform:"browser",absWorkingDir:Qe(),loader:{".js":"ts"}},serve:{port:3e3,host:"localhost",active:!1}};import{createRequire as rt}from"module";import{SourceService as it}from"@remotex-labs/xmap";import{Script as et,createContext as tt}from"vm";function oe(i,e={}){e.RegExp=RegExp,e.console=console;let t=new et(i),r=tt(e);return t.runInContext(r,{breakOnSigint:!0})}function ne(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let r=i[t];typeof r=="function"?i[t]=ot(r,e):typeof r=="object"&&r!==null&&ne(r,e)}return i}function ot(i,e){return(...t)=>{try{return i(...t)}catch(r){throw new y(r,e)}}}function nt(i,e){return ne(i,e)}async function R(i){let{code:e,sourceMap:t}=await J(i,{banner:{js:"(function(module, exports) {"},footer:{js:"})(module, module.exports);"}}),r={exports:{}},o=rt(import.meta.url),n=new it(JSON.parse(atob(t)));try{await oe(e,{require:o,module:r})}catch(a){throw new y(a,n)}return nt(r.exports.default,n)}var ct=JSON.stringify({compilerOptions:{strict:!0,target:"ESNext",module:"ESNext",outDir:"dist",skipLibCheck:!0,isolatedModules:!1,esModuleInterop:!1,moduleDetection:"force",moduleResolution:"node",resolveJsonModule:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0}});function lt(i){let e=i.argv,t=o=>Object.fromEntries(Object.entries(o).filter(([,n])=>n!==void 0)),r=t({bundle:e.bundle,minify:e.minify,outdir:e.outdir,tsconfig:e.tsconfig,entryPoints:e.file?[e.file]:void 0,target:e.node?[`node${process.version.slice(1)}`]:void 0,platform:e.node?"node":void 0,format:e.format});return{...t({dev:e.dev,watch:e.watch,declaration:e.declaration,serve:e.serve?{active:e.serve}:{undefined:void 0}}),esbuild:r}}function ae(i){let e=i.tsconfig??"tsconfig.json",t=se(e)?at(e,"utf8"):JSON.stringify(ct),r=g.parseConfigFileTextToJson(e,t);if(r.error)throw new m(g.formatDiagnosticsWithColorAndContext([r.error],{getCurrentDirectory:g.sys.getCurrentDirectory,getCanonicalFileName:n=>n,getNewLine:()=>g.sys.newLine}));let o=g.parseJsonConfigFileContent(r.config,g.sys,st(e));if(o.errors.length>0)throw new m(g.formatDiagnosticsWithColorAndContext(o.errors,{getCurrentDirectory:g.sys.getCurrentDirectory,getCanonicalFileName:n=>n,getNewLine:()=>g.sys.newLine}));return o}async function M(i,e={}){let t=Array.isArray(i)?i:[i],r=t[0];return t.flatMap(o=>{let n={...D,...r,...o,...e,esbuild:{...D.esbuild,...r?.esbuild,...o?.esbuild,...e.esbuild},serve:{...D.serve,...r.serve,...o.serve,...e.serve}};if(!n.esbuild.entryPoints)throw new m("entryPoints cannot be undefined.");return n})}async function ce(i,e){let t=lt(e),r=se(i)?await R(i):{};return M(r,t)}function ft(i){let e={};return i.forEach(t=>{let r=t.substring(0,t.lastIndexOf("."));e[r]=t}),e}function I(i){if(Array.isArray(i)){let e={};return i.length>0&&typeof i[0]=="object"?i.forEach(t=>{e[t.out]=t.in}):typeof i[0]=="string"&&(e=ft(i)),e}else if(i&&typeof i=="object")return i;throw new m("Unsupported entry points format")}import{join as ut}from"path";import{mkdirSync as pt,writeFileSync as dt}from"fs";function le(i){let e=i.moduleTypeOutDir??i.esbuild.outdir??"dist",t=i.esbuild.format==="esm"?"module":"commonjs";pt(e,{recursive:!0}),dt(ut(e,"package.json"),`{"type": "${t}"}`)}var S=class{constructor(e){this.config=e;let t=ae(this.config.esbuild);this.config.esbuild.logLevel="silent",this.pluginsProvider=new T,this.typeScriptProvider=new O(t,this.config.declarationOutDir??t.options.outDir??this.config.esbuild.outdir),this.configureDevelopmentMode(),this.setupPlugins()}typeScriptProvider;activePossess=[];pluginsProvider;async run(){return await this.execute(async()=>{let e=await this.build();return(this.config.watch||this.config.dev)&&await e.watch(),e})}async runDebug(e){return await this.execute(async()=>{this.config.dev=!1,this.config.watch=!1;let t=await this.build();this.spawnDev(t.metafile,e,!0)})}async serve(){let e=new w(this.config.serve,this.config.esbuild.outdir??"");return await this.execute(async()=>{e.start(),await(await this.build()).watch()})}async execute(e){try{return await e()}catch(t){let r=t;Array.isArray(r.errors)&&(!this.config.watch||!this.config.dev||!this.config.serve.active)?this.handleErrors(r):console.error(new y(t).stack)}}configureDevelopmentMode(){this.config.dev!==!1&&(!Array.isArray(this.config.dev)||this.config.dev.length<1)&&(this.config.dev=["index"])}setupPlugins(){let e=b(this.typeScriptProvider.options.baseUrl??""),t=this.generatePathAlias(e);this.registerPluginHooks(t,e),this.pluginsProvider.registerOnLoad(async(r,o,n,a)=>await G(r,o,n,a,this.config))}registerPluginHooks(e,t){this.pluginsProvider.registerOnEnd(this.end.bind(this)),this.pluginsProvider.registerOnStart(this.start.bind(this)),this.pluginsProvider.registerOnLoad((r,o,n)=>{if(n.path.endsWith(".ts")){if(!this.config.esbuild.bundle){let a=mt(b(n.path).replace(t,"."));r=ie(r.toString(),a,e,this.config.esbuild.format==="esm")}return{loader:"ts",contents:re(r.toString(),this.config.define)}}})}generatePathAlias(e){let t=this.typeScriptProvider.options.paths,r={};for(let o in t){let n=t[o];if(n.length>0){let a=o.replace(/\*/g,"");r[a]=b(n[0].replace(/\*/g,"")).replace(e,".")}}return r}handleErrors(e){let t=e.errors??[];for(let r of t){if(!r.detail){console.error(new E(r).stack);continue}if(r.detail.name!=="TypesError"){if(r.detail.name){if(r.detail.name==="VMRuntimeError"){console.error(r.detail.stack);continue}if(r.detail instanceof Error){console.error(new y(r.detail).stack);continue}}return console.error(r.text)}}}injects(e,t,r){if(!t)return;e[r]||(e[r]={});let o=e[r];for(let n in t)if(t.hasOwnProperty(n)){let a=t[n];if(typeof a=="function"){console.log(`${d()} trigger ${r} function`),o[n]=a();continue}o[n]=a}}async build(){le(this.config);let e=this.config.esbuild;this.config.hooks&&(this.pluginsProvider.registerOnEnd(this.config.hooks.onEnd),this.pluginsProvider.registerOnLoad(this.config.hooks.onLoad),this.pluginsProvider.registerOnEnd(this.config.hooks.onSuccess),this.pluginsProvider.registerOnStart(this.config.hooks.onStart),this.pluginsProvider.registerOnResolve(this.config.hooks.onResolve)),e.define||(e.define={});for(let t in this.config.define)e.define[t]=JSON.stringify(this.config.define[t]);return this.config.esbuild.bundle||await this.processEntryPoints(),e.plugins=[this.pluginsProvider.setup()],this.injects(this.config.esbuild,this.config.banner,"banner"),this.injects(this.config.esbuild,this.config.footer,"footer"),this.config.watch||this.config.dev||this.config.serve.active?await ht(e):await gt(e)}spawnDev(e,t,r=!1){if(Array.isArray(t))for(let o in e.outputs)o.includes("map")||!t.some(n=>o.includes(`/${n}.`))||this.activePossess.push(V(o,r))}async start(e,t){try{t.startTime=Date.now(),console.log(`${d()} StartBuild ${e.initialOptions.outdir}`),this.config.bundleDeclaration?this.typeScriptProvider.generateBundleDeclarations(I(this.config.esbuild.entryPoints),this.config.noTypeChecker,this.config.buildOnError):this.config.declaration?this.typeScriptProvider.generateDeclarations(this.config.noTypeChecker,this.config.buildOnError):this.config.noTypeChecker||this.typeScriptProvider.typeCheck(this.config.buildOnError)}finally{for(;this.activePossess.length>0;){let r=this.activePossess.pop();r&&r.kill("SIGTERM")}}}async end(e,t){if(e.errors.length>0){this.handleErrors(e),!this.config.serve.active&&!this.config.dev&&!this.config.watch&&fe.exit(1);return}let r=Date.now()-t.startTime;console.log(`
|
|
83
|
+
${d()} ${f("\x1B[38;5;166m",`Build completed! in ${r} ms`)}`),console.log(`${d()} ${Object.keys(e.metafile.outputs).length} Modules:`),Object.keys(e.metafile.outputs).forEach(o=>{let n=e.metafile.outputs[o].bytes;console.log(`${d()} ${f("\x1B[38;5;227m",o)}: ${f("\x1B[38;5;208m",n.toString())} bytes`)}),console.log(`
|
|
84
|
+
`),this.config.dev&&this.spawnDev(e.metafile,this.config.dev)}async processEntryPoints(){let e=this.config.esbuild,t=await C(e.entryPoints,e.platform),r=b(this.typeScriptProvider.options.baseUrl??""),o=I(e.entryPoints),n=Object.values(o);Array.isArray(e.entryPoints)&&typeof e.entryPoints[0]=="string"&&(o={},n=[]);for(let a in t.metafile.inputs){if(n.includes(a))continue;let c=b(a).replace(r,"."),l=c.substring(0,c.lastIndexOf("."));o[l]=a}e.entryPoints=o}};global.__ACTIVE_COLOR=!0;async function gi(i){let e=K(i),t=e.argv,o=(await ce(t.config,e)).map(async n=>{let a=new S(n);if(t.typeCheck)return a.typeScriptProvider.typeCheck(!0);if(t.serve||n.serve.active)return await a.serve();if(Array.isArray(t.debug))return t.debug.length<1&&(t.debug=["index"]),await a.runDebug(t.debug);await a.run()});await Promise.all(o)}async function hi(i){let e=yt(i)?await R(i):{},r=(await M(e)).map(async o=>await new S(o).run());return await Promise.all(r)}async function yi(i){let t=(await M(i)).map(async r=>await new S(r).run());return await Promise.all(t)}export{yi as build,gi as buildWithArgv,hi as buildWithConfigPath};
|
|
84
85
|
//# sourceMappingURL=index.js.map
|