@empjs/cli 3.8.4 → 3.9.0-beta.0

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,17 +1,17 @@
1
- "use strict";var rs=Object.create;var B=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var ps=Object.getOwnPropertyNames;var as=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var D=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},He=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ps(e))!ls.call(s,o)&&o!==t&&B(s,o,{get:()=>e[o],enumerable:!(i=ns(e,o))||i.enumerable});return s};var l=(s,e,t)=>(t=s!=null?rs(as(s)):{},He(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),cs=s=>He(B({},"__esModule",{value:!0}),s);var r=c(()=>{"use strict"});var d,ms,S,us,hs,fs,ne,H,gs,ds,R,pe,ys,ae,L,h,A=c(()=>{"use strict";r();d=l(require("chalk"),1),ms=d.default.hex("#1abc9c"),S=d.default.hex("#16a085"),us=d.default.hex("#2ecc71"),hs=d.default.hex("#27ae60"),fs=d.default.hex("#e74c3c"),ne=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),gs=d.default.hex("#f39c12"),ds=d.default.hex("#3498db"),R=d.default.hex("#2980b9"),pe=d.default.hex("#ecf0f1"),ys=d.default.hex("#fd79a8"),ae=d.default.hex("#e84393"),L=d.default.hex("#7f8c8d"),h={lightGreen:ms,green:S,lightCyan:us,cyan:hs,lightRed:fs,red:ne,yellow:H,orange:gs,lightBlue:ds,blue:R,white:pe,lightMagenta:ys,magenta:ae,gray:L}});var le,n,P=c(()=>{"use strict";r();A();le=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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
- `)}},n=new le});var ce,Je,me,vs,_e,Ve,We,qe,J=c(()=>{"use strict";r();ce=l(require("fs"),1),Je=require("jiti"),me=l(require("path"),1);w();P();vs=["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"],_e=(0,Je.createJiti)(__filename,{interopDefault:!0}),Ve=async()=>{n.time("[store]GetEmpConfigPath");let s=vs.map(i=>me.default.resolve(p.root,i)),e=await Promise.all(s.map(i=>ce.default.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,o)=>e[o]);return n.timeEnd("[store]GetEmpConfigPath"),t},We=async()=>{let s=me.default.join(p.root,"tsconfig.json");return await ce.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},qe=()=>{let s=[];return p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ge={};D(ge,{clearConsole:()=>he,deepAssign:()=>v,ensureArray:()=>bs,getLanIp:()=>T,getPkgVersion:()=>ue,importJsVm:()=>fe,jsonFilter:()=>Cs,timeFormat:()=>V,vCompare:()=>_});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function v(s,...e){for(let t of e)for(let i in t){let o=t[i],a=s[i];if(Object(o)==o&&Object(a)===a){s[i]=v(a,o);continue}s[i]=t[i]}return s}var Xe,Qe,Ke,Ye,T,ue,bs,Cs,_,V,fe,x=c(()=>{"use strict";r();Xe=require("address"),Qe=l(require("chalk"),1),Ke=require("default-gateway"),Ye=l(require("fs-extra"),1),T=()=>{let s="127.0.0.1";try{let{int:e}=(0,Ke.gateway4sync)();return(0,Xe.ip)(e||"")||s}catch{return s}},ue=s=>{try{let{version:e}=Ye.default.readJSONSync(s);return e}catch{return}};bs=s=>Array.isArray(s)?s:[s],Cs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),a=0;for(let u=0;u<o;u++){let f=t.length>u?t[u]:0,y=isNaN(Number(f))?f.charCodeAt():Number(f),j=i.length>u?i[u]:0,g=isNaN(Number(j))?j.charCodeAt():Number(j);if(y<g){a=-1;break}else if(y>g){a=1;break}}return a},V=s=>{s=s/1e3;let e=i=>Qe.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},fe=s=>`data:text/javascript,${s}`});var de,Ze,ye=c(()=>{"use strict";r();de=l(require("webpack-chain"),1),Ze={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var ve={};D(ve,{chalk:()=>et.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ge});var et,F,z=c(()=>{"use strict";r();et=l(require("chalk"),1),F=require("glob");A();P();x()});var W,tt=c(()=>{"use strict";r();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var be,st,it=c(()=>{"use strict";r();z();J();x();tt();be=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},v(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},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:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open: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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(a,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return v({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await _e(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},st=new be});var ot,Ce,rt,nt=c(()=>{"use strict";r();ot=l(require("fs-extra"),1);J();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({name:this.store.pkg.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:qe(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ot.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},rt=new Ce});var we,pt,at=c(()=>{"use strict";r();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},pt=new we});function ws(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
- `);return fe(s)}var X,q,G,Q=c(()=>{"use strict";r();X=l(require("html-webpack-plugin"),1);x();w();q=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ws(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{X.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:a,...u}=o;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var b,xe,lt,ct=c(()=>{"use strict";r();b=l(require("path"),1);z();Q();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),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(b.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${b.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(b.default.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),a=[i];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(X.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=b.default.join(this.store.appSrc,e),i=b.default.join(t,"**","*.{ts,tsx,jsx,js}"),o=await(0,F.glob)([i],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${b.default.sep}`,"")),o.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},b.default.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=b.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,F.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let i=b.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(i,this.store.empConfig.html,t[0])}n.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)}},lt=new xe});var Se,Oe,mt,ut=c(()=>{"use strict";r();Se=l(require("path"),1);x();Oe=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:v(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",Se.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ue(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Se.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},mt=new Oe});var O,ke,ht,Pe,ft,gt=c(()=>{"use strict";r();O=l(require("@rspack/core"),1),ke=l(require("fs"),1),ht=require("ts-checker-rspack-plugin");Q();Pe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(ht.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(O.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");ke.default.existsSync(e)&&ke.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(O.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(O.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(O.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=O.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(O.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(O.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(O.default.experiments.CssChunkingPlugin,[{}])}},ft=new Pe});var Ee,dt,yt=c(()=>{"use strict";r();nt();at();ct();ut();gt();Ee=class{store;async setup(e){this.store=e;let t=[rt.setup(this.store),mt.setup(this.store),ft.setup(this.store),lt.setup(this.store),pt.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},dt=new Ee});async function K(s,e=void 0){if(s!==xs&&(s<vt||s>$e))throw new Error(`Port number must lie between ${vt} and ${$e}`);let t=s,i=Ss(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=$e;)try{return await ks(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var bt,Ct,vt,$e,xs,Ss,Os,ks,wt=c(()=>{"use strict";r();bt=l(require("net"),1),Ct=l(require("os"),1),vt=1024,$e=65535,xs=443,Ss=()=>{let s=Ct.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Os=(s,e)=>new Promise((t,i)=>{let o=bt.default.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),ks=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Os(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});var xt,Te,je,Y,St=c(()=>{"use strict";r();xt=l(require("chalk"),1);A();Te=l(require("url"),1);x();je=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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Te.default.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Te.default.format({protocol:t,hostname:e,port:xt.default.bold(i),pathname:o})}},Y=new je});var kt,Pt,Et,Ot,Ps,Es,$t,Tt=c(()=>{"use strict";r();kt=require("child_process"),Pt=require("util");w();P();Et=(0,Pt.promisify)(kt.exec),Ot=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ps=async()=>{let s=process.env.BROWSER;if(!s||!Ot.includes(s)){let{stdout:e}=await Et("ps cax");s=Ot.find(t=>e.includes(t))}return s},Es=async s=>{if(process.platform==="darwin")try{let t=await Ps();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Et(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},$t=Es});var De,Z,jt=c(()=>{"use strict";r();De=l(require("fs/promises"),1);z();A();wt();St();Tt();x();Z=class{ip=T();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await K(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await K(e.empConfig.server.port)),Y.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Y.prettyPrintUrl("localhost")):(this.urls=Y.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
11
- `)),this.isOpenBrower&&$t(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([De.default.readFile(e.resource.key),De.default.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await K(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Dt,C,Rt,Lt,Re,p,w=c(()=>{"use strict";r();Dt=l(require("fs/promises"),1),C=l(require("path"),1),Rt=l(require("util"),1),Lt=require("@rspack/core");J();P();x();ye();it();yt();jt();ye();Q();Re=class{rspackVersion=Lt.rspack.rspackVersion;isOldRspack=_(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=C.default.resolve(__dirname,__filename).replace(`${C.default.sep}dist${C.default.sep}index.js`,"");empSource=C.default.resolve(this.empRoot,"dist");resolve=e=>C.default.isAbsolute(e)?e:C.default.resolve(this.root,e);empResolve=e=>C.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Ze;server=new Z(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,o]=await Promise.all([Ve(),We()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,await this.initVars(e,t),this.empConfig=st,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new de.default,await dt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=require(this.empResolve("package.json")),o=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=C.default.join(this.empRoot,"resource"),this.resource.cert=C.default.join(this.resource.dir,"emp.cert"),this.resource.key=C.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),n.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=C.default.join(this.root,this.debug.showRsconfig);Dt.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"?v(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(Rt.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"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=_;deepAssign=v;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new Re});function As(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let f=t[u],y=a;return f&&(y=a.length<f?a+" ".repeat(f-a.length):a),`${o+y} `}," ");console.log(R.bold(i))}async function Mt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>Ds(g.name)).map(Ls);i.sort((g,M)=>g.size-M.size);let o=Math.max(...i.map(g=>g.sizeLabel.length)),a=Math.max(...i.map(g=>(g.folder+k.default.sep+g.name).length));As(a,o);let u=0,f=0;i.forEach(g=>{let{sizeLabel:M}=g,{name:ss,folder:is,gzipSizeLabel:os}=g,Ie=(is+k.default.sep+ss).length,Ue=M.length;if(u+=g.size,f+=g.gzippedSize,Ue<o){let re=" ".repeat(o-Ue);M+=re}let Be=L(g.folder+k.default.sep)+Ns(g.name);if(Ie<a){let re=" ".repeat(a-Ie);Be+=re}n.info(` ${Be} ${L(M)} ${os}`)});let y=`${R.bold("Total size:")} ${ee(u)}`,j=`${R.bold("Gzipped size:")} ${ee(f)}`;n.info(`
1
+ "use strict";var as=Object.create;var B=Object.defineProperty;var ls=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var ms=Object.getPrototypeOf,us=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var R=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},Je=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of cs(e))!us.call(s,r)&&r!==t&&B(s,r,{get:()=>e[r],enumerable:!(i=ls(e,r))||i.enumerable});return s};var l=(s,e,t)=>(t=s!=null?as(ms(s)):{},Je(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),hs=s=>Je(B({},"__esModule",{value:!0}),s);var o=c(()=>{"use strict"});var d,fs,x,gs,ds,ys,ne,H,vs,bs,L,pe,Cs,ae,N,f,A=c(()=>{"use strict";o();d=l(require("chalk"),1),fs=d.default.hex("#1abc9c"),x=d.default.hex("#16a085"),gs=d.default.hex("#2ecc71"),ds=d.default.hex("#27ae60"),ys=d.default.hex("#e74c3c"),ne=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),vs=d.default.hex("#f39c12"),bs=d.default.hex("#3498db"),L=d.default.hex("#2980b9"),pe=d.default.hex("#ecf0f1"),Cs=d.default.hex("#fd79a8"),ae=d.default.hex("#e84393"),N=d.default.hex("#7f8c8d"),f={lightGreen:fs,green:x,lightCyan:gs,cyan:ds,lightRed:ys,red:ne,yellow:H,orange:vs,lightBlue:bs,blue:L,white:pe,lightMagenta:Cs,magenta:ae,gray:N}});var le,n,$=c(()=>{"use strict";o();A();le=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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
+ `)}},n=new le});var ce,_e,me,ws,Ve,We,qe,Xe,J=c(()=>{"use strict";o();ce=l(require("fs"),1),_e=require("jiti"),me=l(require("path"),1);w();$();ws=["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"],Ve=(0,_e.createJiti)(__filename,{interopDefault:!0}),We=async()=>{n.time("[store]GetEmpConfigPath");let s=ws.map(i=>me.default.resolve(p.root,i)),e=await Promise.all(s.map(i=>ce.default.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,r)=>e[r]);return n.timeEnd("[store]GetEmpConfigPath"),t},qe=async()=>{let s=me.default.join(p.root,"tsconfig.json");return await ce.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Xe=()=>{let s=[];return p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ge={};R(ge,{clearConsole:()=>he,deepAssign:()=>v,ensureArray:()=>Ss,getLanIp:()=>D,getPkgVersion:()=>ue,importJsVm:()=>fe,jsonFilter:()=>xs,timeFormat:()=>V,vCompare:()=>_});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function v(s,...e){for(let t of e)for(let i in t){let r=t[i],a=s[i];if(Object(r)==r&&Object(a)===a){s[i]=v(a,r);continue}s[i]=t[i]}return s}var Qe,Ke,Ye,Ze,D,ue,Ss,xs,_,V,fe,S=c(()=>{"use strict";o();Qe=require("address"),Ke=l(require("chalk"),1),Ye=require("default-gateway"),Ze=l(require("fs-extra"),1),D=()=>{let s="127.0.0.1";try{let{int:e}=(0,Ye.gateway4sync)();return(0,Qe.ip)(e||"")||s}catch{return s}},ue=s=>{try{let{version:e}=Ze.default.readJSONSync(s);return e}catch{return}};Ss=s=>Array.isArray(s)?s:[s],xs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),a=0;for(let u=0;u<r;u++){let h=t.length>u?t[u]:0,y=isNaN(Number(h))?h.charCodeAt():Number(h),E=i.length>u?i[u]:0,g=isNaN(Number(E))?E.charCodeAt():Number(E);if(y<g){a=-1;break}else if(y>g){a=1;break}}return a},V=s=>{s=s/1e3;let e=i=>Ke.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},fe=s=>`data:text/javascript,${s}`});var de,et,ye=c(()=>{"use strict";o();de=l(require("webpack-chain"),1),et={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var ve={};R(ve,{chalk:()=>tt.default,color:()=>f,glob:()=>F.glob,logger:()=>n,utils:()=>ge});var tt,F,z=c(()=>{"use strict";o();tt=l(require("chalk"),1),F=require("glob");A();$();S()});var W,st=c(()=>{"use strict";o();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var be,it,rt=c(()=>{"use strict";o();z();J();S();st();be=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},v(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},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:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open: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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,a={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}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(a,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return v({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await Ve(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},it=new be});var ot,Ce,nt,pt=c(()=>{"use strict";o();ot=l(require("fs-extra"),1);J();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({name:this.store.pkg.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Xe(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ot.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},nt=new Ce});var we,at,lt=c(()=>{"use strict";o();we=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},at=new we});function Os(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
+ `);return fe(s)}var X,q,G,Q=c(()=>{"use strict";o();X=l(require("html-webpack-plugin"),1);S();w();q=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Os(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{X.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:a,...u}=r;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var b,Se,ct,mt=c(()=>{"use strict";o();b=l(require("path"),1);z();Q();Se=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(b.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${b.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(b.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(b.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),a=[i];this.entriesConfig[r]={entry:{[r]:a},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(X.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=b.default.join(this.store.appSrc,e),i=b.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,F.glob)([i],{windowsPathsNoEscape:!0});r=r.map(a=>a.replace(`${t}${b.default.sep}`,"")),r.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},b.default.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=b.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,F.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let i=b.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(i,this.store.empConfig.html,t[0])}n.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)}},ct=new Se});var xe,Oe,ut,ht=c(()=>{"use strict";o();xe=l(require("path"),1);S();Oe=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:v(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",xe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ue(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=xe.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},ut=new Oe});var P,Pe,ft,ke,gt,dt=c(()=>{"use strict";o();P=l(require("@rspack/core"),1),Pe=l(require("fs"),1),ft=require("ts-checker-rspack-plugin");Q();ke=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(ft.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(P.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Pe.default.existsSync(e)&&Pe.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(P.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(P.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(P.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=P.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(P.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(P.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(P.default.experiments.CssChunkingPlugin,[{}])}},gt=new ke});var Ee,yt,vt=c(()=>{"use strict";o();pt();lt();mt();ht();dt();Ee=class{store;async setup(e){this.store=e;let t=[nt.setup(this.store),ut.setup(this.store),gt.setup(this.store),ct.setup(this.store),at.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()}},yt=new Ee});async function K(s,e=void 0){if(s!==Ps&&(s<bt||s>$e))throw new Error(`Port number must lie between ${bt} and ${$e}`);let t=s,i=ks(),r;e&&!i.has(e)?r=new Set([e]):r=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=$e;)try{return await $s(t,r)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ct,wt,bt,$e,Ps,ks,Es,$s,St=c(()=>{"use strict";o();Ct=l(require("net"),1),wt=l(require("os"),1),bt=1024,$e=65535,Ps=443,ks=()=>{let s=wt.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Es=(s,e)=>new Promise((t,i)=>{let r=Ct.default.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:a}=r.address();r.close(()=>{t(a)})})}),$s=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Es(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});var xt,Te,je,Y,Ot=c(()=>{"use strict";o();xt=l(require("chalk"),1);A();Te=l(require("url"),1);S();je=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:N("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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=D;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return Te.default.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return Te.default.format({protocol:t,hostname:e,port:xt.default.bold(i),pathname:r})}},Y=new je});var kt,Et,$t,Pt,Ts,js,Tt,jt=c(()=>{"use strict";o();kt=require("child_process"),Et=require("util");w();$();$t=(0,Et.promisify)(kt.exec),Pt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Ts=async()=>{let s=process.env.BROWSER;if(!s||!Pt.includes(s)){let{stdout:e}=await $t("ps cax");s=Pt.find(t=>e.includes(t))}return s},js=async s=>{if(process.platform==="darwin")try{let t=await Ts();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await $t(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},Tt=js});var De,Z,Dt=c(()=>{"use strict";o();De=l(require("fs/promises"),1);z();A();St();Ot();jt();S();Z=class{ip=D();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await K(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await K(e.empConfig.server.port)),Y.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Y.prettyPrintUrl("localhost")):(this.urls=Y.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
11
+ `)),this.isOpenBrower&&Tt(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([De.default.readFile(e.resource.key),De.default.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await K(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Rt,C,Lt,Nt,Re,p,w=c(()=>{"use strict";o();Rt=l(require("fs/promises"),1),C=l(require("path"),1),Lt=l(require("util"),1),Nt=require("@rspack/core");J();$();S();ye();rt();vt();Dt();ye();Q();Re=class{rspackVersion=Nt.rspack.rspackVersion;isOldRspack=_(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=C.default.resolve(__dirname,__filename).replace(`${C.default.sep}dist${C.default.sep}index.js`,"");empSource=C.default.resolve(this.empRoot,"dist");resolve=e=>C.default.isAbsolute(e)?e:C.default.resolve(this.root,e);empResolve=e=>C.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=et;server=new Z(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,r]=await Promise.all([We(),qe()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=r,await this.initVars(e,t),this.empConfig=it,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new de.default,await yt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=C.default.join(this.empRoot,"resource"),this.resource.cert=C.default.join(this.resource.dir,"emp.cert"),this.resource.key=C.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),n.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=C.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"?v(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(Lt.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"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=_;deepAssign=v;getLanIp=D;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new Re});function Fs(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,a,u)=>{let h=t[u],y=a;return h&&(y=a.length<h?a+" ".repeat(h-a.length):a),`${r+y} `}," ");console.log(L.bold(i))}async function Ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>Ns(g.name)).map(Ms);i.sort((g,O)=>g.size-O.size);let r=Math.max(...i.map(g=>g.sizeLabel.length)),a=Math.max(...i.map(g=>(g.folder+k.default.sep+g.name).length));Fs(a,r);let u=0,h=0;i.forEach(g=>{let{sizeLabel:O}=g,{name:os,folder:ns,gzipSizeLabel:ps}=g,Ue=(ns+k.default.sep+os).length,Be=O.length;if(u+=g.size,h+=g.gzippedSize,Be<r){let oe=" ".repeat(r-Be);O+=oe}let He=N(g.folder+k.default.sep)+zs(g.name);if(Ue<a){let oe=" ".repeat(a-Ue);He+=oe}n.info(` ${He} ${N(O)} ${ps}`)});let y=`${L.bold("Total size:")} ${ee(u)}`,E=`${L.bold("Gzipped size:")} ${ee(h)}`;n.info(`
12
12
  ${y}
13
- ${j}
14
- `),n.info(`${S("\u2713")} Ready in ${V(Number(e.time))}
15
- `)}function te(s=0){n.info(`${S("\u2713")} Ready in ${V(Number(s))}`)}var At,k,Nt,$s,Ts,js,Ds,Rs,Ls,ee,Ns,se=c(()=>{"use strict";r();At=l(require("fs"),1),k=l(require("path"),1),Nt=require("gzip-size");A();w();P();x();$s=/\.html$/,Ts=/\.(?:js|mjs|cjs|jsx)$/,js=/\.css$/,Ds=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Rs=s=>s>300*1e3?ne:s>100*1e3?H:pe,Ls=s=>{let e=s.name.split("?")[0],t=ee(s.size),i=k.default.basename(e),o=k.default.join(k.default.basename(p.empConfig.build.outDir),k.default.dirname(e)),a=At.default.readFileSync(k.default.join(p.empConfig.build.outDir,e)),u=a.length,f=(0,Nt.gzipSizeSync)(a),y=Rs(f)(ee(f));return{size:u,folder:o,name:i,gzippedSize:f,sizeLabel:t,gzipSizeLabel:y}};ee=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ns=s=>Ts.test(s)?H(s):js.test(s)?S(s):$s.test(s)?R(s):ae(s)});var E,ie=c(()=>{"use strict";r();P();x();w();E=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&he(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var Ft,I,zt=c(()=>{"use strict";r();Ft=require("@rspack/dev-server"),I=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new Ft.RspackDevServer(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(o),a}async beforeCompiler(e){return e}}});var Gt,It,Ut,Bt,Le,Ht,Jt,N,U,_t=c(()=>{"use strict";r();Gt=l(require("fs"),1),It=l(require("fs/promises"),1),Ut=l(require("compression"),1),Bt=l(require("cors"),1),Le=l(require("express"),1),Ht=l(require("https"),1),Jt=l(require("path"),1),N=(0,Le.default)();N.use((0,Ut.default)());N.use((0,Bt.default)());U=class{async setup(e,t=()=>{}){console.log(e.rsConfig.entry);let i="index",o=Object.keys(e.rsConfig.entry);if(o.length===0)return e.logger.sysError("emp serve must include entry!");if(o.includes(i)||(i=o[0]),!Gt.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let a=e.resolve(e.rsConfig.output?.path);N.use(Le.default.static(a));let u=await It.default.readFile(Jt.default.join(a,`${i}.html`),"utf8");if(N.get("*",(f,y)=>y.send(u)),e.server.isHttps){let{key:f,cert:y}=await e.server.getcert();Ht.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:f,cert:y},N).listen(e.server.port,t)}else N.listen(e.server.port,t)}}});var Ae=c(()=>{"use strict";r();zt();_t()});var qt={};D(qt,{default:()=>Ms});var Wt,Vt,Ne,Ms,Xt=c(()=>{"use strict";r();Wt=require("@rspack/core");se();x();ie();Ae();w();Vt=new I,Ne=class extends E{get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=v(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await Vt.beforeCompiler(t);let i=(0,Wt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Vt.setup(i,t,p,async o=>{this.showTimeDone(o),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});te(t.time)}},Ms=new Ne});var Me={};D(Me,{ServeScript:()=>oe,default:()=>zs});var Fs,Qt,oe,zs,Fe=c(()=>{"use strict";r();se();ie();Ae();w();Fs=new U,Qt=0,oe=class extends E{async run(){Qt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Fs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),te(Date.now()-Qt),await p.empConfig.lifeCycle.afterServe()}},zs=new oe});var Yt={};D(Yt,{default:()=>Gs});var Kt,ze,Gs,Zt=c(()=>{"use strict";r();Kt=require("@rspack/core");se();P();ie();w();ze=class extends E{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(Fe(),Me));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),(0,Kt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
- `),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Mt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Gs=new ze});var Us={};D(Us,{defineConfig:()=>Is,empHelper:()=>ve,rspack:()=>ts.rspack,runScript:()=>Ge,store:()=>p});module.exports=cs(Us);r();var ts=require("@rspack/core");r();var es=l(require("process"),1),$=require("commander");w();function Ge(){$.program.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),$.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Xt(),qt));await e.setup("dev",s)}),$.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Zt(),Yt));await e.setup("build",s)}),$.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Fe(),Me));await e.setup("serve",s)}),$.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(s=>{}),$.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(s=>{}),$.program.parse(es.default.argv)}w();z();function Is(s){return s}0&&(module.exports={defineConfig,empHelper,rspack,runScript,store});
13
+ ${E}
14
+ `),n.info(`${x("\u2713")} Ready in ${V(Number(e.time))}
15
+ `)}function te(s=0){n.info(`${x("\u2713")} Ready in ${V(Number(s))}`)}var At,k,Mt,Ds,Rs,Ls,Ns,As,Ms,ee,zs,se=c(()=>{"use strict";o();At=l(require("fs"),1),k=l(require("path"),1),Mt=require("gzip-size");A();w();$();S();Ds=/\.html$/,Rs=/\.(?:js|mjs|cjs|jsx)$/,Ls=/\.css$/,Ns=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),As=s=>s>300*1e3?ne:s>100*1e3?H:pe,Ms=s=>{let e=s.name.split("?")[0],t=ee(s.size),i=k.default.basename(e),r=k.default.join(k.default.basename(p.empConfig.build.outDir),k.default.dirname(e)),a=At.default.readFileSync(k.default.join(p.empConfig.build.outDir,e)),u=a.length,h=(0,Mt.gzipSizeSync)(a),y=As(h)(ee(h));return{size:u,folder:r,name:i,gzippedSize:h,sizeLabel:t,gzipSizeLabel:y}};ee=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},zs=s=>Rs.test(s)?H(s):Ls.test(s)?x(s):Ds.test(s)?L(s):ae(s)});var T,ie=c(()=>{"use strict";o();$();S();w();T=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&he(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var zt,Gt,I,It=c(()=>{"use strict";o();zt=require("@rspack/dev-server"),Gt=l(require("connect"),1),I=class{async setup(e,t,i,r=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new zt.RspackDevServer(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(r),a}async beforeCompiler(e){return e.devServer.app=()=>(0,Gt.default)(),e.devServer.server&&e.devServer.server.type==="https"&&(e.devServer.server.type="http2"),e}}});var Le,Ut,Bt,Ht,Jt,_t,Ne,Vt,Wt,M,U,qt=c(()=>{"use strict";o();Le=l(require("fs"),1),Ut=l(require("fs/promises"),1),Bt=l(require("compression"),1),Ht=l(require("connect"),1),Jt=l(require("cors"),1),_t=l(require("http2"),1),Ne=l(require("path"),1),Vt=l(require("serve-static"),1),Wt=require("url"),M=(0,Ht.default)();M.use((0,Bt.default)());M.use((0,Jt.default)());U=class{async setup(e,t=()=>{}){let i="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(i)||(i=r[0]),!Le.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let a=e.resolve(e.rsConfig.output?.path);M.use((0,Vt.default)(a));let u=await Ut.default.readFile(Ne.default.join(a,`${i}.html`),"utf8");if(M.use((h,y,E)=>{let O=(0,Wt.parse)(h.url||"",!0).pathname;if(O&&O!=="/"&&Le.default.existsSync(Ne.default.join(a,O)))return E();y.setHeader("Content-Type","text/html"),y.end(u)}),e.server.isHttps){let{key:h,cert:y}=await e.server.getcert();_t.default.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:h,cert:y,allowHTTP1:!0},M).listen(e.server.port,t)}else require("http").createServer(M).listen(e.server.port,t)}}});var Ae=c(()=>{"use strict";o();It();qt()});var Kt={};R(Kt,{default:()=>Gs});var Qt,Xt,Me,Gs,Yt=c(()=>{"use strict";o();Qt=require("@rspack/core");se();S();ie();Ae();w();Xt=new I,Me=class extends T{get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=v(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:r}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await Xt.beforeCompiler(t);let i=(0,Qt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Xt.setup(i,t,p,async r=>{this.showTimeDone(r),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});te(t.time)}},Gs=new Me});var Fe={};R(Fe,{ServeScript:()=>re,default:()=>Us});var Is,Zt,re,Us,ze=c(()=>{"use strict";o();se();ie();Ae();w();Is=new U,Zt=0,re=class extends T{async run(){Zt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Is.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),te(Date.now()-Zt),await p.empConfig.lifeCycle.afterServe()}},Us=new re});var ts={};R(ts,{default:()=>Bs});var es,Ge,Bs,ss=c(()=>{"use strict";o();es=require("@rspack/core");se();$();ie();w();Ge=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(()=>(ze(),Fe));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),(0,es.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
+ `),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Ft(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Bs=new Ge});var Js={};R(Js,{defineConfig:()=>Hs,empHelper:()=>ve,rspack:()=>rs.rspack,runScript:()=>Ie,store:()=>p});module.exports=hs(Js);o();var rs=require("@rspack/core");o();var is=l(require("process"),1),j=require("commander");w();function Ie(){j.program.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),j.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Yt(),Kt));await e.setup("dev",s)}),j.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(ss(),ts));await e.setup("build",s)}),j.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>(ze(),Fe));await e.setup("serve",s)}),j.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(s=>{}),j.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(s=>{}),j.program.parse(is.default.argv)}w();z();function Hs(s){return s}0&&(module.exports={defineConfig,empHelper,rspack,runScript,store});
17
17
  if (module.exports.default) module.exports = module.exports.default;
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
- var jt=Object.defineProperty;var b=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var F=(s,e)=>{for(var t in e)jt(s,t,{get:e[t],enumerable:!0})};import Dt from"path";import{fileURLToPath as Rt}from"url";var Le,Lt,c,l,r=m(()=>{"use strict";Le=()=>Rt(import.meta.url),Lt=()=>Dt.dirname(Le()),c=Lt(),l=Le()});import d from"chalk";var At,O,Nt,Mt,Ft,re,U,zt,Gt,R,ne,It,pe,L,h,A=m(()=>{"use strict";r();At=d.hex("#1abc9c"),O=d.hex("#16a085"),Nt=d.hex("#2ecc71"),Mt=d.hex("#27ae60"),Ft=d.hex("#e74c3c"),re=d.hex("#c0392b"),U=d.hex("#f1c40f"),zt=d.hex("#f39c12"),Gt=d.hex("#3498db"),R=d.hex("#2980b9"),ne=d.hex("#ecf0f1"),It=d.hex("#fd79a8"),pe=d.hex("#e84393"),L=d.hex("#7f8c8d"),h={lightGreen:At,green:O,lightCyan:Nt,cyan:Mt,lightRed:Ft,red:re,yellow:U,orange:zt,lightBlue:Gt,blue:R,white:ne,lightMagenta:It,magenta:pe,gray:L}});var ae,n,k=m(()=>{"use strict";r();A();ae=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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
- `)}},n=new ae});import Ae from"fs";import{createJiti as Bt}from"jiti";import Ne from"path";var Ut,Me,Fe,ze,Ge,H=m(()=>{"use strict";r();C();k();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"],Me=Bt(l,{interopDefault:!0}),Fe=async()=>{n.time("[store]GetEmpConfigPath");let s=Ut.map(i=>Ne.resolve(p.root,i)),e=await Promise.all(s.map(i=>Ae.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,o)=>e[o]);return n.timeEnd("[store]GetEmpConfigPath"),t},ze=async()=>{let s=Ne.join(p.root,"tsconfig.json");return await Ae.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ge=()=>{let s=[];return p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ue={};F(ue,{clearConsole:()=>ce,deepAssign:()=>v,ensureArray:()=>Wt,getLanIp:()=>T,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>qt,timeFormat:()=>_,vCompare:()=>J});import{ip as Ht}from"address";import Jt from"chalk";import{gateway4sync as _t}from"default-gateway";import Vt from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function v(s,...e){for(let t of e)for(let i in t){let o=t[i],a=s[i];if(Object(o)==o&&Object(a)===a){s[i]=v(a,o);continue}s[i]=t[i]}return s}var T,le,Wt,qt,J,_,me,w=m(()=>{"use strict";r();T=()=>{let s="127.0.0.1";try{let{int:e}=_t();return Ht(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Vt.readJSONSync(s);return e}catch{return}};Wt=s=>Array.isArray(s)?s:[s],qt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),a=0;for(let u=0;u<o;u++){let f=t.length>u?t[u]:0,y=isNaN(Number(f))?f.charCodeAt():Number(f),D=i.length>u?i[u]:0,g=isNaN(Number(D))?D.charCodeAt():Number(D);if(y<g){a=-1;break}else if(y>g){a=1;break}}return a},_=s=>{s=s/1e3;let e=i=>Jt.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});import Ie from"webpack-chain";var Be,he=m(()=>{"use strict";r();Be={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Ue={};F(Ue,{chalk:()=>Xt,color:()=>h,glob:()=>V,logger:()=>n,utils:()=>ue});import Xt from"chalk";import{glob as V}from"glob";var z=m(()=>{"use strict";r();A();k();w()});var W,He=m(()=>{"use strict";r();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var fe,Je,_e=m(()=>{"use strict";r();z();H();w();He();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},v(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},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:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open: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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(a,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return v({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await Me(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Je=new fe});import Qt from"fs-extra";var ge,Ve,We=m(()=>{"use strict";r();H();ge=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({name:this.store.pkg.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ge(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Qt.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},Ve=new ge});var de,qe,Xe=m(()=>{"use strict";r();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:b.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:b.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:b.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},qe=new de});import ye from"html-webpack-plugin";function Kt(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
- `);return me(s)}var q,G,X=m(()=>{"use strict";r();w();C();q=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Kt(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{ye.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:a,...u}=o;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import x from"path";var ve,Qe,Ke=m(()=>{"use strict";r();z();X();ve=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(x.extname(e),"").replace(`${this.store.empConfig.appSrc}${x.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(x.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(x.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),a=[i];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(ye,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=x.join(this.store.appSrc,e),i=x.join(t,"**","*.{ts,tsx,jsx,js}"),o=await V([i],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${x.sep}`,"")),o.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},x.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=x.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await V([e],{windowsPathsNoEscape:!0});if(t[0]){let i=x.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(i,this.store.empConfig.html,t[0])}n.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)}},Qe=new ve});import Ye from"path";var be,Ze,et=m(()=>{"use strict";r();w();be=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:v(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",Ye.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ye.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ze=new be});import P from"@rspack/core";import tt from"fs";import{TsCheckerRspackPlugin as Yt}from"ts-checker-rspack-plugin";var Ce,st,it=m(()=>{"use strict";r();X();Ce=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(Yt,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(P.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");tt.existsSync(e)&&tt.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(P.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(P.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(P.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=P;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=b("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(P.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(P.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(P.experiments.CssChunkingPlugin,[{}])}},st=new Ce});var we,ot,rt=m(()=>{"use strict";r();We();Xe();Ke();et();it();we=class{store;async setup(e){this.store=e;let t=[Ve.setup(this.store),Ze.setup(this.store),st.setup(this.store),Qe.setup(this.store),qe.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ot=new we});import Zt from"net";import es from"os";async function Q(s,e=void 0){if(s!==ts&&(s<nt||s>xe))throw new Error(`Port number must lie between ${nt} and ${xe}`);let t=s,i=ss(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await os(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var nt,xe,ts,ss,is,os,pt=m(()=>{"use strict";r();nt=1024,xe=65535,ts=443,ss=()=>{let s=es.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},is=(s,e)=>new Promise((t,i)=>{let o=Zt.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),os=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await is(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import rs from"chalk";import at from"url";var Se,K,lt=m(()=>{"use strict";r();A();w();Se=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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return at.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return at.format({protocol:t,hostname:e,port:rs.bold(i),pathname:o})}},K=new Se});import{exec as ns}from"child_process";import{promisify as ps}from"util";var mt,ct,as,ls,ut,ht=m(()=>{"use strict";r();C();k();mt=ps(ns),ct=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],as=async()=>{let s=process.env.BROWSER;if(!s||!ct.includes(s)){let{stdout:e}=await mt("ps cax");s=ct.find(t=>e.includes(t))}return s},ls=async s=>{if(process.platform==="darwin")try{let t=await as();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await mt(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},ut=ls});import ft from"fs/promises";var Y,gt=m(()=>{"use strict";r();z();A();pt();lt();ht();w();Y=class{ip=T();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Q(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Q(e.empConfig.server.port)),K.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=K.prettyPrintUrl("localhost")):(this.urls=K.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${O("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${O("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${O("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${O("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
12
- `)),this.isOpenBrower&&ut(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([ft.readFile(e.resource.key),ft.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Q(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import cs from"fs/promises";import S from"path";import ms from"util";import{rspack as us}from"@rspack/core";var Oe,p,C=m(()=>{"use strict";r();H();k();w();he();_e();rt();gt();he();X();Oe=class{rspackVersion=us.rspackVersion;isOldRspack=J(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(c,l).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:""};chainName=Be;server=new Y(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,o]=await Promise.all([Fe(),ze()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,await this.initVars(e,t),this.empConfig=Je,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Ie,await ot.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=b(this.empResolve("package.json")),o=b(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},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),n.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);cs.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"?v(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(ms.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=J;deepAssign=v;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new Oe});import hs from"fs";import E from"path";import{gzipSizeSync as fs}from"gzip-size";function ws(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let f=t[u],y=a;return f&&(y=a.length<f?a+" ".repeat(f-a.length):a),`${o+y} `}," ");console.log(R.bold(i))}async function dt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>vs(g.name)).map(Cs);i.sort((g,M)=>g.size-M.size);let o=Math.max(...i.map(g=>g.sizeLabel.length)),a=Math.max(...i.map(g=>(g.folder+E.sep+g.name).length));ws(a,o);let u=0,f=0;i.forEach(g=>{let{sizeLabel:M}=g,{name:Et,folder:$t,gzipSizeLabel:Tt}=g,je=($t+E.sep+Et).length,De=M.length;if(u+=g.size,f+=g.gzippedSize,De<o){let oe=" ".repeat(o-De);M+=oe}let Re=L(g.folder+E.sep)+xs(g.name);if(je<a){let oe=" ".repeat(a-je);Re+=oe}n.info(` ${Re} ${L(M)} ${Tt}`)});let y=`${R.bold("Total size:")} ${Z(u)}`,D=`${R.bold("Gzipped size:")} ${Z(f)}`;n.info(`
13
- ${y}
14
- ${D}
2
+ var Dt=Object.defineProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var F=(s,e)=>{for(var t in e)Dt(s,t,{get:e[t],enumerable:!0})};import Rt from"path";import{fileURLToPath as Lt}from"url";var Le,Nt,c,l,r=m(()=>{"use strict";Le=()=>Lt(import.meta.url),Nt=()=>Rt.dirname(Le()),c=Nt(),l=Le()});import y from"chalk";var At,O,Mt,Ft,zt,re,B,Gt,It,L,ne,Ut,pe,N,f,A=m(()=>{"use strict";r();At=y.hex("#1abc9c"),O=y.hex("#16a085"),Mt=y.hex("#2ecc71"),Ft=y.hex("#27ae60"),zt=y.hex("#e74c3c"),re=y.hex("#c0392b"),B=y.hex("#f1c40f"),Gt=y.hex("#f39c12"),It=y.hex("#3498db"),L=y.hex("#2980b9"),ne=y.hex("#ecf0f1"),Ut=y.hex("#fd79a8"),pe=y.hex("#e84393"),N=y.hex("#7f8c8d"),f={lightGreen:At,green:O,lightCyan:Mt,cyan:Ft,lightRed:zt,red:re,yellow:B,orange:Gt,lightBlue:It,blue:L,white:ne,lightMagenta:Ut,magenta:pe,gray:N}});var ae,n,E=m(()=>{"use strict";r();A();ae=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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
+ `)}},n=new ae});import Ne from"fs";import{createJiti as Bt}from"jiti";import Ae from"path";var Ht,Me,Fe,ze,Ge,H=m(()=>{"use strict";r();C();E();Ht=["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"],Me=Bt(l,{interopDefault:!0}),Fe=async()=>{n.time("[store]GetEmpConfigPath");let s=Ht.map(i=>Ae.resolve(a.root,i)),e=await Promise.all(s.map(i=>Ne.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,o)=>e[o]);return n.timeEnd("[store]GetEmpConfigPath"),t},ze=async()=>{let s=Ae.join(a.root,"tsconfig.json");return await Ne.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ge=()=>{let s=[];return a.rootPaths.empConfig&&s.push(a.rootPaths.empConfig),a.rootPaths.tsConfig&&s.push(a.rootPaths.tsConfig),s}});var ue={};F(ue,{clearConsole:()=>ce,deepAssign:()=>b,ensureArray:()=>qt,getLanIp:()=>D,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>Xt,timeFormat:()=>_,vCompare:()=>J});import{ip as Jt}from"address";import _t from"chalk";import{gateway4sync as Vt}from"default-gateway";import Wt from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function b(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=b(p,o);continue}s[i]=t[i]}return s}var D,le,qt,Xt,J,_,me,w=m(()=>{"use strict";r();D=()=>{let s="127.0.0.1";try{let{int:e}=Vt();return Jt(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Wt.readJSONSync(s);return e}catch{return}};qt=s=>Array.isArray(s)?s:[s],Xt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let h=t.length>u?t[u]:0,d=isNaN(Number(h))?h.charCodeAt():Number(h),k=i.length>u?i[u]:0,g=isNaN(Number(k))?k.charCodeAt():Number(k);if(d<g){p=-1;break}else if(d>g){p=1;break}}return p},_=s=>{s=s/1e3;let e=i=>_t.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});import Ie from"webpack-chain";var Ue,he=m(()=>{"use strict";r();Ue={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Be={};F(Be,{chalk:()=>Qt,color:()=>f,glob:()=>V,logger:()=>n,utils:()=>ue});import Qt from"chalk";import{glob as V}from"glob";var z=m(()=>{"use strict";r();A();E();w()});var W,He=m(()=>{"use strict";r();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var fe,Je,_e=m(()=>{"use strict";r();z();H();w();He();fe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},b(e,t)}isESM=!1;checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},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:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open: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&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return b({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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await Me(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Je=new fe});import Kt from"fs-extra";var ge,Ve,We=m(()=>{"use strict";r();H();ge=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({name:this.store.pkg.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ge(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,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,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Kt.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}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.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},Ve=new ge});var de,qe,Xe=m(()=>{"use strict";r();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:v.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:v.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},qe=new de});import ye from"html-webpack-plugin";function Yt(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
+ `);return me(s)}var q,G,X=m(()=>{"use strict";r();w();C();q=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Yt(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{ye.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:p,...u}=o;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import x from"path";var ve,Qe,Ke=m(()=>{"use strict";r();z();X();ve=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(x.extname(e),"").replace(`${this.store.empConfig.appSrc}${x.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(x.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(x.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),p=[i];this.entriesConfig[o]={entry:{[o]:p},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(ye,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=x.join(this.store.appSrc,e),i=x.join(t,"**","*.{ts,tsx,jsx,js}"),o=await V([i],{windowsPathsNoEscape:!0});o=o.map(p=>p.replace(`${t}${x.sep}`,"")),o.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},x.join(t,p))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=x.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await V([e],{windowsPathsNoEscape:!0});if(t[0]){let i=x.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(i,this.store.empConfig.html,t[0])}n.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)}},Qe=new ve});import Ye from"path";var be,Ze,et=m(()=>{"use strict";r();w();be=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:b(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",Ye.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ye.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ze=new be});import $ from"@rspack/core";import tt from"fs";import{TsCheckerRspackPlugin as Zt}from"ts-checker-rspack-plugin";var Ce,st,it=m(()=>{"use strict";r();X();Ce=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(Zt,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use($.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");tt.existsSync(e)&&tt.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use($.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use($.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use($.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=$;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use($.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use($.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use($.experiments.CssChunkingPlugin,[{}])}},st=new Ce});var we,ot,rt=m(()=>{"use strict";r();We();Xe();Ke();et();it();we=class{store;async setup(e){this.store=e;let t=[Ve.setup(this.store),Ze.setup(this.store),st.setup(this.store),Qe.setup(this.store),qe.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ot=new we});import es from"net";import ts from"os";async function Q(s,e=void 0){if(s!==ss&&(s<nt||s>xe))throw new Error(`Port number must lie between ${nt} and ${xe}`);let t=s,i=is(),o;e&&!i.has(e)?o=new Set([e]):o=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await rs(t,o)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var nt,xe,ss,is,os,rs,pt=m(()=>{"use strict";r();nt=1024,xe=65535,ss=443,is=()=>{let s=ts.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},os=(s,e)=>new Promise((t,i)=>{let o=es.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:p}=o.address();o.close(()=>{t(p)})})}),rs=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await os(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import ns from"chalk";import at from"url";var Se,K,lt=m(()=>{"use strict";r();A();w();Se=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:N("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==="::",i;if(t){i="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 i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=D;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return at.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return at.format({protocol:t,hostname:e,port:ns.bold(i),pathname:o})}},K=new Se});import{exec as ps}from"child_process";import{promisify as as}from"util";var mt,ct,ls,cs,ut,ht=m(()=>{"use strict";r();C();E();mt=as(ps),ct=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ls=async()=>{let s=process.env.BROWSER;if(!s||!ct.includes(s)){let{stdout:e}=await mt("ps cax");s=ct.find(t=>e.includes(t))}return s},cs=async s=>{if(process.platform==="darwin")try{let t=await ls();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await mt(i,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},ut=cs});import ft from"fs/promises";var Y,gt=m(()=>{"use strict";r();z();A();pt();lt();ht();w();Y=class{ip=D();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Q(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Q(e.empConfig.server.port)),K.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=K.prettyPrintUrl("localhost")):(this.urls=K.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${O("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${O("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${O("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${O("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
12
+ `)),this.isOpenBrower&&ut(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([ft.readFile(e.resource.key),ft.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Q(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import ms from"fs/promises";import S from"path";import us from"util";import{rspack as hs}from"@rspack/core";var Oe,a,C=m(()=>{"use strict";r();H();E();w();he();_e();rt();gt();he();X();Oe=class{rspackVersion=hs.rspackVersion;isOldRspack=J(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(c,l).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:""};chainName=Ue;server=new Y(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,o]=await Promise.all([Fe(),ze()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,await this.initVars(e,t),this.empConfig=Je,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Ie,await ot.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,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 i=v(this.empResolve("package.json")),o=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},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),n.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);ms.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"?b(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(us.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=J;deepAssign=b;getLanIp=D;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},a=new Oe});import fs from"fs";import T from"path";import{gzipSizeSync as gs}from"gzip-size";function xs(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,p,u)=>{let h=t[u],d=p;return h&&(d=p.length<h?p+" ".repeat(h-p.length):p),`${o+d} `}," ");console.log(L.bold(i))}async function dt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(g=>bs(g.name)).map(ws);i.sort((g,P)=>g.size-P.size);let o=Math.max(...i.map(g=>g.sizeLabel.length)),p=Math.max(...i.map(g=>(g.folder+T.sep+g.name).length));xs(p,o);let u=0,h=0;i.forEach(g=>{let{sizeLabel:P}=g,{name:$t,folder:Tt,gzipSizeLabel:jt}=g,je=(Tt+T.sep+$t).length,De=P.length;if(u+=g.size,h+=g.gzippedSize,De<o){let oe=" ".repeat(o-De);P+=oe}let Re=N(g.folder+T.sep)+Ss(g.name);if(je<p){let oe=" ".repeat(p-je);Re+=oe}n.info(` ${Re} ${N(P)} ${jt}`)});let d=`${L.bold("Total size:")} ${Z(u)}`,k=`${L.bold("Gzipped size:")} ${Z(h)}`;n.info(`
13
+ ${d}
14
+ ${k}
15
15
  `),n.info(`${O("\u2713")} Ready in ${_(Number(e.time))}
16
- `)}function ee(s=0){n.info(`${O("\u2713")} Ready in ${_(Number(s))}`)}var gs,ds,ys,vs,bs,Cs,Z,xs,te=m(()=>{"use strict";r();A();C();k();w();gs=/\.html$/,ds=/\.(?:js|mjs|cjs|jsx)$/,ys=/\.css$/,vs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),bs=s=>s>300*1e3?re:s>100*1e3?U:ne,Cs=s=>{let e=s.name.split("?")[0],t=Z(s.size),i=E.basename(e),o=E.join(E.basename(p.empConfig.build.outDir),E.dirname(e)),a=hs.readFileSync(E.join(p.empConfig.build.outDir,e)),u=a.length,f=fs(a),y=bs(f)(Z(f));return{size:u,folder:o,name:i,gzippedSize:f,sizeLabel:t,gzipSizeLabel:y}};Z=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},xs=s=>ds.test(s)?U(s):ys.test(s)?O(s):gs.test(s)?R(s):pe(s)});var $,se=m(()=>{"use strict";r();k();w();C();$=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&ce(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});import{RspackDevServer as Ss}from"@rspack/dev-server";var I,yt=m(()=>{"use strict";r();I=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new Ss(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(o),a}async beforeCompiler(e){return e}}});import Os from"fs";import ks from"fs/promises";import Ps from"compression";import Es from"cors";import vt from"express";import $s from"https";import Ts from"path";var N,B,bt=m(()=>{"use strict";r();N=vt();N.use(Ps());N.use(Es());B=class{async setup(e,t=()=>{}){console.log(e.rsConfig.entry);let i="index",o=Object.keys(e.rsConfig.entry);if(o.length===0)return e.logger.sysError("emp serve must include entry!");if(o.includes(i)||(i=o[0]),!Os.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let a=e.resolve(e.rsConfig.output?.path);N.use(vt.static(a));let u=await ks.readFile(Ts.join(a,`${i}.html`),"utf8");if(N.get("*",(f,y)=>y.send(u)),e.server.isHttps){let{key:f,cert:y}=await e.server.getcert();$s.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:f,cert:y},N).listen(e.server.port,t)}else N.listen(e.server.port,t)}}});var ke=m(()=>{"use strict";r();yt();bt()});var wt={};F(wt,{default:()=>Ds});import{rspack as js}from"@rspack/core";var Ct,Pe,Ds,xt=m(()=>{"use strict";r();te();w();se();ke();C();Ct=new I,Pe=class extends ${get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=v(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await Ct.beforeCompiler(t);let i=js(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Ct.setup(i,t,p,async o=>{this.showTimeDone(o),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});ee(t.time)}},Ds=new Pe});var Ee={};F(Ee,{ServeScript:()=>ie,default:()=>Ls});var Rs,St,ie,Ls,$e=m(()=>{"use strict";r();te();se();ke();C();Rs=new B,St=0,ie=class extends ${async run(){St=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Rs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),ee(Date.now()-St),await p.empConfig.lifeCycle.afterServe()}},Ls=new ie});var Ot={};F(Ot,{default:()=>Ns});import{rspack as As}from"@rspack/core";var Te,Ns,kt=m(()=>{"use strict";r();te();k();se();C();Te=class extends ${isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>($e(),Ee));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),As(this.rspackConfig,async(e,t)=>{if(console.log(`
17
- `),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await dt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Ns=new Te});r();import{rspack as Jr}from"@rspack/core";r();C();import Ms from"process";import{program as j}from"commander";function Pt(){j.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),j.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(xt(),wt));await e.setup("dev",s)}),j.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(kt(),Ot));await e.setup("build",s)}),j.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>($e(),Ee));await e.setup("serve",s)}),j.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(s=>{}),j.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(s=>{}),j.parse(Ms.argv)}C();z();function Wr(s){return s}export{Wr as defineConfig,Ue as empHelper,Jr as rspack,Pt as runScript,p as store};
16
+ `)}function ee(s=0){n.info(`${O("\u2713")} Ready in ${_(Number(s))}`)}var ds,ys,vs,bs,Cs,ws,Z,Ss,te=m(()=>{"use strict";r();A();C();E();w();ds=/\.html$/,ys=/\.(?:js|mjs|cjs|jsx)$/,vs=/\.css$/,bs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Cs=s=>s>300*1e3?re:s>100*1e3?B:ne,ws=s=>{let e=s.name.split("?")[0],t=Z(s.size),i=T.basename(e),o=T.join(T.basename(a.empConfig.build.outDir),T.dirname(e)),p=fs.readFileSync(T.join(a.empConfig.build.outDir,e)),u=p.length,h=gs(p),d=Cs(h)(Z(h));return{size:u,folder:o,name:i,gzippedSize:h,sizeLabel:t,gzipSizeLabel:d}};Z=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ss=s=>ys.test(s)?B(s):vs.test(s)?O(s):ds.test(s)?L(s):pe(s)});var j,se=m(()=>{"use strict";r();E();w();C();j=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&ce(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});import{RspackDevServer as Os}from"@rspack/dev-server";import Ps from"connect";var I,yt=m(()=>{"use strict";r();I=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new Os(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(o),p}async beforeCompiler(e){return e.devServer.app=()=>Ps(),e.devServer.server&&e.devServer.server.type==="https"&&(e.devServer.server.type="http2"),e}}});import vt from"fs";import ks from"fs/promises";import Es from"compression";import $s from"connect";import Ts from"cors";import js from"http2";import bt from"path";import Ds from"serve-static";import{parse as Rs}from"url";var M,U,Ct=m(()=>{"use strict";r();M=$s();M.use(Es());M.use(Ts());U=class{async setup(e,t=()=>{}){let i="index",o=Object.keys(e.rsConfig.entry);if(o.length===0)return e.logger.sysError("emp serve must include entry!");if(o.includes(i)||(i=o[0]),!vt.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let p=e.resolve(e.rsConfig.output?.path);M.use(Ds(p));let u=await ks.readFile(bt.join(p,`${i}.html`),"utf8");if(M.use((h,d,k)=>{let P=Rs(h.url||"",!0).pathname;if(P&&P!=="/"&&vt.existsSync(bt.join(p,P)))return k();d.setHeader("Content-Type","text/html"),d.end(u)}),e.server.isHttps){let{key:h,cert:d}=await e.server.getcert();js.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:h,cert:d,allowHTTP1:!0},M).listen(e.server.port,t)}else v("http").createServer(M).listen(e.server.port,t)}}});var Pe=m(()=>{"use strict";r();yt();Ct()});var xt={};F(xt,{default:()=>Ns});import{rspack as Ls}from"@rspack/core";var wt,ke,Ns,St=m(()=>{"use strict";r();te();w();se();Pe();C();wt=new I,ke=class extends j{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=b(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:a.server.port}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await a.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=a,t=await this.getRspackDevConfig();t=await wt.beforeCompiler(t);let i=Ls(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await wt.setup(i,t,a,async o=>{this.showTimeDone(o),await a.empConfig.lifeCycle.afterDevServe()}),a.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});ee(t.time)}},Ns=new ke});var Ee={};F(Ee,{ServeScript:()=>ie,default:()=>Ms});var As,Ot,ie,Ms,$e=m(()=>{"use strict";r();te();se();Pe();C();As=new U,Ot=0,ie=class extends j{async run(){Ot=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await As.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),ee(Date.now()-Ot),await a.empConfig.lifeCycle.afterServe()}},Ms=new ie});var Pt={};F(Pt,{default:()=>zs});import{rspack as Fs}from"@rspack/core";var Te,zs,kt=m(()=>{"use strict";r();te();E();se();C();Te=class extends j{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(()=>($e(),Ee));await e.setup("serve",a.cliOptions)}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(),Fs(this.rspackConfig,async(e,t)=>{if(console.log(`
17
+ `),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await dt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},zs=new Te});r();import{rspack as Qr}from"@rspack/core";r();C();import Gs from"process";import{program as R}from"commander";function Et(){R.version(a.empPkg.version,"-v, --version").usage("<command> [options]"),R.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(St(),xt));await e.setup("dev",s)}),R.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(kt(),Pt));await e.setup("build",s)}),R.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>($e(),Ee));await e.setup("serve",s)}),R.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(s=>{}),R.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(s=>{}),R.parse(Gs.argv)}C();z();function Zr(s){return s}export{Zr as defineConfig,Be as empHelper,Qr as rspack,Et as runScript,a as store};
package/emp-tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "types": ["@empjs/cli/client"],
4
- "plugins": [{ "name": "typescript-plugin-css-modules" }],
4
+ "plugins": [{ "name": "@empjs/typescript-plugin-css-modules" }],
5
5
  "target": "ESNext",
6
6
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
7
7
  "allowJs": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.8.4",
3
+ "version": "3.9.0-beta.0",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,12 +55,13 @@
55
55
  "author": "Ken",
56
56
  "devDependencies": {
57
57
  "@types/compression": "^1.7.2",
58
+ "@types/connect": "^3.4.38",
58
59
  "@types/cors": "^2.8.12",
59
60
  "@types/default-gateway": "^7.2.1",
60
- "@types/express": "^4.17.13",
61
61
  "@types/fs-extra": "^11.0.4",
62
62
  "@types/node": "^20.8.7",
63
63
  "@types/react": "^18.3.2",
64
+ "@types/serve-static": "^1.15.8",
64
65
  "@types/watchpack": "^2.4.3",
65
66
  "@types/webpack": "^5.28.4",
66
67
  "@types/webpack-bundle-analyzer": "^4.6.2",
@@ -68,6 +69,7 @@
68
69
  "tsup": "^8.4.0"
69
70
  },
70
71
  "dependencies": {
72
+ "@empjs/typescript-plugin-css-modules": "1.0.0",
71
73
  "@rsdoctor/rspack-plugin": "1.1.8",
72
74
  "@rspack/core": "1.4.9",
73
75
  "@rspack/dev-server": "1.1.3",
@@ -76,10 +78,10 @@
76
78
  "chalk": "^5.3.0",
77
79
  "commander": "^11.1.0",
78
80
  "compression": "^1.7.4",
81
+ "connect": "^3.7.0",
79
82
  "core-js": "^3.41.0",
80
83
  "cors": "^2.8.5",
81
84
  "default-gateway": "^7.2.2",
82
- "express": "^4.21.2",
83
85
  "fs-extra": "^11.2.0",
84
86
  "glob": "^11.0.1",
85
87
  "gzip-size": "^7.0.0",
@@ -89,8 +91,8 @@
89
91
  "open": "^10.1.0",
90
92
  "sass-embedded": "1.89.2",
91
93
  "sass-loader": "^16.0.5",
94
+ "serve-static": "^2.2.0",
92
95
  "ts-checker-rspack-plugin": "^1.1.4",
93
- "typescript-plugin-css-modules": "^5.1.0",
94
96
  "webpack-bundle-analyzer": "^4.10.2",
95
97
  "webpack-chain": "^6.5.1"
96
98
  },