@empjs/cli 3.0.0-beta.8 → 3.0.0-beta.9

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -6,10 +6,10 @@ var Ze=Object.defineProperty;var m=(r,e)=>()=>(r&&(e=r(r=0)),e);var G=(r,e)=>{fo
6
6
  `)};red=e=>{console.log(`${u.white.bgRed(this.pname)}${u.red.bgWhite(` ${e} `)}
7
7
  `)};sysError=e=>{console.log(`${u.white.bgRed(" System Error Tips ")}${u.red.bgWhite(` ${e} `)}
8
8
  `)};link=e=>u.hex("#3498db")(e);title=e=>{console.log(`${u.greenBright.bold(`${this.pname}`)} ${u.bgGreenBright(` ${e} `)}
9
- `)};tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(at(this.tableData,this.tableConfig))}},p=new V});var j,Pe=m(()=>{"use strict";j=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;async setup(e){this.setShareLib(e),delete e.shareLib}async setShareLib(e){let t=[];if(typeof e.shareLib=="object")for(let[s,i]of Object.entries(e.shareLib)){let o={};if(o.module=s,typeof i=="string"){let n=i.match(this.exp)||[];n.length>0?(o.global=n[1],o.entry=n[2],o.type="js",t.push(o),o={}):(o.global="",o.entry=i,o.type="js",t.push(o),o={})}else Array.isArray(i)?i.map(n=>{if(!n)return;if(n.split("?")[0].endsWith(".css"))o.entry=n,o.type="css";else{let c=n.match(this.exp)||[];c.length>0?(o.global=c[1],o.entry=c[2],o.type="js"):(o.global="",o.entry=n,o.type="js")}t.push(o),o={}}):typeof i=="object"&&i.entry&&(o.entry=i.entry,o.global=i.global,o.type=i.type,t.push(o),o={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global&&(this.externals[s.module]=s.global),s.entry&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});import pt from"node:fs";var W,Re,ke=m(()=>{"use strict";S();Pe();W=class{store;appSrc="src";appEntry="";base="";assign(e,t){return t=t||{},v(e,t)}empShareLib=new j;async setup(e){this.store=e,await this.syncEmpOptions();let{appSrc:t,base:s,appEntry:i}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),i&&(this.appEntry=i),this.store.empOptions.empShare?.shareLib&&await this.empShareLib.setup(this.store.empOptions.empShare)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{}},{...this.store.empOptions.build,staticDir:e})}get html(){return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,meta:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"}},files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgr:!1},this.store.empOptions.react)}get server(){return this.assign({host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,static:[{directory:this.store.publicDir,watch:this.store.isDev},{directory:this.store.outDir,watch:this.store.isDev,publicPath:"/",staticOptions:{setHeaders:function(e,t){t.toString().endsWith(".d.ts")&&e?.set("Content-Type","application/javascript; charset=utf-8")}}}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}},this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({postcss:[]},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:i}=this.store.empConfig.build;return this.assign({publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${i}js/[name]${e}.js`,cssFilename:`${i}css/[name]${t}.css`,cssChunkFilename:`${i}css/[name]${t}.css`,assetModuleFilename:`${i}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0},this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:"cjs",s={};return Object.keys(e).map(i=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${i}`]=JSON.stringify(e[i])),(t==="all"||t==="cjs")&&(s[`process.env.${i}`]=JSON.stringify(e[i])),s[`${i}`]=JSON.stringify(e[i])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return v({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!pt.existsSync(e))return;let{default:t}=await import(this.store.importFileUrl(e));typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}get moduleTransformRule(){let e={and:[/(node_modules|bower_components)/]},{moduleTransform:t}=this.store.empOptions;return t?.exclude&&(e.and=t.exclude),t?.include&&(e.not=t.include),e}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get reactRuntime(){if(this.store.reactVersion)return this.store.empOptions.reactRuntime?this.store.empOptions.reactRuntime:k(this.store.reactVersion,"17")>-1?"automatic":"classic"}},Re=new W});import O from"node:path";import lt from"webpack-chain";import{pathToFileURL as ct}from"node:url";var X,a,d=m(()=>{"use strict";me();$e();y();ke();X=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=ce;empSource=O.resolve(this.empRoot,"dist");resolve=e=>O.isAbsolute(e)?e:O.resolve(this.root,e);empResolve=e=>O.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=Re,await this.empConfig.setup(this),this.initPaths(),this.chain=new lt,await Oe.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await M(this.empResolve("package.json")),i=await M(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...i},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir),this.resource.dir=O.join(this.empRoot,"resource"),this.resource.cert=O.join(this.resource.dir,"emp.cert"),this.resource.key=O.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),p.setup({pname:`EMP \u26A1v${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return le(e,t)}importFileUrl(e){return ct(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){this.empConfig.debug.showRsconfig&&console.log("[ChainConfig]",JSON.stringify(this.rsConfig,null,2))}},a=new X});import je from"url";import De from"chalk";import{ip as mt}from"address";import{gateway4sync as ht}from"default-gateway";function Le(r,e,t,s="/"){let i=b=>je.format({protocol:r,hostname:b,port:t,pathname:s}),o=b=>je.format({protocol:r,hostname:b,port:De.bold(t),pathname:s}),n=e==="0.0.0.0"||e==="::",l,c,f=De.gray("unavailable");if(n){l="localhost";try{let{int:b}=ht();c=mt(b||""),c&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(c)?f=o(c):c=void 0)}catch{}}else l=e,c=e,f=o(c);let h=o(l),C=i(l);return{lanUrlForConfig:c,lanUrlForTerminal:f,localUrlForTerminal:h,localUrlForBrowser:C}}var Te=m(()=>{"use strict"});import{exec as ut}from"node:child_process";import{promisify as ft}from"node:util";var Fe,Ae,gt,dt,ze,Ge=m(()=>{"use strict";y();d();Fe=ft(ut),Ae=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],gt=async()=>{let r=process.env.BROWSER;if(!r||!Ae.includes(r)){let{stdout:e}=await Fe("ps cax");r=Ae.find(t=>e.includes(t))}return r},dt=async r=>{if(process.platform==="darwin")try{let t=await gt();if(t){let s=`osascript openChrome.applescript "${encodeURI(r)}" "${t}"`;return await Fe(s,{cwd:a.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(r),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},ze=dt});import Be from"node:fs/promises";import q from"chalk";var x,D=m(()=>{"use strict";y();d();S();Te();Ge();x=class{publicPath;localUrl;isOpenBrower=!1;startOpen({host:e,port:t}){let s=this.publicPath;if(s&&(s.indexOf("http://")>-1||s.indexOf("https://")>-1))p.info(`${q.greenBright("\u279C")} Network: ${p.link(s)}`),this.localUrl=s;else{let i=this.isHttps?"https":"http",n=Le(i,e||"0.0.0.0",t,s);p.info(`${q.greenBright("\u279C")} Local: ${p.link(n.localUrlForTerminal)}`),p.info(`${q.greenBright("\u279C")} Network: ${p.link(n.lanUrlForTerminal)}
9
+ `)};tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(at(this.tableData,this.tableConfig))}},p=new V});var j,Pe=m(()=>{"use strict";j=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;async setup(e){this.setShareLib(e),delete e.shareLib}async setShareLib(e){let t=[];if(typeof e.shareLib=="object")for(let[s,i]of Object.entries(e.shareLib)){let o={};if(o.module=s,typeof i=="string"){let n=i.match(this.exp)||[];n.length>0?(o.global=n[1],o.entry=n[2],o.type="js",t.push(o),o={}):(o.global="",o.entry=i,o.type="js",t.push(o),o={})}else Array.isArray(i)?i.map(n=>{if(!n)return;if(n.split("?")[0].endsWith(".css"))o.entry=n,o.type="css";else{let c=n.match(this.exp)||[];c.length>0?(o.global=c[1],o.entry=c[2],o.type="js"):(o.global="",o.entry=n,o.type="js")}t.push(o),o={}}):typeof i=="object"&&i.entry&&(o.entry=i.entry,o.global=i.global,o.type=i.type,t.push(o),o={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global&&(this.externals[s.module]=s.global),s.entry&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});import pt from"node:fs";var W,Re,ke=m(()=>{"use strict";S();Pe();W=class{store;appSrc="src";appEntry="";base="";assign(e,t){return t=t||{},v(e,t)}empShareLib=new j;async setup(e){this.store=e,await this.syncEmpOptions();let{appSrc:t,base:s,appEntry:i}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),i&&(this.appEntry=i),this.store.empOptions.empShare?.shareLib&&await this.empShareLib.setup(this.store.empOptions.empShare)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{}},{...this.store.empOptions.build,staticDir:e})}get html(){return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,meta:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"}},files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgr:!1},this.store.empOptions.react)}get server(){return this.assign({host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,static:[{directory:this.store.publicDir,watch:this.store.isDev},{directory:this.store.outDir,watch:this.store.isDev,publicPath:"/",staticOptions:{setHeaders:function(e,t){t.toString().endsWith(".d.ts")&&e?.set("Content-Type","application/javascript; charset=utf-8")}}}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}},this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({postcss:[]},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:i}=this.store.empConfig.build;return this.assign({publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${i}js/[name]${e}.js`,cssFilename:`${i}css/[name]${t}.css`,cssChunkFilename:`${i}css/[name]${t}.css`,assetModuleFilename:`${i}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0},this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:"cjs",s={};return Object.keys(e).map(i=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${i}`]=JSON.stringify(e[i])),(t==="all"||t==="cjs")&&(s[`process.env.${i}`]=JSON.stringify(e[i])),s[`${i}`]=JSON.stringify(e[i])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return v({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!pt.existsSync(e))return;let{default:t}=await import(this.store.importFileUrl(e));typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}get moduleTransformRule(){let e={and:[/(node_modules|bower_components)/]},{moduleTransform:t}=this.store.empOptions;return t?.exclude&&(e.and=t.exclude),t?.include&&(e.not=t.include),e}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get reactRuntime(){if(this.store.reactVersion)return this.store.empOptions.reactRuntime?this.store.empOptions.reactRuntime:k(this.store.reactVersion,"17")>-1?"automatic":"classic"}},Re=new W});import O from"node:path";import lt from"webpack-chain";import{pathToFileURL as ct}from"node:url";var X,a,d=m(()=>{"use strict";me();$e();y();ke();X=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=ce;empSource=O.resolve(this.empRoot,"dist");resolve=e=>O.isAbsolute(e)?e:O.resolve(this.root,e);empResolve=e=>O.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=Re,await this.empConfig.setup(this),this.initPaths(),this.chain=new lt,await Oe.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await M(this.empResolve("package.json")),i=await M(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...i},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir),this.resource.dir=O.join(this.empRoot,"resource"),this.resource.cert=O.join(this.resource.dir,"emp.cert"),this.resource.key=O.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),p.setup({pname:`EMP\u26A1v${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return le(e,t)}importFileUrl(e){return ct(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){this.empConfig.debug.showRsconfig&&console.log("[ChainConfig]",JSON.stringify(this.rsConfig,null,2))}},a=new X});import je from"url";import De from"chalk";import{ip as mt}from"address";import{gateway4sync as ht}from"default-gateway";function Le(r,e,t,s="/"){let i=b=>je.format({protocol:r,hostname:b,port:t,pathname:s}),o=b=>je.format({protocol:r,hostname:b,port:De.bold(t),pathname:s}),n=e==="0.0.0.0"||e==="::",l,c,f=De.gray("unavailable");if(n){l="localhost";try{let{int:b}=ht();c=mt(b||""),c&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(c)?f=o(c):c=void 0)}catch{}}else l=e,c=e,f=o(c);let h=o(l),C=i(l);return{lanUrlForConfig:c,lanUrlForTerminal:f,localUrlForTerminal:h,localUrlForBrowser:C}}var Te=m(()=>{"use strict"});import{exec as ut}from"node:child_process";import{promisify as ft}from"node:util";var Fe,Ae,gt,dt,ze,Ge=m(()=>{"use strict";y();d();Fe=ft(ut),Ae=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],gt=async()=>{let r=process.env.BROWSER;if(!r||!Ae.includes(r)){let{stdout:e}=await Fe("ps cax");r=Ae.find(t=>e.includes(t))}return r},dt=async r=>{if(process.platform==="darwin")try{let t=await gt();if(t){let s=`osascript openChrome.applescript "${encodeURI(r)}" "${t}"`;return await Fe(s,{cwd:a.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(r),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},ze=dt});import Be from"node:fs/promises";import q from"chalk";var x,D=m(()=>{"use strict";y();d();S();Te();Ge();x=class{publicPath;localUrl;isOpenBrower=!1;startOpen({host:e,port:t}){let s=this.publicPath;if(s&&(s.indexOf("http://")>-1||s.indexOf("https://")>-1))p.info(`${q.greenBright("\u279C")} Network: ${p.link(s)}`),this.localUrl=s;else{let i=this.isHttps?"https":"http",n=Le(i,e||"0.0.0.0",t,s);p.info(`${q.greenBright("\u279C")} Local: ${p.link(n.localUrlForTerminal)}`),p.info(`${q.greenBright("\u279C")} Network: ${p.link(n.lanUrlForTerminal)}
10
10
  `),this.localUrl=n.localUrlForBrowser}this.isOpenBrower&&ze(this.localUrl)}async setup(e,t){await a.setup(e,t),a.empConfig.debug.clearLog&&ve(),p.title(`${e}`),this.publicPath=a.rsConfig.output?.publicPath==="auto"?"/":a.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!a.empConfig.server.open,await this.run()}async run(){}get isHttps(){let{server:e,https:t}=a.rsConfig.devServer||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0}getcert(){return Promise.all([Be.readFile(a.resource.key),Be.readFile(a.resource.cert)])}}});import yt from"net";import bt from"os";async function L(r,e="localhost"){if(r!==vt&&(r<Me||r>Q))throw new Error(`Port number must lie between ${Me} and ${Q}`);let t=r,s=xt(),i;e&&!s.has(e)?i=new Set([e]):i=s;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=Q;)try{return await Ct(t,i)}catch(n){if(!o.has(n.code))throw n;t+=1}throw new Error("No available ports found")}var Me,Q,vt,xt,wt,Ct,Y=m(()=>{"use strict";Me=1024,Q=65535,vt=443,xt=()=>{let r=bt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(r))if(t)for(let s of t)e.add(s.address);return e},wt=(r,e)=>new Promise((t,s)=>{let i=yt.createServer();i.unref(),i.on("error",s),i.listen(r,e,()=>{let{port:o}=i.address();i.close(()=>{t(o)})})}),Ct=async(r,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await wt(r,s)}catch(i){if(!t.has(i.code))throw i}return r}});import g from"chalk";import w from"node:path";import{gzipSizeSync as St}from"gzip-size";import Et from"node:fs";async function Dt(r,e){let t=[r,e],s=["File","Size","Gzipped"].reduce((i,o,n)=>{let l=t[n],c=o;return l&&(c=o.length<l?o+" ".repeat(l-o.length):o),`${i+c} `}," ");console.log(g.bold.blue(s))}async function Ne(r){let e=r.toJson({all:!1,assets:!0,timings:!0});R(e.time);let s=e.assets.filter(h=>Rt(h.name)).map(jt);s.sort((h,C)=>h.size-C.size);let i=Math.max(...s.map(h=>h.sizeLabel.length)),o=Math.max(...s.map(h=>(h.folder+w.sep+h.name).length));Dt(o,i);let n=0,l=0;s.forEach(h=>{let{sizeLabel:C}=h,{name:b,folder:Qe,gzipSizeLabel:Ye}=h,ie=(Qe+w.sep+b).length,oe=C.length;if(n+=h.size,l+=h.gzippedSize,oe<i){let z=" ".repeat(i-oe);C+=z}let ne=g.gray(h.folder+w.sep)+Lt(h.name);if(ie<o){let z=" ".repeat(o-ie);ne+=z}p.info(` ${ne} ${g.gray(C)} ${Ye}`)});let c=`${g.bold.blue("Total size:")} ${T(n)}`,f=`${g.bold.blue("Gzipped size:")} ${T(l)}`;p.info(`
11
11
  ${c}
12
12
  ${f}
13
- `)}function R(r=0){p.info(`${g.greenBright("\u2713")} Ready in ${xe(Number(r))}`)}var Ot,$t,Pt,Rt,kt,jt,T,Lt,A=m(()=>{"use strict";d();y();S();Ot=/\.html$/,$t=/\.(?:js|mjs|cjs|jsx)$/,Pt=/\.css$/,Rt=r=>!/\.map$/.test(r)&&!/\.LICENSE\.txt$/.test(r),kt=r=>r>300*1e3?g.red:r>100*1e3?g.yellow:g.gray,jt=r=>{let e=r.name.split("?")[0],t=T(r.size),s=w.basename(e),i=w.join(w.basename(a.empConfig.build.outDir),w.dirname(e)),o=Et.readFileSync(w.join(a.empConfig.build.outDir,e)),n=o.length,l=St(o),c=kt(l)(T(l));return{size:n,folder:i,name:s,gzippedSize:l,sizeLabel:t,gzipSizeLabel:c}};T=r=>{let e=r/1e3;return`${e.toFixed(e<1?2:1)} kB`},Lt=r=>$t.test(r)?g.yellowBright(r):Pt.test(r)?g.greenBright(r):Ot.test(r)?g.blueBright(r):g.magenta(r)});var Ue={};G(Ue,{default:()=>Ft});import{rspack as Tt}from"@rspack/core";import{RspackDevServer as At}from"@rspack/dev-server";var Z,Ft,_e=m(()=>{"use strict";d();D();y();Y();S();A();Z=class extends x{async run(){let e=v(a.rsConfig,{stats:{all:!1,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}}),t=Tt(e);if(!a.rsConfig.devServer){p.error("devServer is not defined in config");return}let s=Object.assign({},a.rsConfig.devServer),{host:i,port:o}=s;if(this.isHttps&&(s.https===!0&&delete s.https,!s.server)){let[c,f]=await this.getcert();s.server={type:"https",options:{key:c,cert:f}}}let n=await L(Number(o),i);n!==o&&(a.rsConfig.devServer.port=n,s.port=n);let l=new At(s,t);this.startOpen({host:i,port:n}),await l.start(),l.middleware?.waitUntilValid(c=>{let f=c?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});R(f.time)})}},Ft=new Z});var Ie={};G(Ie,{default:()=>Gt});import{rspack as zt}from"@rspack/core";var K,Gt,He=m(()=>{"use strict";y();d();D();A();K=class extends x{async run(){zt(a.rsConfig,(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({colors:!0,children:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({colors:!0,children:!0}))),Ne(t)})}},Gt=new K});import Bt from"express";import Mt from"cors";import Nt from"compression";import Ut from"https";var F,Je=m(()=>{"use strict";Y();d();D();F=class extends x{app;async init(){let e=Bt();e.use(Nt()),e.use(Mt()),this.app=e}async server(){let e=Object.assign({},a.rsConfig.devServer),{host:t,port:s}=e,i=await L(Number(s),t);if(this.isHttps){let[o,n]=await this.getcert();Ut.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:o,cert:n},this.app).listen(i,async()=>{this.startOpen({host:t,port:i}),await this.onReady()})}else this.app.listen(i,async()=>{this.startOpen({host:t,port:i}),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var Ve={};G(Ve,{default:()=>Vt});import _t from"express";import It from"path";import Ht from"node:fs/promises";import Jt from"node:fs";var ee,Vt,We=m(()=>{"use strict";Je();d();y();A();ee=class extends F{timing=0;async run(){if(this.timing=Date.now(),!Jt.existsSync(a.outDir))return p.sysError(`emp serve must be executed after emp build,${a.outDir} not exist!`);this.start()}async middleware(){let e=a.resolve(a.rsConfig.output?.path);this.app.use(_t.static(e));let t=await Ht.readFile(It.join(e,"index.html"),"utf8");this.app.get("*",(s,i)=>i.send(t))}async onReady(){R(Date.now()-this.timing)}},Vt=new ee});d();d();S();y();import{program as $}from"commander";import te,{exit as Wt}from"node:process";function Xe(){let r="20.0.0";k(r,te.versions.node)===1&&(p.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${te.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${r}`),Wt(0)),$.version(a.empPkg.version,"-v, --version").usage("<command> [options]"),$.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,i]=e.split("=");return t[s]=i,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(_e(),Ue));await t.setup("dev",e)}),$.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,i]=e.split("=");return t[s]=i,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(He(),Ie));await t.setup("build",e)}),$.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(We(),Ve));await t.setup("serve",e)}),$.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(e=>{}),$.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(e=>{}),$.parse(te.argv)}d();import Xt from"fast-glob";import qe from"node:fs/promises";import se from"node:path";var qt=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Qt=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Yt=/import\(['"]([^;\n]+?)['"]\)/,re=class{list=[];outDir=a.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await Xt([`${a.empConfig.build.outDir}/**/*.d.ts`]);let e=[];this.list.map(s=>{s=a.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await qe.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(qt,i=>{let o=i.match(Qt);if(o||(o=i.match(Yt)),o&&o[1]){let n=o[1];if(!n.startsWith("."))return i;let l=se.resolve(se.dirname(e),n).replace(this.outDir,this.aliasName);return i.replace(o[1],l)}return i});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
13
+ `)}function R(r=0){p.info(`${g.greenBright("\u2713")} Ready in ${xe(Number(r))}`)}var Ot,$t,Pt,Rt,kt,jt,T,Lt,A=m(()=>{"use strict";d();y();S();Ot=/\.html$/,$t=/\.(?:js|mjs|cjs|jsx)$/,Pt=/\.css$/,Rt=r=>!/\.map$/.test(r)&&!/\.LICENSE\.txt$/.test(r),kt=r=>r>300*1e3?g.red:r>100*1e3?g.yellow:g.white,jt=r=>{let e=r.name.split("?")[0],t=T(r.size),s=w.basename(e),i=w.join(w.basename(a.empConfig.build.outDir),w.dirname(e)),o=Et.readFileSync(w.join(a.empConfig.build.outDir,e)),n=o.length,l=St(o),c=kt(l)(T(l));return{size:n,folder:i,name:s,gzippedSize:l,sizeLabel:t,gzipSizeLabel:c}};T=r=>{let e=r/1e3;return`${e.toFixed(e<1?2:1)} kB`},Lt=r=>$t.test(r)?g.yellowBright(r):Pt.test(r)?g.greenBright(r):Ot.test(r)?g.blueBright(r):g.magenta(r)});var Ue={};G(Ue,{default:()=>Ft});import{rspack as Tt}from"@rspack/core";import{RspackDevServer as At}from"@rspack/dev-server";var Z,Ft,_e=m(()=>{"use strict";d();D();y();Y();S();A();Z=class extends x{async run(){let e=v(a.rsConfig,{stats:{all:!1,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}}),t=Tt(e);if(!a.rsConfig.devServer){p.error("devServer is not defined in config");return}let s=Object.assign({},a.rsConfig.devServer),{host:i,port:o}=s;if(this.isHttps&&(s.https===!0&&delete s.https,!s.server)){let[c,f]=await this.getcert();s.server={type:"https",options:{key:c,cert:f}}}let n=await L(Number(o),i);n!==o&&(a.rsConfig.devServer.port=n,s.port=n);let l=new At(s,t);this.startOpen({host:i,port:n}),await l.start(),l.middleware?.waitUntilValid(c=>{let f=c?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});R(f.time)})}},Ft=new Z});var Ie={};G(Ie,{default:()=>Gt});import{rspack as zt}from"@rspack/core";var K,Gt,He=m(()=>{"use strict";y();d();D();A();K=class extends x{async run(){zt(a.rsConfig,(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({colors:!0,children:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({colors:!0,children:!0}))),Ne(t)})}},Gt=new K});import Bt from"express";import Mt from"cors";import Nt from"compression";import Ut from"https";var F,Je=m(()=>{"use strict";Y();d();D();F=class extends x{app;async init(){let e=Bt();e.use(Nt()),e.use(Mt()),this.app=e}async server(){let e=Object.assign({},a.rsConfig.devServer),{host:t,port:s}=e,i=await L(Number(s),t);if(this.isHttps){let[o,n]=await this.getcert();Ut.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:o,cert:n},this.app).listen(i,async()=>{this.startOpen({host:t,port:i}),await this.onReady()})}else this.app.listen(i,async()=>{this.startOpen({host:t,port:i}),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var Ve={};G(Ve,{default:()=>Vt});import _t from"express";import It from"path";import Ht from"node:fs/promises";import Jt from"node:fs";var ee,Vt,We=m(()=>{"use strict";Je();d();y();A();ee=class extends F{timing=0;async run(){if(this.timing=Date.now(),!Jt.existsSync(a.outDir))return p.sysError(`emp serve must be executed after emp build,${a.outDir} not exist!`);this.start()}async middleware(){let e=a.resolve(a.rsConfig.output?.path);this.app.use(_t.static(e));let t=await Ht.readFile(It.join(e,"index.html"),"utf8");this.app.get("*",(s,i)=>i.send(t))}async onReady(){R(Date.now()-this.timing)}},Vt=new ee});d();d();S();y();import{program as $}from"commander";import te,{exit as Wt}from"node:process";function Xe(){let r="20.0.0";k(r,te.versions.node)===1&&(p.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${te.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${r}`),Wt(0)),$.version(a.empPkg.version,"-v, --version").usage("<command> [options]"),$.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,i]=e.split("=");return t[s]=i,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(_e(),Ue));await t.setup("dev",e)}),$.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,i]=e.split("=");return t[s]=i,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(He(),Ie));await t.setup("build",e)}),$.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(We(),Ve));await t.setup("serve",e)}),$.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(e=>{}),$.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(e=>{}),$.parse(te.argv)}d();import Xt from"fast-glob";import qe from"node:fs/promises";import se from"node:path";var qt=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Qt=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Yt=/import\(['"]([^;\n]+?)['"]\)/,re=class{list=[];outDir=a.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await Xt([`${a.empConfig.build.outDir}/**/*.d.ts`]);let e=[];this.list.map(s=>{s=a.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await qe.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(qt,i=>{let o=i.match(Qt);if(o||(o=i.match(Yt)),o&&o[1]){let n=o[1];if(!n.startsWith("."))return i;let l=se.resolve(se.dirname(e),n).replace(this.outDir,this.aliasName);return i.replace(o[1],l)}return i});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
14
14
  ${t}}\r
15
15
  `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await qe.writeFile(se.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Zt=new re;function li(r){return r}export{li as defineConfig,Zt as dts,Xe as runScript,a as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-beta.9",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -81,9 +81,9 @@
81
81
  "tsc-alias": "^1.8.8"
82
82
  },
83
83
  "dependencies": {
84
- "@rspack/core": "^0.5.6",
85
- "@rspack/dev-server": "^0.5.6",
86
- "@rspack/plugin-react-refresh": "^0.5.6",
84
+ "@rspack/core": "^0.5.7",
85
+ "@rspack/dev-server": "^0.5.7",
86
+ "@rspack/plugin-react-refresh": "^0.5.7",
87
87
  "@svgr/webpack": "^8.1.0",
88
88
  "@types/node": "^20.8.7",
89
89
  "@types/react": "^18.2.30",