@empjs/cli 3.12.5-beta.3 → 4.0.0-alpha.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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/346.js +10 -0
  3. package/dist/627.js +5 -0
  4. package/dist/build.js +1 -0
  5. package/dist/dev.js +2 -0
  6. package/dist/dev.js.LICENSE.txt +1 -0
  7. package/dist/helper/buildPrint.d.ts +41 -0
  8. package/dist/helper/chalk.d.ts +3 -0
  9. package/dist/helper/color.d.ts +31 -0
  10. package/dist/helper/compilerWatcher.d.ts +5 -0
  11. package/dist/helper/empRoot.d.ts +1 -0
  12. package/dist/helper/getPort.d.ts +6 -0
  13. package/dist/helper/hmr/client.d.ts +0 -0
  14. package/dist/helper/hmr/config.d.ts +0 -0
  15. package/dist/helper/hmr/index.d.ts +0 -0
  16. package/dist/helper/hmr/overlay.d.ts +0 -0
  17. package/dist/helper/hmr/process-update.d.ts +0 -0
  18. package/dist/helper/hono.d.ts +0 -0
  19. package/dist/helper/index.d.ts +6 -0
  20. package/dist/helper/ipAddress.d.ts +27 -0
  21. package/dist/helper/loadConfig.d.ts +5 -0
  22. package/dist/helper/logger.d.ts +27 -0
  23. package/dist/helper/nodePolyfill.d.ts +1 -0
  24. package/dist/helper/openBrowser.d.ts +2 -0
  25. package/dist/helper/utils.d.ts +15 -0
  26. package/dist/index.d.ts +16 -841
  27. package/dist/index.js +1 -22
  28. package/dist/script/base.d.ts +6 -0
  29. package/dist/script/build.d.ts +15 -0
  30. package/dist/script/dev.d.ts +30 -0
  31. package/dist/script/index.d.ts +1 -0
  32. package/dist/script/serve.d.ts +7 -0
  33. package/dist/serve.js +1 -0
  34. package/dist/server/connect/dev.d.ts +9 -0
  35. package/dist/server/connect/prod.d.ts +3 -0
  36. package/dist/server/express/dev.d.ts +0 -0
  37. package/dist/server/express/prod.d.ts +0 -0
  38. package/dist/server/hono/dev.d.ts +0 -0
  39. package/dist/server/hono/devServer/devMiddleware.d.ts +0 -0
  40. package/dist/server/hono/prod.d.ts +0 -0
  41. package/dist/server/index.d.ts +3 -0
  42. package/dist/server/types.d.ts +3 -0
  43. package/dist/server.js +1 -0
  44. package/dist/store/chain.d.ts +41 -0
  45. package/dist/store/empConfig.d.ts +75 -0
  46. package/dist/store/index.d.ts +179 -0
  47. package/dist/store/lifeCycle.d.ts +57 -0
  48. package/dist/store/rspack/builtInPlugin.d.ts +16 -0
  49. package/dist/store/rspack/common.d.ts +21 -0
  50. package/dist/store/rspack/css.d.ts +10 -0
  51. package/dist/store/rspack/entries.d.ts +44 -0
  52. package/dist/store/rspack/index.d.ts +7 -0
  53. package/dist/store/rspack/module.d.ts +22 -0
  54. package/dist/store/rspack/plugin.d.ts +19 -0
  55. package/dist/store/server.d.ts +39 -0
  56. package/dist/types/config.d.ts +428 -0
  57. package/dist/types/env.d.ts +3 -0
  58. package/dist/types/plugin.d.ts +6 -0
  59. package/package.json +16 -21
  60. package/dist/index.cjs +0 -22
  61. package/dist/index.d.cts +0 -841
package/README.md CHANGED
@@ -10,7 +10,7 @@ EMP 是一个基于 Rspack 的高性能模块联邦框架,专注于微前端
10
10
  ## 快速开始
11
11
 
12
12
  ### 环境要求
13
- - Node.js 18+
13
+ - Node.js `^20.19.0 || >=22.12.0`
14
14
  - pnpm 8+(推荐)
15
15
 
16
16
  ### 安装
@@ -196,4 +196,4 @@ EMP 支持多种前端框架:
196
196
  [github-src]: https://img.shields.io/badge/github-@emp/cli-blue?style=flat&colorA=18181B&colorB=F0DB4F
197
197
  [github-href]: https://github.com/empjs/emp
198
198
  [node-src]: https://img.shields.io/node/v/@empjs/cli?style=flat&colorA=18181B&colorB=F0DB4F
