@empjs/cli 3.0.0-rc.29 → 3.0.0-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var bs=Object.create;var B=Object.defineProperty;var vs=Object.getOwnPropertyDescriptor;var Cs=Object.getOwnPropertyNames;var ws=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var j=(i,e)=>{for(var t in e)B(i,t,{get:e[t],enumerable:!0})},Ke=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cs(e))!xs.call(i,r)&&r!==t&&B(i,r,{get:()=>e[r],enumerable:!(s=vs(e,r))||s.enumerable});return i};var p=(i,e,t)=>(t=i!=null?bs(ws(i)):{},Ke(e||!i||!i.__esModule?B(t,"default",{value:i,enumerable:!0}):t,i)),Ss=i=>Ke(B({},"__esModule",{value:!0}),i);var Es,m,a=f(()=>{"use strict";Es=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,m=Es()});var b,Os,x,Ps,ks,$s,le,U,Ms,js,L,ce,Ls,me,D,h,R=f(()=>{"use strict";a();b=p(require("chalk"),1),Os=b.default.hex("#1abc9c"),x=b.default.hex("#16a085"),Ps=b.default.hex("#2ecc71"),ks=b.default.hex("#27ae60"),$s=b.default.hex("#e74c3c"),le=b.default.hex("#c0392b"),U=b.default.hex("#f1c40f"),Ms=b.default.hex("#f39c12"),js=b.default.hex("#3498db"),L=b.default.hex("#2980b9"),ce=b.default.hex("#ecf0f1"),Ls=b.default.hex("#fd79a8"),me=b.default.hex("#e84393"),D=b.default.hex("#7f8c8d"),h={lightGreen:Os,green:x,lightCyan:Ps,cyan:ks,lightRed:$s,red:le,yellow:U,orange:Ms,lightBlue:js,blue:L,white:ce,lightMagenta:Ls,magenta:me,gray:D}});var fe,c,S=f(()=>{"use strict";a();R();fe=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.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(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
1
+ "use strict";var ls=Object.create;var H=Object.defineProperty;var cs=Object.getOwnPropertyDescriptor;var ms=Object.getOwnPropertyNames;var fs=Object.getPrototypeOf,hs=Object.prototype.hasOwnProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var M=(i,e)=>{for(var t in e)H(i,t,{get:e[t],enumerable:!0})},_e=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ms(e))!hs.call(i,r)&&r!==t&&H(i,r,{get:()=>e[r],enumerable:!(s=cs(e,r))||s.enumerable});return i};var p=(i,e,t)=>(t=i!=null?ls(fs(i)):{},_e(e||!i||!i.__esModule?H(t,"default",{value:i,enumerable:!0}):t,i)),us=i=>_e(H({},"__esModule",{value:!0}),i);var a=f(()=>{"use strict"});var b,gs,S,ds,ys,bs,ne,B,vs,Cs,j,ae,ws,pe,L,h,D=f(()=>{"use strict";a();b=p(require("chalk"),1),gs=b.default.hex("#1abc9c"),S=b.default.hex("#16a085"),ds=b.default.hex("#2ecc71"),ys=b.default.hex("#27ae60"),bs=b.default.hex("#e74c3c"),ne=b.default.hex("#c0392b"),B=b.default.hex("#f1c40f"),vs=b.default.hex("#f39c12"),Cs=b.default.hex("#3498db"),j=b.default.hex("#2980b9"),ae=b.default.hex("#ecf0f1"),ws=b.default.hex("#fd79a8"),pe=b.default.hex("#e84393"),L=b.default.hex("#7f8c8d"),h={lightGreen:gs,green:S,lightCyan:ds,cyan:ys,lightRed:bs,red:ne,yellow:B,orange:vs,lightBlue:Cs,blue:j,white:ae,lightMagenta:ws,magenta:pe,gray:L}});var le,c,E=f(()=>{"use strict";a();D();le=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.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(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
2
2
  `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
3
3
  `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
4
4
  `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
@@ -6,12 +6,13 @@
6
6
  `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
7
7
  `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
8
8
  `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
9
- `)}},c=new fe});var de={};j(de,{clearConsole:()=>ue,deepAssign:()=>g,ensureArray:()=>Ds,getLanIp:()=>z,getPkgVersion:()=>he,importJsVm:()=>ge,jsonFilter:()=>Rs,timeFormat:()=>J,vCompare:()=>G});function ue(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function g(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]=g(n,r);continue}i[s]=t[s]}return i}var Qe,Ze,Ye,et,z,he,Ds,Rs,G,J,ge,C=f(()=>{"use strict";a();Qe=require("address"),Ze=p(require("chalk"),1),Ye=require("default-gateway"),et=p(require("fs-extra"),1),z=()=>{let{int:i}=(0,Ye.gateway4sync)();return(0,Qe.ip)(i||"")||"127.0.0.1"},he=i=>{try{let{version:e}=et.default.readJSONSync(i);return e}catch{return}};Ds=i=>Array.isArray(i)?i:[i],Rs=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),G=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let l=0;l<r;l++){let d=t.length>l?t[l]:0,v=isNaN(Number(d))?d.charCodeAt():Number(d),N=s.length>l?s[l]:0,u=isNaN(Number(N))?N.charCodeAt():Number(N);if(v<u){n=-1;break}else if(v>u){n=1;break}}return n},J=i=>{i=i/1e3;let e=s=>Ze.default.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`},ge=i=>`data:text/javascript,${i}`});var tt,ye,_,be,k,st,it,V=f(()=>{"use strict";a();tt=require("fs/promises"),ye=p(require("module"),1),_=p(require("path"),1),be=async i=>{try{let e=await(0,tt.readFile)(i);return JSON.parse(e)}catch(e){console.error(e)}},k=ye.default.createRequire(m),st=(i,e)=>{let t=k;return e&&(t=ye.default.createRequire(e)),t.resolve(i)},it=_.default.resolve(__dirname,__filename).replace(`${_.default.sep}dist${_.default.sep}index.js`,"")});var ve={};j(ve,{chalk:()=>rt.default,color:()=>h,glob:()=>E.glob,logger:()=>c,utils:()=>de});var rt,E,H=f(()=>{"use strict";a();rt=p(require("chalk"),1),E=require("glob");R();C();S()});var ot,nt,at,pt,lt=f(()=>{"use strict";a();ot=p(require("path"),1),nt=p(require("jiti"),1);H();y();at=(0,nt.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),pt=async()=>{let i=ot.default.join(o.root,"emp{-,.}config.{ts,js,mjs,cjs,mts,cts}");return(await(0,E.glob)([i],{windowsPathsNoEscape:!0})||[])[0]}});var W,ct=f(()=>{"use strict";a();y();W=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 l=r.match(this.exp)||[];l.length>0?(n.global=l[1],n.entry=l[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(l=>{if(!l)return;if(l.split("?")[0].endsWith(".css"))n.entry=l,n.type="css";else{let v=l.match(this.exp)||[];v.length>0?(n.global=v[1],n.entry=v[2],n.type="js"):(n.global="",n.entry=l,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 q,mt=f(()=>{"use strict";a();y();q=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)}}});async function X(i,e="localhost"){if(i!==Ts&&(i<ft||i>Ce))throw new Error(`Port number must lie between ${ft} and ${Ce}`);let t=i,s=Fs(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=Ce;)try{return await Ns(t,r)}catch(l){if(!n.has(l.code))throw l;t+=1}throw new Error("No available ports found")}var ht,ut,ft,Ce,Ts,Fs,As,Ns,we=f(()=>{"use strict";a();ht=p(require("net"),1),ut=p(require("os"),1),ft=1024,Ce=65535,Ts=443,Fs=()=>{let i=ut.default.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},As=(i,e)=>new Promise((t,s)=>{let r=ht.default.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),Ns=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await As(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});var xe,gt,Se,T,Ee=f(()=>{"use strict";a();xe=p(require("url"),1),gt=p(require("chalk"),1);R();C();Se=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=z;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return xe.default.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return xe.default.format({protocol:t,hostname:e,port:gt.default.bold(s),pathname:r})}},T=new Se});var Oe,K,Pe=f(()=>{"use strict";a();we();Ee();C();y();Oe=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=T.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await X(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=g({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},K=new Oe});var ke,dt,Q,yt,Z,Is,Y,$e=f(()=>{"use strict";a();ke=p(require("html-webpack-plugin"),1);C();y();dt="HtmlImportMapPlugin",Q=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(dt,t=>{ke.default.getHooks(t).alterAssetTagGroups.tapAsync(dt,(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)})})}},yt="HtmlEmpShareLibPlugin",Z=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(yt,t=>{let s=this.files;ke.default.getHooks(t).alterAssetTagGroups.tapAsync(yt,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(l=>{r.headTags.push({tagName:"script",attributes:{src:l},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(l=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:l},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},Is=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
10
- `);return ge(i)},Y=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,Is(),{name:void 0}).apply(e)}}});var ee,bt=f(()=>{"use strict";a();y();Pe();$e();ee=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await K.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(Y),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()}}});var vt,Me,Ct,wt=f(()=>{"use strict";a();vt=p(require("fs"),1);lt();C();ct();mt();bt();Me=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new q;empShareLib=new W;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 ee(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 g({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=await pt();if(!e||!vt.default.existsSync(e))return;let t=await at(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}},Ct=new Me});var xt,je,St,Et=f(()=>{"use strict";a();xt=p(require("fs-extra"),1),je=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 xt.default.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})}},St=new je});var Le,Ot,Pt=f(()=>{"use strict";a();V();Le=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:k.resolve("sass-embedded"),e.api=t.api,t.sassOptions&&(e.sassOptions=t.sassOptions));let s={loader:k.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:k.resolve("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"}}}})}},Ot=new Le});var w,kt,De,$t,Mt=f(()=>{"use strict";a();w=p(require("path"),1),kt=p(require("html-webpack-plugin"),1);H();C();$e();De=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(w.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.default.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(kt.default,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(Z,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(Q,[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=w.default.join(this.store.appSrc,e),s=w.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,E.glob)([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.default.sep}`,"")),r.map(n=>{let l=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...l},w.default.join(t,n))})}async setDefaultEntry(){let e=w.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,E.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let s=w.default.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)}},$t=new De});var Re,Te,jt,Lt=f(()=>{"use strict";a();Re=p(require("path"),1);V();C();Te=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:g(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",Re.default.dirname(k.resolve("@swc/helpers/package.json"))),this.coreJs.path=k.resolve("core-js/package.json");let t=he(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Re.default.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"}}}})}},jt=new Te});var Fe,Dt,F,Ae,Rt,Tt=f(()=>{"use strict";a();Fe=p(require("fs"),1),Dt=require("@module-federation/enhanced/rspack"),F=p(require("@rspack/core"),1),Ae=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.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Fe.default.existsSync(e)&&Fe.default.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(F.default.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.default.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=Dt.ModuleFederationPlugin;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.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(F.default.SwcCssMinimizerRspackPlugin,[{}])}},Rt=new Ae});var Ne,Ft,At=f(()=>{"use strict";a();Et();Pt();Mt();Lt();Tt();Ne=class{store;async setup(e){this.store=e;let t=[St.setup(this.store),jt.setup(this.store),Rt.setup(this.store),$t.setup(this.store),Ot.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()}},Ft=new Ne});var Nt,O,It,zt,Gt,Ie,o,y=f(()=>{"use strict";a();Nt=p(require("fs/promises"),1),O=p(require("path"),1),It=require("url"),zt=p(require("util"),1);S();V();C();wt();At();Gt=p(require("webpack-chain"),1),Ie=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=it;empSource=O.default.resolve(this.empRoot,"dist");resolve=e=>O.default.isAbsolute(e)?e:O.default.resolve(this.root,e);empResolve=e=>O.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=G;deepAssign=g;getLanIp=z;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=Ct,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Gt.default,await Ft.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 be(this.empResolve("package.json")),r=await be(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=O.default.join(this.empRoot,"resource"),this.resource.cert=O.default.join(this.resource.dir,"emp.cert"),this.resource.key=O.default.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),c.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 st(e,t)}importFileUrl(e){return(0,It.pathToFileURL)(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=O.default.join(this.root,this.debug.showRsconfig);Nt.default.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"?g(e,this.debug.showRsconfig):e;console.log(c.link("[Compile Config]")),console.log(zt.default.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 Ie});function _s(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,l)=>{let d=t[l],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(L.bold(s))}async function Ut(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>Bs(u.name)).map(Js);s.sort((u,I)=>u.size-I.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+P.default.sep+u.name).length));_s(n,r);let l=0,d=0;s.forEach(u=>{let{sizeLabel:I}=u,{name:gs,folder:ds,gzipSizeLabel:ys}=u,We=(ds+P.default.sep+gs).length,qe=I.length;if(l+=u.size,d+=u.gzippedSize,qe<r){let pe=" ".repeat(r-qe);I+=pe}let Xe=D(u.folder+P.default.sep)+Vs(u.name);if(We<n){let pe=" ".repeat(n-We);Xe+=pe}c.info(` ${Xe} ${D(I)} ${ys}`)});let v=`${L.bold("Total size:")} ${te(l)}`,N=`${L.bold("Gzipped size:")} ${te(d)}`;c.info(`
9
+ `)}},c=new le});var he={};M(he,{clearConsole:()=>me,deepAssign:()=>g,ensureArray:()=>xs,getLanIp:()=>I,getPkgVersion:()=>ce,importJsVm:()=>fe,jsonFilter:()=>Ss,timeFormat:()=>U,vCompare:()=>z});function me(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function g(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]=g(n,r);continue}i[s]=t[s]}return i}var Ve,We,qe,Xe,I,ce,xs,Ss,z,U,fe,C=f(()=>{"use strict";a();Ve=require("address"),We=p(require("chalk"),1),qe=require("default-gateway"),Xe=p(require("fs-extra"),1),I=()=>{let{int:i}=(0,qe.gateway4sync)();return(0,Ve.ip)(i||"")||"127.0.0.1"},ce=i=>{try{let{version:e}=Xe.default.readJSONSync(i);return e}catch{return}};xs=i=>Array.isArray(i)?i:[i],Ss=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),z=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let l=0;l<r;l++){let d=t.length>l?t[l]:0,v=isNaN(Number(d))?d.charCodeAt():Number(d),F=s.length>l?s[l]:0,u=isNaN(Number(F))?F.charCodeAt():Number(F);if(v<u){n=-1;break}else if(v>u){n=1;break}}return n},U=i=>{i=i/1e3;let e=s=>We.default.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`},fe=i=>`data:text/javascript,${i}`});var ue={};M(ue,{chalk:()=>Ke.default,color:()=>h,glob:()=>O.glob,logger:()=>c,utils:()=>he});var Ke,O,G=f(()=>{"use strict";a();Ke=p(require("chalk"),1),O=require("glob");D();C();E()});var Qe,Ze,Ye,et,tt=f(()=>{"use strict";a();Qe=p(require("path"),1),Ze=p(require("jiti"),1);G();y();Ye=(0,Ze.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),et=async()=>{let i=Qe.default.join(o.root,"emp{-,.}config.{ts,js,mjs,cjs,mts,cts}");return(await(0,O.glob)([i],{windowsPathsNoEscape:!0})||[])[0]}});var J,st=f(()=>{"use strict";a();y();J=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 l=r.match(this.exp)||[];l.length>0?(n.global=l[1],n.entry=l[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(l=>{if(!l)return;if(l.split("?")[0].endsWith(".css"))n.entry=l,n.type="css";else{let v=l.match(this.exp)||[];v.length>0?(n.global=v[1],n.entry=v[2],n.type="js"):(n.global="",n.entry=l,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 _,it=f(()=>{"use strict";a();y();_=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)}}});async function V(i,e="localhost"){if(i!==Es&&(i<rt||i>ge))throw new Error(`Port number must lie between ${rt} and ${ge}`);let t=i,s=Os(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=ge;)try{return await ks(t,r)}catch(l){if(!n.has(l.code))throw l;t+=1}throw new Error("No available ports found")}var ot,nt,rt,ge,Es,Os,Ps,ks,de=f(()=>{"use strict";a();ot=p(require("net"),1),nt=p(require("os"),1),rt=1024,ge=65535,Es=443,Os=()=>{let i=nt.default.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},Ps=(i,e)=>new Promise((t,s)=>{let r=ot.default.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),ks=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Ps(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});var ye,at,be,T,ve=f(()=>{"use strict";a();ye=p(require("url"),1),at=p(require("chalk"),1);D();C();be=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:L("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=I;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return ye.default.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return ye.default.format({protocol:t,hostname:e,port:at.default.bold(s),pathname:r})}},T=new be});var Ce,W,we=f(()=>{"use strict";a();de();ve();C();y();Ce=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=T.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await V(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=g({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},W=new Ce});var xe,pt,q,lt,X,$s,K,Se=f(()=>{"use strict";a();xe=p(require("html-webpack-plugin"),1);C();y();pt="HtmlImportMapPlugin",q=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(pt,t=>{xe.default.getHooks(t).alterAssetTagGroups.tapAsync(pt,(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)})})}},lt="HtmlEmpShareLibPlugin",X=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(lt,t=>{let s=this.files;xe.default.getHooks(t).alterAssetTagGroups.tapAsync(lt,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(l=>{r.headTags.push({tagName:"script",attributes:{src:l},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(l=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:l},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},$s=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
10
+ `);return fe(i)},K=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,$s(),{name:void 0}).apply(e)}}});var Q,ct=f(()=>{"use strict";a();y();we();Se();Q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await W.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(K),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()}}});var mt,Ee,ft,ht=f(()=>{"use strict";a();mt=p(require("fs"),1);tt();C();st();it();ct();Ee=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new _;empShareLib=new J;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 Q(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 g({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=await et();if(!e||!mt.default.existsSync(e))return;let t=await Ye(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}},ft=new Ee});var ut,Oe,gt,dt=f(()=>{"use strict";a();ut=p(require("fs-extra"),1),Oe=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 ut.default.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})}},gt=new Oe});var Pe,yt,bt=f(()=>{"use strict";a();Pe=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:require.resolve("sass-embedded"),e.api=t.api,t.sassOptions&&(e.sassOptions=t.sassOptions));let s={loader:require.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:require.resolve("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"}}}})}},yt=new Pe});var w,vt,ke,Ct,wt=f(()=>{"use strict";a();w=p(require("path"),1),vt=p(require("html-webpack-plugin"),1);G();C();Se();ke=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(w.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.default.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.default.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(vt.default,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(X,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(q,[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=w.default.join(this.store.appSrc,e),s=w.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,O.glob)([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.default.sep}`,"")),r.map(n=>{let l=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...l},w.default.join(t,n))})}async setDefaultEntry(){let e=w.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,O.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let s=w.default.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)}},Ct=new ke});var $e,Me,xt,St=f(()=>{"use strict";a();$e=p(require("path"),1);C();Me=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:g(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",$e.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ce(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=$e.default.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"}}}})}},xt=new Me});var je,Et,R,Le,Ot,Pt=f(()=>{"use strict";a();je=p(require("fs"),1),Et=require("@module-federation/enhanced/rspack"),R=p(require("@rspack/core"),1),Le=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(R.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");je.default.existsSync(e)&&je.default.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(R.default.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(R.default.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=Et.ModuleFederationPlugin;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(R.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(R.default.SwcCssMinimizerRspackPlugin,[{}])}},Ot=new Le});var De,kt,$t=f(()=>{"use strict";a();dt();bt();wt();St();Pt();De=class{store;async setup(e){this.store=e;let t=[gt.setup(this.store),xt.setup(this.store),Ot.setup(this.store),Ct.setup(this.store),yt.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()}},kt=new De});var Mt,x,jt,Lt,Te,o,y=f(()=>{"use strict";a();Mt=p(require("fs/promises"),1),x=p(require("path"),1),jt=p(require("util"),1);E();C();ht();$t();Lt=p(require("webpack-chain"),1),Te=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.default.resolve(__dirname,__filename).replace(`${x.default.sep}dist${x.default.sep}index.js`,"");empSource=x.default.resolve(this.empRoot,"dist");resolve=e=>x.default.isAbsolute(e)?e:x.default.resolve(this.root,e);empResolve=e=>x.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=z;deepAssign=g;getLanIp=I;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=ft,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Lt.default,await kt.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=require(this.empResolve("package.json")),r=require(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=x.default.join(this.empRoot,"resource"),this.resource.cert=x.default.join(this.resource.dir,"emp.cert"),this.resource.key=x.default.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),c.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.default.join(this.root,this.debug.showRsconfig);Mt.default.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"?g(e,this.debug.showRsconfig):e;console.log(c.link("[Compile Config]")),console.log(jt.default.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 Te});function As(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,l)=>{let d=t[l],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(j.bold(s))}async function Rt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>Ds(u.name)).map(Rs);s.sort((u,N)=>u.size-N.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+P.default.sep+u.name).length));As(n,r);let l=0,d=0;s.forEach(u=>{let{sizeLabel:N}=u,{name:ns,folder:as,gzipSizeLabel:ps}=u,Be=(as+P.default.sep+ns).length,Ue=N.length;if(l+=u.size,d+=u.gzippedSize,Ue<r){let oe=" ".repeat(r-Ue);N+=oe}let Je=L(u.folder+P.default.sep)+Fs(u.name);if(Be<n){let oe=" ".repeat(n-Be);Je+=oe}c.info(` ${Je} ${L(N)} ${ps}`)});let v=`${j.bold("Total size:")} ${Z(l)}`,F=`${j.bold("Gzipped size:")} ${Z(d)}`;c.info(`
11
11
  ${v}
12
- ${N}
13
- `),c.info(`${x("\u2713")} Ready in ${J(Number(e.time))}
14
- `)}function se(i=0){c.info(`${x("\u2713")} Ready in ${J(Number(i))}`)}var Ht,P,Bt,zs,Gs,Hs,Bs,Us,Js,te,Vs,ie=f(()=>{"use strict";a();Ht=p(require("fs"),1),P=p(require("path"),1),Bt=require("gzip-size");R();y();S();C();zs=/\.html$/,Gs=/\.(?:js|mjs|cjs|jsx)$/,Hs=/\.css$/,Bs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Us=i=>i>300*1e3?le:i>100*1e3?U:ce,Js=i=>{let e=i.name.split("?")[0],t=te(i.size),s=P.default.basename(e),r=P.default.join(P.default.basename(o.empConfig.build.outDir),P.default.dirname(e)),n=Ht.default.readFileSync(P.default.join(o.empConfig.build.outDir,e)),l=n.length,d=(0,Bt.gzipSizeSync)(n),v=Us(d)(te(d));return{size:l,folder:r,name:s,gzippedSize:d,sizeLabel:t,gzipSizeLabel:v}};te=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Vs=i=>Gs.test(i)?U(i):Hs.test(i)?x(i):zs.test(i)?L(i):me(i)});var _t,Vt,Wt,Jt,Ws,qs,qt,Xt=f(()=>{"use strict";a();_t=require("child_process"),Vt=require("util");y();S();Wt=(0,Vt.promisify)(_t.exec),Jt=["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||!Jt.includes(i)){let{stdout:e}=await Wt("ps cax");i=Jt.find(t=>e.includes(t))}return i},qs=async i=>{if(process.platform==="darwin")try{let t=await Ws();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Wt(s,{cwd:o.resource.dir}),!0}}catch(t){c.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return c.error("Failed to open start URL."),c.error(t),!1}},qt=qs});var ze,$,re=f(()=>{"use strict";a();ze=p(require("fs/promises"),1);R();we();Ee();S();Xt();C();y();Pe();$=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(),T.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=T.prettyPrintUrl("localhost")):(this.sf.urls=T.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(c.info(`${x("\u279C")} Local: ${c.link(e.localUrlForTerminal)}`),c.info(`${x("\u279C")} Network: ${c.link(this.sf.publicPath)}`)):(c.info(`${x("\u279C")} Local: ${c.link(e.localUrlForTerminal)}`),c.info(`${x("\u279C")} Network: ${c.link(e.lanUrlForTerminal)}
15
- `)),this.sf.isOpenBrower&&qt(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&ue(),c.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([ze.default.readFile(o.resource.key),ze.default.readFile(o.resource.cert)])}async serverPort(){if(K.isADB)return;let{port:e,host:t}=this.sf,s=await X(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var Zt={};j(Zt,{default:()=>Xs});var Kt,Qt,Ge,Xs,Yt=f(()=>{"use strict";a();Kt=require("@rspack/core"),Qt=require("@rspack/dev-server");ie();S();C();re();y();Ge=class extends ${get rspackDevConfig(){return g(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=(0,Kt.rspack)(this.rspackDevConfig);if(!o.rsConfig.devServer){c.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Qt.RspackDevServer(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=n=>{let l=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});se(l.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()})}},Xs=new Ge});var es,ts,ss,is,oe,rs=f(()=>{"use strict";a();es=p(require("https"),1),ts=p(require("compression"),1),ss=p(require("cors"),1),is=p(require("express"),1);re();oe=class extends ${app;async init(){let e=(0,is.default)();e.use((0,ts.default)()),e.use((0,ss.default)()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();es.default.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 He={};j(He,{ServeScript:()=>ne,default:()=>Ks});var os,ns,as,ps,ne,Ks,Be=f(()=>{"use strict";a();os=p(require("fs"),1),ns=p(require("fs/promises"),1),as=p(require("path"),1),ps=p(require("express"),1);ie();S();y();rs();ne=class extends oe{timing=0;async run(){if(this.timing=Date.now(),!os.default.existsSync(o.outDir))return c.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(ps.default.static(e));let t=await ns.default.readFile(as.default.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){se(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Ks=new ne});var cs={};j(cs,{default:()=>Qs});var ls,Ue,Qs,ms=f(()=>{"use strict";a();ls=require("@rspack/core");ie();S();re();y();Ue=class extends ${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(()=>(Be(),He));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(),(0,ls.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){c.error(e.stack||e),e.message&&c.error(e.message);return}if(!t){c.red("Stats is Undefined.");return}t.hasErrors()&&(c.error(t.toString({all:!1,colors:!0,errors:!0})),c.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(c.yellow("Compiled with warnings."),c.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Ut(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},Qs=new Ue});var si={};j(si,{HtmlWebpackPlugin:()=>us.default,defineConfig:()=>ti,dts:()=>fs,empHelper:()=>ve,rspack:()=>hs.rspack,runScript:()=>Je,store:()=>o});module.exports=Ss(si);a();var hs=require("@rspack/core"),us=p(require("html-webpack-plugin"),1);a();var A=p(require("process"),1),M=require("commander");S();C();y();function Je(){let i="20.0.0";G(i,A.default.versions.node)===1&&(c.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${A.default.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),(0,A.exit)(0)),M.program.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),M.program.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(()=>(Yt(),Zt));await t.setup("dev",e)}),M.program.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(()=>(ms(),cs));await t.setup("build",e)}),M.program.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(()=>(Be(),He));await t.setup("serve",e)}),M.program.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=>{}),M.program.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=>{}),M.program.parse(A.default.argv)}a();var _e=p(require("fs/promises"),1),ae=p(require("path"),1);H();y();var Zs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Ys=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,ei=/import\(['"]([^;\n]+?)['"]\)/,Ve=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(0,E.glob)([`${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 _e.default.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Zs,r=>{let n=r.match(Ys);if(n||(n=r.match(ei)),n&&n[1]){let l=n[1];if(!l.startsWith("."))return r;let d=ae.default.resolve(ae.default.dirname(e),l).replace(this.outDir,this.aliasName);return r.replace(n[1],d)}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
+ ${F}
13
+ `),c.info(`${S("\u2713")} Ready in ${U(Number(e.time))}
14
+ `)}function Y(i=0){c.info(`${S("\u2713")} Ready in ${U(Number(i))}`)}var Dt,P,Tt,Ms,js,Ls,Ds,Ts,Rs,Z,Fs,ee=f(()=>{"use strict";a();Dt=p(require("fs"),1),P=p(require("path"),1),Tt=require("gzip-size");D();y();E();C();Ms=/\.html$/,js=/\.(?:js|mjs|cjs|jsx)$/,Ls=/\.css$/,Ds=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Ts=i=>i>300*1e3?ne:i>100*1e3?B:ae,Rs=i=>{let e=i.name.split("?")[0],t=Z(i.size),s=P.default.basename(e),r=P.default.join(P.default.basename(o.empConfig.build.outDir),P.default.dirname(e)),n=Dt.default.readFileSync(P.default.join(o.empConfig.build.outDir,e)),l=n.length,d=(0,Tt.gzipSizeSync)(n),v=Ts(d)(Z(d));return{size:l,folder:r,name:s,gzippedSize:d,sizeLabel:t,gzipSizeLabel:v}};Z=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Fs=i=>js.test(i)?B(i):Ls.test(i)?S(i):Ms.test(i)?j(i):pe(i)});var Ft,Nt,It,At,Ns,Is,zt,Gt=f(()=>{"use strict";a();Ft=require("child_process"),Nt=require("util");y();E();It=(0,Nt.promisify)(Ft.exec),At=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ns=async()=>{let i=process.env.BROWSER;if(!i||!At.includes(i)){let{stdout:e}=await It("ps cax");i=At.find(t=>e.includes(t))}return i},Is=async i=>{if(process.platform==="darwin")try{let t=await Ns();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await It(s,{cwd:o.resource.dir}),!0}}catch(t){c.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return c.error("Failed to open start URL."),c.error(t),!1}},zt=Is});var Re,k,te=f(()=>{"use strict";a();Re=p(require("fs/promises"),1);D();de();ve();E();Gt();C();y();we();k=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(),T.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=T.prettyPrintUrl("localhost")):(this.sf.urls=T.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(c.info(`${S("\u279C")} Local: ${c.link(e.localUrlForTerminal)}`),c.info(`${S("\u279C")} Network: ${c.link(this.sf.publicPath)}`)):(c.info(`${S("\u279C")} Local: ${c.link(e.localUrlForTerminal)}`),c.info(`${S("\u279C")} Network: ${c.link(e.lanUrlForTerminal)}
15
+ `)),this.sf.isOpenBrower&&zt(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&me(),c.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([Re.default.readFile(o.resource.key),Re.default.readFile(o.resource.cert)])}async serverPort(){if(W.isADB)return;let{port:e,host:t}=this.sf,s=await V(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var Ut={};M(Ut,{default:()=>zs});var Ht,Bt,Ae,zs,Jt=f(()=>{"use strict";a();Ht=require("@rspack/core"),Bt=require("@rspack/dev-server");ee();E();C();te();y();Ae=class extends k{get rspackDevConfig(){return g(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=(0,Ht.rspack)(this.rspackDevConfig);if(!o.rsConfig.devServer){c.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Bt.RspackDevServer(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=n=>{let l=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Y(l.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()})}},zs=new Ae});var _t,Vt,Wt,qt,se,Xt=f(()=>{"use strict";a();_t=p(require("https"),1),Vt=p(require("compression"),1),Wt=p(require("cors"),1),qt=p(require("express"),1);te();se=class extends k{app;async init(){let e=(0,qt.default)();e.use((0,Vt.default)()),e.use((0,Wt.default)()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();_t.default.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 Fe={};M(Fe,{ServeScript:()=>ie,default:()=>Gs});var Kt,Qt,Zt,Yt,ie,Gs,Ne=f(()=>{"use strict";a();Kt=p(require("fs"),1),Qt=p(require("fs/promises"),1),Zt=p(require("path"),1),Yt=p(require("express"),1);ee();E();y();Xt();ie=class extends se{timing=0;async run(){if(this.timing=Date.now(),!Kt.default.existsSync(o.outDir))return c.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(Yt.default.static(e));let t=await Qt.default.readFile(Zt.default.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){Y(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Gs=new ie});var ts={};M(ts,{default:()=>Hs});var es,Ie,Hs,ss=f(()=>{"use strict";a();es=require("@rspack/core");ee();E();te();y();Ie=class extends k{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(()=>(Ne(),Fe));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(),(0,es.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){c.error(e.stack||e),e.message&&c.error(e.message);return}if(!t){c.red("Stats is Undefined.");return}t.hasErrors()&&(c.error(t.toString({all:!1,colors:!0,errors:!0})),c.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(c.yellow("Compiled with warnings."),c.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Rt(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},Hs=new Ie});var Vs={};M(Vs,{HtmlWebpackPlugin:()=>os.default,defineConfig:()=>_s,dts:()=>is,empHelper:()=>ue,rspack:()=>rs.rspack,runScript:()=>ze,store:()=>o});module.exports=us(Vs);a();var rs=require("@rspack/core"),os=p(require("html-webpack-plugin"),1);a();var A=p(require("process"),1),$=require("commander");E();C();y();function ze(){let i="20.0.0";z(i,A.default.versions.node)===1&&(c.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${A.default.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),(0,A.exit)(0)),$.program.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),$.program.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(()=>(Jt(),Ut));await t.setup("dev",e)}),$.program.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(()=>(ss(),ts));await t.setup("build",e)}),$.program.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(()=>(Ne(),Fe));await t.setup("serve",e)}),$.program.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=>{}),$.program.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=>{}),$.program.parse(A.default.argv)}a();var Ge=p(require("fs/promises"),1),re=p(require("path"),1);G();y();var Bs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Us=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Js=/import\(['"]([^;\n]+?)['"]\)/,He=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(0,O.glob)([`${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 Ge.default.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Bs,r=>{let n=r.match(Us);if(n||(n=r.match(Js)),n&&n[1]){let l=n[1];if(!l.startsWith("."))return r;let d=re.default.resolve(re.default.dirname(e),l).replace(this.outDir,this.aliasName);return r.replace(n[1],d)}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 _e.default.writeFile(ae.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},fs=new Ve;y();H();function ti(i){return i}0&&(module.exports={HtmlWebpackPlugin,defineConfig,dts,empHelper,rspack,runScript,store});
17
+ `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await Ge.default.writeFile(re.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},is=new He;y();G();function _s(i){return i}0&&(module.exports={HtmlWebpackPlugin,defineConfig,dts,empHelper,rspack,runScript,store});
18
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/index.d.cts CHANGED
@@ -260,14 +260,6 @@ declare class GlobalStore {
260
260
  */
261
261
  setLogger(): void;
262
262
  merge(o: RspackOptions): void;
263
- importResolve(scope: string, importMetaUrl?: string): string;
264
- /**
265
- * windows import() 情况下 ES 的物理路径转换
266
- * pathToFileURL 是为了解决在window下,import文件路径解析异常
267
- * @param scope
268
- * @returns
269
- */
270
- importFileUrl(scope: string): string;
271
263
  /**
272
264
  * 同步 chain 配置到 rsConfig
273
265
  */
package/dist/index.d.ts CHANGED
@@ -260,14 +260,6 @@ declare class GlobalStore {
260
260
  */
261
261
  setLogger(): void;
262
262
  merge(o: RspackOptions): void;
263
- importResolve(scope: string, importMetaUrl?: string): string;
264
- /**
265
- * windows import() 情况下 ES 的物理路径转换
266
- * pathToFileURL 是为了解决在window下,import文件路径解析异常
267
- * @param scope
268
- * @returns
269
- */
270
- importFileUrl(scope: string): string;
271
263
  /**
272
264
  * 同步 chain 配置到 rsConfig
273
265
  */
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- var Rt=Object.defineProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var A=(i,e)=>{for(var t in e)Rt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Ft}from"url";import At from"path";var Ge,Nt,m,c,a=f(()=>{"use strict";Ge=()=>Ft(import.meta.url),Nt=()=>At.dirname(Ge()),m=Nt(),c=Ge()});import b from"chalk";var zt,x,It,Gt,Ht,oe,H,Bt,Ut,j,ne,Jt,ae,L,h,D=f(()=>{"use strict";a();zt=b.hex("#1abc9c"),x=b.hex("#16a085"),It=b.hex("#2ecc71"),Gt=b.hex("#27ae60"),Ht=b.hex("#e74c3c"),oe=b.hex("#c0392b"),H=b.hex("#f1c40f"),Bt=b.hex("#f39c12"),Ut=b.hex("#3498db"),j=b.hex("#2980b9"),ne=b.hex("#ecf0f1"),Jt=b.hex("#fd79a8"),ae=b.hex("#e84393"),L=b.hex("#7f8c8d"),h={lightGreen:zt,green:x,lightCyan:It,cyan:Gt,lightRed:Ht,red:oe,yellow:H,orange:Bt,lightBlue:Ut,blue:j,white:ne,lightMagenta:Jt,magenta:ae,gray:L}});var pe,l,S=f(()=>{"use strict";a();D();pe=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.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(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
1
+ import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
+ var $t=Object.defineProperty;var S=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var A=(i,e)=>{for(var t in e)$t(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Mt}from"url";import jt from"path";var Ne,Lt,m,c,a=f(()=>{"use strict";Ne=()=>Mt(import.meta.url),Lt=()=>jt.dirname(Ne()),m=Lt(),c=Ne()});import b from"chalk";var Dt,E,Tt,Rt,Ft,re,H,At,Nt,j,oe,zt,ne,L,h,D=f(()=>{"use strict";a();Dt=b.hex("#1abc9c"),E=b.hex("#16a085"),Tt=b.hex("#2ecc71"),Rt=b.hex("#27ae60"),Ft=b.hex("#e74c3c"),re=b.hex("#c0392b"),H=b.hex("#f1c40f"),At=b.hex("#f39c12"),Nt=b.hex("#3498db"),j=b.hex("#2980b9"),oe=b.hex("#ecf0f1"),zt=b.hex("#fd79a8"),ne=b.hex("#e84393"),L=b.hex("#7f8c8d"),h={lightGreen:Dt,green:E,lightCyan:Tt,cyan:Rt,lightRed:Ft,red:re,yellow:H,orange:At,lightBlue:Nt,blue:j,white:oe,lightMagenta:zt,magenta:ne,gray:L}});var ae,l,O=f(()=>{"use strict";a();D();ae=class{brandName="";fullName="";logLevel="debug";setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.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(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
2
3
  `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
3
4
  `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
4
5
  `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
@@ -6,12 +7,12 @@ var Rt=Object.defineProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var A=(i,e)=>{fo
6
7
  `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
7
8
  `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
8
9
  `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
9
- `)}},l=new pe});var fe={};A(fe,{clearConsole:()=>ce,deepAssign:()=>g,ensureArray:()=>Xt,getLanIp:()=>N,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>Kt,timeFormat:()=>B,vCompare:()=>z});import{ip as _t}from"address";import Vt from"chalk";import{gateway4sync as Wt}from"default-gateway";import qt from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function g(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]=g(n,r);continue}i[s]=t[s]}return i}var N,le,Xt,Kt,z,B,me,C=f(()=>{"use strict";a();N=()=>{let{int:i}=Wt();return _t(i||"")||"127.0.0.1"},le=i=>{try{let{version:e}=qt.readJSONSync(i);return e}catch{return}};Xt=i=>Array.isArray(i)?i:[i],Kt=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),z=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let p=0;p<r;p++){let d=t.length>p?t[p]:0,v=isNaN(Number(d))?d.charCodeAt():Number(d),R=s.length>p?s[p]:0,u=isNaN(Number(R))?R.charCodeAt():Number(R);if(v<u){n=-1;break}else if(v>u){n=1;break}}return n},B=i=>{i=i/1e3;let e=s=>Vt.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`},me=i=>`data:text/javascript,${i}`});import{readFile as Qt}from"fs/promises";import He from"module";import he from"path";var ue,E,Be,Ue,U=f(()=>{"use strict";a();ue=async i=>{try{let e=await Qt(i);return JSON.parse(e)}catch(e){console.error(e)}},E=He.createRequire(import.meta.url),Be=(i,e)=>{let t=E;return e&&(t=He.createRequire(e)),t.resolve(i)},Ue=he.resolve(m,c).replace(`${he.sep}dist${he.sep}index.js`,"")});var Je={};A(Je,{chalk:()=>Zt,color:()=>h,glob:()=>O,logger:()=>l,utils:()=>fe});import Zt from"chalk";import{glob as O}from"glob";var I=f(()=>{"use strict";a();D();C();S()});import Yt from"path";import es from"jiti";var _e,Ve,We=f(()=>{"use strict";a();I();y();_e=es(c,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ve=async()=>{let i=Yt.join(o.root,"emp{-,.}config.{ts,js,mjs,cjs,mts,cts}");return(await O([i],{windowsPathsNoEscape:!0})||[])[0]}});var J,qe=f(()=>{"use strict";a();y();J=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 p=r.match(this.exp)||[];p.length>0?(n.global=p[1],n.entry=p[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(p=>{if(!p)return;if(p.split("?")[0].endsWith(".css"))n.entry=p,n.type="css";else{let v=p.match(this.exp)||[];v.length>0?(n.global=v[1],n.entry=v[2],n.type="js"):(n.global="",n.entry=p,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 _,Xe=f(()=>{"use strict";a();y();_=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 ts from"net";import ss from"os";async function V(i,e="localhost"){if(i!==is&&(i<Ke||i>ge))throw new Error(`Port number must lie between ${Ke} and ${ge}`);let t=i,s=rs(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=ge;)try{return await ns(t,r)}catch(p){if(!n.has(p.code))throw p;t+=1}throw new Error("No available ports found")}var Ke,ge,is,rs,os,ns,de=f(()=>{"use strict";a();Ke=1024,ge=65535,is=443,rs=()=>{let i=ss.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},os=(i,e)=>new Promise((t,s)=>{let r=ts.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),ns=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await os(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import Qe from"url";import as from"chalk";var ye,T,be=f(()=>{"use strict";a();D();C();ye=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:L("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=N;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Qe.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Qe.format({protocol:t,hostname:e,port:as.bold(s),pathname:r})}},T=new ye});var ve,W,Ce=f(()=>{"use strict";a();de();be();C();y();ve=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=T.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await V(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=g({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},W=new ve});import et from"html-webpack-plugin";var Ze,q,Ye,X,ps,K,we=f(()=>{"use strict";a();C();y();Ze="HtmlImportMapPlugin",q=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(Ze,t=>{et.getHooks(t).alterAssetTagGroups.tapAsync(Ze,(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)})})}},Ye="HtmlEmpShareLibPlugin",X=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(Ye,t=>{let s=this.files;et.getHooks(t).alterAssetTagGroups.tapAsync(Ye,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(p=>{r.headTags.push({tagName:"script",attributes:{src:p},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(p=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:p},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},ps=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
10
- `);return me(i)},K=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,ps(),{name:void 0}).apply(e)}}});var Q,tt=f(()=>{"use strict";a();y();Ce();we();Q=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await W.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(K),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 ls from"fs";var xe,st,it=f(()=>{"use strict";a();We();C();qe();Xe();tt();xe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new _;empShareLib=new J;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 Q(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 g({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=await Ve();if(!e||!ls.existsSync(e))return;let t=await _e(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}},st=new xe});import cs from"fs-extra";var Se,rt,ot=f(()=>{"use strict";a();Se=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 cs.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})}},rt=new Se});var Ee,nt,at=f(()=>{"use strict";a();U();Ee=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:E.resolve("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"}}}})}},nt=new Ee});import w from"path";import ms from"html-webpack-plugin";var Oe,pt,lt=f(()=>{"use strict";a();I();C();we();Oe=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(w.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.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(ms,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(X,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(q,[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=w.join(this.store.appSrc,e),s=w.join(t,"**","*.{ts,tsx,jsx,js}"),r=await O([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.sep}`,"")),r.map(n=>{let p=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...p},w.join(t,n))})}async setDefaultEntry(){let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await O([e],{windowsPathsNoEscape:!0});if(t[0]){let s=w.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)}},pt=new Oe});import ct from"path";var Pe,mt,ft=f(()=>{"use strict";a();U();C();Pe=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:g(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",ct.dirname(E.resolve("@swc/helpers/package.json"))),this.coreJs.path=E.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ct.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"}}}})}},mt=new Pe});import ht from"fs";import{ModuleFederationPlugin as fs}from"@module-federation/enhanced/rspack";import G from"@rspack/core";var ke,ut,gt=f(()=>{"use strict";a();ke=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(G.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ht.existsSync(e)&&ht.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(G.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(G.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=fs;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(G.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(G.SwcCssMinimizerRspackPlugin,[{}])}},ut=new ke});var $e,dt,yt=f(()=>{"use strict";a();ot();at();lt();ft();gt();$e=class{store;async setup(e){this.store=e;let t=[rt.setup(this.store),mt.setup(this.store),ut.setup(this.store),pt.setup(this.store),nt.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()}},dt=new $e});import hs from"fs/promises";import P from"path";import{pathToFileURL as us}from"url";import gs from"util";import ds from"webpack-chain";var Me,o,y=f(()=>{"use strict";a();S();U();C();it();yt();Me=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=Ue;empSource=P.resolve(this.empRoot,"dist");resolve=e=>P.isAbsolute(e)?e:P.resolve(this.root,e);empResolve=e=>P.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=z;deepAssign=g;getLanIp=N;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=st,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new ds,await dt.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 ue(this.empResolve("package.json")),r=await ue(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=P.join(this.empRoot,"resource"),this.resource.cert=P.join(this.resource.dir,"emp.cert"),this.resource.key=P.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),l.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 Be(e,t)}importFileUrl(e){return us(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=P.join(this.root,this.debug.showRsconfig);hs.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"?g(e,this.debug.showRsconfig):e;console.log(l.link("[Compile Config]")),console.log(gs.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 Me});import ys from"fs";import k from"path";import{gzipSizeSync as bs}from"gzip-size";function Os(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,p)=>{let d=t[p],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(j.bold(s))}async function bt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>xs(u.name)).map(Es);s.sort((u,F)=>u.size-F.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));Os(n,r);let p=0,d=0;s.forEach(u=>{let{sizeLabel:F}=u,{name:Lt,folder:Dt,gzipSizeLabel:Tt}=u,Ne=(Dt+k.sep+Lt).length,ze=F.length;if(p+=u.size,d+=u.gzippedSize,ze<r){let re=" ".repeat(r-ze);F+=re}let Ie=L(u.folder+k.sep)+Ps(u.name);if(Ne<n){let re=" ".repeat(n-Ne);Ie+=re}l.info(` ${Ie} ${L(F)} ${Tt}`)});let v=`${j.bold("Total size:")} ${Z(p)}`,R=`${j.bold("Gzipped size:")} ${Z(d)}`;l.info(`
10
+ `)}},l=new ae});var me={};A(me,{clearConsole:()=>le,deepAssign:()=>g,ensureArray:()=>Ut,getLanIp:()=>N,getPkgVersion:()=>pe,importJsVm:()=>ce,jsonFilter:()=>Jt,timeFormat:()=>B,vCompare:()=>z});import{ip as It}from"address";import Gt from"chalk";import{gateway4sync as Ht}from"default-gateway";import Bt from"fs-extra";function le(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function g(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]=g(n,r);continue}i[s]=t[s]}return i}var N,pe,Ut,Jt,z,B,ce,C=f(()=>{"use strict";a();N=()=>{let{int:i}=Ht();return It(i||"")||"127.0.0.1"},pe=i=>{try{let{version:e}=Bt.readJSONSync(i);return e}catch{return}};Ut=i=>Array.isArray(i)?i:[i],Jt=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),z=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let p=0;p<r;p++){let d=t.length>p?t[p]:0,v=isNaN(Number(d))?d.charCodeAt():Number(d),R=s.length>p?s[p]:0,u=isNaN(Number(R))?R.charCodeAt():Number(R);if(v<u){n=-1;break}else if(v>u){n=1;break}}return n},B=i=>{i=i/1e3;let e=s=>Gt.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`},ce=i=>`data:text/javascript,${i}`});var ze={};A(ze,{chalk:()=>_t,color:()=>h,glob:()=>P,logger:()=>l,utils:()=>me});import _t from"chalk";import{glob as P}from"glob";var I=f(()=>{"use strict";a();D();C();O()});import Vt from"path";import Wt from"jiti";var Ie,Ge,He=f(()=>{"use strict";a();I();y();Ie=Wt(c,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ge=async()=>{let i=Vt.join(o.root,"emp{-,.}config.{ts,js,mjs,cjs,mts,cts}");return(await P([i],{windowsPathsNoEscape:!0})||[])[0]}});var U,Be=f(()=>{"use strict";a();y();U=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 p=r.match(this.exp)||[];p.length>0?(n.global=p[1],n.entry=p[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(p=>{if(!p)return;if(p.split("?")[0].endsWith(".css"))n.entry=p,n.type="css";else{let v=p.match(this.exp)||[];v.length>0?(n.global=v[1],n.entry=v[2],n.type="js"):(n.global="",n.entry=p,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 J,Ue=f(()=>{"use strict";a();y();J=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 qt from"net";import Xt from"os";async function _(i,e="localhost"){if(i!==Kt&&(i<Je||i>fe))throw new Error(`Port number must lie between ${Je} and ${fe}`);let t=i,s=Qt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=fe;)try{return await Yt(t,r)}catch(p){if(!n.has(p.code))throw p;t+=1}throw new Error("No available ports found")}var Je,fe,Kt,Qt,Zt,Yt,he=f(()=>{"use strict";a();Je=1024,fe=65535,Kt=443,Qt=()=>{let i=Xt.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},Zt=(i,e)=>new Promise((t,s)=>{let r=qt.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),Yt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Zt(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import _e from"url";import es from"chalk";var ue,T,ge=f(()=>{"use strict";a();D();C();ue=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:L("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=N;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return _e.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return _e.format({protocol:t,hostname:e,port:es.bold(s),pathname:r})}},T=new ue});var de,V,ye=f(()=>{"use strict";a();he();ge();C();y();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=T.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;n=await _(n,s),o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=g({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},V=new de});import qe from"html-webpack-plugin";var Ve,W,We,q,ts,X,be=f(()=>{"use strict";a();C();y();Ve="HtmlImportMapPlugin",W=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(Ve,t=>{qe.getHooks(t).alterAssetTagGroups.tapAsync(Ve,(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)})})}},We="HtmlEmpShareLibPlugin",q=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(We,t=>{let s=this.files;qe.getHooks(t).alterAssetTagGroups.tapAsync(We,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(p=>{r.headTags.push({tagName:"script",attributes:{src:p},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(p=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:p},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},ts=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
11
+ `);return ce(i)},X=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,ts(),{name:void 0}).apply(e)}}});var K,Xe=f(()=>{"use strict";a();y();ye();be();K=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await V.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(X),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 ss from"fs";var ve,Ke,Qe=f(()=>{"use strict";a();He();C();Be();Ue();Xe();ve=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new J;empShareLib=new U;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 K(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 g({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=await Ge();if(!e||!ss.existsSync(e))return;let t=await Ie(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}},Ke=new ve});import is from"fs-extra";var Ce,Ze,Ye=f(()=>{"use strict";a();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 is.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})}},Ze=new Ce});var we,et,tt=f(()=>{"use strict";a();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:S.resolve("sass-embedded"),e.api=t.api,t.sassOptions&&(e.sassOptions=t.sassOptions));let s={loader:S.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:S.resolve("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"}}}})}},et=new we});import w from"path";import rs from"html-webpack-plugin";var xe,st,it=f(()=>{"use strict";a();I();C();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(w.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(w.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(rs,[e]),this.store.empConfig.empShareLib&&(e.files=g(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(q,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(W,[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=w.join(this.store.appSrc,e),s=w.join(t,"**","*.{ts,tsx,jsx,js}"),r=await P([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.sep}`,"")),r.map(n=>{let p=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...p},w.join(t,n))})}async setDefaultEntry(){let e=w.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=w.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"path";var Se,ot,nt=f(()=>{"use strict";a();C();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:g(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(S.resolve("@swc/helpers/package.json"))),this.coreJs.path=S.resolve("core-js/package.json");let t=pe(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 os}from"@module-federation/enhanced/rspack";import G from"@rspack/core";var Ee,pt,lt=f(()=>{"use strict";a();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(G.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(G.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(G.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=os;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(G.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(G.SwcCssMinimizerRspackPlugin,[{}])}},pt=new Ee});var Oe,ct,mt=f(()=>{"use strict";a();Ye();tt();it();nt();lt();Oe=class{store;async setup(e){this.store=e;let t=[Ze.setup(this.store),ot.setup(this.store),pt.setup(this.store),st.setup(this.store),et.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 ns from"fs/promises";import x from"path";import as from"util";import ps from"webpack-chain";var Pe,o,y=f(()=>{"use strict";a();O();C();Qe();mt();Pe=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(m,c).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=z;deepAssign=g;getLanIp=N;entries={};debug;async setup(e,t){await this.initVars(e,t),this.empConfig=Ke,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=S(this.empResolve("package.json")),r=S(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=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),l.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.join(this.root,this.debug.showRsconfig);ns.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"?g(e,this.debug.showRsconfig):e;console.log(l.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"fs";import k from"path";import{gzipSizeSync as cs}from"gzip-size";function ys(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,p)=>{let d=t[p],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(j.bold(s))}async function ft(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>us(u.name)).map(ds);s.sort((u,F)=>u.size-F.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));ys(n,r);let p=0,d=0;s.forEach(u=>{let{sizeLabel:F}=u,{name:Ot,folder:Pt,gzipSizeLabel:kt}=u,Re=(Pt+k.sep+Ot).length,Fe=F.length;if(p+=u.size,d+=u.gzippedSize,Fe<r){let ie=" ".repeat(r-Fe);F+=ie}let Ae=L(u.folder+k.sep)+bs(u.name);if(Re<n){let ie=" ".repeat(n-Re);Ae+=ie}l.info(` ${Ae} ${L(F)} ${kt}`)});let v=`${j.bold("Total size:")} ${Q(p)}`,R=`${j.bold("Gzipped size:")} ${Q(d)}`;l.info(`
11
12
  ${v}
12
13
  ${R}
13
- `),l.info(`${x("\u2713")} Ready in ${B(Number(e.time))}
14
- `)}function Y(i=0){l.info(`${x("\u2713")} Ready in ${B(Number(i))}`)}var vs,Cs,ws,xs,Ss,Es,Z,Ps,ee=f(()=>{"use strict";a();D();y();S();C();vs=/\.html$/,Cs=/\.(?:js|mjs|cjs|jsx)$/,ws=/\.css$/,xs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Ss=i=>i>300*1e3?oe:i>100*1e3?H:ne,Es=i=>{let e=i.name.split("?")[0],t=Z(i.size),s=k.basename(e),r=k.join(k.basename(o.empConfig.build.outDir),k.dirname(e)),n=ys.readFileSync(k.join(o.empConfig.build.outDir,e)),p=n.length,d=bs(n),v=Ss(d)(Z(d));return{size:p,folder:r,name:s,gzippedSize:d,sizeLabel:t,gzipSizeLabel:v}};Z=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ps=i=>Cs.test(i)?H(i):ws.test(i)?x(i):vs.test(i)?j(i):ae(i)});import{exec as ks}from"child_process";import{promisify as $s}from"util";var Ct,vt,Ms,js,wt,xt=f(()=>{"use strict";a();y();S();Ct=$s(ks),vt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ms=async()=>{let i=process.env.BROWSER;if(!i||!vt.includes(i)){let{stdout:e}=await Ct("ps cax");i=vt.find(t=>e.includes(t))}return i},js=async i=>{if(process.platform==="darwin")try{let t=await Ms();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Ct(s,{cwd:o.resource.dir}),!0}}catch(t){l.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return l.error("Failed to open start URL."),l.error(t),!1}},wt=js});import St from"fs/promises";var $,te=f(()=>{"use strict";a();D();de();be();S();xt();C();y();Ce();$=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(),T.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=T.prettyPrintUrl("localhost")):(this.sf.urls=T.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(l.info(`${x("\u279C")} Local: ${l.link(e.localUrlForTerminal)}`),l.info(`${x("\u279C")} Network: ${l.link(this.sf.publicPath)}`)):(l.info(`${x("\u279C")} Local: ${l.link(e.localUrlForTerminal)}`),l.info(`${x("\u279C")} Network: ${l.link(e.lanUrlForTerminal)}
15
- `)),this.sf.isOpenBrower&&wt(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&ce(),l.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([St.readFile(o.resource.key),St.readFile(o.resource.cert)])}async serverPort(){if(W.isADB)return;let{port:e,host:t}=this.sf,s=await V(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var Et={};A(Et,{default:()=>Ts});import{rspack as Ls}from"@rspack/core";import{RspackDevServer as Ds}from"@rspack/dev-server";var je,Ts,Ot=f(()=>{"use strict";a();ee();S();C();te();y();je=class extends ${get rspackDevConfig(){return g(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=Ls(this.rspackDevConfig);if(!o.rsConfig.devServer){l.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Ds(t,e);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await s.start();let r=n=>{let p=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Y(p.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()})}},Ts=new je});import Rs from"https";import Fs from"compression";import As from"cors";import Ns from"express";var se,Pt=f(()=>{"use strict";a();te();se=class extends ${app;async init(){let e=Ns();e.use(Fs()),e.use(As()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();Rs.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 Le={};A(Le,{ServeScript:()=>ie,default:()=>Bs});import zs from"fs";import Is from"fs/promises";import Gs from"path";import Hs from"express";var ie,Bs,De=f(()=>{"use strict";a();ee();S();y();Pt();ie=class extends se{timing=0;async run(){if(this.timing=Date.now(),!zs.existsSync(o.outDir))return l.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(Hs.static(e));let t=await Is.readFile(Gs.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){Y(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Bs=new ie});var kt={};A(kt,{default:()=>Js});import{rspack as Us}from"@rspack/core";var Te,Js,$t=f(()=>{"use strict";a();ee();S();te();y();Te=class extends ${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(()=>(De(),Le));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(),Us(this.rspackConfig,async(e,t)=>{if(e!==null){l.error(e.stack||e),e.message&&l.error(e.message);return}if(!t){l.red("Stats is Undefined.");return}t.hasErrors()&&(l.error(t.toString({all:!1,colors:!0,errors:!0})),l.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(l.yellow("Compiled with warnings."),l.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await bt(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},Js=new Te});a();import{rspack as vn}from"@rspack/core";import wn from"html-webpack-plugin";a();S();C();y();import Re,{exit as _s}from"process";import{program as M}from"commander";function Mt(){let i="20.0.0";z(i,Re.versions.node)===1&&(l.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${Re.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),_s(0)),M.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),M.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(()=>(Ot(),Et));await t.setup("dev",e)}),M.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(()=>($t(),kt));await t.setup("build",e)}),M.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(()=>(De(),Le));await t.setup("serve",e)}),M.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=>{}),M.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=>{}),M.parse(Re.argv)}a();I();y();import jt from"fs/promises";import Fe from"path";var Vs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Ws=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,qs=/import\(['"]([^;\n]+?)['"]\)/,Ae=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 O([`${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 jt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Vs,r=>{let n=r.match(Ws);if(n||(n=r.match(qs)),n&&n[1]){let p=n[1];if(!p.startsWith("."))return r;let d=Fe.resolve(Fe.dirname(e),p).replace(this.outDir,this.aliasName);return r.replace(n[1],d)}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
14
+ `),l.info(`${E("\u2713")} Ready in ${B(Number(e.time))}
15
+ `)}function Z(i=0){l.info(`${E("\u2713")} Ready in ${B(Number(i))}`)}var ms,fs,hs,us,gs,ds,Q,bs,Y=f(()=>{"use strict";a();D();y();O();C();ms=/\.html$/,fs=/\.(?:js|mjs|cjs|jsx)$/,hs=/\.css$/,us=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),gs=i=>i>300*1e3?re:i>100*1e3?H:oe,ds=i=>{let e=i.name.split("?")[0],t=Q(i.size),s=k.basename(e),r=k.join(k.basename(o.empConfig.build.outDir),k.dirname(e)),n=ls.readFileSync(k.join(o.empConfig.build.outDir,e)),p=n.length,d=cs(n),v=gs(d)(Q(d));return{size:p,folder:r,name:s,gzippedSize:d,sizeLabel:t,gzipSizeLabel:v}};Q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},bs=i=>fs.test(i)?H(i):hs.test(i)?E(i):ms.test(i)?j(i):ne(i)});import{exec as vs}from"child_process";import{promisify as Cs}from"util";var ut,ht,ws,xs,gt,dt=f(()=>{"use strict";a();y();O();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){l.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return l.error("Failed to open start URL."),l.error(t),!1}},gt=xs});import yt from"fs/promises";var $,ee=f(()=>{"use strict";a();D();he();ge();O();dt();C();y();ye();$=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(),T.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=T.prettyPrintUrl("localhost")):(this.sf.urls=T.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(l.info(`${E("\u279C")} Local: ${l.link(e.localUrlForTerminal)}`),l.info(`${E("\u279C")} Network: ${l.link(this.sf.publicPath)}`)):(l.info(`${E("\u279C")} Local: ${l.link(e.localUrlForTerminal)}`),l.info(`${E("\u279C")} Network: ${l.link(e.lanUrlForTerminal)}
16
+ `)),this.sf.isOpenBrower&&gt(this.sf.url)}async setup(e,t){await o.setup(e,t),o.debug.clearLog&&le(),l.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(V.isADB)return;let{port:e,host:t}=this.sf,s=await _(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var bt={};A(bt,{default:()=>Os});import{rspack as Ss}from"@rspack/core";import{RspackDevServer as Es}from"@rspack/dev-server";var ke,Os,vt=f(()=>{"use strict";a();Y();O();C();ee();y();ke=class extends ${get rspackDevConfig(){return g(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){l.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 p=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Z(p.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 te,Ct=f(()=>{"use strict";a();ee();te=class extends ${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={};A($e,{ServeScript:()=>se,default:()=>Rs});import js from"fs";import Ls from"fs/promises";import Ds from"path";import Ts from"express";var se,Rs,Me=f(()=>{"use strict";a();Y();O();y();Ct();se=class extends te{timing=0;async run(){if(this.timing=Date.now(),!js.existsSync(o.outDir))return l.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(){Z(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},Rs=new se});var wt={};A(wt,{default:()=>As});import{rspack as Fs}from"@rspack/core";var je,As,xt=f(()=>{"use strict";a();Y();O();ee();y();je=class extends ${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){l.error(e.stack||e),e.message&&l.error(e.message);return}if(!t){l.red("Stats is Undefined.");return}t.hasErrors()&&(l.error(t.toString({all:!1,colors:!0,errors:!0})),l.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(l.yellow("Compiled with warnings."),l.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});a();import{rspack as on}from"@rspack/core";import an from"html-webpack-plugin";a();O();C();y();import Le,{exit as Ns}from"process";import{program as M}from"commander";function St(){let i="20.0.0";z(i,Le.versions.node)===1&&(l.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${Le.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),Ns(0)),M.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),M.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)}),M.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)}),M.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)}),M.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=>{}),M.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=>{}),M.parse(Le.argv)}a();I();y();import Et from"fs/promises";import De from"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 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 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 p=n[1];if(!p.startsWith("."))return r;let d=De.resolve(De.dirname(e),p).replace(this.outDir,this.aliasName);return r.replace(n[1],d)}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
17
  ${t}}\r
17
- `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await jt.writeFile(Fe.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Xs=new Ae;y();I();function On(i){return i}export{wn as HtmlWebpackPlugin,On as defineConfig,Xs as dts,Je as empHelper,vn as rspack,Mt as runScript,o as store};
18
+ `}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;y();I();function mn(i){return i}export{an as HtmlWebpackPlugin,mn as defineConfig,Hs as dts,ze as empHelper,on as rspack,St as runScript,o as store};
package/package.json CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.0.0-rc.29",
3
+ "version": "3.0.0-rc.30",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "files": ["dist", "bin", "resource", "template", "client.d.ts", "emp-tsconfig.json"],
8
- "maintainers": ["xuhongbin", "ckken", "doerme"],
7
+ "files": [
8
+ "dist",
9
+ "bin",
10
+ "resource",
11
+ "template",
12
+ "client.d.ts",
13
+ "emp-tsconfig.json"
14
+ ],
15
+ "maintainers": [
16
+ "xuhongbin",
17
+ "ckken",
18
+ "doerme"
19
+ ],
9
20
  "repository": {
10
21
  "type": "git",
11
22
  "url": "git+https://github.com/empjs/emp.git",
@@ -14,7 +25,11 @@
14
25
  "publishConfig": {
15
26
  "access": "public"
16
27
  },
17
- "keywords": ["rspack", "rust", "typescript"],
28
+ "keywords": [
29
+ "rspack",
30
+ "rust",
31
+ "typescript"
32
+ ],
18
33
  "bin": {
19
34
  "emp": "./bin/emp.js"
20
35
  },
@@ -33,12 +48,8 @@
33
48
  },
34
49
  "./emp-tsconfig.json": "./emp-tsconfig.json"
35
50
  },
36
- "scripts": {
37
- "dev": "tsup --watch --env.ENV dev",
38
- "build": "tsup --env.ENV prod"
39
- },
40
51
  "engines": {
41
- "node": ">=18.0.0"
52
+ "node": ">=16.0.0"
42
53
  },
43
54
  "author": "Ken",
44
55
  "devDependencies": {
@@ -57,7 +68,7 @@
57
68
  "tsup": "^8.0.2"
58
69
  },
59
70
  "dependencies": {
60
- "@module-federation/enhanced": "0.1.15",
71
+ "@module-federation/enhanced": "^0.1.15",
61
72
  "@rspack/core": "0.6.5",
62
73
  "@rspack/dev-server": "0.7.0",
63
74
  "@swc/helpers": "^0.5.11",
@@ -83,5 +94,9 @@
83
94
  "typescript-plugin-css-modules": "^5.1.0",
84
95
  "webpack-bundle-analyzer": "^4.10.2",
85
96
  "webpack-chain": "^6.5.1"
97
+ },
98
+ "scripts": {
99
+ "dev": "tsup --watch --env.ENV dev",
100
+ "build": "tsup --env.ENV prod"
86
101
  }
87
- }
102
+ }