@empjs/cli 3.0.0-rc.26 → 3.0.0-rc.27

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.
@@ -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;
@@ -1,4 +1,6 @@
1
1
  import chalk from 'chalk';
2
+ import { glob } from 'glob';
3
+ import color from './color';
2
4
  export * as utils from './utils';
3
5
  export { default as logger } from './logger';
4
- export { chalk };
6
+ export { glob, color, chalk };
@@ -1,18 +1,4 @@
1
1
  export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
2
- export declare const lightGreen: import("chalk").ChalkInstance;
3
- export declare const green: import("chalk").ChalkInstance;
4
- export declare const lightCyan: import("chalk").ChalkInstance;
5
- export declare const cyan: import("chalk").ChalkInstance;
6
- export declare const lightRed: import("chalk").ChalkInstance;
7
- export declare const red: import("chalk").ChalkInstance;
8
- export declare const yellow: import("chalk").ChalkInstance;
9
- export declare const orange: import("chalk").ChalkInstance;
10
- export declare const lightBlue: import("chalk").ChalkInstance;
11
- export declare const blue: import("chalk").ChalkInstance;
12
- export declare const white: import("chalk").ChalkInstance;
13
- export declare const lightMagenta: import("chalk").ChalkInstance;
14
- export declare const magenta: import("chalk").ChalkInstance;
15
- export declare const gray: import("chalk").ChalkInstance;
16
2
  declare class Logger {
17
3
  brandName: string;
18
4
  fullName: string;
@@ -1,5 +1,3 @@
1
- import { glob } from 'glob';
2
- export { glob };
3
1
  export declare const getLanIp: () => string;
4
2
  export declare const getPkgVersion: (pkgPath: string) => any;
5
3
  export declare function clearConsole(): void;
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- var Pt=Object.defineProperty;var l=(i,e)=>()=>(i&&(e=i(i=0)),e);var j=(i,e)=>{for(var t in e)Pt(i,t,{get:e[t],enumerable:!0})};import g from"chalk";var kt,y,$t,Mt,Te,A,L,jt,Lt,S,Re,Dt,te,D,ee,p,b=l(()=>{"use strict";kt=g.hex("#1abc9c"),y=g.hex("#16a085"),$t=g.hex("#2ecc71"),Mt=g.hex("#27ae60"),Te=g.hex("#e74c3c"),A=g.hex("#c0392b"),L=g.hex("#f1c40f"),jt=g.hex("#f39c12"),Lt=g.hex("#3498db"),S=g.hex("#2980b9"),Re=g.hex("#ecf0f1"),Dt=g.hex("#fd79a8"),te=g.hex("#e84393"),D=g.hex("#7f8c8d"),ee=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=y.bold(this.fullName),t&&(this.logLevel=t)}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(`${Lt(this.brandName)}${S(` ${e} `)}
2
- `)};cyan=e=>{console.log(`${$t(this.brandName)}${Mt(` ${e} `)}
3
- `)};magenta=e=>{console.log(`${Dt(this.brandName)}${te(` ${e} `)}
4
- `)};green=e=>{console.log(`${kt(this.brandName)}${y(` ${e} `)}
5
- `)};yellow=e=>{console.log(`${L(this.brandName)}${jt(` ${e} `)}
6
- `)};red=e=>{console.log(`${Te(this.brandName)}${A(` ${e} `)}
7
- `)};sysError=e=>{console.log(`${Te(" System Error Tips ")}${A(` ${e} `)}
8
- `)};link=e=>S(e);title=e=>{console.log(`${this.fullName}${L.underline(`${e}`)}
9
- `)}},p=new ee});var oe={};j(oe,{clearConsole:()=>ie,deepAssign:()=>m,ensureArray:()=>Nt,getLanIp:()=>T,getPkgVersion:()=>se,glob:()=>P,importJsVm:()=>re,jsonFilter:()=>zt,timeFormat:()=>N,vCompare:()=>R});import{ip as Tt}from"address";import Rt from"chalk";import{gateway4sync as Ft}from"default-gateway";import At from"fs-extra";import{glob as P}from"glob";function ie(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function m(i,...e){for(let t of e)for(let s in t){let r=t[s],n=i[s];if(Object(r)==r&&Object(n)===n){i[s]=m(n,r);continue}i[s]=t[s]}return i}var T,se,Nt,zt,R,N,re,h=l(()=>{"use strict";T=()=>{let{int:i}=Ft();return Tt(i||"")||"127.0.0.1"},se=i=>{try{let{version:e}=At.readJSONSync(i);return e}catch{return}};Nt=i=>Array.isArray(i)?i:[i],zt=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),R=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let a=0;a<r;a++){let f=t.length>a?t[a]:0,d=isNaN(Number(f))?f.charCodeAt():Number(f),$=s.length>a?s[a]:0,c=isNaN(Number($))?$.charCodeAt():Number($);if(d<c){n=-1;break}else if(d>c){n=1;break}}return n},N=i=>{i=i/1e3;let e=s=>Rt.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},re=i=>`data:text/javascript,${i}`});import{readFile as It}from"node:fs/promises";import Fe from"node:module";import{dirname as Gt}from"node:path";import ne from"node:path";import{fileURLToPath as Ht}from"node:url";var Ae,Bt,ae,E,Ne,ze,z=l(()=>{"use strict";Ae=Ht(import.meta.url),Bt=Gt(Ae),ae=async i=>{try{let e=await It(i);return JSON.parse(e)}catch(e){console.error(e)}},E=Fe.createRequire(import.meta.url),Ne=(i,e)=>{let t=E;return e&&(t=Fe.createRequire(e)),t.resolve(i)},ze=ne.resolve(Bt,Ae).replace(`${ne.sep}dist${ne.sep}index.js`,"")});var I,Ie=l(()=>{"use strict";u();I=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;config;importMap={imports:{}};isEmpshare=!1;async setup(){this.config=o.empConfig.empShare,this.isEmpshare=!!o.empConfig.empShare.name,o.empConfig.empShare.fastMode&&o.empConfig.empShareFastMode.setup(),this.config.shareLib&&this.setShareLib(),this.prepareEsm()}get useImportMap(){return this.config.useImportMap&&o.empConfig.isESM}get pluginConfig(){let e={...this.config};return delete e.shareLib,delete e.useImportMap,delete e.fastMode,{manifest:!1,dts:!1,...e}}prepareEsm(){if(o.empConfig.isESM){this.config.library={type:"module"};let e=this.config.remotes||{};for(let[t,s]of Object.entries(e))if(typeof s=="string"){let r=s.match(this.exp)||[];r.length>0&&(e[t]=r[2])}this.config.remotes=e}}async setShareLib(){let e=this.config,t=[];if(typeof e.shareLib=="object")for(let[s,r]of Object.entries(e.shareLib)){let n={};if(n.module=s,typeof r=="string"){let a=r.match(this.exp)||[];a.length>0?(n.global=a[1],n.entry=a[2],n.type="js",t.push(n),n={}):(n.global="",n.entry=r,n.type="js",t.push(n),n={})}else Array.isArray(r)?r.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))n.entry=a,n.type="css";else{let d=a.match(this.exp)||[];d.length>0?(n.global=d[1],n.entry=d[2],n.type="js"):(n.global="",n.entry=a,n.type="js")}t.push(n),n={}}):typeof r=="object"&&r.entry&&(n.entry=r.entry,n.global=r.global,n.type=r.type,t.push(n),n={})}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:o.empConfig.isESM&&(this.useImportMap?(this.externals[s.module]=s.module,this.importMap.imports[s.module]=s.entry):this.externals[s.module]=s.entry),s.entry&&!o.empConfig.isESM&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});var G,Ge=l(()=>{"use strict";u();G=class{fastMode={runtimeHost:"",runtimeLib:"",externals:{},globalVal:"EmpShareLib",framework:"react"};externalMF={"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"};externalReact={react:"React","react-dom":"ReactDOM","react-router-dom":"ReactRouterDOM"};externals={};getRuntimeLib(e){return`${e}/runtime${o.mode==="development"?".development":""}.umd.js`}setup(){this.fastMode=o.deepAssign(this.fastMode,o.empConfig.empShare.fastMode),this.injectLib(),this.setExternals()}injectLib(){let{runtimeHost:e,runtimeLib:t}=this.fastMode;if(e||t){let s=t||this.getRuntimeLib(e);o.empConfig.empShareLib.externalAssets.js.push(s)}}setExternals(){for(let[e,t]of Object.entries(this.externalMF))this.externals[e]=`${this.fastMode.globalVal}.${t}`;if(this.fastMode.framework==="react")for(let[e,t]of Object.entries(this.externalReact))this.externals[e]=`${this.fastMode.globalVal}.${t}`;Object.entries(this.fastMode.externals).length>0&&(this.externals=o.deepAssign(this.externals,this.fastMode.externals)),o.empConfig.empShareLib.externals=o.deepAssign(o.empConfig.empShareLib.externals,this.externals)}}});import Ut from"net";import Jt from"os";async function H(i,e="localhost"){if(i!==_t&&(i<He||i>pe))throw new Error(`Port number must lie between ${He} and ${pe}`);let t=i,s=Vt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=pe;)try{return await qt(t,r)}catch(a){if(!n.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var He,pe,_t,Vt,Wt,qt,le=l(()=>{"use strict";He=1024,pe=65535,_t=443,Vt=()=>{let i=Jt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},Wt=(i,e)=>new Promise((t,s)=>{let r=Ut.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),qt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Wt(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import Be from"url";import Xt from"chalk";var ce,k,me=l(()=>{"use strict";b();h();ce=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:D("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{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="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{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=T;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Be.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Be.format({protocol:t,hostname:e,port:Xt.bold(s),pathname:r})}},k=new ce});var fe,B,he=l(()=>{"use strict";le();me();h();u();fe=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=o.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!o.empOptions.autoDevBase&&o.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=o.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=k.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await H(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=m({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},B=new fe});import _e from"html-webpack-plugin";var Ue,U,Je,J,Kt,_,ue=l(()=>{"use strict";h();u();Ue="HtmlImportMapPlugin",U=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(Ue,t=>{_e.getHooks(t).alterAssetTagGroups.tapAsync(Ue,(s,r)=>{if(!s.plugin.userOptions.chunks?.includes(this.chunk))return r(null,s);s.headTags.push({tagName:"script",attributes:{type:"importmap"},innerHTML:`${JSON.stringify(this.importMap,null,2)}`,voidTag:!1,meta:{plugin:void 0}}),r(null,s)})})}},Je="HtmlEmpShareLibPlugin",J=class{chunk;files;constructor(e,t){this.files=m({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(Je,t=>{let s=this.files;_e.getHooks(t).alterAssetTagGroups.tapAsync(Je,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(a=>{r.headTags.push({tagName:"script",attributes:{src:a},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(a=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:a},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},Kt=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
10
- `);return re(i)},_=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,Kt(),{name:void 0}).apply(e)}}});var V,Ve=l(()=>{"use strict";u();he();ue();V=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await B.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(_),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()}}});import Qt from"node:fs";var ge,We,qe=l(()=>{"use strict";h();Ie();Ge();Ve();ge=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},m(e,t)}empShareFastMode=new G;empShareLib=new I;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),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:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}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,showPerformance:!1,rspackCache:!0,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM},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",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:["es.object.values","es.object.entries","es.array.flat"],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{}},{...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,files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},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:process.platform==="darwin",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"}};return this.assign(e,this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({sass:{mode:"modern",api:"modern-compiler"}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0};return this.store.isDev&&this.store.empConfig.empShare.dts!==!1&&(n.clean=!1),this.assign(n,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:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${r}`]=JSON.stringify(e[r])),(t==="all"||t==="cjs")&&(s[`process.env.${r}`]=JSON.stringify(e[r])),s[`${r}`]=JSON.stringify(e[r])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return m({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(!Qt.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{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&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 ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},We=new ge});import Zt from"fs-extra";var de,Xe,Ke=l(()=>{"use strict";de=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?"source-map":!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Zt.exists(e)){let s={tsConfigPath:e};this.store.merge({resolve:s})}}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:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},Xe=new de});var ye,Qe,Ze=l(()=>{"use strict";z();ye=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={},t=this.store.empConfig.css?.sass;t&&t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:E.resolve("sass-embedded"),e.api=t.api,t.sassOptions&&(e.sassOptions=t.sassOptions));let s={loader:E.resolve("sass-loader"),options:e};this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:s},type:"css/auto"}}}})}async less(){let e={loader:this.store.importResolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{less:{test:/\.less$/,use:{lessLoader:e},type:"css/auto"}}}})}async css(){this.store.chain.merge({module:{rule:{css:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Qe=new ye});import v from"node:path";import Yt from"html-webpack-plugin";var be,Ye,et=l(()=>{"use strict";h();h();ue();be=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),e.tags=e.tags||{},e}setChunk(e){return e.replace(v.extname(e),"").replace(`${this.store.empConfig.appSrc}${v.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(v.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(v.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),n=[s];this.entriesConfig[r]={entry:{[r]:n},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=n}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`html-plugin-${t}`).use(Yt,[e]),this.store.empConfig.empShareLib&&(e.files=m(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(J,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(U,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){let e=this.store.empConfig.autoPages?.path||"pages",t=v.join(this.store.appSrc,e),s=v.join(t,"**","*.{ts,tsx,jsx,js}"),r=await P([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${v.sep}`,"")),r.map(n=>{let a=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...a},v.join(t,n))})}async setDefaultEntry(){let e=v.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await P([e],{windowsPathsNoEscape:!0});if(t[0]){let s=v.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}}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)}},Ye=new be});import tt from"node:path";var ve,st,it=l(()=>{"use strict";z();h();ve=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e;let t=[this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}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,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:m(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.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",tt.dirname(E.resolve("@swc/helpers/package.json"))),this.coreJs.path=E.resolve("core-js/package.json");let t=se(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=tt.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(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")}async scripts(){this.swcInitOptions();let e=!1,t=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:t,sideEffects:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:t,sideEffects:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},st=new ve});import rt from"fs";import{ModuleFederationPlugin as es}from"@module-federation/enhanced/rspack";import F from"@rspack/core";var Ce,ot,nt=l(()=>{"use strict";Ce=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare(),this.minify()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin("bundleAnalyzerPlugin").use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin("definePlugin").use(F.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");rt.existsSync(e)&&rt.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(F.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir)}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin("progressPlugin").use(F.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=es;this.store.chain.plugin("empShare").use(t,[this.store.empConfig.empShareLib.pluginConfig])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer("minJs").use(F.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(F.SwcCssMinimizerRspackPlugin,[{}])}},ot=new Ce});var we,at,pt=l(()=>{"use strict";Ke();Ze();et();it();nt();we=class{store;async setup(e){this.store=e;let t=[Xe.setup(this.store),st.setup(this.store),ot.setup(this.store),Ye.setup(this.store),Qe.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()}},at=new we});import ts from"node:fs/promises";import C from"node:path";import{pathToFileURL as ss}from"node:url";import is from"node:util";import rs from"webpack-chain";var xe,o,u=l(()=>{"use strict";b();z();h();qe();pt();xe=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=ze;empSource=C.resolve(this.empRoot,"dist");resolve=e=>C.isAbsolute(e)?e:C.resolve(this.root,e);empResolve=e=>C.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=R;deepAssign=m;getLanIp=T;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=We,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new rs,await at.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",process.env.NODE_ENV=e==="dev"?"development":"production";let s=await ae(this.empResolve("package.json")),r=await ae(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r}}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=C.join(this.empRoot,"resource"),this.resource.cert=C.join(this.resource.dir,"emp.cert"),this.resource.key=C.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return Ne(e,t)}importFileUrl(e){return ss(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=C.join(this.root,this.debug.showRsconfig);ts.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?m(e,this.debug.showRsconfig):e;console.log(p.link("[Compile Config]")),console.log(is.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 >= 20"]}}},o=new xe});import os from"node:fs";import w from"node:path";import{gzipSizeSync as ns}from"gzip-size";function hs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,a)=>{let f=t[a],d=n;return f&&(d=n.length<f?n+" ".repeat(f-n.length):n),`${r+d} `}," ");console.log(S.bold(s))}async function lt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(c=>cs(c.name)).map(fs);s.sort((c,M)=>c.size-M.size);let r=Math.max(...s.map(c=>c.sizeLabel.length)),n=Math.max(...s.map(c=>(c.folder+w.sep+c.name).length));hs(n,r);let a=0,f=0;s.forEach(c=>{let{sizeLabel:M}=c,{name:St,folder:Et,gzipSizeLabel:Ot}=c,je=(Et+w.sep+St).length,Le=M.length;if(a+=c.size,f+=c.gzippedSize,Le<r){let Y=" ".repeat(r-Le);M+=Y}let De=D(c.folder+w.sep)+us(c.name);if(je<n){let Y=" ".repeat(n-je);De+=Y}p.info(` ${De} ${D(M)} ${Ot}`)});let d=`${S.bold("Total size:")} ${W(a)}`,$=`${S.bold("Gzipped size:")} ${W(f)}`;p.info(`
1
+ var $t=Object.defineProperty;var l=(i,e)=>()=>(i&&(e=i(i=0)),e);var T=(i,e)=>{for(var t in e)$t(i,t,{get:e[t],enumerable:!0})};import g from"chalk";var Mt,v,jt,Lt,Dt,se,N,Tt,Rt,P,ie,Ft,re,k,c,$=l(()=>{"use strict";Mt=g.hex("#1abc9c"),v=g.hex("#16a085"),jt=g.hex("#2ecc71"),Lt=g.hex("#27ae60"),Dt=g.hex("#e74c3c"),se=g.hex("#c0392b"),N=g.hex("#f1c40f"),Tt=g.hex("#f39c12"),Rt=g.hex("#3498db"),P=g.hex("#2980b9"),ie=g.hex("#ecf0f1"),Ft=g.hex("#fd79a8"),re=g.hex("#e84393"),k=g.hex("#7f8c8d"),c={lightGreen:Mt,green:v,lightCyan:jt,cyan:Lt,lightRed:Dt,red:se,yellow:N,orange:Tt,lightBlue:Rt,blue:P,white:ie,lightMagenta:Ft,magenta:re,gray:k}});var oe,p,C=l(()=>{"use strict";$();oe=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=c.green.bold(this.fullName),t&&(this.logLevel=t)}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(`${c.lightBlue(this.brandName)}${c.blue(` ${e} `)}
2
+ `)};cyan=e=>{console.log(`${c.lightCyan(this.brandName)}${c.cyan(` ${e} `)}
3
+ `)};magenta=e=>{console.log(`${c.lightMagenta(this.brandName)}${c.magenta(` ${e} `)}
4
+ `)};green=e=>{console.log(`${c.lightGreen(this.brandName)}${c.green(` ${e} `)}
5
+ `)};yellow=e=>{console.log(`${c.yellow(this.brandName)}${c.orange(` ${e} `)}
6
+ `)};red=e=>{console.log(`${c.lightRed(this.brandName)}${c.red(` ${e} `)}
7
+ `)};sysError=e=>{console.log(`${c.lightRed(" System Error Tips ")}${c.red(` ${e} `)}
8
+ `)};link=e=>c.blue(e);title=e=>{console.log(`${this.fullName}${c.yellow.underline(`${e}`)}
9
+ `)}},p=new oe});var le={};T(le,{clearConsole:()=>ae,deepAssign:()=>f,ensureArray:()=>Gt,getLanIp:()=>R,getPkgVersion:()=>ne,importJsVm:()=>pe,jsonFilter:()=>Ht,timeFormat:()=>z,vCompare:()=>F});import{ip as At}from"address";import Nt from"chalk";import{gateway4sync as zt}from"default-gateway";import It from"fs-extra";function ae(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function f(i,...e){for(let t of e)for(let s in t){let r=t[s],n=i[s];if(Object(r)==r&&Object(n)===n){i[s]=f(n,r);continue}i[s]=t[s]}return i}var R,ne,Gt,Ht,F,z,pe,y=l(()=>{"use strict";R=()=>{let{int:i}=zt();return At(i||"")||"127.0.0.1"},ne=i=>{try{let{version:e}=It.readJSONSync(i);return e}catch{return}};Gt=i=>Array.isArray(i)?i:[i],Ht=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),F=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let a=0;a<r;a++){let h=t.length>a?t[a]:0,d=isNaN(Number(h))?h.charCodeAt():Number(h),L=s.length>a?s[a]:0,m=isNaN(Number(L))?L.charCodeAt():Number(L);if(d<m){n=-1;break}else if(d>m){n=1;break}}return n},z=i=>{i=i/1e3;let e=s=>Nt.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},pe=i=>`data:text/javascript,${i}`});import{readFile as Bt}from"node:fs/promises";import Ne from"node:module";import{dirname as Ut}from"node:path";import ce from"node:path";import{fileURLToPath as Jt}from"node:url";var ze,_t,me,E,Ie,Ge,I=l(()=>{"use strict";ze=Jt(import.meta.url),_t=Ut(ze),me=async i=>{try{let e=await Bt(i);return JSON.parse(e)}catch(e){console.error(e)}},E=Ne.createRequire(import.meta.url),Ie=(i,e)=>{let t=E;return e&&(t=Ne.createRequire(e)),t.resolve(i)},Ge=ce.resolve(_t,ze).replace(`${ce.sep}dist${ce.sep}index.js`,"")});var G,He=l(()=>{"use strict";u();G=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;config;importMap={imports:{}};isEmpshare=!1;async setup(){this.config=o.empConfig.empShare,this.isEmpshare=!!o.empConfig.empShare.name,o.empConfig.empShare.fastMode&&o.empConfig.empShareFastMode.setup(),this.config.shareLib&&this.setShareLib(),this.prepareEsm()}get useImportMap(){return this.config.useImportMap&&o.empConfig.isESM}get pluginConfig(){let e={...this.config};return delete e.shareLib,delete e.useImportMap,delete e.fastMode,{manifest:!1,dts:!1,...e}}prepareEsm(){if(o.empConfig.isESM){this.config.library={type:"module"};let e=this.config.remotes||{};for(let[t,s]of Object.entries(e))if(typeof s=="string"){let r=s.match(this.exp)||[];r.length>0&&(e[t]=r[2])}this.config.remotes=e}}async setShareLib(){let e=this.config,t=[];if(typeof e.shareLib=="object")for(let[s,r]of Object.entries(e.shareLib)){let n={};if(n.module=s,typeof r=="string"){let a=r.match(this.exp)||[];a.length>0?(n.global=a[1],n.entry=a[2],n.type="js",t.push(n),n={}):(n.global="",n.entry=r,n.type="js",t.push(n),n={})}else Array.isArray(r)?r.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))n.entry=a,n.type="css";else{let d=a.match(this.exp)||[];d.length>0?(n.global=d[1],n.entry=d[2],n.type="js"):(n.global="",n.entry=a,n.type="js")}t.push(n),n={}}):typeof r=="object"&&r.entry&&(n.entry=r.entry,n.global=r.global,n.type=r.type,t.push(n),n={})}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:o.empConfig.isESM&&(this.useImportMap?(this.externals[s.module]=s.module,this.importMap.imports[s.module]=s.entry):this.externals[s.module]=s.entry),s.entry&&!o.empConfig.isESM&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});var H,Be=l(()=>{"use strict";u();H=class{fastMode={runtimeHost:"",runtimeLib:"",externals:{},globalVal:"EmpShareLib",framework:"react"};externalMF={"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"};externalReact={react:"React","react-dom":"ReactDOM","react-router-dom":"ReactRouterDOM"};externals={};getRuntimeLib(e){return`${e}/runtime${o.mode==="development"?".development":""}.umd.js`}setup(){this.fastMode=o.deepAssign(this.fastMode,o.empConfig.empShare.fastMode),this.injectLib(),this.setExternals()}injectLib(){let{runtimeHost:e,runtimeLib:t}=this.fastMode;if(e||t){let s=t||this.getRuntimeLib(e);o.empConfig.empShareLib.externalAssets.js.push(s)}}setExternals(){for(let[e,t]of Object.entries(this.externalMF))this.externals[e]=`${this.fastMode.globalVal}.${t}`;if(this.fastMode.framework==="react")for(let[e,t]of Object.entries(this.externalReact))this.externals[e]=`${this.fastMode.globalVal}.${t}`;Object.entries(this.fastMode.externals).length>0&&(this.externals=o.deepAssign(this.externals,this.fastMode.externals)),o.empConfig.empShareLib.externals=o.deepAssign(o.empConfig.empShareLib.externals,this.externals)}}});import Vt from"net";import Wt from"os";async function B(i,e="localhost"){if(i!==qt&&(i<Ue||i>fe))throw new Error(`Port number must lie between ${Ue} and ${fe}`);let t=i,s=Xt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=fe;)try{return await Qt(t,r)}catch(a){if(!n.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var Ue,fe,qt,Xt,Kt,Qt,he=l(()=>{"use strict";Ue=1024,fe=65535,qt=443,Xt=()=>{let i=Wt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},Kt=(i,e)=>new Promise((t,s)=>{let r=Vt.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),Qt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Kt(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import Je from"url";import Zt from"chalk";var ue,M,ge=l(()=>{"use strict";$();y();ue=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:k("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{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="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{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=R;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Je.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Je.format({protocol:t,hostname:e,port:Zt.bold(s),pathname:r})}},M=new ue});var de,U,ye=l(()=>{"use strict";he();ge();y();u();de=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=o.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!o.empOptions.autoDevBase&&o.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=o.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=M.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await B(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=f({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},U=new de});import We from"html-webpack-plugin";var _e,J,Ve,_,Yt,V,be=l(()=>{"use strict";y();u();_e="HtmlImportMapPlugin",J=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(_e,t=>{We.getHooks(t).alterAssetTagGroups.tapAsync(_e,(s,r)=>{if(!s.plugin.userOptions.chunks?.includes(this.chunk))return r(null,s);s.headTags.push({tagName:"script",attributes:{type:"importmap"},innerHTML:`${JSON.stringify(this.importMap,null,2)}`,voidTag:!1,meta:{plugin:void 0}}),r(null,s)})})}},Ve="HtmlEmpShareLibPlugin",_=class{chunk;files;constructor(e,t){this.files=f({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(Ve,t=>{let s=this.files;We.getHooks(t).alterAssetTagGroups.tapAsync(Ve,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(a=>{r.headTags.push({tagName:"script",attributes:{src:a},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(a=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:a},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},Yt=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
10
+ `);return pe(i)},V=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,Yt(),{name:void 0}).apply(e)}}});var W,qe=l(()=>{"use strict";u();ye();be();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await U.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(V),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()}}});import es from"node:fs";var ve,Xe,Ke=l(()=>{"use strict";y();He();Be();qe();ve=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},f(e,t)}empShareFastMode=new H;empShareLib=new G;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),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:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}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,showPerformance:!1,rspackCache:!0,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM},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",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:["es.object.values","es.object.entries","es.array.flat"],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{}},{...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,files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},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:process.platform==="darwin",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"}};return this.assign(e,this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({sass:{mode:"modern",api:"modern-compiler"}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0};return this.store.isDev&&this.store.empConfig.empShare.dts!==!1&&(n.clean=!1),this.assign(n,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:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${r}`]=JSON.stringify(e[r])),(t==="all"||t==="cjs")&&(s[`process.env.${r}`]=JSON.stringify(e[r])),s[`${r}`]=JSON.stringify(e[r])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return f({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(!es.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{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&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 ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Xe=new ve});import ts from"fs-extra";var Ce,Qe,Ze=l(()=>{"use strict";Ce=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?"source-map":!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ts.exists(e)){let s={tsConfigPath:e};this.store.merge({resolve:s})}}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:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},Qe=new Ce});var we,Ye,et=l(()=>{"use strict";I();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={},t=this.store.empConfig.css?.sass;t&&t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:E.resolve("sass-embedded"),e.api=t.api,t.sassOptions&&(e.sassOptions=t.sassOptions));let s={loader:E.resolve("sass-loader"),options:e};this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:s},type:"css/auto"}}}})}async less(){let e={loader:this.store.importResolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{less:{test:/\.less$/,use:{lessLoader:e},type:"css/auto"}}}})}async css(){this.store.chain.merge({module:{rule:{css:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Ye=new we});var tt={};T(tt,{chalk:()=>ss,color:()=>c,glob:()=>j,logger:()=>p,utils:()=>le});import ss from"chalk";import{glob as j}from"glob";var q=l(()=>{"use strict";$();y();C()});import b from"node:path";import is from"html-webpack-plugin";var xe,st,it=l(()=>{"use strict";q();y();be();xe=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),e.tags=e.tags||{},e}setChunk(e){return e.replace(b.extname(e),"").replace(`${this.store.empConfig.appSrc}${b.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(b.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(b.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(b.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),n=[s];this.entriesConfig[r]={entry:{[r]:n},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=n}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`html-plugin-${t}`).use(is,[e]),this.store.empConfig.empShareLib&&(e.files=f(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(_,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(J,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){let e=this.store.empConfig.autoPages?.path||"pages",t=b.join(this.store.appSrc,e),s=b.join(t,"**","*.{ts,tsx,jsx,js}"),r=await j([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${b.sep}`,"")),r.map(n=>{let a=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...a},b.join(t,n))})}async setDefaultEntry(){let e=b.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await j([e],{windowsPathsNoEscape:!0});if(t[0]){let s=b.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}}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)}},st=new xe});import rt from"node:path";var Se,ot,nt=l(()=>{"use strict";I();y();Se=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e;let t=[this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return this.store.empConfig.build.polyfill}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,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:f(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.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfillInclude)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",rt.dirname(E.resolve("@swc/helpers/package.json"))),this.coreJs.path=E.resolve("core-js/package.json");let t=ne(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=rt.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(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")}async scripts(){this.swcInitOptions();let e=!1,t=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:t,sideEffects:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:t,sideEffects:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},ot=new Se});import at from"fs";import{ModuleFederationPlugin as rs}from"@module-federation/enhanced/rspack";import A from"@rspack/core";var Ee,pt,lt=l(()=>{"use strict";Ee=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare(),this.minify()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin("bundleAnalyzerPlugin").use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}async define(){this.store.chain.plugin("definePlugin").use(A.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");at.existsSync(e)&&at.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(A.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir)}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin("progressPlugin").use(A.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=rs;this.store.chain.plugin("empShare").use(t,[this.store.empConfig.empShareLib.pluginConfig])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer("minJs").use(A.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(A.SwcCssMinimizerRspackPlugin,[{}])}},pt=new Ee});var Oe,ct,mt=l(()=>{"use strict";Ze();et();it();nt();lt();Oe=class{store;async setup(e){this.store=e;let t=[Qe.setup(this.store),ot.setup(this.store),pt.setup(this.store),st.setup(this.store),Ye.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()}},ct=new Oe});import os from"node:fs/promises";import w from"node:path";import{pathToFileURL as ns}from"node:url";import as from"node:util";import ps from"webpack-chain";var Pe,o,u=l(()=>{"use strict";C();I();y();Ke();mt();Pe=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=Ge;empSource=w.resolve(this.empRoot,"dist");resolve=e=>w.isAbsolute(e)?e:w.resolve(this.root,e);empResolve=e=>w.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=F;deepAssign=f;getLanIp=R;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=Xe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new ps,await ct.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",process.env.NODE_ENV=e==="dev"?"development":"production";let s=await me(this.empResolve("package.json")),r=await me(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r}}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=w.join(this.empRoot,"resource"),this.resource.cert=w.join(this.resource.dir,"emp.cert"),this.resource.key=w.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return Ie(e,t)}importFileUrl(e){return ns(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=w.join(this.root,this.debug.showRsconfig);os.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?f(e,this.debug.showRsconfig):e;console.log(p.link("[Compile Config]")),console.log(as.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 >= 20"]}}},o=new Pe});import ls from"node:fs";import x from"node:path";import{gzipSizeSync as cs}from"gzip-size";function ys(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,a)=>{let h=t[a],d=n;return h&&(d=n.length<h?n+" ".repeat(h-n.length):n),`${r+d} `}," ");console.log(P.bold(s))}async function ft(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(m=>us(m.name)).map(ds);s.sort((m,D)=>m.size-D.size);let r=Math.max(...s.map(m=>m.sizeLabel.length)),n=Math.max(...s.map(m=>(m.folder+x.sep+m.name).length));ys(n,r);let a=0,h=0;s.forEach(m=>{let{sizeLabel:D}=m,{name:Ot,folder:Pt,gzipSizeLabel:kt}=m,Re=(Pt+x.sep+Ot).length,Fe=D.length;if(a+=m.size,h+=m.gzippedSize,Fe<r){let te=" ".repeat(r-Fe);D+=te}let Ae=k(m.folder+x.sep)+bs(m.name);if(Re<n){let te=" ".repeat(n-Re);Ae+=te}p.info(` ${Ae} ${k(D)} ${kt}`)});let d=`${P.bold("Total size:")} ${X(a)}`,L=`${P.bold("Gzipped size:")} ${X(h)}`;p.info(`
11
11
  ${d}
12
- ${$}
13
- `),p.info(`${y("\u2713")} Ready in ${N(Number(e.time))}
14
- `)}function q(i=0){p.info(`${y("\u2713")} Ready in ${N(Number(i))}`)}var as,ps,ls,cs,ms,fs,W,us,X=l(()=>{"use strict";u();b();h();as=/\.html$/,ps=/\.(?:js|mjs|cjs|jsx)$/,ls=/\.css$/,cs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),ms=i=>i>300*1e3?A:i>100*1e3?L:Re,fs=i=>{let e=i.name.split("?")[0],t=W(i.size),s=w.basename(e),r=w.join(w.basename(o.empConfig.build.outDir),w.dirname(e)),n=os.readFileSync(w.join(o.empConfig.build.outDir,e)),a=n.length,f=ns(n),d=ms(f)(W(f));return{size:a,folder:r,name:s,gzippedSize:f,sizeLabel:t,gzipSizeLabel:d}};W=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},us=i=>ps.test(i)?L(i):ls.test(i)?y(i):as.test(i)?S(i):te(i)});import{exec as gs}from"node:child_process";import{promisify as ds}from"node:util";var mt,ct,ys,bs,ft,ht=l(()=>{"use strict";u();b();mt=ds(gs),ct=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ys=async()=>{let i=process.env.BROWSER;if(!i||!ct.includes(i)){let{stdout:e}=await mt("ps cax");i=ct.find(t=>e.includes(t))}return i},bs=async i=>{if(process.platform==="darwin")try{let t=await ys();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await mt(s,{cwd:o.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},ft=bs});import ut from"node:fs/promises";var x,K=l(()=>{"use strict";le();me();b();ht();h();u();he();x=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};async adaptServer(){this.sf.publicPath=o.rsConfig.output?.publicPath==="auto"?"/":o.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!o.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=o.empConfig.server.host?o.empConfig.server.host:this.sf.host,this.sf.port=o.empConfig.server.port,await this.serverPort(),k.setup(this.sf),this.sf.publicPath&&(this.sf.publicPath.indexOf("http://")>-1||this.sf.publicPath.indexOf("https://")>-1)?(this.sf.url=this.sf.publicPath,this.sf.publicHasHttp=!0,this.sf.urls.localUrlForTerminal=k.prettyPrintUrl("localhost")):(this.sf.urls=k.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${y("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${y("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${y("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${y("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
15
- `)),this.sf.isOpenBrower&&ft(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&ie(),p.title(`${e}`),await this.adaptServer(),await this.run(),this.afterRun()}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t}=o.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0}getcert(){return Promise.all([ut.readFile(o.resource.key),ut.readFile(o.resource.cert)])}async serverPort(){if(B.isADB)return;let{port:e,host:t}=this.sf,s=await H(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var gt={};j(gt,{default:()=>ws});import{rspack as vs}from"@rspack/core";import{RspackDevServer as Cs}from"@rspack/dev-server";var Se,ws,dt=l(()=>{"use strict";X();b();h();K();u();Se=class extends x{get rspackDevConfig(){return m(o.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}})}async devServerConfig(){let e=Object.assign({},o.rsConfig.devServer);if(this.isHttps&&(e.https===!0&&delete e.https,!e.server)){let[t,s]=await this.getcert();e.server={type:"https",options:{key:t,cert:s}}}return e}async run(){let e=vs(this.rspackDevConfig);if(!o.rsConfig.devServer){p.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Cs(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=n=>{let a=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});q(a.time)};o.debug.showPerformance&&e.hooks.afterDone.tap("done",r),s.middleware?.waitUntilValid(n=>{o.debug.showPerformance||r(n),o.empConfig.lifeCycle.afterDevServe&&o.empConfig.lifeCycle.afterDevServe()})}},ws=new Se});import xs from"https";import Ss from"compression";import Es from"cors";import Os from"express";var Q,yt=l(()=>{"use strict";K();Q=class extends x{app;async init(){let e=Os();e.use(Ss()),e.use(Es()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();xs.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:e,cert:t},this.app).listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}else this.app.listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var Ee={};j(Ee,{ServeScript:()=>Z,default:()=>js});import Ps from"node:fs";import ks from"node:fs/promises";import $s from"path";import Ms from"express";var Z,js,Oe=l(()=>{"use strict";X();b();u();yt();Z=class extends Q{timing=0;async run(){if(this.timing=Date.now(),!Ps.existsSync(o.outDir))return p.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(Ms.static(e));let t=await ks.readFile($s.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){q(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},js=new Z});var bt={};j(bt,{default:()=>Ds});import{rspack as Ls}from"@rspack/core";var Pe,Ds,vt=l(()=>{"use strict";X();b();K();u();Pe=class extends x{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:e}=await Promise.resolve().then(()=>(Oe(),Ee));await e.setup("serve",o.cliOptions)}async run(){o.empConfig.lifeCycle.beforeBuild&&await o.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!o.cliOptions.watch,this.isuseServe=!!o.cliOptions.serve,this.rspackConfig=o.rsConfig,this.isWatchMode&&this.watchMode(),Ls(this.rspackConfig,async(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({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await lt(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},Ds=new Pe});import{rspack as Co}from"@rspack/core";import xo from"html-webpack-plugin";b();h();u();import ke,{exit as Ts}from"node:process";import{program as O}from"commander";function Ct(){let i="20.0.0";R(i,ke.versions.node)===1&&(p.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${ke.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),Ts(0)),O.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),O.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,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(dt(),gt));await t.setup("dev",e)}),O.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("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").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,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(vt(),bt));await t.setup("build",e)}),O.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(()=>(Oe(),Ee));await t.setup("serve",e)}),O.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=>{}),O.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=>{}),O.parse(ke.argv)}h();u();import wt from"node:fs/promises";import $e from"node:path";var Rs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Fs=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,As=/import\(['"]([^;\n]+?)['"]\)/,Me=class{list=[];outDir=o.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 P([`${o.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=o.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 wt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Rs,r=>{let n=r.match(Fs);if(n||(n=r.match(As)),n&&n[1]){let a=n[1];if(!a.startsWith("."))return r;let f=$e.resolve($e.dirname(e),a).replace(this.outDir,this.aliasName);return r.replace(n[1],f)}return r});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
12
+ ${L}
13
+ `),p.info(`${v("\u2713")} Ready in ${z(Number(e.time))}
14
+ `)}function K(i=0){p.info(`${v("\u2713")} Ready in ${z(Number(i))}`)}var ms,fs,hs,us,gs,ds,X,bs,Q=l(()=>{"use strict";$();u();C();y();ms=/\.html$/,fs=/\.(?:js|mjs|cjs|jsx)$/,hs=/\.css$/,us=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),gs=i=>i>300*1e3?se:i>100*1e3?N:ie,ds=i=>{let e=i.name.split("?")[0],t=X(i.size),s=x.basename(e),r=x.join(x.basename(o.empConfig.build.outDir),x.dirname(e)),n=ls.readFileSync(x.join(o.empConfig.build.outDir,e)),a=n.length,h=cs(n),d=gs(h)(X(h));return{size:a,folder:r,name:s,gzippedSize:h,sizeLabel:t,gzipSizeLabel:d}};X=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},bs=i=>fs.test(i)?N(i):hs.test(i)?v(i):ms.test(i)?P(i):re(i)});import{exec as vs}from"node:child_process";import{promisify as Cs}from"node:util";var ut,ht,ws,xs,gt,dt=l(()=>{"use strict";u();C();ut=Cs(vs),ht=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ws=async()=>{let i=process.env.BROWSER;if(!i||!ht.includes(i)){let{stdout:e}=await ut("ps cax");i=ht.find(t=>e.includes(t))}return i},xs=async i=>{if(process.platform==="darwin")try{let t=await ws();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await ut(s,{cwd:o.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},gt=xs});import yt from"node:fs/promises";var S,Z=l(()=>{"use strict";$();he();ge();C();dt();y();u();ye();S=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};async adaptServer(){this.sf.publicPath=o.rsConfig.output?.publicPath==="auto"?"/":o.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!o.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=o.empConfig.server.host?o.empConfig.server.host:this.sf.host,this.sf.port=o.empConfig.server.port,await this.serverPort(),M.setup(this.sf),this.sf.publicPath&&(this.sf.publicPath.indexOf("http://")>-1||this.sf.publicPath.indexOf("https://")>-1)?(this.sf.url=this.sf.publicPath,this.sf.publicHasHttp=!0,this.sf.urls.localUrlForTerminal=M.prettyPrintUrl("localhost")):(this.sf.urls=M.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${v("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${v("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${v("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${v("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
15
+ `)),this.sf.isOpenBrower&&gt(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&ae(),p.title(`${e}`),await this.adaptServer(),await this.run(),this.afterRun()}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{server:e,https:t}=o.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0}getcert(){return Promise.all([yt.readFile(o.resource.key),yt.readFile(o.resource.cert)])}async serverPort(){if(U.isADB)return;let{port:e,host:t}=this.sf,s=await B(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var bt={};T(bt,{default:()=>Os});import{rspack as Ss}from"@rspack/core";import{RspackDevServer as Es}from"@rspack/dev-server";var ke,Os,vt=l(()=>{"use strict";Q();C();y();Z();u();ke=class extends S{get rspackDevConfig(){return f(o.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}})}async devServerConfig(){let e=Object.assign({},o.rsConfig.devServer);if(this.isHttps&&(e.https===!0&&delete e.https,!e.server)){let[t,s]=await this.getcert();e.server={type:"https",options:{key:t,cert:s}}}return e}async run(){let e=Ss(this.rspackDevConfig);if(!o.rsConfig.devServer){p.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Es(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=n=>{let a=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});K(a.time)};o.debug.showPerformance&&e.hooks.afterDone.tap("done",r),s.middleware?.waitUntilValid(n=>{o.debug.showPerformance||r(n),o.empConfig.lifeCycle.afterDevServe&&o.empConfig.lifeCycle.afterDevServe()})}},Os=new ke});import Ps from"https";import ks from"compression";import $s from"cors";import Ms from"express";var Y,Ct=l(()=>{"use strict";Z();Y=class extends S{app;async init(){let e=Ms();e.use(ks()),e.use($s()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();Ps.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:e,cert:t},this.app).listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}else this.app.listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var $e={};T($e,{ServeScript:()=>ee,default:()=>Rs});import js from"node:fs";import Ls from"node:fs/promises";import Ds from"path";import Ts from"express";var ee,Rs,Me=l(()=>{"use strict";Q();C();u();Ct();ee=class extends Y{timing=0;async run(){if(this.timing=Date.now(),!js.existsSync(o.outDir))return p.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(Ts.static(e));let t=await Ls.readFile(Ds.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){K(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Rs=new ee});var wt={};T(wt,{default:()=>As});import{rspack as Fs}from"@rspack/core";var je,As,xt=l(()=>{"use strict";Q();C();Z();u();je=class extends S{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:e}=await Promise.resolve().then(()=>(Me(),$e));await e.setup("serve",o.cliOptions)}async run(){o.empConfig.lifeCycle.beforeBuild&&await o.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!o.cliOptions.watch,this.isuseServe=!!o.cliOptions.serve,this.rspackConfig=o.rsConfig,this.isWatchMode&&this.watchMode(),Fs(this.rspackConfig,async(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({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await ft(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},As=new je});import{rspack as $o}from"@rspack/core";import jo from"html-webpack-plugin";C();y();u();import Le,{exit as Ns}from"node:process";import{program as O}from"commander";function St(){let i="20.0.0";F(i,Le.versions.node)===1&&(p.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${Le.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),Ns(0)),O.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),O.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,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(vt(),bt));await t.setup("dev",e)}),O.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("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").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,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(xt(),wt));await t.setup("build",e)}),O.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(()=>(Me(),$e));await t.setup("serve",e)}),O.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=>{}),O.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=>{}),O.parse(Le.argv)}q();u();import Et from"node:fs/promises";import De from"node:path";var zs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Is=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Gs=/import\(['"]([^;\n]+?)['"]\)/,Te=class{list=[];outDir=o.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 j([`${o.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=o.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 Et.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(zs,r=>{let n=r.match(Is);if(n||(n=r.match(Gs)),n&&n[1]){let a=n[1];if(!a.startsWith("."))return r;let h=De.resolve(De.dirname(e),a).replace(this.outDir,this.aliasName);return r.replace(n[1],h)}return r});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
16
16
  ${t}}\r
17
- `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await wt.writeFile($e.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Ns=new Me;u();var xt={};j(xt,{chalk:()=>zs,logger:()=>p,utils:()=>oe});h();b();import zs from"chalk";function Po(i){return i}export{xo as HtmlWebpackPlugin,Po as defineConfig,Ns as dts,xt as empHelper,Co as rspack,Ct as runScript,o as store};
17
+ `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await Et.writeFile(De.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Hs=new Te;u();q();function Ro(i){return i}export{jo as HtmlWebpackPlugin,Ro as defineConfig,Hs as dts,tt as empHelper,$o as rspack,St as runScript,o as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.0.0-rc.26",
3
+ "version": "3.0.0-rc.27",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",