@empjs/cli 3.0.2-beta.1 → 3.1.0-alpha.1

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,18 +1,18 @@
1
- "use strict";var ms=Object.create;var z=Object.defineProperty;var fs=Object.getOwnPropertyDescriptor;var hs=Object.getOwnPropertyNames;var us=Object.getPrototypeOf,gs=Object.prototype.hasOwnProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var M=(i,e)=>{for(var t in e)z(i,t,{get:e[t],enumerable:!0})},Je=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hs(e))!gs.call(i,r)&&r!==t&&z(i,r,{get:()=>e[r],enumerable:!(s=fs(e,r))||s.enumerable});return i};var l=(i,e,t)=>(t=i!=null?ms(us(i)):{},Je(e||!i||!i.__esModule?z(t,"default",{value:i,enumerable:!0}):t,i)),ds=i=>Je(z({},"__esModule",{value:!0}),i);var a=f(()=>{"use strict"});var b,ys,E,bs,vs,Cs,re,U,ws,xs,j,oe,Ss,ne,L,h,D=f(()=>{"use strict";a();b=l(require("chalk"),1),ys=b.default.hex("#1abc9c"),E=b.default.hex("#16a085"),bs=b.default.hex("#2ecc71"),vs=b.default.hex("#27ae60"),Cs=b.default.hex("#e74c3c"),re=b.default.hex("#c0392b"),U=b.default.hex("#f1c40f"),ws=b.default.hex("#f39c12"),xs=b.default.hex("#3498db"),j=b.default.hex("#2980b9"),oe=b.default.hex("#ecf0f1"),Ss=b.default.hex("#fd79a8"),ne=b.default.hex("#e84393"),L=b.default.hex("#7f8c8d"),h={lightGreen:ys,green:E,lightCyan:bs,cyan:vs,lightRed:Cs,red:re,yellow:U,orange:ws,lightBlue:xs,blue:j,white:oe,lightMagenta:Ss,magenta:ne,gray:L}});var ae,p,O=f(()=>{"use strict";a();D();ae=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
2
- `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
3
- `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
4
- `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
5
- `)};yellow=e=>{console.log(`${h.yellow(this.brandName)}${h.orange(` ${e} `)}
6
- `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
7
- `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
8
- `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
9
- `)}},p=new ae});var fe={};M(fe,{clearConsole:()=>le,deepAssign:()=>g,ensureArray:()=>Es,getLanIp:()=>I,getPkgVersion:()=>pe,importJsVm:()=>me,jsonFilter:()=>Os,timeFormat:()=>B,vCompare:()=>ce});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 _e,Ve,We,qe,I,pe,Es,Os,ce,B,me,C=f(()=>{"use strict";a();_e=require("address"),Ve=l(require("chalk"),1),We=require("default-gateway"),qe=l(require("fs-extra"),1),I=()=>{let{int:i}=(0,We.gateway4sync)();return(0,_e.ip)(i||"")||"127.0.0.1"},pe=i=>{try{let{version:e}=qe.default.readJSONSync(i);return e}catch{return}};Es=i=>Array.isArray(i)?i:[i],Os=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),ce=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let c=0;c<r;c++){let d=t.length>c?t[c]:0,v=isNaN(Number(d))?d.charCodeAt():Number(d),R=s.length>c?s[c]: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=>Ve.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`},me=i=>`data:text/javascript,${i}`});var he={};M(he,{chalk:()=>Xe.default,color:()=>h,glob:()=>$.glob,logger:()=>p,utils:()=>fe});var Xe,$,G=f(()=>{"use strict";a();Xe=l(require("chalk"),1),$=require("glob");D();C();O()});var Ke,Qe,Ze,Ps,Ye,et,ks,tt=f(()=>{"use strict";a();Ke=l(require("fs"),1),Qe=l(require("path"),1),Ze=l(require("jiti"),1);y();O();Ps=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],Ye=(0,Ze.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),et=async()=>ks(),ks=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of Ps){let t=Qe.default.resolve(o.root,e);if(Ke.default.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});async function H(i,e="localhost"){if(i!==$s&&(i<st||i>ue))throw new Error(`Port number must lie between ${st} and ${ue}`);let t=i,s=Ms(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=ue;)try{return await Ls(t,r)}catch(c){if(!n.has(c.code))throw c;t+=1}throw new Error("No available ports found")}var it,rt,st,ue,$s,Ms,js,Ls,ge=f(()=>{"use strict";a();it=l(require("net"),1),rt=l(require("os"),1),st=1024,ue=65535,$s=443,Ms=()=>{let i=rt.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},js=(i,e)=>new Promise((t,s)=>{let r=it.default.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),Ls=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await js(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});var de,ot,ye,T,be=f(()=>{"use strict";a();de=l(require("url"),1),ot=l(require("chalk"),1);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=I;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return de.default.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return de.default.format({protocol:t,hostname:e,port:ot.default.bold(s),pathname:r})}},T=new ye});var at,pt,lt,nt,Ds,Ts,ct,mt=f(()=>{"use strict";a();at=require("child_process"),pt=require("util");y();O();lt=(0,pt.promisify)(at.exec),nt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ds=async()=>{let i=process.env.BROWSER;if(!i||!nt.includes(i)){let{stdout:e}=await lt("ps cax");i=nt.find(t=>e.includes(t))}return i},Ts=async i=>{if(process.platform==="darwin")try{let t=await Ds();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await lt(s,{cwd:o.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},ct=Ts});var ve,J,Ce=f(()=>{"use strict";a();ge();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 H(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)}},J=new ve});var we,S,N=f(()=>{"use strict";a();we=l(require("fs/promises"),1);D();ge();be();O();mt();C();y();Ce();S=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";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?(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
10
- `)),this.sf.isOpenBrower&&ct(this.sf.url)}async setup(e,t){p.time(`[${e}]Setup`),await o.setup(e,t),o.debug.clearLog&&le(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}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([we.default.readFile(o.resource.key),we.default.readFile(o.resource.cert)])}async serverPort(){if(J.isADB)return;let{port:e,host:t}=this.sf,s=await H(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var _,ft=f(()=>{"use strict";a();y();_=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 c=r.match(this.exp)||[];c.length>0?(n.global=c[1],n.entry=c[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(c=>{if(!c)return;if(c.split("?")[0].endsWith(".css"))n.entry=c,n.type="css";else{let v=c.match(this.exp)||[];v.length>0?(n.global=v[1],n.entry=v[2],n.type="js"):(n.global="",n.entry=c,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 V,ht=f(()=>{"use strict";a();y();V=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)}}});var xe,ut,W,gt,q,Fs,X,Se=f(()=>{"use strict";a();xe=l(require("html-webpack-plugin"),1);C();y();ut="HtmlImportMapPlugin",W=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(ut,t=>{xe.default.getHooks(t).alterAssetTagGroups.tapAsync(ut,(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)})})}},gt="HtmlEmpShareLibPlugin",q=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(gt,t=>{let s=this.files;xe.default.getHooks(t).alterAssetTagGroups.tapAsync(gt,(r,n)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return n(null,r);s.js.map(c=>{r.headTags.push({tagName:"script",attributes:{src:c},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(c=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:c},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},Fs=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
11
- `);return me(i)},X=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,Fs(),{name:void 0}).apply(e)}}});var K,dt=f(()=>{"use strict";a();y();Ce();Se();K=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await J.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()}}});var yt,Ee,bt,vt=f(()=>{"use strict";a();yt=l(require("fs"),1);G();tt();C();N();ft();ht();dt();Ee=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new V;empShareLib=new _;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:this.store.isDev,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,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.store.empOptions.server?.http2&&(S.httpsType="h2",delete this.store.empOptions.server.http2),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"}},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(){p.time("[store][empConfig]SyncEmpOptions");let e=await et();if(!e||!yt.default.existsSync(e))return;let t=await Ye(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}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}},bt=new Ee});var Ct,Oe,wt,xt=f(()=>{"use strict";a();Ct=l(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?this.store.empConfig.build.devtool:!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 Ct.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})}},wt=new Oe});var Pe,St,Et=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={},{sass:t}=this.store.empConfig.css||{sass:{}};t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:require.resolve("sass-embedded"),e.api=t.api?t.api:"legacy",e.sourceMap=this.store.empConfig.build.sourcemap,t.sassOptions&&(e.sassOptions=t.sassOptions)),this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:{loader:require.resolve("sass-loader"),options:e}},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"}}}})}},St=new Pe});var w,Ot,ke,Pt,kt=f(()=>{"use strict";a();w=l(require("path"),1),Ot=l(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(Ot.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(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(){p.time("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,$.glob)([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${w.default.sep}`,"")),r.map(n=>{let c=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...c},w.default.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]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,$.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])}p.timeEnd("[store][empConfig]SetDefaultEntry")}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 ke});var $e,Me,$t,Mt=f(()=>{"use strict";a();$e=l(require("path"),1);C();Me=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.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=pe(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")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},sourceMapLoader:{test:/\.[tj]sx?$/,enforce:"pre",use:{sourceMapLoader:{loader:require.resolve("source-map-loader")}}}}}})}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"}}}})}},$t=new Me});var je,jt,F,Le,Lt,Dt=f(()=>{"use strict";a();je=l(require("fs"),1),jt=require("@module-federation/enhanced/rspack"),F=l(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(F.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(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=jt.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,[{}])}},Lt=new Le});var De,Tt,Ft=f(()=>{"use strict";a();xt();Et();kt();Mt();Dt();De=class{store;async setup(e){this.store=e;let t=[wt.setup(this.store),$t.setup(this.store),Lt.setup(this.store),Pt.setup(this.store),St.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()}},Tt=new De});var Rt,x,At,It,Te,o,y=f(()=>{"use strict";a();Rt=l(require("fs/promises"),1),x=l(require("path"),1),At=l(require("util"),1);O();C();vt();Ft();It=l(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=ce;deepAssign=g;getLanIp=I;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=bt,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new It.default,await Tt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}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},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")}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)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}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);Rt.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(p.link("[Compile Config]")),console.log(At.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 >= 16"]}}},o=new Te});function Us(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,c)=>{let d=t[c],v=n;return d&&(v=n.length<d?n+" ".repeat(d-n.length):n),`${r+v} `}," ");console.log(j.bold(s))}async function zt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>Gs(u.name)).map(zs);s.sort((u,A)=>u.size-A.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));Us(n,r);let c=0,d=0;s.forEach(u=>{let{sizeLabel:A}=u,{name:ps,folder:ls,gzipSizeLabel:cs}=u,Ue=(ls+P.default.sep+ps).length,Be=A.length;if(c+=u.size,d+=u.gzippedSize,Be<r){let ie=" ".repeat(r-Be);A+=ie}let He=L(u.folder+P.default.sep)+Bs(u.name);if(Ue<n){let ie=" ".repeat(n-Ue);He+=ie}p.info(` ${He} ${L(A)} ${cs}`)});let v=`${j.bold("Total size:")} ${Q(c)}`,R=`${j.bold("Gzipped size:")} ${Q(d)}`;p.info(`
12
- ${v}
13
- ${R}
14
- `),p.info(`${E("\u2713")} Ready in ${B(Number(e.time))}
15
- `)}function Z(i=0){p.info(`${E("\u2713")} Ready in ${B(Number(i))}`)}var Gt,P,Nt,Rs,As,Is,Gs,Ns,zs,Q,Bs,Y=f(()=>{"use strict";a();Gt=l(require("fs"),1),P=l(require("path"),1),Nt=require("gzip-size");D();y();O();C();Rs=/\.html$/,As=/\.(?:js|mjs|cjs|jsx)$/,Is=/\.css$/,Gs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Ns=i=>i>300*1e3?re:i>100*1e3?U:oe,zs=i=>{let e=i.name.split("?")[0],t=Q(i.size),s=P.default.basename(e),r=P.default.join(P.default.basename(o.empConfig.build.outDir),P.default.dirname(e)),n=Gt.default.readFileSync(P.default.join(o.empConfig.build.outDir,e)),c=n.length,d=(0,Nt.gzipSizeSync)(n),v=Ns(d)(Q(d));return{size:c,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=>As.test(i)?U(i):Is.test(i)?E(i):Rs.test(i)?j(i):ne(i)});var Ht={};M(Ht,{default:()=>Hs});var Ut,Bt,Fe,Hs,Jt=f(()=>{"use strict";a();Ut=require("@rspack/core"),Bt=require("@rspack/dev-server");Y();O();C();N();y();Fe=class extends S{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,Ut.rspack)(this.rspackDevConfig);if(!o.rsConfig.devServer){p.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 c=n?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Z(c.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()})}},Hs=new Fe});var _t,Vt,Wt,qt,Xt,ee,Kt=f(()=>{"use strict";a();_t=l(require("https"),1),Vt=l(require("compression"),1),Wt=l(require("cors"),1),qt=l(require("express"),1),Xt=l(require("spdy"),1);N();ee=class extends S{app;async init(){let e=(0,qt.default)();e.use((0,Vt.default)()),e.use((0,Wt.default)()),e.disable("x-powered-by"),e.get("*",(t,s)=>{t.next()}),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();(S.httpsType==="h2"?Xt.default:_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 Re={};M(Re,{ServeScript:()=>te,default:()=>Js});var Qt,Zt,Yt,es,te,Js,Ae=f(()=>{"use strict";a();Qt=l(require("fs"),1),Zt=l(require("fs/promises"),1),Yt=l(require("path"),1),es=l(require("express"),1);Y();O();y();Kt();te=class extends ee{timing=0;async run(){if(this.timing=Date.now(),!Qt.default.existsSync(o.outDir))return p.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(es.default.static(e));let t=await Zt.default.readFile(Yt.default.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()}},Js=new te});var ss={};M(ss,{default:()=>_s});var ts,Ie,_s,is=f(()=>{"use strict";a();ts=require("@rspack/core");Y();O();N();y();Ie=class extends S{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(Ae(),Re));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,ts.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await zt(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},_s=new Ie});var Ks={};M(Ks,{HtmlWebpackPlugin:()=>as.default,defineConfig:()=>Xs,dts:()=>os,empHelper:()=>he,rspack:()=>ns.rspack,runScript:()=>Ge,store:()=>o});module.exports=ds(Ks);a();var ns=require("@rspack/core"),as=l(require("html-webpack-plugin"),1);a();var rs=l(require("process"),1),k=require("commander");y();function Ge(){k.program.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),k.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Jt(),Ht));await e.setup("dev",i)}),k.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(is(),ss));await e.setup("build",i)}),k.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Ae(),Re));await e.setup("serve",i)}),k.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(i=>{}),k.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(i=>{}),k.program.parse(rs.default.argv)}a();var Ne=l(require("fs/promises"),1),se=l(require("path"),1);G();y();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]+?)['"]\)/,ze=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,$.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 Ne.default.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 c=n[1];if(!c.startsWith("."))return r;let d=se.default.resolve(se.default.dirname(e),c).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
1
+ "use strict";var Qt=Object.create;var z=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var es=Object.getPrototypeOf,ts=Object.prototype.hasOwnProperty;var h=(i,e)=>()=>(i&&(e=i(i=0)),e);var k=(i,e)=>{for(var t in e)z(i,t,{get:e[t],enumerable:!0})},Ge=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!ts.call(i,r)&&r!==t&&z(i,r,{get:()=>e[r],enumerable:!(s=Zt(e,r))||s.enumerable});return i};var l=(i,e,t)=>(t=i!=null?Qt(es(i)):{},Ge(e||!i||!i.__esModule?z(t,"default",{value:i,enumerable:!0}):t,i)),ss=i=>Ge(z({},"__esModule",{value:!0}),i);var a=h(()=>{"use strict"});var y,is,S,rs,os,ns,Q,N,as,ps,$,Z,ls,Y,M,f,L=h(()=>{"use strict";a();y=l(require("chalk"),1),is=y.default.hex("#1abc9c"),S=y.default.hex("#16a085"),rs=y.default.hex("#2ecc71"),os=y.default.hex("#27ae60"),ns=y.default.hex("#e74c3c"),Q=y.default.hex("#c0392b"),N=y.default.hex("#f1c40f"),as=y.default.hex("#f39c12"),ps=y.default.hex("#3498db"),$=y.default.hex("#2980b9"),Z=y.default.hex("#ecf0f1"),ls=y.default.hex("#fd79a8"),Y=y.default.hex("#e84393"),M=y.default.hex("#7f8c8d"),f={lightGreen:is,green:S,lightCyan:rs,cyan:os,lightRed:ns,red:Q,yellow:N,orange:as,lightBlue:ps,blue:$,white:Z,lightMagenta:ls,magenta:Y,gray:M}});var ee,p,O=h(()=>{"use strict";a();L();ee=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setLogLevel(e){this.logLevel=e}setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=f.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${f.lightBlue(this.brandName)}${f.blue(` ${e} `)}
2
+ `)};cyan=e=>{console.log(`${f.lightCyan(this.brandName)}${f.cyan(` ${e} `)}
3
+ `)};magenta=e=>{console.log(`${f.lightMagenta(this.brandName)}${f.magenta(` ${e} `)}
4
+ `)};green=e=>{console.log(`${f.lightGreen(this.brandName)}${f.green(` ${e} `)}
5
+ `)};yellow=e=>{console.log(`${f.yellow(this.brandName)}${f.orange(` ${e} `)}
6
+ `)};red=e=>{console.log(`${f.lightRed(this.brandName)}${f.red(` ${e} `)}
7
+ `)};sysError=e=>{console.log(`${f.lightRed(" System Error Tips ")}${f.red(` ${e} `)}
8
+ `)};link=e=>f.blue(e);title=e=>{console.log(`${this.fullName}${f.yellow.underline(`${e}`)}
9
+ `)}},p=new ee});var ne={};k(ne,{clearConsole:()=>se,deepAssign:()=>d,ensureArray:()=>cs,getLanIp:()=>G,getPkgVersion:()=>te,importJsVm:()=>oe,jsonFilter:()=>ms,timeFormat:()=>re,vCompare:()=>ie});function se(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function d(i,...e){for(let t of e)for(let s in t){let r=t[s],o=i[s];if(Object(r)==r&&Object(o)===o){i[s]=d(o,r);continue}i[s]=t[s]}return i}var Ie,ze,Ne,Ue,G,te,cs,ms,ie,re,oe,x=h(()=>{"use strict";a();Ie=require("address"),ze=l(require("chalk"),1),Ne=require("default-gateway"),Ue=l(require("fs-extra"),1),G=()=>{let{int:i}=(0,Ne.gateway4sync)();return(0,Ie.ip)(i||"")||"127.0.0.1"},te=i=>{try{let{version:e}=Ue.default.readJSONSync(i);return e}catch{return}};cs=i=>Array.isArray(i)?i:[i],ms=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),ie=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),o=0;for(let c=0;c<r;c++){let g=t.length>c?t[c]:0,b=isNaN(Number(g))?g.charCodeAt():Number(g),A=s.length>c?s[c]:0,u=isNaN(Number(A))?A.charCodeAt():Number(A);if(b<u){o=-1;break}else if(b>u){o=1;break}}return o},re=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`},oe=i=>`data:text/javascript,${i}`});var ae={};k(ae,{chalk:()=>Be.default,color:()=>f,glob:()=>P.glob,logger:()=>p,utils:()=>ne});var Be,P,I=h(()=>{"use strict";a();Be=l(require("chalk"),1),P=require("glob");L();x();O()});var He,Je,_e,hs,We,Ve,fs,qe=h(()=>{"use strict";a();He=l(require("fs"),1),Je=l(require("path"),1),_e=l(require("jiti"),1);v();O();hs=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],We=(0,_e.default)(__filename,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ve=async()=>fs(),fs=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of hs){let t=Je.default.resolve(n.root,e);if(He.default.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});async function U(i,e="localhost"){if(i!==us&&(i<Xe||i>pe))throw new Error(`Port number must lie between ${Xe} and ${pe}`);let t=i,s=gs(),r;e&&!s.has(e)?r=new Set([e]):r=s;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=pe;)try{return await ys(t,r)}catch(c){if(!o.has(c.code))throw c;t+=1}throw new Error("No available ports found")}var Ke,Qe,Xe,pe,us,gs,ds,ys,le=h(()=>{"use strict";a();Ke=l(require("net"),1),Qe=l(require("os"),1),Xe=1024,pe=65535,us=443,gs=()=>{let i=Qe.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},ds=(i,e)=>new Promise((t,s)=>{let r=Ke.default.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),ys=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await ds(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});var ce,Ze,me,j,he=h(()=>{"use strict";a();ce=l(require("url"),1),Ze=l(require("chalk"),1);L();x();me=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:M("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=G;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return ce.default.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return ce.default.format({protocol:t,hostname:e,port:Ze.default.bold(s),pathname:r})}},j=new me});var et,tt,st,Ye,bs,vs,it,rt=h(()=>{"use strict";a();et=require("child_process"),tt=require("util");v();O();st=(0,tt.promisify)(et.exec),Ye=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],bs=async()=>{let i=process.env.BROWSER;if(!i||!Ye.includes(i)){let{stdout:e}=await st("ps cax");i=Ye.find(t=>e.includes(t))}return i},vs=async i=>{if(process.platform==="darwin")try{let t=await bs();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await st(s,{cwd:n.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},it=vs});var fe,T,ue=h(()=>{"use strict";a();fe=l(require("fs/promises"),1);L();le();he();O();rt();x();T=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";store;async adaptServer(){let{store:e}=this;this.sf.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!e.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=e.empConfig.server.host?e.empConfig.server.host:this.sf.host,this.sf.port=e.empConfig.server.port,await this.serverPort(),j.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=j.prettyPrintUrl("localhost")):(this.sf.urls=j.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${S("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${S("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${S("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${S("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
10
+ `)),this.sf.isOpenBrower&&it(this.sf.url)}async setup(e,t,s){p.time(`[${e}]Setup`),this.store=s,await s.setup(e,t),s.debug.clearLog&&se(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{store:e}=this,{server:t,https:s,http2:r}=e.empConfig.server||{};return t==="https"||typeof t=="object"&&t.type==="https"||s===!0||r===!0}getcert(){let{store:e}=this;return Promise.all([fe.default.readFile(e.resource.key),fe.default.readFile(e.resource.cert)])}async serverPort(){let{store:e}=this;if(e.autoDevBase.adb)return;let{port:t,host:s}=this.sf,r=await U(t,s);r!==t&&(this.sf.port=r,e.rsConfig.devServer?.port&&(e.rsConfig.devServer.port=r))}}});var B,ot=h(()=>{"use strict";a();v();B=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;config;importMap={imports:{}};isEmpshare=!1;async setup(){this.config=n.empConfig.empShare,this.isEmpshare=!!n.empConfig.empShare.name,n.empConfig.empShare.fastMode&&n.empConfig.empShareFastMode.setup(),this.config.shareLib&&this.setShareLib(),this.prepareEsm()}get useImportMap(){return this.config.useImportMap&&n.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(n.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 o={};if(o.module=s,typeof r=="string"){let c=r.match(this.exp)||[];c.length>0?(o.global=c[1],o.entry=c[2],o.type="js",t.push(o),o={}):(o.global="",o.entry=r,o.type="js",t.push(o),o={})}else Array.isArray(r)?r.map(c=>{if(!c)return;if(c.split("?")[0].endsWith(".css"))o.entry=c,o.type="css";else{let b=c.match(this.exp)||[];b.length>0?(o.global=b[1],o.entry=b[2],o.type="js"):(o.global="",o.entry=c,o.type="js")}t.push(o),o={}}):typeof r=="object"&&r.entry&&(o.entry=r.entry,o.global=r.global,o.type=r.type,t.push(o),o={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global?this.externals[s.module]=s.global:n.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&&!n.empConfig.isESM&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});var H,nt=h(()=>{"use strict";a();v();H=class{fastMode={runtimeHost:"",runtimeLib:"",externals:{},globalVal:"EmpShareLib",framework:"react"};externalMF={"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"};externalReact={react:"React","react-dom":"ReactDOM","react-router-dom":"ReactRouterDOM"};externals={};getRuntimeLib(e){return`${e}/runtime${n.mode==="development"?".development":""}.umd.js`}setup(){this.fastMode=n.deepAssign(this.fastMode,n.empConfig.empShare.fastMode),this.injectLib(),this.setExternals()}injectLib(){let{runtimeHost:e,runtimeLib:t}=this.fastMode;if(e||t){let s=t||this.getRuntimeLib(e);n.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=n.deepAssign(this.externals,this.fastMode.externals)),n.empConfig.empShareLib.externals=n.deepAssign(n.empConfig.empShareLib.externals,this.externals)}}});var ge,at,pt=h(()=>{"use strict";a();le();he();x();v();ge=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=n.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!n.empOptions.autoDevBase&&n.mode==="development"&&!this.isHttpBase,n.autoDevBase.adb=this.isADB,!this.isADB)return;let{server:e,https:t}=n.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0,n.autoDevBase.https=this.isHttps;let s=j.getLanIp(),r=this.isHttps?"https":"http",o=n.empOptions.server?.port||8e3;o=await U(o,s),n.empOptions.base=`${r}://${s}:${o}/`,n.empOptions.server=d({port:o,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${o}/ws`}},n.empOptions.server)}},at=new ge});var de,lt,J,ct,_,Cs,W,ye=h(()=>{"use strict";a();de=l(require("html-webpack-plugin"),1);x();v();lt="HtmlImportMapPlugin",J=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(lt,t=>{de.default.getHooks(t).alterAssetTagGroups.tapAsync(lt,(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)})})}},ct="HtmlEmpShareLibPlugin",_=class{chunk;files;constructor(e,t){this.files=d({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(ct,t=>{let s=this.files;de.default.getHooks(t).alterAssetTagGroups.tapAsync(ct,(r,o)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return o(null,r);s.js.map(c=>{r.headTags.push({tagName:"script",attributes:{src:c},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(c=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:c},voidTag:!1,meta:{plugin:void 0}})}),o(null,r)})})}},Cs=()=>{let i=[`import 'core-js/${n.empConfig.build.coreJsFeatures}'`].join(`
11
+ `);return oe(i)},W=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,Cs(),{name:void 0}).apply(e)}}});var V,mt=h(()=>{"use strict";a();v();pt();ye();V=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await at.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){n.empConfig.build.polyfill==="entry"&&n.chain.plugin("empPolyfill").use(W),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 ht,be,ft,ut=h(()=>{"use strict";a();ht=l(require("fs"),1);I();qe();x();ue();ot();nt();mt();be=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},d(e,t)}empShareFastMode=new H;empShareLib=new B;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,showHMRTime:!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:this.store.isDev,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,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.store.empOptions.server?.http2&&(T.httpsType="h2",delete this.store.empOptions.server.http2),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"}},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,o={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&&(o.clean=!1),this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 d({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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Ve();if(!e||!ht.default.existsSync(e))return;let t=await We(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}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 be});var gt,ve,dt,yt=h(()=>{"use strict";a();gt=l(require("fs-extra"),1),ve=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?this.store.empConfig.build.devtool:!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 gt.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})}},dt=new ve});var Ce,bt,vt=h(()=>{"use strict";a();Ce=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={},{sass:t}=this.store.empConfig.css||{sass:{}};t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:require.resolve("sass-embedded"),e.api=t.api?t.api:"legacy",e.sourceMap=this.store.empConfig.build.sourcemap,t.sassOptions&&(e.sassOptions=t.sassOptions)),this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:{loader:require.resolve("sass-loader"),options:e}},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"}}}})}},bt=new Ce});var C,Ct,we,wt,xt=h(()=>{"use strict";a();C=l(require("path"),1),Ct=l(require("html-webpack-plugin"),1);I();x();ye();we=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(C.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${C.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(C.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(C.default.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(C.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[s];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`html-plugin-${t}`).use(Ct.default,[e]),this.store.empConfig.empShareLib&&(e.files=d(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(_,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(J,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){p.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=C.default.join(this.store.appSrc,e),s=C.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,P.glob)([s],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${C.default.sep}`,"")),r.map(o=>{let c=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...c},C.default.join(t,o))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=C.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,P.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let s=C.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])}p.timeEnd("[store][empConfig]SetDefaultEntry")}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)}},wt=new we});var xe,Se,St,Et=h(()=>{"use strict";a();xe=l(require("path"),1);x();Se=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.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:d(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",xe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=te(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=xe.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")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},sourceMapLoader:{test:/\.[tj]sx?$/,enforce:"pre",use:{sourceMapLoader:{loader:require.resolve("source-map-loader")}}}}}})}async files(){this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},St=new Se});var Ee,Ot,D,Oe,Pt,kt=h(()=>{"use strict";a();Ee=l(require("fs"),1),Ot=require("@module-federation/enhanced/rspack"),D=l(require("@rspack/core"),1),Oe=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(D.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Ee.default.existsSync(e)&&Ee.default.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(D.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(D.default.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=Ot.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(D.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(D.default.SwcCssMinimizerRspackPlugin,[{}])}},Pt=new Oe});var Pe,$t,Mt=h(()=>{"use strict";a();yt();vt();xt();Et();kt();Pe=class{store;async setup(e){this.store=e;let t=[dt.setup(this.store),St.setup(this.store),Pt.setup(this.store),wt.setup(this.store),bt.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()}},$t=new Pe});var Lt,w,jt,Tt,ke,n,v=h(()=>{"use strict";a();Lt=l(require("fs/promises"),1),w=l(require("path"),1),jt=l(require("util"),1);O();x();ut();Mt();Tt=l(require("webpack-chain"),1),ke=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=w.default.resolve(__dirname,__filename).replace(`${w.default.sep}dist${w.default.sep}index.js`,"");empSource=w.default.resolve(this.empRoot,"dist");resolve=e=>w.default.isAbsolute(e)?e:w.default.resolve(this.root,e);empResolve=e=>w.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=ie;deepAssign=d;getLanIp=G;entries={};debug;autoDevBase={adb:!1,https:!1};logger=p;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=ft,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Tt.default,await $t.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}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},this.resource.dir=w.default.join(this.empRoot,"resource"),this.resource.cert=w.default.join(this.resource.dir,"emp.cert"),this.resource.key=w.default.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=w.default.join(this.root,this.debug.showRsconfig);Lt.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"?d(e,this.debug.showRsconfig):e;console.log(p.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 >= 16"]}}},n=new ke});var Dt={};k(Dt,{default:()=>Ft.devServer});var Ft,At=h(()=>{"use strict";a();Ft=require("@empjs/server")});function ks(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,o,c)=>{let g=t[c],b=o;return g&&(b=o.length<g?o+" ".repeat(g-o.length):o),`${r+b} `}," ");console.log($.bold(s))}async function It(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>Es(u.name)).map(Ps);s.sort((u,R)=>u.size-R.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),o=Math.max(...s.map(u=>(u.folder+E.default.sep+u.name).length));ks(o,r);let c=0,g=0;s.forEach(u=>{let{sizeLabel:R}=u,{name:qt,folder:Xt,gzipSizeLabel:Kt}=u,Fe=(Xt+E.default.sep+qt).length,Ae=R.length;if(c+=u.size,g+=u.gzippedSize,Ae<r){let K=" ".repeat(r-Ae);R+=K}let Re=M(u.folder+E.default.sep)+$s(u.name);if(Fe<o){let K=" ".repeat(o-Fe);Re+=K}p.info(` ${Re} ${M(R)} ${Kt}`)});let b=`${$.bold("Total size:")} ${q(c)}`,A=`${$.bold("Gzipped size:")} ${q(g)}`;p.info(`
12
+ ${b}
13
+ ${A}
14
+ `),p.info(`${S("\u2713")} Ready in ${re(Number(e.time))}
15
+ `)}var Rt,E,Gt,ws,xs,Ss,Es,Os,Ps,q,$s,zt=h(()=>{"use strict";a();Rt=l(require("fs"),1),E=l(require("path"),1),Gt=require("gzip-size");L();v();O();x();ws=/\.html$/,xs=/\.(?:js|mjs|cjs|jsx)$/,Ss=/\.css$/,Es=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Os=i=>i>300*1e3?Q:i>100*1e3?N:Z,Ps=i=>{let e=i.name.split("?")[0],t=q(i.size),s=E.default.basename(e),r=E.default.join(E.default.basename(n.empConfig.build.outDir),E.default.dirname(e)),o=Rt.default.readFileSync(E.default.join(n.empConfig.build.outDir,e)),c=o.length,g=(0,Gt.gzipSizeSync)(o),b=Os(g)(q(g));return{size:c,folder:r,name:s,gzippedSize:g,sizeLabel:t,gzipSizeLabel:b}};q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},$s=i=>xs.test(i)?N(i):Ss.test(i)?S(i):ws.test(i)?$(i):Y(i)});var $e={};k($e,{default:()=>Nt.prodServer});var Nt,Me=h(()=>{"use strict";a();Nt=require("@empjs/server")});var Bt={};k(Bt,{default:()=>Ms});var Ut,Le,Ms,Ht=h(()=>{"use strict";a();Ut=require("@rspack/core");zt();O();ue();v();Le=class extends T{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",n.cliOptions,n)}async run(){await n.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!n.cliOptions.watch,this.isuseServe=!!n.cliOptions.serve,this.rspackConfig=n.rsConfig,this.isWatchMode&&this.watchMode(),(0,Ut.rspack)(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await It(t),this.startServe(),await n.empConfig.lifeCycle.afterBulid()})}},Ms=new Le});var Fs={};k(Fs,{HtmlWebpackPlugin:()=>Vt.default,defineConfig:()=>Ds,dts:()=>_t,empHelper:()=>ae,rspack:()=>Wt.rspack,runScript:()=>je,store:()=>n});module.exports=ss(Fs);a();var Wt=require("@rspack/core"),Vt=l(require("html-webpack-plugin"),1);a();var Jt=l(require("process"),1),F=require("commander");v();function je(){F.program.version(n.empPkg.version,"-v, --version").usage("<command> [options]"),F.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(At(),Dt));await e.setup("dev",i,n)}),F.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Ht(),Bt));await e.setup("build",i,n)}),F.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Me(),$e));await e.setup("serve",i,n)}),F.program.parse(Jt.default.argv)}a();var Te=l(require("fs/promises"),1),X=l(require("path"),1);I();v();var Ls=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,js=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Ts=/import\(['"]([^;\n]+?)['"]\)/,De=class{list=[];outDir=n.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,P.glob)([`${n.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=n.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 Te.default.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Ls,r=>{let o=r.match(js);if(o||(o=r.match(Ts)),o&&o[1]){let c=o[1];if(!c.startsWith("."))return r;let g=X.default.resolve(X.default.dirname(e),c).replace(this.outDir,this.aliasName);return r.replace(o[1],g)}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 Ne.default.writeFile(se.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},os=new ze;y();G();function Xs(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 Te.default.writeFile(X.default.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},_t=new De;v();I();function Ds(i){return i}0&&(module.exports={HtmlWebpackPlugin,defineConfig,dts,empHelper,rspack,runScript,store});
18
18
  if (module.exports.default) module.exports = module.exports.default;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { InspectOptions } from 'node:util';
2
2
  import * as _rspack_core from '@rspack/core';
3
- import { Configuration, Output, RspackOptions, Externals, Resolve, SwcJsMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
3
+ import { Configuration, Output, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
4
4
  export { rspack } from '@rspack/core';
5
- import { Configuration as Configuration$1 } from '@rspack/dev-server';
6
5
  import { Options } from 'sass-embedded';
7
6
  import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
8
7
  import WPChain from 'webpack-chain';
@@ -97,6 +96,32 @@ declare class LifeCycle {
97
96
  afterServe(): Promise<void>;
98
97
  }
99
98
 
99
+ type LoggerType$1 = 'debug' | 'info' | 'warn' | 'error';
100
+ declare class Logger {
101
+ brandName: string;
102
+ fullName: string;
103
+ logLevel: string;
104
+ isLogTime: boolean;
105
+ setLogLevel(lv: LoggerType$1): void;
106
+ setup({ brandName, logLevel, fullName }: any): void;
107
+ time: (...args: any[]) => false | void;
108
+ timeEnd: (...args: any[]) => false | void;
109
+ debug: (...args: any[]) => false | void;
110
+ info: (...args: any[]) => false | void;
111
+ warn: (...args: any[]) => false | void;
112
+ error: (...args: any[]) => false | void;
113
+ blue: (msg: string) => void;
114
+ cyan: (msg: string) => void;
115
+ magenta: (msg: string) => void;
116
+ green: (msg: string) => void;
117
+ yellow: (msg: string) => void;
118
+ red: (msg: string) => void;
119
+ sysError: (msg: string) => void;
120
+ link: (msg: string) => string;
121
+ title: (msg: string) => void;
122
+ }
123
+ declare const _default$3: Logger;
124
+
100
125
  declare const getLanIp: () => string;
101
126
  declare const getPkgVersion: (pkgPath: string) => any;
102
127
  declare function clearConsole(): void;
@@ -283,6 +308,11 @@ declare class GlobalStore {
283
308
  [chunkName: string]: RspackOptions['entry'];
284
309
  };
285
310
  debug: EmpConfig['debug'];
311
+ autoDevBase: {
312
+ adb: boolean;
313
+ https: boolean;
314
+ };
315
+ logger: Logger;
286
316
  setup(mode: string, cliOptions: any): Promise<void>;
287
317
  /**
288
318
  * 初始化 基础变量
@@ -313,7 +343,7 @@ declare class GlobalStore {
313
343
  node: string[];
314
344
  };
315
345
  }
316
- declare const _default$3: GlobalStore;
346
+ declare const _default$2: GlobalStore;
317
347
 
318
348
  type EMP3PluginType = {
319
349
  name: string;
@@ -328,6 +358,7 @@ type DebugType = {
328
358
  progress?: boolean;
329
359
  showRsconfig?: boolean | string | InspectOptions;
330
360
  showPerformance?: boolean;
361
+ showHMRTime?: boolean;
331
362
  rspackCache?: boolean;
332
363
  newTreeshaking?: boolean;
333
364
  /**
@@ -336,7 +367,7 @@ type DebugType = {
336
367
  */
337
368
  infrastructureLogging?: Configuration['infrastructureLogging'];
338
369
  };
339
- type ServerType = Configuration$1 & {
370
+ type ServerType = DevServer & {
340
371
  /**
341
372
  * 访问 host
342
373
  * @default '0.0.0.0'
@@ -351,12 +382,12 @@ type ServerType = Configuration$1 & {
351
382
  * 自动打开
352
383
  * @default false
353
384
  */
354
- open?: Configuration$1['open'];
385
+ open?: DevServer['open'];
355
386
  /**
356
387
  * 热重载
357
388
  * @default true
358
389
  */
359
- hot?: Configuration$1['hot'];
390
+ hot?: DevServer['hot'];
360
391
  };
361
392
  type BuildType = {
362
393
  /**
@@ -674,9 +705,9 @@ declare class DTSBundle {
674
705
  mod: string;
675
706
  }[]): Promise<void>;
676
707
  }
677
- declare const _default$2: DTSBundle;
708
+ declare const _default$1: DTSBundle;
678
709
 
679
- declare const _default$1: {
710
+ declare const _default: {
680
711
  lightGreen: chalk.ChalkInstance;
681
712
  green: chalk.ChalkInstance;
682
713
  lightCyan: chalk.ChalkInstance;
@@ -693,38 +724,14 @@ declare const _default$1: {
693
724
  gray: chalk.ChalkInstance;
694
725
  };
695
726
 
696
- declare class Logger {
697
- brandName: string;
698
- fullName: string;
699
- logLevel: string;
700
- isLogTime: boolean;
701
- setup({ brandName, logLevel, fullName }: any): void;
702
- time: (...args: any[]) => false | void;
703
- timeEnd: (...args: any[]) => false | void;
704
- debug: (...args: any[]) => false | void;
705
- info: (...args: any[]) => false | void;
706
- warn: (...args: any[]) => false | void;
707
- error: (...args: any[]) => false | void;
708
- blue: (msg: string) => void;
709
- cyan: (msg: string) => void;
710
- magenta: (msg: string) => void;
711
- green: (msg: string) => void;
712
- yellow: (msg: string) => void;
713
- red: (msg: string) => void;
714
- sysError: (msg: string) => void;
715
- link: (msg: string) => string;
716
- title: (msg: string) => void;
717
- }
718
- declare const _default: Logger;
719
-
720
727
  declare const index_glob: typeof glob;
721
728
  declare const index_utils: typeof utils;
722
729
  declare namespace index {
723
- export { chalk__default as chalk, _default$1 as color, index_glob as glob, _default as logger, index_utils as utils };
730
+ export { chalk__default as chalk, _default as color, index_glob as glob, _default$3 as logger, index_utils as utils };
724
731
  }
725
732
 
726
733
  type EMPConfigFn = (store: GlobalStore) => EmpOptions | Promise<EmpOptions>;
727
734
  type EMPConfigExport = EmpOptions | EMPConfigFn;
728
735
  declare function defineConfig(config: EMPConfigExport): EMPConfigExport;
729
736
 
730
- export { type EMP3PluginFnType, type EMP3PluginType, type EMPConfigExport, type EMPConfigFn, type EmpOptions, GlobalStore, defineConfig, _default$2 as dts, index as empHelper, runScript, _default$3 as store };
737
+ export { type EMP3PluginFnType, type EMP3PluginType, type EMPConfigExport, type EMPConfigFn, type EmpOptions, GlobalStore, defineConfig, _default$1 as dts, index as empHelper, runScript, _default$2 as store };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { InspectOptions } from 'node:util';
2
2
  import * as _rspack_core from '@rspack/core';
3
- import { Configuration, Output, RspackOptions, Externals, Resolve, SwcJsMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
3
+ import { Configuration, Output, RspackOptions, Externals, Resolve, DevServer, SwcJsMinimizerRspackPluginOptions, HtmlRspackPluginOptions, RuleSetRule } from '@rspack/core';
4
4
  export { rspack } from '@rspack/core';
5
- import { Configuration as Configuration$1 } from '@rspack/dev-server';
6
5
  import { Options } from 'sass-embedded';
7
6
  import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
8
7
  import WPChain from 'webpack-chain';
@@ -97,6 +96,32 @@ declare class LifeCycle {
97
96
  afterServe(): Promise<void>;
98
97
  }
99
98
 
99
+ type LoggerType$1 = 'debug' | 'info' | 'warn' | 'error';
100
+ declare class Logger {
101
+ brandName: string;
102
+ fullName: string;
103
+ logLevel: string;
104
+ isLogTime: boolean;
105
+ setLogLevel(lv: LoggerType$1): void;
106
+ setup({ brandName, logLevel, fullName }: any): void;
107
+ time: (...args: any[]) => false | void;
108
+ timeEnd: (...args: any[]) => false | void;
109
+ debug: (...args: any[]) => false | void;
110
+ info: (...args: any[]) => false | void;
111
+ warn: (...args: any[]) => false | void;
112
+ error: (...args: any[]) => false | void;
113
+ blue: (msg: string) => void;
114
+ cyan: (msg: string) => void;
115
+ magenta: (msg: string) => void;
116
+ green: (msg: string) => void;
117
+ yellow: (msg: string) => void;
118
+ red: (msg: string) => void;
119
+ sysError: (msg: string) => void;
120
+ link: (msg: string) => string;
121
+ title: (msg: string) => void;
122
+ }
123
+ declare const _default$3: Logger;
124
+
100
125
  declare const getLanIp: () => string;
101
126
  declare const getPkgVersion: (pkgPath: string) => any;
102
127
  declare function clearConsole(): void;
@@ -283,6 +308,11 @@ declare class GlobalStore {
283
308
  [chunkName: string]: RspackOptions['entry'];
284
309
  };
285
310
  debug: EmpConfig['debug'];
311
+ autoDevBase: {
312
+ adb: boolean;
313
+ https: boolean;
314
+ };
315
+ logger: Logger;
286
316
  setup(mode: string, cliOptions: any): Promise<void>;
287
317
  /**
288
318
  * 初始化 基础变量
@@ -313,7 +343,7 @@ declare class GlobalStore {
313
343
  node: string[];
314
344
  };
315
345
  }
316
- declare const _default$3: GlobalStore;
346
+ declare const _default$2: GlobalStore;
317
347
 
318
348
  type EMP3PluginType = {
319
349
  name: string;
@@ -328,6 +358,7 @@ type DebugType = {
328
358
  progress?: boolean;
329
359
  showRsconfig?: boolean | string | InspectOptions;
330
360
  showPerformance?: boolean;
361
+ showHMRTime?: boolean;
331
362
  rspackCache?: boolean;
332
363
  newTreeshaking?: boolean;
333
364
  /**
@@ -336,7 +367,7 @@ type DebugType = {
336
367
  */
337
368
  infrastructureLogging?: Configuration['infrastructureLogging'];
338
369
  };
339
- type ServerType = Configuration$1 & {
370
+ type ServerType = DevServer & {
340
371
  /**
341
372
  * 访问 host
342
373
  * @default '0.0.0.0'
@@ -351,12 +382,12 @@ type ServerType = Configuration$1 & {
351
382
  * 自动打开
352
383
  * @default false
353
384
  */
354
- open?: Configuration$1['open'];
385
+ open?: DevServer['open'];
355
386
  /**
356
387
  * 热重载
357
388
  * @default true
358
389
  */
359
- hot?: Configuration$1['hot'];
390
+ hot?: DevServer['hot'];
360
391
  };
361
392
  type BuildType = {
362
393
  /**
@@ -674,9 +705,9 @@ declare class DTSBundle {
674
705
  mod: string;
675
706
  }[]): Promise<void>;
676
707
  }
677
- declare const _default$2: DTSBundle;
708
+ declare const _default$1: DTSBundle;
678
709
 
679
- declare const _default$1: {
710
+ declare const _default: {
680
711
  lightGreen: chalk.ChalkInstance;
681
712
  green: chalk.ChalkInstance;
682
713
  lightCyan: chalk.ChalkInstance;
@@ -693,38 +724,14 @@ declare const _default$1: {
693
724
  gray: chalk.ChalkInstance;
694
725
  };
695
726
 
696
- declare class Logger {
697
- brandName: string;
698
- fullName: string;
699
- logLevel: string;
700
- isLogTime: boolean;
701
- setup({ brandName, logLevel, fullName }: any): void;
702
- time: (...args: any[]) => false | void;
703
- timeEnd: (...args: any[]) => false | void;
704
- debug: (...args: any[]) => false | void;
705
- info: (...args: any[]) => false | void;
706
- warn: (...args: any[]) => false | void;
707
- error: (...args: any[]) => false | void;
708
- blue: (msg: string) => void;
709
- cyan: (msg: string) => void;
710
- magenta: (msg: string) => void;
711
- green: (msg: string) => void;
712
- yellow: (msg: string) => void;
713
- red: (msg: string) => void;
714
- sysError: (msg: string) => void;
715
- link: (msg: string) => string;
716
- title: (msg: string) => void;
717
- }
718
- declare const _default: Logger;
719
-
720
727
  declare const index_glob: typeof glob;
721
728
  declare const index_utils: typeof utils;
722
729
  declare namespace index {
723
- export { chalk__default as chalk, _default$1 as color, index_glob as glob, _default as logger, index_utils as utils };
730
+ export { chalk__default as chalk, _default as color, index_glob as glob, _default$3 as logger, index_utils as utils };
724
731
  }
725
732
 
726
733
  type EMPConfigFn = (store: GlobalStore) => EmpOptions | Promise<EmpOptions>;
727
734
  type EMPConfigExport = EmpOptions | EMPConfigFn;
728
735
  declare function defineConfig(config: EMPConfigExport): EMPConfigExport;
729
736
 
730
- export { type EMP3PluginFnType, type EMP3PluginType, type EMPConfigExport, type EMPConfigFn, type EmpOptions, GlobalStore, defineConfig, _default$2 as dts, index as empHelper, runScript, _default$3 as store };
737
+ export { type EMP3PluginFnType, type EMP3PluginType, type EMPConfigExport, type EMPConfigFn, type EmpOptions, GlobalStore, defineConfig, _default$1 as dts, index as empHelper, runScript, _default$2 as store };
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
- var kt=Object.defineProperty;var w=(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)kt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as $t}from"url";import Mt from"path";var Ae,jt,m,c,a=f(()=>{"use strict";Ae=()=>$t(import.meta.url),jt=()=>Mt.dirname(Ae()),m=jt(),c=Ae()});import b from"chalk";var Lt,O,Dt,Tt,Ft,ie,B,Rt,At,M,re,Gt,oe,j,h,L=f(()=>{"use strict";a();Lt=b.hex("#1abc9c"),O=b.hex("#16a085"),Dt=b.hex("#2ecc71"),Tt=b.hex("#27ae60"),Ft=b.hex("#e74c3c"),ie=b.hex("#c0392b"),B=b.hex("#f1c40f"),Rt=b.hex("#f39c12"),At=b.hex("#3498db"),M=b.hex("#2980b9"),re=b.hex("#ecf0f1"),Gt=b.hex("#fd79a8"),oe=b.hex("#e84393"),j=b.hex("#7f8c8d"),h={lightGreen:Lt,green:O,lightCyan:Dt,cyan:Tt,lightRed:Ft,red:ie,yellow:B,orange:Rt,lightBlue:At,blue:M,white:re,lightMagenta:Gt,magenta:oe,gray:j}});var ne,p,P=f(()=>{"use strict";a();L();ne=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
3
- `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
4
- `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
5
- `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
6
- `)};yellow=e=>{console.log(`${h.yellow(this.brandName)}${h.orange(` ${e} `)}
7
- `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
8
- `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
9
- `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
10
- `)}},p=new ne});var me={};A(me,{clearConsole:()=>pe,deepAssign:()=>g,ensureArray:()=>Ht,getLanIp:()=>G,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>Ut,timeFormat:()=>H,vCompare:()=>le});import{ip as It}from"address";import Nt from"chalk";import{gateway4sync as zt}from"default-gateway";import Bt from"fs-extra";function pe(){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 G,ae,Ht,Ut,le,H,ce,C=f(()=>{"use strict";a();G=()=>{let{int:i}=zt();return It(i||"")||"127.0.0.1"},ae=i=>{try{let{version:e}=Bt.readJSONSync(i);return e}catch{return}};Ht=i=>Array.isArray(i)?i:[i],Ut=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),le=(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},H=i=>{i=i/1e3;let e=s=>Nt.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},ce=i=>`data:text/javascript,${i}`});var Ge={};A(Ge,{chalk:()=>Jt,color:()=>h,glob:()=>D,logger:()=>p,utils:()=>me});import Jt from"chalk";import{glob as D}from"glob";var I=f(()=>{"use strict";a();L();C();P()});import _t from"fs";import Vt from"path";import Wt from"jiti";var qt,Ie,Ne,Xt,ze=f(()=>{"use strict";a();y();P();qt=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],Ie=Wt(c,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Ne=async()=>Xt(),Xt=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of qt){let t=Vt.resolve(o.root,e);if(_t.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});import Kt from"net";import Qt from"os";async function U(i,e="localhost"){if(i!==Zt&&(i<Be||i>fe))throw new Error(`Port number must lie between ${Be} and ${fe}`);let t=i,s=Yt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=fe;)try{return await ts(t,r)}catch(l){if(!n.has(l.code))throw l;t+=1}throw new Error("No available ports found")}var Be,fe,Zt,Yt,es,ts,he=f(()=>{"use strict";a();Be=1024,fe=65535,Zt=443,Yt=()=>{let i=Qt.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},es=(i,e)=>new Promise((t,s)=>{let r=Kt.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),ts=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await es(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import He from"url";import ss from"chalk";var ue,T,ge=f(()=>{"use strict";a();L();C();ue=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:j("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=G;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return He.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return He.format({protocol:t,hostname:e,port:ss.bold(s),pathname:r})}},T=new ue});import{exec as is}from"child_process";import{promisify as rs}from"util";var Je,Ue,os,ns,_e,Ve=f(()=>{"use strict";a();y();P();Je=rs(is),Ue=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],os=async()=>{let i=process.env.BROWSER;if(!i||!Ue.includes(i)){let{stdout:e}=await Je("ps cax");i=Ue.find(t=>e.includes(t))}return i},ns=async i=>{if(process.platform==="darwin")try{let t=await os();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Je(s,{cwd:o.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},_e=ns});var de,J,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 U(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)}},J=new de});import We from"fs/promises";var x,N=f(()=>{"use strict";a();L();he();ge();P();Ve();C();y();ye();x=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";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?(p.info(`${O("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${O("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${O("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${O("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
11
- `)),this.sf.isOpenBrower&&_e(this.sf.url)}async setup(e,t){p.time(`[${e}]Setup`),await o.setup(e,t),o.debug.clearLog&&pe(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}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([We.readFile(o.resource.key),We.readFile(o.resource.cert)])}async serverPort(){if(J.isADB)return;let{port:e,host:t}=this.sf,s=await U(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});var _,qe=f(()=>{"use strict";a();y();_=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 V,Xe=f(()=>{"use strict";a();y();V=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 Ze from"html-webpack-plugin";var Ke,W,Qe,q,as,X,be=f(()=>{"use strict";a();C();y();Ke="HtmlImportMapPlugin",W=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(Ke,t=>{Ze.getHooks(t).alterAssetTagGroups.tapAsync(Ke,(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)})})}},Qe="HtmlEmpShareLibPlugin",q=class{chunk;files;constructor(e,t){this.files=g({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(Qe,t=>{let s=this.files;Ze.getHooks(t).alterAssetTagGroups.tapAsync(Qe,(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)})})}},as=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
12
- `);return ce(i)},X=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,as(),{name:void 0}).apply(e)}}});var K,Ye=f(()=>{"use strict";a();y();ye();be();K=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await J.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 ps from"fs";var ve,et,tt=f(()=>{"use strict";a();I();ze();C();N();qe();Xe();Ye();ve=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},g(e,t)}empShareFastMode=new V;empShareLib=new _;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:this.store.isDev,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,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.store.empOptions.server?.http2&&(x.httpsType="h2",delete this.store.empOptions.server.http2),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"}},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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Ne();if(!e||!ps.existsSync(e))return;let t=await Ie(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}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}},et=new ve});import ls from"fs-extra";var Ce,st,it=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?this.store.empConfig.build.devtool:!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 ls.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 Ce});var we,rt,ot=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={},{sass:t}=this.store.empConfig.css||{sass:{}};t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:w.resolve("sass-embedded"),e.api=t.api?t.api:"legacy",e.sourceMap=this.store.empConfig.build.sourcemap,t.sassOptions&&(e.sassOptions=t.sassOptions)),this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:{loader:w.resolve("sass-loader"),options:e}},type:"css/auto"}}}})}async less(){let e={loader:w.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"}}}})}},rt=new we});import S from"path";import cs from"html-webpack-plugin";var xe,nt,at=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(S.extname(e),"").replace(`${this.store.empConfig.appSrc}${S.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(S.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(S.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(S.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(cs,[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(){p.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=S.join(this.store.appSrc,e),s=S.join(t,"**","*.{ts,tsx,jsx,js}"),r=await D([s],{windowsPathsNoEscape:!0});r=r.map(n=>n.replace(`${t}${S.sep}`,"")),r.map(n=>{let l=this.store.empConfig.entries[n]||{};this.setEntryItem(n,{...this.store.empConfig.html,...l},S.join(t,n))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=S.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await D([e],{windowsPathsNoEscape:!0});if(t[0]){let s=S.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])}p.timeEnd("[store][empConfig]SetDefaultEntry")}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)}},nt=new xe});import pt from"path";var Se,lt,ct=f(()=>{"use strict";a();C();Se=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.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",pt.dirname(w.resolve("@swc/helpers/package.json"))),this.coreJs.path=w.resolve("core-js/package.json");let t=ae(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=pt.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")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},sourceMapLoader:{test:/\.[tj]sx?$/,enforce:"pre",use:{sourceMapLoader:{loader:w.resolve("source-map-loader")}}}}}})}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"}}}})}},lt=new Se});import mt from"fs";import{ModuleFederationPlugin as ms}from"@module-federation/enhanced/rspack";import z from"@rspack/core";var Ee,ft,ht=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(z.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");mt.existsSync(e)&&mt.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(z.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(z.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=ms;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(z.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(z.SwcCssMinimizerRspackPlugin,[{}])}},ft=new Ee});var Oe,ut,gt=f(()=>{"use strict";a();it();ot();at();ct();ht();Oe=class{store;async setup(e){this.store=e;let t=[st.setup(this.store),lt.setup(this.store),ft.setup(this.store),nt.setup(this.store),rt.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()}},ut=new Oe});import fs from"fs/promises";import E from"path";import hs from"util";import us from"webpack-chain";var Pe,o,y=f(()=>{"use strict";a();P();C();tt();gt();Pe=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=E.resolve(m,c).replace(`${E.sep}dist${E.sep}index.js`,"");empSource=E.resolve(this.empRoot,"dist");resolve=e=>E.isAbsolute(e)?e:E.resolve(this.root,e);empResolve=e=>E.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=le;deepAssign=g;getLanIp=G;entries={};debug;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=et,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new us,await ut.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}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=w(this.empResolve("package.json")),r=w(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=E.join(this.empRoot,"resource"),this.resource.cert=E.join(this.resource.dir,"emp.cert"),this.resource.key=E.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=E.join(this.root,this.debug.showRsconfig);fs.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(p.link("[Compile Config]")),console.log(hs.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}},o=new Pe});import gs from"fs";import k from"path";import{gzipSizeSync as ds}from"gzip-size";function Ss(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(M.bold(s))}async function dt(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>Cs(u.name)).map(xs);s.sort((u,R)=>u.size-R.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),n=Math.max(...s.map(u=>(u.folder+k.sep+u.name).length));Ss(n,r);let l=0,d=0;s.forEach(u=>{let{sizeLabel:R}=u,{name:Et,folder:Ot,gzipSizeLabel:Pt}=u,Te=(Ot+k.sep+Et).length,Fe=R.length;if(l+=u.size,d+=u.gzippedSize,Fe<r){let se=" ".repeat(r-Fe);R+=se}let Re=j(u.folder+k.sep)+Es(u.name);if(Te<n){let se=" ".repeat(n-Te);Re+=se}p.info(` ${Re} ${j(R)} ${Pt}`)});let v=`${M.bold("Total size:")} ${Q(l)}`,F=`${M.bold("Gzipped size:")} ${Q(d)}`;p.info(`
13
- ${v}
14
- ${F}
15
- `),p.info(`${O("\u2713")} Ready in ${H(Number(e.time))}
16
- `)}function Z(i=0){p.info(`${O("\u2713")} Ready in ${H(Number(i))}`)}var ys,bs,vs,Cs,ws,xs,Q,Es,Y=f(()=>{"use strict";a();L();y();P();C();ys=/\.html$/,bs=/\.(?:js|mjs|cjs|jsx)$/,vs=/\.css$/,Cs=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),ws=i=>i>300*1e3?ie:i>100*1e3?B:re,xs=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=gs.readFileSync(k.join(o.empConfig.build.outDir,e)),l=n.length,d=ds(n),v=ws(d)(Q(d));return{size:l,folder:r,name:s,gzippedSize:d,sizeLabel:t,gzipSizeLabel:v}};Q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Es=i=>bs.test(i)?B(i):vs.test(i)?O(i):ys.test(i)?M(i):oe(i)});var yt={};A(yt,{default:()=>ks});import{rspack as Os}from"@rspack/core";import{RspackDevServer as Ps}from"@rspack/dev-server";var ke,ks,bt=f(()=>{"use strict";a();Y();P();C();N();y();ke=class extends x{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=Os(this.rspackDevConfig);if(!o.rsConfig.devServer){p.error("devServer is not defined in config");return}let t=await this.devServerConfig(),s=new Ps(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});Z(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()})}},ks=new ke});import $s from"https";import Ms from"compression";import js from"cors";import Ls from"express";import Ds from"spdy";var ee,vt=f(()=>{"use strict";a();N();ee=class extends x{app;async init(){let e=Ls();e.use(Ms()),e.use(js()),e.disable("x-powered-by"),e.get("*",(t,s)=>{t.next()}),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();(x.httpsType==="h2"?Ds:$s).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:()=>te,default:()=>Gs});import Ts from"fs";import Fs from"fs/promises";import Rs from"path";import As from"express";var te,Gs,Me=f(()=>{"use strict";a();Y();P();y();vt();te=class extends ee{timing=0;async run(){if(this.timing=Date.now(),!Ts.existsSync(o.outDir))return p.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(As.static(e));let t=await Fs.readFile(Rs.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()}},Gs=new te});var Ct={};A(Ct,{default:()=>Ns});import{rspack as Is}from"@rspack/core";var je,Ns,wt=f(()=>{"use strict";a();Y();P();N();y();je=class extends x{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(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(),Is(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await dt(t),this.startServe(),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},Ns=new je});a();import{rspack as cn}from"@rspack/core";import fn from"html-webpack-plugin";a();y();import zs from"process";import{program as $}from"commander";function xt(){$.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),$.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(bt(),yt));await e.setup("dev",i)}),$.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(wt(),Ct));await e.setup("build",i)}),$.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Me(),$e));await e.setup("serve",i)}),$.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(i=>{}),$.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(i=>{}),$.parse(zs.argv)}a();I();y();import St from"fs/promises";import Le from"path";var Bs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Hs=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,Us=/import\(['"]([^;\n]+?)['"]\)/,De=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 D([`${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 St.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Bs,r=>{let n=r.match(Hs);if(n||(n=r.match(Us)),n&&n[1]){let l=n[1];if(!l.startsWith("."))return r;let d=Le.resolve(Le.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
2
+ var wt=Object.defineProperty;var C=(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 h=(i,e)=>()=>(i&&(e=i(i=0)),e);var A=(i,e)=>{for(var t in e)wt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as St}from"url";import Et from"path";var Me,Ot,m,c,n=h(()=>{"use strict";Me=()=>St(import.meta.url),Ot=()=>Et.dirname(Me()),m=Ot(),c=Me()});import y from"chalk";var Pt,E,kt,$t,Mt,K,N,jt,Lt,k,Q,Tt,Z,$,f,M=h(()=>{"use strict";n();Pt=y.hex("#1abc9c"),E=y.hex("#16a085"),kt=y.hex("#2ecc71"),$t=y.hex("#27ae60"),Mt=y.hex("#e74c3c"),K=y.hex("#c0392b"),N=y.hex("#f1c40f"),jt=y.hex("#f39c12"),Lt=y.hex("#3498db"),k=y.hex("#2980b9"),Q=y.hex("#ecf0f1"),Tt=y.hex("#fd79a8"),Z=y.hex("#e84393"),$=y.hex("#7f8c8d"),f={lightGreen:Pt,green:E,lightCyan:kt,cyan:$t,lightRed:Mt,red:K,yellow:N,orange:jt,lightBlue:Lt,blue:k,white:Q,lightMagenta:Tt,magenta:Z,gray:$}});var Y,p,O=h(()=>{"use strict";n();M();Y=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setLogLevel(e){this.logLevel=e}setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=f.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${f.lightBlue(this.brandName)}${f.blue(` ${e} `)}
3
+ `)};cyan=e=>{console.log(`${f.lightCyan(this.brandName)}${f.cyan(` ${e} `)}
4
+ `)};magenta=e=>{console.log(`${f.lightMagenta(this.brandName)}${f.magenta(` ${e} `)}
5
+ `)};green=e=>{console.log(`${f.lightGreen(this.brandName)}${f.green(` ${e} `)}
6
+ `)};yellow=e=>{console.log(`${f.yellow(this.brandName)}${f.orange(` ${e} `)}
7
+ `)};red=e=>{console.log(`${f.lightRed(this.brandName)}${f.red(` ${e} `)}
8
+ `)};sysError=e=>{console.log(`${f.lightRed(" System Error Tips ")}${f.red(` ${e} `)}
9
+ `)};link=e=>f.blue(e);title=e=>{console.log(`${this.fullName}${f.yellow.underline(`${e}`)}
10
+ `)}},p=new Y});var oe={};A(oe,{clearConsole:()=>te,deepAssign:()=>d,ensureArray:()=>Gt,getLanIp:()=>R,getPkgVersion:()=>ee,importJsVm:()=>re,jsonFilter:()=>It,timeFormat:()=>ie,vCompare:()=>se});import{ip as Dt}from"address";import Ft from"chalk";import{gateway4sync as At}from"default-gateway";import Rt from"fs-extra";function te(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function d(i,...e){for(let t of e)for(let s in t){let r=t[s],o=i[s];if(Object(r)==r&&Object(o)===o){i[s]=d(o,r);continue}i[s]=t[s]}return i}var R,ee,Gt,It,se,ie,re,x=h(()=>{"use strict";n();R=()=>{let{int:i}=At();return Dt(i||"")||"127.0.0.1"},ee=i=>{try{let{version:e}=Rt.readJSONSync(i);return e}catch{return}};Gt=i=>Array.isArray(i)?i:[i],It=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),se=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),o=0;for(let l=0;l<r;l++){let g=t.length>l?t[l]:0,b=isNaN(Number(g))?g.charCodeAt():Number(g),D=s.length>l?s[l]:0,u=isNaN(Number(D))?D.charCodeAt():Number(D);if(b<u){o=-1;break}else if(b>u){o=1;break}}return o},ie=i=>{i=i/1e3;let e=s=>Ft.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},re=i=>`data:text/javascript,${i}`});var je={};A(je,{chalk:()=>zt,color:()=>f,glob:()=>j,logger:()=>p,utils:()=>oe});import zt from"chalk";import{glob as j}from"glob";var G=h(()=>{"use strict";n();M();x();O()});import Nt from"fs";import Bt from"path";import Ht from"jiti";var Ut,Le,Te,Jt,De=h(()=>{"use strict";n();v();O();Ut=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],Le=Ht(c,{esmResolve:!0,requireCache:!1,interopDefault:!0}),Te=async()=>Jt(),Jt=()=>{p.time("[store]GetEmpConfigPath");let i;for(let e of Ut){let t=Bt.resolve(a.root,e);if(Nt.existsSync(t)){i=t;break}}return p.timeEnd("[store]GetEmpConfigPath"),i}});import _t from"net";import Wt from"os";async function B(i,e="localhost"){if(i!==Vt&&(i<Fe||i>ne))throw new Error(`Port number must lie between ${Fe} and ${ne}`);let t=i,s=qt(),r;e&&!s.has(e)?r=new Set([e]):r=s;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=ne;)try{return await Kt(t,r)}catch(l){if(!o.has(l.code))throw l;t+=1}throw new Error("No available ports found")}var Fe,ne,Vt,qt,Xt,Kt,ae=h(()=>{"use strict";n();Fe=1024,ne=65535,Vt=443,qt=()=>{let i=Wt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},Xt=(i,e)=>new Promise((t,s)=>{let r=_t.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),Kt=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Xt(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import Ae from"url";import Qt from"chalk";var pe,L,le=h(()=>{"use strict";n();M();x();pe=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:$("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=R;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Ae.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Ae.format({protocol:t,hostname:e,port:Qt.bold(s),pathname:r})}},L=new pe});import{exec as Zt}from"child_process";import{promisify as Yt}from"util";var Ge,Re,es,ts,Ie,ze=h(()=>{"use strict";n();v();O();Ge=Yt(Zt),Re=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],es=async()=>{let i=process.env.BROWSER;if(!i||!Re.includes(i)){let{stdout:e}=await Ge("ps cax");i=Re.find(t=>e.includes(t))}return i},ts=async i=>{if(process.platform==="darwin")try{let t=await es();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Ge(s,{cwd:a.resource.dir}),!0}}catch(t){p.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return p.error("Failed to open start URL."),p.error(t),!1}},Ie=ts});import Ne from"fs/promises";var T,ce=h(()=>{"use strict";n();M();ae();le();O();ze();x();T=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};static httpsType="default";store;async adaptServer(){let{store:e}=this;this.sf.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!e.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=e.empConfig.server.host?e.empConfig.server.host:this.sf.host,this.sf.port=e.empConfig.server.port,await this.serverPort(),L.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=L.prettyPrintUrl("localhost")):(this.sf.urls=L.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(this.sf.publicPath)}`)):(p.info(`${E("\u279C")} Local: ${p.link(e.localUrlForTerminal)}`),p.info(`${E("\u279C")} Network: ${p.link(e.lanUrlForTerminal)}
11
+ `)),this.sf.isOpenBrower&&Ie(this.sf.url)}async setup(e,t,s){p.time(`[${e}]Setup`),this.store=s,await s.setup(e,t),s.debug.clearLog&&te(),p.title(`${e}`),await this.adaptServer(),p.time(`[${e}]Run`),await this.run(),p.timeEnd(`[${e}]Run`),this.afterRun(),p.timeEnd(`[${e}]Setup`)}async run(){}afterRun(){process.on("SIGINT",function(){process.exit()})}get isHttps(){let{store:e}=this,{server:t,https:s,http2:r}=e.empConfig.server||{};return t==="https"||typeof t=="object"&&t.type==="https"||s===!0||r===!0}getcert(){let{store:e}=this;return Promise.all([Ne.readFile(e.resource.key),Ne.readFile(e.resource.cert)])}async serverPort(){let{store:e}=this;if(e.autoDevBase.adb)return;let{port:t,host:s}=this.sf,r=await B(t,s);r!==t&&(this.sf.port=r,e.rsConfig.devServer?.port&&(e.rsConfig.devServer.port=r))}}});var H,Be=h(()=>{"use strict";n();v();H=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;config;importMap={imports:{}};isEmpshare=!1;async setup(){this.config=a.empConfig.empShare,this.isEmpshare=!!a.empConfig.empShare.name,a.empConfig.empShare.fastMode&&a.empConfig.empShareFastMode.setup(),this.config.shareLib&&this.setShareLib(),this.prepareEsm()}get useImportMap(){return this.config.useImportMap&&a.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(a.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 o={};if(o.module=s,typeof r=="string"){let l=r.match(this.exp)||[];l.length>0?(o.global=l[1],o.entry=l[2],o.type="js",t.push(o),o={}):(o.global="",o.entry=r,o.type="js",t.push(o),o={})}else Array.isArray(r)?r.map(l=>{if(!l)return;if(l.split("?")[0].endsWith(".css"))o.entry=l,o.type="css";else{let b=l.match(this.exp)||[];b.length>0?(o.global=b[1],o.entry=b[2],o.type="js"):(o.global="",o.entry=l,o.type="js")}t.push(o),o={}}):typeof r=="object"&&r.entry&&(o.entry=r.entry,o.global=r.global,o.type=r.type,t.push(o),o={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global?this.externals[s.module]=s.global:a.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&&!a.empConfig.isESM&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});var U,He=h(()=>{"use strict";n();v();U=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${a.mode==="development"?".development":""}.umd.js`}setup(){this.fastMode=a.deepAssign(this.fastMode,a.empConfig.empShare.fastMode),this.injectLib(),this.setExternals()}injectLib(){let{runtimeHost:e,runtimeLib:t}=this.fastMode;if(e||t){let s=t||this.getRuntimeLib(e);a.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=a.deepAssign(this.externals,this.fastMode.externals)),a.empConfig.empShareLib.externals=a.deepAssign(a.empConfig.empShareLib.externals,this.externals)}}});var me,Ue,Je=h(()=>{"use strict";n();ae();le();x();v();me=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=a.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}async setup(){if(this.isADB=!!a.empOptions.autoDevBase&&a.mode==="development"&&!this.isHttpBase,a.autoDevBase.adb=this.isADB,!this.isADB)return;let{server:e,https:t}=a.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0,a.autoDevBase.https=this.isHttps;let s=L.getLanIp(),r=this.isHttps?"https":"http",o=a.empOptions.server?.port||8e3;o=await B(o,s),a.empOptions.base=`${r}://${s}:${o}/`,a.empOptions.server=d({port:o,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${o}/ws`}},a.empOptions.server)}},Ue=new me});import Ve from"html-webpack-plugin";var _e,J,We,_,ss,W,he=h(()=>{"use strict";n();x();v();_e="HtmlImportMapPlugin",J=class{importMap;chunk;constructor(e,t){this.importMap=e,this.chunk=t}apply(e){e.hooks.compilation.tap(_e,t=>{Ve.getHooks(t).alterAssetTagGroups.tapAsync(_e,(s,r)=>{if(!s.plugin.userOptions.chunks?.includes(this.chunk))return r(null,s);s.headTags.push({tagName:"script",attributes:{type:"importmap"},innerHTML:`${JSON.stringify(this.importMap,null,2)}`,voidTag:!1,meta:{plugin:void 0}}),r(null,s)})})}},We="HtmlEmpShareLibPlugin",_=class{chunk;files;constructor(e,t){this.files=d({js:[],css:[]},e),this.chunk=t}apply(e){e.hooks.compilation.tap(We,t=>{let s=this.files;Ve.getHooks(t).alterAssetTagGroups.tapAsync(We,(r,o)=>{if(!r.plugin.userOptions.chunks?.includes(this.chunk))return o(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}})}),o(null,r)})})}},ss=()=>{let i=[`import 'core-js/${a.empConfig.build.coreJsFeatures}'`].join(`
12
+ `);return re(i)},W=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,ss(),{name:void 0}).apply(e)}}});var V,qe=h(()=>{"use strict";n();v();Je();he();V=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){await Ue.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){a.empConfig.build.polyfill==="entry"&&a.chain.plugin("empPolyfill").use(W),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 is from"fs";var fe,Xe,Ke=h(()=>{"use strict";n();G();De();x();ce();Be();He();qe();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},d(e,t)}empShareFastMode=new U;empShareLib=new H;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,showHMRTime:!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:this.store.isDev,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,polyfillInclude:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default,swcConfig:{},devtool:"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,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.store.empOptions.server?.http2&&(T.httpsType="h2",delete this.store.empOptions.server.http2),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"}},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,o={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&&(o.clean=!1),this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 d({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(){p.time("[store][empConfig]SyncEmpOptions");let e=await Te();if(!e||!is.existsSync(e))return;let t=await Le(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},p.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Xe=new fe});import rs from"fs-extra";var ue,Qe,Ze=h(()=>{"use strict";n();ue=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?this.store.empConfig.build.devtool:!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 rs.exists(e)){let s={tsConfigPath:e};this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},Qe=new ue});var ge,Ye,et=h(()=>{"use strict";n();ge=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={},{sass:t}=this.store.empConfig.css||{sass:{}};t.mode==="modern"&&(e.implementation=t.implementation?t.implementation:C.resolve("sass-embedded"),e.api=t.api?t.api:"legacy",e.sourceMap=this.store.empConfig.build.sourcemap,t.sassOptions&&(e.sassOptions=t.sassOptions)),this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{sassLoader:{loader:C.resolve("sass-loader"),options:e}},type:"css/auto"}}}})}async less(){let e={loader:C.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"}}}})}},Ye=new ge});import w from"path";import os from"html-webpack-plugin";var de,tt,st=h(()=>{"use strict";n();G();x();he();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.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),o=[s];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`html-plugin-${t}`).use(os,[e]),this.store.empConfig.empShareLib&&(e.files=d(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(_,[e.files,t]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(J,[this.store.empConfig.empShareLib.importMap,t])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){p.time("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 j([s],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${w.sep}`,"")),r.map(o=>{let l=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...l},w.join(t,o))}),p.timeEnd("setAutoPage")}async setDefaultEntry(){p.time("[store][empConfig]SetDefaultEntry");let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await j([e],{windowsPathsNoEscape:!0});if(t[0]){let s=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])}p.timeEnd("[store][empConfig]SetDefaultEntry")}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)}},tt=new de});import it from"path";var ye,rt,ot=h(()=>{"use strict";n();x();ye=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.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:d(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",it.dirname(C.resolve("@swc/helpers/package.json"))),this.coreJs.path=C.resolve("core-js/package.json");let t=ee(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=it.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")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},javascript:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{swc:{loader:"builtin:swc-loader",options:this.swcJsOptions}}},sourceMapLoader:{test:/\.[tj]sx?$/,enforce:"pre",use:{sourceMapLoader:{loader:C.resolve("source-map-loader")}}}}}})}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"}}}})}},rt=new ye});import nt from"fs";import{ModuleFederationPlugin as ns}from"@module-federation/enhanced/rspack";import I from"@rspack/core";var be,at,pt=h(()=>{"use strict";n();be=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(I.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");nt.existsSync(e)&&nt.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(I.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(I.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{isEmpshare:e}=this.store.empConfig.empShareLib;if(!e)return;let t=ns;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(I.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(I.SwcCssMinimizerRspackPlugin,[{}])}},at=new be});var ve,lt,ct=h(()=>{"use strict";n();Ze();et();st();ot();pt();ve=class{store;async setup(e){this.store=e;let t=[Qe.setup(this.store),rt.setup(this.store),at.setup(this.store),tt.setup(this.store),Ye.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},lt=new ve});import as from"fs/promises";import S from"path";import ps from"util";import ls from"webpack-chain";var Ce,a,v=h(()=>{"use strict";n();O();x();Ke();ct();Ce=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(m,c).replace(`${S.sep}dist${S.sep}index.js`,"");empSource=S.resolve(this.empRoot,"dist");resolve=e=>S.isAbsolute(e)?e:S.resolve(this.root,e);empResolve=e=>S.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;vCompare=se;deepAssign=d;getLanIp=R;entries={};debug;autoDevBase={adb:!1,https:!1};logger=p;async setup(e,t){p.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Xe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new ls,await lt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),p.timeEnd("[store]Setup")}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=C(this.empResolve("package.json")),r=C(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.resource.dir=S.join(this.empRoot,"resource"),this.resource.cert=S.join(this.resource.dir,"emp.cert"),this.resource.key=S.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),p.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=S.join(this.root,this.debug.showRsconfig);as.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"?d(e,this.debug.showRsconfig):e;console.log(p.link("[Compile Config]")),console.log(ps.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}},a=new Ce});var mt={};A(mt,{default:()=>cs});import{devServer as cs}from"@empjs/server";var ht=h(()=>{"use strict";n()});import ms from"fs";import P from"path";import{gzipSizeSync as hs}from"gzip-size";function vs(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,o,l)=>{let g=t[l],b=o;return g&&(b=o.length<g?o+" ".repeat(g-o.length):o),`${r+b} `}," ");console.log(k.bold(s))}async function ft(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(u=>ds(u.name)).map(bs);s.sort((u,F)=>u.size-F.size);let r=Math.max(...s.map(u=>u.sizeLabel.length)),o=Math.max(...s.map(u=>(u.folder+P.sep+u.name).length));vs(o,r);let l=0,g=0;s.forEach(u=>{let{sizeLabel:F}=u,{name:vt,folder:Ct,gzipSizeLabel:xt}=u,Pe=(Ct+P.sep+vt).length,ke=F.length;if(l+=u.size,g+=u.gzippedSize,ke<r){let X=" ".repeat(r-ke);F+=X}let $e=$(u.folder+P.sep)+Cs(u.name);if(Pe<o){let X=" ".repeat(o-Pe);$e+=X}p.info(` ${$e} ${$(F)} ${xt}`)});let b=`${k.bold("Total size:")} ${q(l)}`,D=`${k.bold("Gzipped size:")} ${q(g)}`;p.info(`
13
+ ${b}
14
+ ${D}
15
+ `),p.info(`${E("\u2713")} Ready in ${ie(Number(e.time))}
16
+ `)}var fs,us,gs,ds,ys,bs,q,Cs,ut=h(()=>{"use strict";n();M();v();O();x();fs=/\.html$/,us=/\.(?:js|mjs|cjs|jsx)$/,gs=/\.css$/,ds=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),ys=i=>i>300*1e3?K:i>100*1e3?N:Q,bs=i=>{let e=i.name.split("?")[0],t=q(i.size),s=P.basename(e),r=P.join(P.basename(a.empConfig.build.outDir),P.dirname(e)),o=ms.readFileSync(P.join(a.empConfig.build.outDir,e)),l=o.length,g=hs(o),b=ys(g)(q(g));return{size:l,folder:r,name:s,gzippedSize:g,sizeLabel:t,gzipSizeLabel:b}};q=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Cs=i=>us.test(i)?N(i):gs.test(i)?E(i):fs.test(i)?k(i):Z(i)});var xe={};A(xe,{default:()=>xs});import{prodServer as xs}from"@empjs/server";var we=h(()=>{"use strict";n()});var gt={};A(gt,{default:()=>Ss});import{rspack as ws}from"@rspack/core";var Se,Ss,dt=h(()=>{"use strict";n();ut();O();ce();v();Se=class extends T{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(()=>(we(),xe));await e.setup("serve",a.cliOptions,a)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),ws(this.rspackConfig,async(e,t)=>{if(e!==null){p.error(e.stack||e),e.message&&p.error(e.message);return}if(!t){p.red("Stats is Undefined.");return}t.hasErrors()&&(p.error(t.toString({all:!1,colors:!0,errors:!0})),p.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(p.yellow("Compiled with warnings."),p.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await ft(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Ss=new Se});n();import{rspack as Eo}from"@rspack/core";import Po from"html-webpack-plugin";n();v();import Es from"process";import{program as z}from"commander";function yt(){z.version(a.empPkg.version,"-v, --version").usage("<command> [options]"),z.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(ht(),mt));await e.setup("dev",i,a)}),z.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",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(dt(),gt));await e.setup("build",i,a)}),z.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async i=>{let{default:e}=await Promise.resolve().then(()=>(we(),xe));await e.setup("serve",i,a)}),z.parse(Es.argv)}n();G();v();import bt from"fs/promises";import Ee from"path";var Os=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,Ps=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,ks=/import\(['"]([^;\n]+?)['"]\)/,Oe=class{list=[];outDir=a.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await j([`${a.empConfig.build.outDir}/**/*.d.ts`],{windowsPathsNoEscape:!0});let e=[];this.list.map(s=>{s=a.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await bt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(Os,r=>{let o=r.match(Ps);if(o||(o=r.match(ks)),o&&o[1]){let l=o[1];if(!l.startsWith("."))return r;let g=Ee.resolve(Ee.dirname(e),l).replace(this.outDir,this.aliasName);return r.replace(o[1],g)}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
17
17
  ${t}}\r
18
- `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await St.writeFile(Le.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},Js=new De;y();I();function dn(i){return i}export{fn as HtmlWebpackPlugin,dn as defineConfig,Js as dts,Ge as empHelper,cn as rspack,xt as runScript,o as store};
18
+ `}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await bt.writeFile(Ee.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},$s=new Oe;v();G();function jo(i){return i}export{Po as HtmlWebpackPlugin,jo as defineConfig,$s as dts,je as empHelper,Eo as rspack,yt as runScript,a as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.0.2-beta.1",
3
+ "version": "3.1.0-alpha.1",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,35 +53,25 @@
53
53
  },
54
54
  "author": "Ken",
55
55
  "devDependencies": {
56
- "@types/compression": "^1.7.2",
57
- "@types/cors": "^2.8.12",
58
56
  "@types/default-gateway": "^7.2.1",
59
- "@types/express": "^4.17.13",
60
57
  "@types/fs-extra": "^11.0.4",
61
58
  "@types/node": "^20.8.7",
62
59
  "@types/react": "^18.3.2",
63
- "@types/spdy": "^3.4.9",
64
- "@types/watchpack": "^2.4.3",
65
60
  "@types/webpack": "^5.28.4",
66
61
  "@types/webpack-bundle-analyzer": "^4.6.2",
67
- "@types/webpack-hot-middleware": "^2.25.9",
68
62
  "@types/webpack-sources": "^3.2.2",
69
63
  "tsup": "^8.1.0"
70
64
  },
71
65
  "dependencies": {
66
+ "@empjs/server": "3.1.0-alpha.1",
72
67
  "@module-federation/enhanced": "0.1.19",
73
68
  "@rspack/core": "0.7.0",
74
- "@rspack/dev-server": "0.7.0",
75
69
  "@swc/helpers": "^0.5.11",
76
70
  "address": "^2.0.2",
77
- "ansi-html-community": "^0.0.8",
78
71
  "chalk": "^5.3.0",
79
72
  "commander": "^11.1.0",
80
- "compression": "^1.7.4",
81
73
  "core-js": "^3.37.0",
82
- "cors": "^2.8.5",
83
74
  "default-gateway": "^7.2.2",
84
- "express": "^4.18.2",
85
75
  "fs-extra": "^11.2.0",
86
76
  "glob": "^10.3.15",
87
77
  "gzip-size": "^7.0.0",
@@ -92,8 +82,6 @@
92
82
  "sass-embedded": "^1.77.2",
93
83
  "sass-loader": "^14.2.1",
94
84
  "source-map-loader": "^5.0.0",
95
- "spdy": "^4.0.2",
96
- "strip-ansi": "^7.1.0",
97
85
  "typescript-plugin-css-modules": "^5.1.0",
98
86
  "webpack-bundle-analyzer": "^4.10.2",
99
87
  "webpack-chain": "^6.5.1"