199
- [node-href]: https://nodejs.org/en/about/previous-releases
199
+ [node-href]: https://nodejs.org/en/about/previous-releases
package/dist/346.js ADDED
@@ -0,0 +1,10 @@
1
+ import e from"node:module";let t=e.createRequire(import.meta.url);import s,{rspack as i}from"@rspack/core";import{program as o}from"commander";import r from"node:process";import n from"node:fs/promises";import a,{dirname as l}from"node:path";import p,{promisify as h}from"node:util";import c from"node:fs";import{createJiti as m}from"jiti";import u from"path";import*as g from"chalk";import{ip as d}from"address";import{gateway4sync as f}from"default-gateway";import v from"fs-extra";import y from"@empjs/chain";import{glob as C}from"glob";import b from"html-webpack-plugin";import w from"fs";import{TsCheckerRspackPlugin as O}from"ts-checker-rspack-plugin";import P from"net";import k from"os";import j from"url";import{exec as x}from"node:child_process";import{fileURLToPath as $}from"node:url";var E,S={},N={};function D(e){var t=N[e];if(void 0!==t)return t.exports;var s=N[e]={exports:{}};return S[e](s,s.exports,D),s.exports}D.m=S,D.d=(e,t,s)=>{var i=(t,s)=>{for(var i in t)D.o(t,i)&&!D.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,[s]:t[i]})};i(t,"get"),i(s,"value")},D.add=function(e){Object.assign(D.m,e)};var A=D;D.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),D.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},E={346:0,410:0},D.C=e=>{var t,s,i=e.__rspack_esm_ids,o=e.__webpack_modules__,r=e.__rspack_esm_runtime,n=0;for(t in o)D.o(o,t)&&(D.m[t]=o[t]);for(r&&r(D);n<i.length;n++)s=i[n],D.o(E,s)&&E[s]&&E[s][0](),E[i[n]]=0},D.add({"@rsdoctor/rspack-plugin"(e){e.exports=t("@rsdoctor/rspack-plugin")}});var R={};D.r(R),D.d(R,{chalk:()=>z,color:()=>es,glob:()=>C,logger:()=>eo,utils:()=>L});var L={};D.r(L),D.d(L,{clearConsole:()=>em,deepAssign:()=>eu,ensureArray:()=>eg,getLanIp:()=>eh,getPkgVersion:()=>ec,importJsVm:()=>ey,jsonFilter:()=>ed,timeFormat:()=>ev,vCompare:()=>ef});var T=JSON.parse('{"rE":"4.0.0-alpha.2"}');async function _(){o.version(T.rE,"-v, --version").usage("<command> [options]"),o.command("dev").description("Dev 模式").option("-e, --env <env>","部署环境 dev、test、prod").option("-rd, --doctor","开启rsdoctor,可通过debug.rsdoctor操作").option("-h, --hot","是否使用热更新 默认启动").option("-o, --open","是否打开调试页面 默认不打开").option("-t, --ts","生成类型文件 默认为 false").option("-pr, --profile","统计模块消耗").option("-cl, --clearLog <clearLog>","清空日志 默认为 true").option("-ev, --env-vars <key=value>","定义一个环境变量 -ev key=value 多个环境变量重复调用 -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 import("./dev.js");await t.setup("dev",e)}),o.command("build").description("Build 模式").option("-e, --env <env>","部署环境 dev、test、prod").option("-rd, --doctor","开启rsdoctor,可通过debug.rsdoctor操作").option("-a, --analyze","生成分析报告 默认为 false").option("-t, --ts","生成类型文件 默认为 false").option("-pr, --profile","统计模块消耗").option("-cl, --clearLog <clearLog>","清空日志 默认为 true").option("-w, --watch","watch 模式").option("-sv, --serve","watch 模式下启动serve").option("-ev, --env-vars <key=value>","定义一个环境变量 -ev key=value 多个环境变量重复调用 -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 import("./build.js");await t.setup("build",e)}),o.command("serve").description("Server 模式").option("-cl, --clearLog <clearLog>","清空日志 默认为 true").option("-e, --env <env>","部署环境 dev、test、prod").option("-ev, --env-vars <key=value>","定义一个环境变量 -ev key=value 多个环境变量重复调用 -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 import("./serve.js");await t.setup("serve",e)}),o.command("dts").description("拉取 remote 项目的 d.ts").option("-p, --typingsPath <typingsPath>","下载目录").option("-e, --env <env>","部署环境 dev、test、prod").action(e=>{}),o.command("init").description("初始化 emp 项目").option("-d, --data [data]","JSON数据 http地址 或者 文件路径相对、绝对路径").action(e=>{}),o.parse(r.argv)}var M=l($(import.meta.url)),U=$(import.meta.url);let F=function(e){let t=a.resolve(e);for(;;){let e=a.join(t,"package.json");if(c.existsSync(e))try{if("@empjs/cli"===JSON.parse(c.readFileSync(e,"utf8")).name)return t}catch{}let s=a.dirname(t);if(s===t)break;t=s}return a.resolve(M,U).replace(`${a.sep}dist${a.sep}index.js`,"")}(M),J=e=>"function"==typeof e&&"function"==typeof e.hex,z=(e=>{let t=e.default;if(J(t))return t;if(t&&"object"==typeof t){let e=t.default;if(J(e))return e}return e})(g),I=z.hex("#1abc9c"),H=z.hex("#16a085"),B=z.hex("#2ecc71"),V=z.hex("#27ae60"),W=z.hex("#e74c3c"),G=z.hex("#c0392b"),q=z.hex("#f1c40f"),K=z.hex("#f39c12"),Q=z.hex("#3498db"),X=z.hex("#2980b9"),Y=z.hex("#ecf0f1"),Z=z.hex("#fd79a8"),ee=z.hex("#e84393"),et=z.hex("#7f8c8d"),es={lightGreen:I,green:H,lightCyan:B,cyan:V,lightRed:W,red:G,yellow:q,orange:K,lightBlue:Q,blue:X,white:Y,lightMagenta:Z,magenta:ee,gray:et};class ei{brandName="";fullName="";logLevel="info";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=es.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${es.lightBlue(this.brandName)}${es.blue(` ${e} `)}
2
+ `)};cyan=e=>{console.log(`${es.lightCyan(this.brandName)}${es.cyan(` ${e} `)}
3
+ `)};magenta=e=>{console.log(`${es.lightMagenta(this.brandName)}${es.magenta(` ${e} `)}
4
+ `)};green=e=>{console.log(`${es.lightGreen(this.brandName)}${es.green(` ${e} `)}
5
+ `)};yellow=e=>{console.log(`${es.yellow(this.brandName)}${es.orange(` ${e} `)}
6
+ `)};red=e=>{console.log(`${es.lightRed(this.brandName)}${es.red(` ${e} `)}
7
+ `)};sysError=e=>{console.log(`${es.lightRed(" System Error Tips ")}${es.red(` ${e} `)}
8
+ `)};link=e=>es.blue(e);title=e=>{console.log(`${this.fullName}${es.yellow.underline(`${e}`)}
9
+ `)}}let eo=new ei;var er=$(import.meta.url);let en=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],ea=m(er,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:T.rE}),el=async()=>{let e="store.getEmpConfigPath";eo.time(e);let t=en.map(e=>u.resolve(ez.root,e)),s=await Promise.all(t.map(e=>c.promises.access(e).then(()=>!0,()=>!1))),i=t.find((e,t)=>s[t]);return eo.timeEnd(e),i},ep=async()=>{let e=u.join(ez.root,"tsconfig.json");return await c.promises.access(e).then(()=>!0,()=>!1)||(e=void 0),e},eh=()=>{let e="127.0.0.1";try{let{int:t}=f();return d(t||"")||e}catch(t){return e}},ec=e=>{try{let{version:t}=v.readJSONSync(e);return t}catch(e){return}};function em(){process.stdout.write("win32"===process.platform?"\x1b[2J\x1b[0f":"\x1b[2J\x1b[3J\x1b[H")}function eu(e,...t){for(let s of t)for(let t in s){let i=s[t],o=e[t];if(Object(i)==i&&Object(o)===o){e[t]=eu(o,i);continue}e[t]=s[t]}return e}let eg=e=>Array.isArray(e)?e:[e],ed=(e={},t=[])=>Object.keys(e).filter(e=>!t.includes(e)).reduce((t,s)=>(t[s]=e[s],t),{}),ef=(e="",t="")=>{let s=e.replace("^","").split("."),i=t.replace("^","").split("."),o=Math.max(s.length,i.length),r=0;for(let e=0;e<o;e++){let t=s.length>e?s[e]:0,o=isNaN(Number(t))?t.charCodeAt():Number(t),n=i.length>e?i[e]:0,a=isNaN(Number(n))?n.charCodeAt():Number(n);if(o<a){r=-1;break}if(o>a){r=1;break}}return r},ev=e=>{let t;if((e/=1e3)<1)return`${1e3*e} ms`;if(e<10){let t,s=e>=.01?2:3;return`${t=e.toFixed(s),z.bold(t)} s`}if(e<60){let t;return`${t=e.toFixed(1),z.bold(t)} s`}let s=e/60;return`${t=s.toFixed(2),z.bold(t)} m`},ey=e=>`data:text/javascript,${e}`,eC={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}};class eb{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}let ew=new class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return eu(e,t=t||{})}get isESM(){return 1!==["es3","es5"].indexOf(this.store.empConfig.build.target)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new eb(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:i}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),i&&(this.appEntry=i)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}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(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,nativeWatcher:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},incremental:"advance-silent",lazyCompilation:this.store.isDev,target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:!1!==this.cache,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:"darwin"===process.platform,hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],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?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2);let t=this.assign(e,this.store.empOptions.server),s="0.0.0.0"===t.host||"::"===t.host,{server:i}=this.store;if(this.store.isDev&&s&&i?.ip){let e=t.client??={};if(!e.webSocketURL){let s=i.isHttps?"wss":"ws",o=t.port??i.port??8e3;e.webSocketURL=`${s}://${i.ip}:${o}/ws`}}return t}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},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,o={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:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,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)}get tsCheckerRspackPlugin(){let e={};return!!this.store.empOptions.tsCheckerRspackPlugin&&("object"==typeof this.store.empOptions.tsCheckerRspackPlugin&&(e=this.store.empOptions.tsCheckerRspackPlugin),this.assign({},e))}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(i=>{"all"===t?(s[`import.meta.env.${i}`]=JSON.stringify(e[i]),s[`process.env.${i}`]=JSON.stringify(e[i])):"esm"===t?s[`import.meta.env.${i}`]=JSON.stringify(e[i]):"cjs"===t?s[`process.env.${i}`]=JSON.stringify(e[i]):"none"===t&&(s[`${i}`]=JSON.stringify(e[i]))}),s}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return eu({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="store.jiti.loadConfig.empConfig";if(eo.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await ea(this.store.rootPaths.empConfig);"function"==typeof t?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},eo.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return!0===t.defaultExclude&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return!1!==this.store.empOptions.cache&&(this.store.empOptions.cache?this.store.empOptions.cache:"persistent")}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e="boolean"==typeof this.store.empOptions.autoPages?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}showLogTitle(e){this.store.empOptions.showLogTitle?this.store.empOptions.showLogTitle(e):eo.title(`${e.cliAction}`)}},eO=new class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){let e;if(!1===this.store.empConfig.cache)return!1;let t={type:"persistent"===this.store.empConfig.cache?"persistent":"memory",buildDependencies:(e=[er],ez.rootPaths.pkg&&e.push(ez.rootPaths.pkg),ez.rootPaths.empConfig&&e.push(ez.rootPaths.empConfig),ez.rootPaths.tsConfig&&e.push(ez.rootPaths.tsConfig),e),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return"object"==typeof this.store.empConfig.cache&&(t=this.store.deepAssign(t,this.store.empConfig.cache)),t}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:this.store.empConfig.debug.nativeWatcher,asyncWebAssembly:!0},incremental:this.store.empConfig.build.incremental,lazyCompilation:this.store.empConfig.build.lazyCompilation,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.cache,devtool:this.store.empConfig.build.sourcemap.js,output:{...this.store.empConfig.output,bundlerInfo:{force:!1},module:this.store.empConfig.output.module||this.store.empConfig.isESM},resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await v.exists(e)){let t={};this.store.isOldRspack?t.tsConfigPath=e:t.tsConfig=e,this.store.merge({resolve:t})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};"entry"===this.store.empConfig.build.polyfill.mode&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},eP=new class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:s}=this.store.chainName,i={},{sass:o}=this.store.empConfig.css;"modern"===o.mode&&(i.implementation=o.implementation?o.implementation:t.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,o.sassOptions&&(i.sassOptions=o.sassOptions)),void 0!==o.additionalData&&(i.additionalData=o.additionalData),void 0!==o.warnRuleAsWarning&&(i.warnRuleAsWarning=o.warnRuleAsWarning),void 0!==o.webpackImporter&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[s.sass]:{loader:t.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:s}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,o={loader:t.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[s.less]:o},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}};class ek{apply(e){let{webpack:t}=e;ez.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ey(`import 'core-js/${ez.empConfig.build.polyfill.coreJsFeatures}'`),{name:void 0}).apply(e)}}class ej{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,e=>{b.getHooks(e).alterAssetTagGroups.tapPromise(this.PluginName,async e=>(this.chunk&&!e.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(t=>{let{pos:s,...i}=t;("body"===s?e.bodyTags:e.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...i})}),e))})}}let ex=new class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(a.extname(e),"").replace(`${this.store.empConfig.appSrc}${a.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(a.join("template","index.html"))}setFavicion(e){if(""!==e)return e?this.store.resolve(e):this.store.empResolve(a.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(a.join(this.store.empConfig.appSrc,e));let i=this.setChunk(e),o=[s];this.entriesConfig[i]={entry:{[i]:o},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(b,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){eo.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=a.join(this.store.appSrc,e),s=a.join(t,"**","*.{ts,tsx,jsx,js}"),i=await C([s],{windowsPathsNoEscape:!0});(i=i.map(e=>e.replace(`${t}${a.sep}`,""))).map(e=>{let s=this.store.empConfig.entries[e]||{};this.setEntryItem(e,{...this.store.empConfig.html,...s},a.join(t,e))}),eo.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";eo.time(e);let t=a.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),s=await C([t],{windowsPathsNoEscape:!0});if(s[0]){let e=a.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(e,this.store.empConfig.html,s[0])}eo.timeEnd(e)}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},e$=new class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:s}=this.store.empConfig.build,{externalHelpers:i}=s;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:i,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:eu(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),"usage"===this.store.empConfig.build.polyfill.mode&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",a.dirname(t.resolve("@swc/helpers/package.json"))),this.coreJs.path=t.resolve("core-js/package.json");let s=ec(this.coreJs.path);s&&(this.coreJs.version=s),this.coreJs.alias=a.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:s}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},eE=new class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;"entry"===e.empConfig.build.polyfill.mode&&e.chain.plugin("empPolyfill").use(ek)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(!1===this.store.empConfig.tsCheckerRspackPlugin)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(O,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(s.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");w.existsSync(e)&&w.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(s.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if("development"===this.store.mode)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"▩▩"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(s.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(s.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=s;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=D("@rsdoctor/rspack-plugin"),t={};"object"==typeof this.store.empConfig.debug.rsdoctor&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){"object"==typeof this.store.empConfig.build.sourcemap&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(s.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(s.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){let e=!0===this.store.empConfig.debug.cssChunkingPlugin?{}:this.store.empConfig.debug.cssChunkingPlugin;e&&this.store.chain.plugin("CssChunkingPlugin").use(s.experiments.CssChunkingPlugin,[e])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let{EsmLibraryPlugin:e}=s.experiments;if(!e)return;let t=u.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(e,[{preserveModules:t}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},eS=new class{store;async setup(e){this.store=e;let t=[eO.setup(this.store),e$.setup(this.store),eE.setup(this.store),ex.setup(this.store),eP.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},eN=(e,t)=>new Promise((s,i)=>{let o=P.createServer();o.unref(),o.on("error",i),o.listen(e,t,()=>{let{port:e}=o.address();o.close(()=>{s(e)})})}),eD=async(e,t)=>{let s=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of t)try{await eN(e,i)}catch(e){if(!s.has(e.code))throw e}return e};async function eA(e,t){let s;if(443!==e&&(e<1024||e>65535))throw Error("Port number must lie between 1024 and 65535");let i=e,o=(()=>{let e=k.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let s of Object.values(e))if(s)for(let e of s)t.add(e.address);return t})();s=t&&!o.has(t)?new Set([t]):o;let r=new Set(["EADDRINUSE","EACCES"]);for(;i<=65535;)try{return await eD(i,s)}catch(e){if(!r.has(e.code))throw e;i+=1}throw Error("No available ports found")}class eR{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:et("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let e,{host:t}=this;if("0.0.0.0"===t||"::"===t){e="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch(e){}}else e=t,this.urls.lanUrlForConfig=t,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(e),this.urls.localUrlForBrowser=this.formatUrl(e)}getLanIp=eh;formatUrl(e){let{protocol:t,port:s,pathname:i}=this.imf;return j.format({protocol:t,hostname:e,port:s,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:i}=this.imf;return j.format({protocol:t,hostname:e,port:z.bold(s),pathname:i})}}let eL=new eR,eT=h(x),e_=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],eM=async()=>{let e=process.env.BROWSER;if(!e||!e_.includes(e)){let{stdout:t}=await eT("ps cax");e=e_.find(e=>t.includes(e))}return e},eU=async e=>{if("darwin"===process.platform)try{let t=await eM();if(t){let s=`osascript openChrome.applescript "${encodeURI(e)}" "${t}"`;return await eT(s,{cwd:ez.resource.dir}),!0}}catch(e){eo.debug(e)}try{let{default:t}=await import("open");return await t(e),!0}catch(e){return eo.error("Failed to open start URL."),eo.error(e),!1}};class eF{ip=eh();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){"build"!==this.store.cliAction&&(this.port=await eA(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if("build"===this.store.cliAction)return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await eA(e.empConfig.server.port)),eL.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=eL.prettyPrintUrl("localhost")):(this.urls=eL.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(eo.info(`${H("➜")} Local: ${eo.link(e.localUrlForTerminal)}`),eo.info(`${H("➜")} Network: ${eo.link(this.publicPath)}`)):(eo.info(`${H("➜")} Local: ${eo.link(e.localUrlForTerminal)}`),eo.info(`${H("➜")} Network: ${eo.link(e.lanUrlForTerminal)}
10
+ `)),this.isOpenBrower&&eU(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if("object"==typeof t.server&&"https"===t.server.type&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[s,i]=await Promise.all([n.readFile(e.resource.key),n.readFile(e.resource.cert)]);return{key:s,cert:i}}setHttps(){let{store:e}=this,{server:t,https:s}=e.empOptions.server||{};this.isHttps="https"===t||"object"==typeof t&&"https"===t.type||!0===s}async setAutoDevBase(){let{store:e}=this;if(this.isAutoDevBase=!!e.empOptions.autoDevBase&&"development"===e.mode&&!this.isHttpBase,!this.isAutoDevBase)return;this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await eA(this.port);let t=`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`;e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:t}},e.empOptions.server)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}class eJ{rspack=i;rspackVersion=i.rspackVersion;isOldRspack=-1===ef(this.rspackVersion,"1.0.0");empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=F;empSource=a.resolve(this.empRoot,"dist");resolve=e=>a.isAbsolute(e)?e:a.resolve(this.root,e);empResolve=e=>a.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=eC;server=new eF(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;cliOptions;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};beforeSetup;afterSetup;async setup(e,t){this.cliAction=e||this.cliAction,this.cliOptions=t||this.cliOptions;let s="store.setup";eo.time(s),this.beforeSetup&&await this.beforeSetup();let[i,o]=await Promise.all([el(),ep()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(this.cliAction,this.cliOptions),this.empConfig=ew,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new y,await eS.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),this.afterSetup&&await this.afterSetup(),eo.timeEnd(s),this.debug.clearLog&&em()}async initVars(e,s){this.cliAction=e,this.cliOptions=s||{},this.cliMode="prod",this.mode="dev"===e?"development":"production",this.isDev="development"===this.mode,process.env.NODE_ENV="dev"===e?"development":"production";let i=t(this.empResolve("package.json")),o=t(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=a.join(this.empRoot,"resource"),this.resource.cert=a.join(this.resource.dir,"emp.cert"),this.resource.key=a.join(this.resource.dir,"emp.key")}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)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e="dev"===this.cliMode?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),eo.setup({fullName:`EMP⚡${this.empPkg.version}${"dev"===this.cliMode?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if("string"==typeof this.debug.showRsconfig){let e=a.join(this.root,this.debug.showRsconfig);n.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t="object"==typeof this.debug.showRsconfig?eu(e,this.debug.showRsconfig):e;console.log(eo.link("[Compile Config]")),console.log(p.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=ef;deepAssign=eu;getLanIp=eh;injectTags(e=[],t="",s=""){this.chain.plugin(`${ej}-${t}`).use(ej,[e,t,s])}}let ez=new eJ;function eI(e){return e}export{A as __webpack_require__,ei as Logger,X as blue,z as chalk,es as color,eu as deepAssign,eI as defineConfig,et as gray,H as green,R as empHelper,eo as logger,ee as magenta,o as program,G as red,i as rspack,_ as runScript,ez as store,ev as timeFormat,Y as white,q as yellow};
package/dist/627.js ADDED
@@ -0,0 +1,5 @@
1
+ import"node:module";import e from"node:fs";import t from"node:path";import{gzipSizeSync as i}from"gzip-size";import{rspackVersion as s}from"@rspack/core";import{chalk as n,logger as o,yellow as r,white as l,magenta as a,store as m,green as p,red as d,gray as u,blue as c,timeFormat as $}from"./346.js";let f=/\.html$/,g=/\.(?:js|mjs|cjs|jsx)$/,h=/\.css$/,b=s=>{let n=s.name.split("?")[0],o=z(s.size),a=t.basename(n),p=t.join(t.basename(m.empConfig.build.outDir),t.dirname(n)),u=e.readFileSync(t.join(m.empConfig.build.outDir,n)),c=u.length,$=i(u),f=($>3e5?d:$>1e5?r:l)(z($));return{size:c,folder:p,name:a,gzippedSize:$,sizeLabel:o,gzipSizeLabel:f}},z=e=>{let t=e/1e3;return`${t.toFixed(t<1?2:1)} kB`};async function x(e){let i,s,l=e.toJson({all:!1,assets:!0,timings:!0}),m=l.assets.filter(e=>{let t;return t=e.name,!/\.map$/.test(t)&&!/\.LICENSE\.txt$/.test(t)}).map(b);m.sort((e,t)=>e.size-t.size);let d=Math.max(...m.map(e=>e.sizeLabel.length)),x=Math.max(...m.map(e=>(e.folder+t.sep+e.name).length));i=[x,d],s=["File","Size","Gzipped"].reduce((e,t,s)=>{let n=i[s],o=t;return n&&(o=t.length<n?t+" ".repeat(n-t.length):t),`${e+o} `}," "),console.log(c.bold(s));let y=0,S=0;m.forEach(e=>{var i;let{sizeLabel:s}=e,{name:n,folder:l,gzipSizeLabel:m}=e,$=(l+t.sep+n).length,b=s.length;y+=e.size,S+=e.gzippedSize,b<d&&(s+=" ".repeat(d-b));let z=u(e.folder+t.sep)+(i=e.name,g.test(i)?r(i):h.test(i)?p(i):f.test(i)?c(i):a(i));$<x&&(z+=" ".repeat(x-$)),o.info(` ${z} ${u(s)} ${m}`)});let E=`${c.bold("Total size:")} ${z(y)}`,k=`${c.bold("Gzipped size:")} ${z(S)}`;o.info(`
2
+ ${E}
3
+ ${k}
4
+ `),o.info(`${n.green("ready ")}Built in ${$(Number(l.time))}
5
+ `)}function y(e,t){console.log(("start"===e?n.cyan("start "):n.green("ready "))+n.white(t))}function S(e=0,t="Ready"){o.info(`${n.green("ready ")}${t} in ${$(Number(e))}`)}function E(e="build"){y("start",`${e} Started...`)}function k(e){let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});y("ready",`built in ${n.bold((t.time/1e3).toFixed(2))} s`)}function F(e="build started..."){y("start",e)}function j(e,t="built"){let i;i="number"==typeof e?(e/1e3).toFixed(2):((e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0})).time/1e3).toFixed(2),y("ready",`${t} in ${n.bold(i)} s`)}class C{async setup(e,t){let i=`${e}.setup`,n=`${e}.run`;o.time(i),await m.setup(e,t),m.empConfig.showLogTitle({cliAction:e,cliOptions:t,rspackVersion:s,empVersion:m.empPkg.version}),o.time(n),await this.run(),this.processExit(),o.timeEnd(n),o.timeEnd(i)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}export{C as BaseScript,j as logDone,F as logStart,k as printBuildDone,E as printBuildStart,x as printFileSizes,S as timeDone};
package/dist/build.js ADDED
@@ -0,0 +1 @@
1
+ import"node:module";import{rspack as s}from"@rspack/core";import{BaseScript as e,printFileSizes as i}from"./627.js";import{logger as t,store as r}from"./346.js";let o=new class extends e{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:s}=await import("./serve.js");await s.setup("serve",r.cliOptions)}async run(){await r.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!r.cliOptions.watch,this.isuseServe=!!r.cliOptions.serve,this.rspackConfig=r.rsConfig,this.isWatchMode&&this.watchMode(),s(this.rspackConfig,async(s,e)=>{if(console.log("\n"),r.debug.showScriptDebug&&console.log(e?.toString()),null!==s){t.error(s.stack||s),s.message&&t.error(s.message);return}e?(e.hasErrors()&&(t.error(e.toString({all:!1,colors:!0,errors:!0})),t.red("Failed to compile."),process.exit(1)),e.hasWarnings()&&(t.yellow("Compiled with warnings."),t.warn(e.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await i(e),this.startServe(),await r.empConfig.lifeCycle.afterBulid()):t.red("Stats is Undefined.")})}};export default o;
package/dist/dev.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! LICENSE: dev.js.LICENSE.txt */
2
+ import t from"node:module";let e=t.createRequire(import.meta.url);import{rspack as i}from"@rspack/core";import s,{stat as r,unwatchFile as a,watch as o,watchFile as n}from"fs";import{lstat as h,open as l,readdir as d,realpath as c,stat as f}from"fs/promises";import{EventEmitter as m}from"events";import{lstat as p,readdir as u,realpath as w,stat as _}from"node:fs/promises";import{Readable as g}from"node:stream";import{join as y,relative as v,resolve as b,sep as P}from"node:path";import{type as E}from"os";import k,*as S from"path";import{printBuildDone as x,logStart as D,printBuildStart as C,logDone as F,BaseScript as W}from"./627.js";import{chalk as R,logger as z,deepAssign as M,store as j}from"./346.js";import{DevServer as I}from"./server.js";let A="files",O="directories",T="files_directories",H={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:A,lstat:!1,depth:0x80000000,alwaysStat:!1,highWaterMark:4096};Object.freeze(H);let N="READDIRP_RECURSIVE_ERROR",U=new Set(["ENOENT","EPERM","EACCES","ELOOP",N]),L=[O,"all",T,A],$=new Set([O,"all",T]),K=new Set(["all",T,A]),q="win32"===process.platform,V=t=>!0,B=t=>{if(void 0===t)return V;if("function"==typeof t)return t;if("string"==typeof t){let e=t.trim();return t=>t.basename===e}if(Array.isArray(t)){let e=t.map(t=>t.trim());return t=>e.some(e=>t.basename===e)}return V};class G extends g{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...H,...t},{root:i,type:s}=e;this._fileFilter=B(e.fileFilter),this._directoryFilter=B(e.directoryFilter);let r=e.lstat?p:_;q?this._stat=t=>r(t,{bigint:!0}):this._stat=r,this._maxDepth=e.depth??H.depth,this._wantsDir=!!s&&$.has(s),this._wantsFile=!!s&&K.has(s),this._wantsEverything="all"===s,this._root=b(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:s,depth:r}=e,a=i.splice(0,t).map(t=>this._formatEntry(t,s));for(let e of(await Promise.all(a))){if(!e)continue;if(this.destroyed)return;let i=await this._getEntryType(e);"directory"===i&&this._directoryFilter(e)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(e.fullPath,r+1)),this._wantsDir&&(this.push(e),t--)):("file"===i||this._includeAsFile(e))&&this._fileFilter(e)&&this._wantsFile&&(this.push(e),t--)}}else{let t=this.parents.pop();if(!t){this.push(null);break}if(this.parent=await t,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await u(t,this._rdOptions)}catch(t){this._onError(t)}return{files:i,depth:e,path:t}}async _formatEntry(t,e){let i,s=this._isDirent?t.name:t;try{let r=b(y(e,s));(i={path:v(this._root,r),fullPath:r,basename:s})[this._statsProp]=this._isDirent?t:await this._stat(r)}catch(t){this._onError(t);return}return i}_onError(t){U.has(t.code)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let e=t.fullPath;try{let t=await w(e),i=await p(t);if(i.isFile())return"file";if(i.isDirectory()){let i=t.length;if(e.startsWith(t)&&e.substr(i,1)===P){let i=Error(`Circular symlink detected: "${e}" points to "${t}"`);return i.code=N,this._onError(i)}return"directory"}}catch(t){return this._onError(t),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}let J=()=>{},Q=process.platform,X="win32"===Q,Y="darwin"===Q,Z="linux"===Q,tt="freebsd"===Q,te="OS400"===E(),ti="all",ts="ready",tr="add",ta="change",to="addDir",tn="unlink",th="unlinkDir",tl="raw",td="error",tc={lstat:h,stat:f},tf="listeners",tm="errHandlers",tp="rawEmitters",tu=[tf,tm,tp],tw=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),t_=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},tg=(t,e,i)=>{let s=t[e];s instanceof Set||(t[e]=s=new Set([s])),s.add(i)},ty=(t,e,i)=>{let s=t[e];s instanceof Set?s.delete(i):s===i&&delete t[e]},tv=t=>t instanceof Set?0===t.size:!t,tb=new Map;function tP(t,e,i,s,r){try{return o(t,{persistent:e.persistent},(e,s)=>{i(t),r(e,s,{watchedPath:t}),s&&t!==s&&tE(S.resolve(t,s),tf,S.join(t,s))})}catch(t){s(t);return}}let tE=(t,e,i,s,r)=>{let a=tb.get(t);a&&t_(a[e],t=>{t(i,s,r)})},tk=new Map;class tS{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i,s=this.fsw.options,r=S.dirname(t),o=S.basename(t);this.fsw._getWatchedDir(r).add(o);let h=S.resolve(t),d={persistent:s.persistent};if(e||(e=J),s.usePolling)d.interval=s.interval!==s.binaryInterval&&tw.has(S.extname(o).slice(1).toLowerCase())?s.binaryInterval:s.interval,i=((t,e,i,s)=>{let{listener:r,rawEmitter:o}=s,h=tk.get(e),l=h&&h.options;return l&&(l.persistent<i.persistent||l.interval>i.interval)&&(a(e),h=void 0),h?(tg(h,tf,r),tg(h,tp,o)):(h={listeners:r,rawEmitters:o,options:i,watcher:n(e,i,(i,s)=>{t_(h.rawEmitters,t=>{t(ta,e,{curr:i,prev:s})});let r=i.mtimeMs;(i.size!==s.size||r>s.mtimeMs||0===r)&&t_(h.listeners,e=>e(t,i))})},tk.set(e,h)),()=>{ty(h,tf,r),ty(h,tp,o),tv(h.listeners)&&(tk.delete(e),a(e),h.options=h.watcher=void 0,Object.freeze(h))}})(t,h,d,{listener:e,rawEmitter:this.fsw._emitRaw});else i=((t,e,i,s)=>{let r,{listener:a,errHandler:o,rawEmitter:n}=s,h=tb.get(e);if(!i.persistent){if(!(r=tP(t,i,a,o,n)))return;return r.close.bind(r)}if(h)tg(h,tf,a),tg(h,tm,o),tg(h,tp,n);else{if(!(r=tP(t,i,tE.bind(null,e,tf),o,tE.bind(null,e,tp))))return;r.on(td,async i=>{let s=tE.bind(null,e,tm);if(h&&(h.watcherUnusable=!0),X&&"EPERM"===i.code)try{let e=await l(t,"r");await e.close(),s(i)}catch(t){}else s(i)}),h={listeners:a,errHandlers:o,rawEmitters:n,watcher:r},tb.set(e,h)}return()=>{if(ty(h,tf,a),ty(h,tm,o),ty(h,tp,n),tv(h.listeners)){let t;h.watcher.close(),tb.delete(e),tu.forEach((t=h,e=>{let i=t[e];i instanceof Set?i.clear():delete t[e]})),h.watcher=void 0,Object.freeze(h)}}})(t,h,d,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return i}_handleFile(t,e,i){if(this.fsw.closed)return;let s=S.dirname(t),r=S.basename(t),a=this.fsw._getWatchedDir(s),o=e;if(a.has(r))return;let n=async(e,i)=>{if(this.fsw._throttle("watch",t,5))if(i&&0!==i.mtimeMs){if(a.has(r)){let e=i.atimeMs,s=i.mtimeMs;(!e||e<=s||s!==o.mtimeMs)&&this.fsw._emit(ta,t,i),o=i}}else try{let i=await f(t);if(this.fsw.closed)return;let s=i.atimeMs,r=i.mtimeMs;if((!s||s<=r||r!==o.mtimeMs)&&this.fsw._emit(ta,t,i),(Y||Z||tt)&&o.ino!==i.ino){this.fsw._closeFile(e),o=i;let s=this._watchWithNodeFs(t,n);s&&this.fsw._addPathCloser(e,s)}else o=i}catch(t){this.fsw._remove(s,r)}},h=this._watchWithNodeFs(t,n);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(tr,t,0))return;this.fsw._emit(tr,t,e)}return h}async _handleSymlink(t,e,i,s){if(this.fsw.closed)return;let r=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){let e;this.fsw._incrReadyCount();try{e=await c(i)}catch(t){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;return a.has(s)?this.fsw._symlinkPaths.get(r)!==e&&(this.fsw._symlinkPaths.set(r,e),this.fsw._emit(ta,i,t.stats)):(a.add(s),this.fsw._symlinkPaths.set(r,e),this.fsw._emit(tr,i,t.stats)),this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(r))return!0;this.fsw._symlinkPaths.set(r,!0)}_handleRead(t,e,i,s,r,a,o){if(t=S.join(t,""),!(o=this.fsw._throttle("readdir",t,1e3)))return;let n=this.fsw._getWatchedDir(i.path),h=new Set,l=this.fsw._readdirp(t,{fileFilter:t=>i.filterPath(t),directoryFilter:t=>i.filterDir(t)});if(l)return l.on("data",async o=>{if(this.fsw.closed){l=void 0;return}let d=o.path,c=S.join(t,d);if(h.add(d),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,t,c,d))){if(this.fsw.closed){l=void 0;return}d!==s&&(s||n.has(d))||(this.fsw._incrReadyCount(),c=S.join(r,S.relative(r,c)),this._addToNodeFs(c,e,i,a+1))}}).on(td,this._boundHandleError),new Promise((e,d)=>{if(!l)return d();l.once("end",()=>{if(this.fsw.closed){l=void 0;return}let d=!!o&&o.clear();e(void 0),n.getChildren().filter(e=>e!==t&&!h.has(e)).forEach(e=>{this.fsw._remove(t,e)}),l=void 0,d&&this._handleRead(t,!1,i,s,r,a,o)})})}async _handleDir(t,e,i,s,r,a,o){let n,h,l=this.fsw._getWatchedDir(S.dirname(t)),d=l.has(S.basename(t));i&&this.fsw.options.ignoreInitial||r||d||this.fsw._emit(to,t,e),l.add(S.basename(t)),this.fsw._getWatchedDir(t);let c=this.fsw.options.depth;if((null==c||s<=c)&&!this.fsw._symlinkPaths.has(o)){if(!r&&(await this._handleRead(t,i,a,r,t,s,n),this.fsw.closed))return;h=this._watchWithNodeFs(t,(e,i)=>{i&&0===i.mtimeMs||this._handleRead(e,!1,a,r,t,s,n)})}return h}async _addToNodeFs(t,e,i,s,r){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);i&&(o.filterPath=t=>i.filterPath(t),o.filterDir=t=>i.filterDir(t));try{let i,n=await tc[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let h=this.fsw.options.followSymlinks;if(n.isDirectory()){let a=S.resolve(t),l=h?await c(t):t;if(this.fsw.closed||(i=await this._handleDir(o.watchPath,n,e,s,r,o,l),this.fsw.closed))return;a!==l&&void 0!==l&&this.fsw._symlinkPaths.set(a,l)}else if(n.isSymbolicLink()){let r=h?await c(t):t;if(this.fsw.closed)return;let a=S.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(tr,o.watchPath,n),i=await this._handleDir(a,n,e,s,t,o,r),this.fsw.closed)return;void 0!==r&&this.fsw._symlinkPaths.set(S.resolve(t),r)}else i=this._handleFile(o.watchPath,n,e);return a(),i&&this.fsw._addPathCloser(t,i),!1}catch(e){if(this.fsw._handleError(e))return a(),t}}}let tx=/\\/g,tD=/\/\//,tC=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,tF=/^\.[/\\]/;function tW(t){return Array.isArray(t)?t:[t]}let tR=t=>"object"==typeof t&&null!==t&&!(t instanceof RegExp);function tz(t,e,i){let s=function(t){if("string"!=typeof t)throw Error("string expected");t=(t=S.normalize(t)).replace(/\\/g,"/");let e=!1;t.startsWith("//")&&(e=!0);let i=/\/\//;for(;t.match(i);)t=t.replace(i,"/");return e&&(t="/"+t),t}(e);for(let e=0;e<t.length;e++)if((0,t[e])(s,i))return!0;return!1}let tM=t=>{let e=tW(t).flat();if(!e.every(t=>"string"==typeof t))throw TypeError(`Non-string provided as watch path: ${e}`);return e.map(tI)},tj=t=>{let e=t.replace(tx,"/"),i=!1;for(e.startsWith("//")&&(i=!0);e.match(tD);)e=e.replace(tD,"/");return i&&(e="/"+e),e},tI=t=>tj(S.normalize(tj(t))),tA=(t="")=>e=>"string"==typeof e?tI(S.isAbsolute(e)?e:S.join(t,e)):e,tO=Object.freeze(new Set);class tT{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&"."!==t&&".."!==t&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await d(i)}catch(t){this._removeWatcher&&this._removeWatcher(S.dirname(i),S.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=J,this.items=tO,Object.freeze(this)}}class tH{constructor(t,e,i){this.fsw=i;let s=t;this.path=t=t.replace(tF,""),this.watchPath=s,this.fullWatchPath=S.resolve(s),this.dirParts=[],this.dirParts.forEach(t=>{t.length>1&&t.pop()}),this.followSymlinks=e,this.statMethod=e?"stat":"lstat"}entryPath(t){return S.join(this.watchPath,S.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}}class tN extends m{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tW(t.ignored):tW([]),awaitWriteFinish:!0===e?i:"object"==typeof e&&{...i,...e}};te&&(s.usePolling=!0),void 0===s.atomic&&(s.atomic=!s.usePolling);let r=process.env.CHOKIDAR_USEPOLLING;if(void 0!==r){let t=r.toLowerCase();"false"===t||"0"===t?s.usePolling=!1:"true"===t||"1"===t?s.usePolling=!0:s.usePolling=!!t}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{++o>=this._readyCount&&(this._emitReady=J,this._readyEmitted=!0,process.nextTick(()=>this.emit(ts)))},this._emitRaw=(...t)=>this.emit(tl,...t),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new tS(this),Object.freeze(s)}_addIgnoredPath(t){if(tR(t)){for(let e of this._ignoredPaths)if(tR(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),"string"==typeof t)for(let e of this._ignoredPaths)tR(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let r=tM(t);return s&&(r=r.map(t=>S.isAbsolute(t)?t:S.join(s,t))),r.forEach(t=>{this._removeIgnoredPath(t)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async t=>{let s=await this._nodeFsHandler._addToNodeFs(t,!i,void 0,0,e);return s&&this._emitReady(),s})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(S.dirname(t),S.basename(e||t))})}),this}unwatch(t){if(this.closed)return this;let e=tM(t),{cwd:i}=this.options;return e.forEach(t=>{S.isAbsolute(t)||this._closers.has(t)||(i&&(t=S.join(i,t)),t=S.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(e=>{let i=e();i instanceof Promise&&t.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{t[(this.options.cwd?S.relative(this.options.cwd,i):i)||"."]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==td&&this.emit(ti,t,...e)}async _emit(t,e,i){let s;if(this.closed)return;let r=this.options;X&&(e=S.normalize(e)),r.cwd&&(e=S.relative(r.cwd,e));let a=[e];null!=i&&a.push(i);let o=r.awaitWriteFinish;if(o&&(s=this._pendingWrites.get(e)))return s.lastChange=new Date,this;if(r.atomic){if(t===tn)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((t,e)=>{this.emit(...t),this.emit(ti,...t),this._pendingUnlinks.delete(e)})},"number"==typeof r.atomic?r.atomic:100),this;t===tr&&this._pendingUnlinks.has(e)&&(t=ta,this._pendingUnlinks.delete(e))}if(o&&(t===tr||t===ta)&&this._readyEmitted){let i=(e,i)=>{e?(t=td,a[0]=e,this.emitWithAll(t,a)):i&&(a.length>1?a[1]=i:a.push(i),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,o.stabilityThreshold,t,i),this}if(t===ta&&!this._throttle(ta,e,50))return this;if(r.alwaysStat&&void 0===i&&(t===tr||t===to||t===ta)){let t,i=r.cwd?S.join(r.cwd,e):e;try{t=await f(i)}catch(t){}if(!t||this.closed)return;a.push(t)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&"ENOENT"!==e&&"ENOTDIR"!==e&&(!this.options.ignorePermissionErrors||"EPERM"!==e&&"EACCES"!==e)&&this.emit(td,t),t||this.closed}_throttle(t,e,i){let s;this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw Error("invalid throttle");let a=r.get(e);if(a)return a.count++,!1;let o=()=>{let t=r.get(e),i=t?t.count:0;return r.delete(e),clearTimeout(s),t&&clearTimeout(t.timeoutObject),i},n={timeoutObject:s=setTimeout(o,i),clear:o,count:0};return r.set(e,n),n}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,s){let a,o=this.options.awaitWriteFinish;if("object"!=typeof o)return;let n=o.pollInterval,h=t;this.options.cwd&&!S.isAbsolute(t)&&(h=S.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(a),i)}),a=setTimeout(function i(o){r(h,(r,h)=>{if(r||!d.has(t)){r&&"ENOENT"!==r.code&&s(r);return}let l=Number(new Date);o&&h.size!==o.size&&(d.get(t).lastChange=l),l-d.get(t).lastChange>=e?(d.delete(t),s(void 0,h)):a=setTimeout(i,n,h)})},n))}_isIgnored(t,e){if(this.options.atomic&&tC.test(t))return!0;if(!this._userIgnored){let{cwd:t}=this.options,e=(this.options.ignored||[]).map(tA(t)),i=[...[...this._ignoredPaths].map(tA(t)),...e];this._userIgnored=function(t,e){if(null==t)throw TypeError("anymatch: specify first argument");let i=tW(t).map(t=>"function"==typeof t?t:"string"==typeof t?e=>t===e:t instanceof RegExp?e=>t.test(e):"object"==typeof t&&null!==t?e=>{if(t.path===e)return!0;if(t.recursive){let i=S.relative(t.path,e);return!!i&&!i.startsWith("..")&&!S.isAbsolute(i)}return!1}:()=>!1);return null==e?(t,e)=>tz(i,t,e):tz(i,e)}(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tH(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=S.resolve(t);return this._watched.has(e)||this._watched.set(e,new tT(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return!!this.options.ignorePermissionErrors||!!(256&Number(t.mode))}_remove(t,e,i){let s=S.join(t,e),r=S.resolve(s);if(i=null!=i?i:this._watched.has(s)||this._watched.has(r),!this._throttle("remove",s,100))return;i||1!==this._watched.size||this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(t=>this._remove(s,t));let a=this._getWatchedDir(t),o=a.has(e);a.remove(e),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let n=s;if(this.options.cwd&&(n=S.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(n)&&this._pendingWrites.get(n).cancelWait()===tr)return;this._watched.delete(s),this._watched.delete(r);let h=i?th:tn;o&&!this._isIgnored(s)&&this._emit(h,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=S.dirname(t);this._getWatchedDir(e).remove(S.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(t=>t()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i=function(t,e={}){let i=e.entryType||e.type;if("both"===i&&(i=T),i&&(e.type=i),t){if("string"!=typeof t)throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(i&&!L.includes(i))throw Error(`readdirp: Invalid type passed. Use one of ${L.join(", ")}`)}else throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new G(e)}(t,{type:ti,alwaysStat:!0,lstat:!0,...e,depth:0});return this._streams.add(i),i.once("close",()=>{i=void 0}),i.once("end",()=>{i&&(this._streams.delete(i),i=void 0)}),i}}let tU=function(t,e={}){let i=new tN(e);return i.add(t),i},tL=/\/src\//,t$=/node_modules/;function tK(t,e){return t.map(t=>{let i=k.relative(e,t);return R.dim(k.dirname(i)+k.sep)+R.dim(k.basename(i))})}let tq=new I,tV=new class extends W{closeHooks=[];get stats(){return{all:j.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let t=M(j.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:j.server.port}}),{devServer:e}=t;if(j.server.isHttps&&(!e.server||"https"===e.server.type&&!e.server.options)){let{key:t,cert:i}=await j.server.getcert();e.server={type:"https",options:{key:t,cert:i}}}return Object.hasOwn(e,"https")&&delete e.https,t}async startDevServer(t=!1){try{let e,s,r,a,o,n,h,l,{server:d}=j,c=await this.getRspackDevConfig();c=await tq.beforeCompiler(c);let f=i(c);await j.empConfig.lifeCycle.beforeDevServe(),d.startOpen(),C("DevServer"),await tq.setup(f,c,j,async t=>{tq.isServerStarted=!0,x(t),await j.empConfig.lifeCycle.afterDevServe()});let m=(e="emp:compiler",s=new Set,r=new Map,a=!1,o=new Set,n=!1,h=f.options.context||process.cwd(),l=t=>tL.test(t)&&!t$.test(t),f.hooks.watchRun.tap(e,t=>{if(n)return;n=!0,s.clear(),o.clear();let{changed:e,removed:i}=(t=>{let e=new Set,i=new Set;if(t.modifiedFiles||t.removedFiles){if(t.modifiedFiles){for(let i of t.modifiedFiles)if(l(i)){let t=r.get(i)||0,s=Date.now();s-t>300&&(e.add(i),r.set(i,s))}}if(t.removedFiles)for(let e of t.removedFiles)l(e)&&(i.add(e),r.delete(e));return{changed:e,removed:i}}if(t.watchFileSystem?.watcher){let i=t.watchFileSystem.watcher.mtimes||{};for(let t of Object.keys(i)){if(!l(t))continue;let s=i[t],a=r.get(t)||0,o=Date.now();a<s&&o-a>300&&(e.add(t),r.set(t,o))}}return{changed:e,removed:i}})(t);(a=e.size>0||i.size>0)&&function(t,e){if(!tq.isServerStarted)return;let i=Array.from(t),s=Array.from(e),r=Array.from(o);if(0===i.length&&0===s.length&&0===r.length)return;let a="";if(i.length>0){let t=tK(i,h);a+=`modified ${t.join(", ")}`}if(r.length>0){let t=tK(r,h);a+=`lazyLoaded ${t.join(", ")}`}if(s.length>0){let t=tK(s,h);a+=`removed ${t.join(", ")}`}D(a)}(e,i),e.forEach(t=>s.add(t))}),f.hooks.done.tap(e,t=>{if(!tq.isServerStarted||!a){n=!1;return}(s.size>0||o.size>0)&&(F(t),a=!1),n=!1}),{cleanup:()=>{s.clear(),r.clear(),o.clear(),a=!1,n=!1}});this.closeHooks.push(()=>m.cleanup()),t&&z.debug("[EMP] Dev server restarted successfully")}catch(e){z.error(`[EMP] Failed to ${t?"restart":"start"} dev server:`,e)}}watchConfigFile(){let t=k.resolve(process.cwd(),"emp.config.ts");if(!s.existsSync(t))return;z.debug("[EMP] Watching for changes in emp.config.ts...");let i=s.readFileSync(t,"utf-8");tU(t,{ignored:/(^|[/\\])\../,persistent:!0}).on("change",async r=>{let a=s.readFileSync(t,"utf-8");i===a?z.debug("[EMP] 配置文件无实际变更(空保存),跳过重启"):(i=a,z.debug(`[EMP] Config file changed: ${r}`),Object.keys(e.cache).forEach(t=>{t.includes("emp.config")&&delete e.cache[t]}),z.debug("[EMP] 配置文件已变更,正在重启服务..."),this.executeCloseHooks(),await tq.close(),await j.setup(),z.debug("[EMP] 重启服务完成,新配置如下:",j.empConfig.debug),await this.startDevServer(!0))})}async run(){await this.startDevServer(!1),this.watchConfigFile()}lastBuildTime=0;executeCloseHooks(){if(this.closeHooks.length>0){for(let t of(z.debug(`[EMP] 执行 ${this.closeHooks.length} 个Hook...`),this.closeHooks))try{t()}catch(t){z.error("[EMP] 执行清理钩子时出错:",t)}this.closeHooks=[]}}};export default tV;
@@ -0,0 +1 @@
1
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
@@ -0,0 +1,41 @@
1
+ import type { Stats } from '@rspack/core';
2
+ export declare const HTML_REGEX: RegExp;
3
+ export declare const JS_REGEX: RegExp;
4
+ export declare const TS_REGEX: RegExp;
5
+ export declare const SCRIPT_REGEX: RegExp;
6
+ export declare const TS_AND_JSX_REGEX: RegExp;
7
+ export declare const SVG_REGEX: RegExp;
8
+ export declare const CSS_REGEX: RegExp;
9
+ export declare const LESS_REGEX: RegExp;
10
+ export declare const SASS_REGEX: RegExp;
11
+ export declare const CSS_MODULES_REGEX: RegExp;
12
+ export declare const NODE_MODULES_REGEX: RegExp;
13
+ export declare const filterAsset: (asset: string) => boolean;
14
+ export declare function printFileSizes(stats: Stats): Promise<void>;
15
+ export declare function timeDone(mis?: number | string, tips?: string): void;
16
+ /**
17
+ * 显示构建开始提示
18
+ */
19
+ export declare function printBuildStart(actionName?: string): void;
20
+ /**
21
+ * 显示构建完成提示
22
+ * @param stats 构建统计信息
23
+ */
24
+ export declare function printBuildDone(stats: any): void;
25
+ /**
26
+ * 显示模块构建开始提示
27
+ * @param moduleId 模块ID
28
+ * @param moduleCache 可选的模块缓存
29
+ */
30
+ export declare function printModuleBuildStart(moduleId: string, moduleCache?: Map<string, number>): void;
31
+ /**
32
+ * 记录构建开始
33
+ * @param message 可选的自定义消息
34
+ */
35
+ export declare function logStart(message?: string): void;
36
+ /**
37
+ * 记录构建完成
38
+ * @param stats 构建统计信息或构建时间(毫秒)
39
+ * @param message 可选的自定义消息前缀
40
+ */
41
+ export declare function logDone(stats: any | number, message?: string): void;
@@ -0,0 +1,3 @@
1
+ import * as chalkModule from 'chalk';
2
+ declare const _default: chalkModule.ChalkInstance;
3
+ export default _default;
@@ -0,0 +1,31 @@
1
+ export declare const lightGreen: import("chalk").ChalkInstance;
2
+ export declare const green: import("chalk").ChalkInstance;
3
+ export declare const lightCyan: import("chalk").ChalkInstance;
4
+ export declare const cyan: import("chalk").ChalkInstance;
5
+ export declare const lightRed: import("chalk").ChalkInstance;
6
+ export declare const red: import("chalk").ChalkInstance;
7
+ export declare const yellow: import("chalk").ChalkInstance;
8
+ export declare const orange: import("chalk").ChalkInstance;
9
+ export declare const lightBlue: import("chalk").ChalkInstance;
10
+ export declare const blue: import("chalk").ChalkInstance;
11
+ export declare const white: import("chalk").ChalkInstance;
12
+ export declare const lightMagenta: import("chalk").ChalkInstance;
13
+ export declare const magenta: import("chalk").ChalkInstance;
14
+ export declare const gray: import("chalk").ChalkInstance;
15
+ declare const _default: {
16
+ lightGreen: import("chalk").ChalkInstance;
17
+ green: import("chalk").ChalkInstance;
18
+ lightCyan: import("chalk").ChalkInstance;
19
+ cyan: import("chalk").ChalkInstance;
20
+ lightRed: import("chalk").ChalkInstance;
21
+ red: import("chalk").ChalkInstance;
22
+ yellow: import("chalk").ChalkInstance;
23
+ orange: import("chalk").ChalkInstance;
24
+ lightBlue: import("chalk").ChalkInstance;
25
+ blue: import("chalk").ChalkInstance;
26
+ white: import("chalk").ChalkInstance;
27
+ lightMagenta: import("chalk").ChalkInstance;
28
+ magenta: import("chalk").ChalkInstance;
29
+ gray: import("chalk").ChalkInstance;
30
+ };
31
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { Compiler } from '@rspack/core';
2
+ import type { DevServer } from '../server/connect/dev';
3
+ export declare function setupCompilerWatcher(compiler: Compiler, devServer: DevServer): {
4
+ cleanup: () => void;
5
+ };
@@ -0,0 +1 @@
1
+ export declare const empRoot: string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {number} basePort
3
+ * @param {string=} host
4
+ * @return {Promise<number>}
5
+ */
6
+ export declare function getPorts(basePort: number, host?: undefined): Promise<number>;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ import chalk from './chalk';
2
+ import { glob } from 'glob';
3
+ import color from './color';
4
+ export { default as logger } from './logger';
5
+ export * as utils from './utils';
6
+ export { glob, color, chalk };
@@ -0,0 +1,27 @@
1
+ type IpAdressOpt = {
2
+ protocol?: string;
3
+ port?: number;
4
+ pathname?: string;
5
+ host?: string;
6
+ };
7
+ declare class IpAdress {
8
+ imf: {
9
+ protocol: string;
10
+ port: number;
11
+ pathname: string;
12
+ };
13
+ host: string;
14
+ urls: {
15
+ lanUrlForConfig: string;
16
+ lanUrlForTerminal: string;
17
+ localUrlForTerminal: string;
18
+ localUrlForBrowser: string;
19
+ };
20
+ setup(o: IpAdressOpt): void;
21
+ private setupUrls;
22
+ getLanIp: () => string;
23
+ formatUrl(hostname: string): string;
24
+ prettyPrintUrl(hostname: string): string;
25
+ }
26
+ declare const _default: IpAdress;
27
+ export default _default;
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_CONFIG_FILES: string[];
2
+ export declare const loadConfig: import("jiti").Jiti;
3
+ export declare const getEmpConfigPath: () => Promise<string | undefined>;
4
+ export declare const getTsConfig: () => Promise<string | undefined>;
5
+ export declare const getBuildDependencies: () => string[];
@@ -0,0 +1,27 @@
1
+ import color from './color';
2
+ export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
3
+ export { color };
4
+ export declare class Logger {
5
+ brandName: string;
6
+ fullName: string;
7
+ logLevel: string;
8
+ isLogTime: boolean;
9
+ setup({ brandName, logLevel, fullName }: any): void;
10
+ time: (...args: any[]) => false | void;
11
+ timeEnd: (...args: any[]) => false | void;
12
+ debug: (...args: any[]) => false | void;
13
+ info: (...args: any[]) => false | void;
14
+ warn: (...args: any[]) => false | void;
15
+ error: (...args: any[]) => false | void;
16
+ blue: (msg: string) => void;
17
+ cyan: (msg: string) => void;
18
+ magenta: (msg: string) => void;
19
+ green: (msg: string) => void;
20
+ yellow: (msg: string) => void;
21
+ red: (msg: string) => void;
22
+ sysError: (msg: string) => void;
23
+ link: (msg: string) => string;
24
+ title: (msg: string) => void;
25
+ }
26
+ declare const _default: Logger;
27
+ export default _default;
@@ -0,0 +1 @@
1
+ export { empRoot } from './empRoot';
@@ -0,0 +1,2 @@
1
+ export declare const openBrowser: (url: string) => Promise<boolean>;
2
+ export default openBrowser;
@@ -0,0 +1,15 @@
1
+ export declare const getLanIp: () => string;
2
+ export declare const getPkgVersion: (pkgPath: string) => any;
3
+ export declare function clearConsole(): void;
4
+ export declare function deepAssign<T>(target: any, ...sources: any): T;
5
+ export declare const ensureArray: <T>(params: T | T[]) => T[];
6
+ /**
7
+ * json Filter
8
+ * @param d
9
+ * @param keys
10
+ * @returns
11
+ */
12
+ export declare const jsonFilter: (d?: any, notIncludeKeys?: string[]) => any;
13
+ export declare const vCompare: (preVersion?: string, lastVersion?: string) => number;
14
+ export declare const timeFormat: (seconds: number) => string;
15
+ export declare const importJsVm: (content: string) => string;