@empjs/cli 3.2.0-beta.1 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6,12 +6,12 @@
6
6
  `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
7
7
  `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
8
8
  `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
9
- `)}},n=new ie});var ae={};T(ae,{clearConsole:()=>re,deepAssign:()=>y,ensureArray:()=>is,getLanIp:()=>$,getPkgVersion:()=>oe,importJsVm:()=>pe,jsonFilter:()=>os,timeFormat:()=>U,vCompare:()=>ne});function re(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(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]=y(a,o);continue}s[i]=t[i]}return s}var Re,Ae,Ne,Me,$,oe,is,os,ne,U,pe,C=c(()=>{"use strict";r();Re=require("address"),Ae=l(require("chalk"),1),Ne=require("default-gateway"),Me=l(require("fs-extra"),1),$=()=>{let{int:s}=(0,Ne.gateway4sync)();return(0,Re.ip)(s||"")||"127.0.0.1"},oe=s=>{try{let{version:e}=Me.default.readJSONSync(s);return e}catch{return}};is=s=>Array.isArray(s)?s:[s],os=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),ne=(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 g=t.length>u?t[u]:0,S=isNaN(Number(g))?g.charCodeAt():Number(g),A=i.length>u?i[u]:0,f=isNaN(Number(A))?A.charCodeAt():Number(A);if(S<f){a=-1;break}else if(S>f){a=1;break}}return a},U=s=>{s=s/1e3;let e=i=>Ae.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`},pe=s=>`data:text/javascript,${s}`});var le={};T(le,{chalk:()=>Fe.default,color:()=>h,glob:()=>M.glob,logger:()=>n,utils:()=>ae});var Fe,M,F=c(()=>{"use strict";r();Fe=l(require("chalk"),1),M=require("glob");R();C();E()});var Ge,ze,Ie,rs,Ue,Be,ns,Je=c(()=>{"use strict";r();Ge=l(require("fs"),1),ze=l(require("path"),1),Ie=require("jiti");w();E();rs=["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"],Ue=(0,Ie.createJiti)(__filename,{interopDefault:!0}),Be=async()=>ns(),ns=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of rs){let t=ze.default.resolve(p.root,e);if(Ge.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var B,He=c(()=>{"use strict";r();B=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 _e,ce,We,qe=c(()=>{"use strict";r();_e=l(require("fs"),1);F();Je();C();He();ce=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 B(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={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1},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,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}},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:!0,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)}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 y({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(){n.time("[store][empConfig]SyncEmpOptions");let e=await Be();if(!e||!_e.default.existsSync(e))return;let t=await Ue(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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 ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},We=new ce});var Ve,me,Xe,Qe=c(()=>{"use strict";r();Ve=l(require("fs-extra"),1),me=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Ve.default.exists(e)){let 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})}},Xe=new me});var ue,Ke,Ye=c(()=>{"use strict";r();ue=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||{sass:{}};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"}}}})}},Ke=new ue});function ps(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
9
+ `)}},n=new ie});var ae={};T(ae,{clearConsole:()=>re,deepAssign:()=>y,ensureArray:()=>is,getLanIp:()=>$,getPkgVersion:()=>oe,importJsVm:()=>pe,jsonFilter:()=>os,timeFormat:()=>U,vCompare:()=>ne});function re(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(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]=y(a,o);continue}s[i]=t[i]}return s}var Re,Ae,Ne,Me,$,oe,is,os,ne,U,pe,C=c(()=>{"use strict";r();Re=require("address"),Ae=l(require("chalk"),1),Ne=require("default-gateway"),Me=l(require("fs-extra"),1),$=()=>{let{int:s}=(0,Ne.gateway4sync)();return(0,Re.ip)(s||"")||"127.0.0.1"},oe=s=>{try{let{version:e}=Me.default.readJSONSync(s);return e}catch{return}};is=s=>Array.isArray(s)?s:[s],os=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),ne=(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 g=t.length>u?t[u]:0,S=isNaN(Number(g))?g.charCodeAt():Number(g),A=i.length>u?i[u]:0,f=isNaN(Number(A))?A.charCodeAt():Number(A);if(S<f){a=-1;break}else if(S>f){a=1;break}}return a},U=s=>{s=s/1e3;let e=i=>Ae.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`},pe=s=>`data:text/javascript,${s}`});var le={};T(le,{chalk:()=>Fe.default,color:()=>h,glob:()=>M.glob,logger:()=>n,utils:()=>ae});var Fe,M,F=c(()=>{"use strict";r();Fe=l(require("chalk"),1),M=require("glob");R();C();E()});var Ge,ze,Ie,rs,Ue,Be,ns,Je=c(()=>{"use strict";r();Ge=l(require("fs"),1),ze=l(require("path"),1),Ie=require("jiti");w();E();rs=["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"],Ue=(0,Ie.createJiti)(__filename,{interopDefault:!0}),Be=async()=>ns(),ns=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of rs){let t=ze.default.resolve(p.root,e);if(Ge.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var B,He=c(()=>{"use strict";r();B=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 _e,ce,We,qe=c(()=>{"use strict";r();_e=l(require("fs"),1);F();Je();C();He();ce=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 B(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={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1},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,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:!1,setupExitSignals:!0,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}},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:!0,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)}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 y({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(){n.time("[store][empConfig]SyncEmpOptions");let e=await Be();if(!e||!_e.default.existsSync(e))return;let t=await Ue(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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 ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},We=new ce});var Ve,me,Xe,Qe=c(()=>{"use strict";r();Ve=l(require("fs-extra"),1),me=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Ve.default.exists(e)){let 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})}},Xe=new me});var ue,Ke,Ye=c(()=>{"use strict";r();ue=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||{sass:{}};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"}}}})}},Ke=new ue});function ps(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
10
  `);return pe(s)}var H,J,G,_=c(()=>{"use strict";r();H=l(require("html-webpack-plugin"),1);C();w();J=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ps(),{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=>{H.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,he,Ze,et=c(()=>{"use strict";r();b=l(require("path"),1);F();_();he=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,"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){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(H.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,M.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,M.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)}},Ze=new he});var fe,ge,tt,st=c(()=>{"use strict";r();fe=l(require("path"),1);C();ge=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.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:y(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",fe.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=oe(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=fe.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.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"}}}})}},tt=new ge});var de,j,ye,it,ot=c(()=>{"use strict";r();de=l(require("fs"),1),j=l(require("@rspack/core"),1);_();ye=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor()];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(J)}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"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(j.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");de.default.existsSync(e)&&de.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(j.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(j.default.ProgressPlugin,[{template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u2592\u2592"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(j.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(j.default.LightningCssMinimizerRspackPlugin,[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(j.default.SourceMapDevToolPlugin,[e])}},it=new ye});var be,rt,nt=c(()=>{"use strict";r();Qe();Ye();et();st();ot();be=class{store;async setup(e){this.store=e;let t=[Xe.setup(this.store),tt.setup(this.store),it.setup(this.store),Ze.setup(this.store),Ke.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()}},rt=new be});async function ct(s,e="localhost"){if(s!==as&&(s<pt||s>ve))throw new Error(`Port number must lie between ${pt} and ${ve}`);let t=s,i=ls(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=ve;)try{return await ms(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var at,lt,pt,ve,as,ls,cs,ms,mt=c(()=>{"use strict";r();at=l(require("net"),1),lt=l(require("os"),1),pt=1024,ve=65535,as=443,ls=()=>{let s=lt.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},cs=(s,e)=>new Promise((t,i)=>{let o=at.default.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),ms=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await cs(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});var Ce,ut,we,W,ht=c(()=>{"use strict";r();Ce=l(require("url"),1),ut=l(require("chalk"),1);R();C();we=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=$;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ce.default.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ce.default.format({protocol:t,hostname:e,port:ut.default.bold(i),pathname:o})}},W=new we});var gt,dt,yt,ft,us,hs,bt,vt=c(()=>{"use strict";r();gt=require("child_process"),dt=require("util");w();E();yt=(0,dt.promisify)(gt.exec),ft=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],us=async()=>{let s=process.env.BROWSER;if(!s||!ft.includes(s)){let{stdout:e}=await yt("ps cax");s=ft.find(t=>e.includes(t))}return s},hs=async s=>{if(process.platform==="darwin")try{let t=await us();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await yt(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}},bt=hs});var xe,q,Ct=c(()=>{"use strict";r();xe=l(require("fs/promises"),1);F();R();mt();ht();vt();C();q=class{ip=$();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.setHttps(),await this.setAutoDevBase()}get config(){return{}}async setupOnStore(){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!==this.port&&this.setPort(e.empConfig.server.port),W.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=W.prettyPrintUrl("localhost")):(this.urls=W.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&&bt(this.url)}getcert(){let{store:e}=this;return Promise.all([xe.default.readFile(e.resource.key),xe.default.readFile(e.resource.cert)])}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",await this.setPort(e.empOptions.server?.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))}async setPort(e){this.port=e||8e3,this.port=await ct(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var wt,xt=c(()=>{"use strict";r();wt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var St,v,Ot,Et,Se,p,w=c(()=>{"use strict";r();St=l(require("fs/promises"),1),v=l(require("path"),1),Ot=l(require("util"),1);E();C();qe();nt();Ct();Et=l(require("webpack-chain"),1);xt();_();Se=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=v.default.resolve(__dirname,__filename).replace(`${v.default.sep}dist${v.default.sep}index.js`,"");empSource=v.default.resolve(this.empRoot,"dist");resolve=e=>v.default.isAbsolute(e)?e:v.default.resolve(this.root,e);empResolve=e=>v.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=wt;server=new q(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=We,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Et.default,await rt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let 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=v.default.join(this.empRoot,"resource"),this.resource.cert=v.default.join(this.resource.dir,"emp.cert"),this.resource.key=v.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=v.default.join(this.root,this.debug.showRsconfig);St.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"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(Ot.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.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=ne;deepAssign=y;getLanIp=$;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new Se});function Cs(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let g=t[u],S=a;return g&&(S=a.length<g?a+" ".repeat(g-a.length):a),`${o+S} `}," ");console.log(D.bold(i))}async function $t(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>ys(f.name)).map(vs);i.sort((f,N)=>f.size-N.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),a=Math.max(...i.map(f=>(f.folder+O.default.sep+f.name).length));Cs(a,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:N}=f,{name:Ut,folder:Bt,gzipSizeLabel:Jt}=f,je=(Bt+O.default.sep+Ut).length,Te=N.length;if(u+=f.size,g+=f.gzippedSize,Te<o){let Z=" ".repeat(o-Te);N+=Z}let De=L(f.folder+O.default.sep)+ws(f.name);if(je<a){let Z=" ".repeat(a-je);De+=Z}n.info(` ${De} ${L(N)} ${Jt}`)});let S=`${D.bold("Total size:")} ${V(u)}`,A=`${D.bold("Gzipped size:")} ${V(g)}`;n.info(`
11
+ `)),this.isOpenBrower&&bt(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([xe.default.readFile(e.resource.key),xe.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",await this.setPort(e.empOptions.server?.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))}async setPort(e){this.port=e||8e3,this.port=await ct(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var wt,xt=c(()=>{"use strict";r();wt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var St,v,Ot,Et,Se,p,w=c(()=>{"use strict";r();St=l(require("fs/promises"),1),v=l(require("path"),1),Ot=l(require("util"),1);E();C();qe();nt();Ct();Et=l(require("webpack-chain"),1);xt();_();Se=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=v.default.resolve(__dirname,__filename).replace(`${v.default.sep}dist${v.default.sep}index.js`,"");empSource=v.default.resolve(this.empRoot,"dist");resolve=e=>v.default.isAbsolute(e)?e:v.default.resolve(this.root,e);empResolve=e=>v.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=wt;server=new q(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=We,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Et.default,await rt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let 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=v.default.join(this.empRoot,"resource"),this.resource.cert=v.default.join(this.resource.dir,"emp.cert"),this.resource.key=v.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=v.default.join(this.root,this.debug.showRsconfig);St.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"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(Ot.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.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=ne;deepAssign=y;getLanIp=$;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new Se});function Cs(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let g=t[u],S=a;return g&&(S=a.length<g?a+" ".repeat(g-a.length):a),`${o+S} `}," ");console.log(D.bold(i))}async function $t(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>ys(f.name)).map(vs);i.sort((f,N)=>f.size-N.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),a=Math.max(...i.map(f=>(f.folder+O.default.sep+f.name).length));Cs(a,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:N}=f,{name:Ut,folder:Bt,gzipSizeLabel:Jt}=f,je=(Bt+O.default.sep+Ut).length,Te=N.length;if(u+=f.size,g+=f.gzippedSize,Te<o){let Z=" ".repeat(o-Te);N+=Z}let De=L(f.folder+O.default.sep)+ws(f.name);if(je<a){let Z=" ".repeat(a-je);De+=Z}n.info(` ${De} ${L(N)} ${Jt}`)});let S=`${D.bold("Total size:")} ${V(u)}`,A=`${D.bold("Gzipped size:")} ${V(g)}`;n.info(`
12
12
  ${S}
13
13
  ${A}
14
14
  `),n.info(`${x("\u2713")} Ready in ${U(Number(e.time))}
15
- `)}function X(s=0){n.info(`${x("\u2713")} Ready in ${U(Number(s))}`)}var Pt,O,kt,fs,gs,ds,ys,bs,vs,V,ws,Q=c(()=>{"use strict";r();Pt=l(require("fs"),1),O=l(require("path"),1),kt=require("gzip-size");R();w();E();C();fs=/\.html$/,gs=/\.(?:js|mjs|cjs|jsx)$/,ds=/\.css$/,ys=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),bs=s=>s>300*1e3?ee:s>100*1e3?I:te,vs=s=>{let e=s.name.split("?")[0],t=V(s.size),i=O.default.basename(e),o=O.default.join(O.default.basename(p.empConfig.build.outDir),O.default.dirname(e)),a=Pt.default.readFileSync(O.default.join(p.empConfig.build.outDir,e)),u=a.length,g=(0,kt.gzipSizeSync)(a),S=bs(g)(V(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:S}};V=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},ws=s=>gs.test(s)?I(s):ds.test(s)?x(s):fs.test(s)?D(s):se(s)});var P,K=c(()=>{"use strict";r();E();C();w();P=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&re(),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 Lt={};T(Lt,{default:()=>xs});var Tt,Dt,jt,Oe,xs,Rt=c(()=>{"use strict";r();Tt=require("@empjs/server"),Dt=require("@rspack/core");Q();C();K();w();jt=new Tt.DevServer,Oe=class extends P{async getRspackDevConfig(){let e=y(p.rsConfig,{stats:{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}}),{devServer:t}=e;if(p.server.isHttps&&!t.server){let[i,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 jt.setConfig(t);let i=(0,Dt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await jt.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});X(t.time)}},xs=new Oe});var Ee={};T(Ee,{ServeScript:()=>Y,default:()=>Os});var Nt,Ss,At,Y,Os,Pe=c(()=>{"use strict";r();Nt=require("@empjs/server");Q();K();w();Ss=new Nt.ProdServer,At=0,Y=class extends P{async run(){At=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Ss.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),X(Date.now()-At),await p.empConfig.lifeCycle.afterServe()}},Os=new Y});var Ft={};T(Ft,{default:()=>Es});var Mt,ke,Es,Gt=c(()=>{"use strict";r();Mt=require("@rspack/core");Q();E();K();w();ke=class extends P{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(()=>(Pe(),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(),(0,Mt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
15
+ `)}function X(s=0){n.info(`${x("\u2713")} Ready in ${U(Number(s))}`)}var Pt,O,kt,fs,gs,ds,ys,bs,vs,V,ws,Q=c(()=>{"use strict";r();Pt=l(require("fs"),1),O=l(require("path"),1),kt=require("gzip-size");R();w();E();C();fs=/\.html$/,gs=/\.(?:js|mjs|cjs|jsx)$/,ds=/\.css$/,ys=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),bs=s=>s>300*1e3?ee:s>100*1e3?I:te,vs=s=>{let e=s.name.split("?")[0],t=V(s.size),i=O.default.basename(e),o=O.default.join(O.default.basename(p.empConfig.build.outDir),O.default.dirname(e)),a=Pt.default.readFileSync(O.default.join(p.empConfig.build.outDir,e)),u=a.length,g=(0,kt.gzipSizeSync)(a),S=bs(g)(V(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:S}};V=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},ws=s=>gs.test(s)?I(s):ds.test(s)?x(s):fs.test(s)?D(s):se(s)});var P,K=c(()=>{"use strict";r();E();C();w();P=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&re(),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 Lt={};T(Lt,{default:()=>xs});var Tt,Dt,jt,Oe,xs,Rt=c(()=>{"use strict";r();Tt=require("@empjs/server"),Dt=require("@rspack/core");Q();C();K();w();jt=new Tt.DevServer,Oe=class extends P{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=y(p.rsConfig,{stats:this.stats}),{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 jt.beforeCompiler(t);let i=(0,Dt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await jt.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});X(t.time)}},xs=new Oe});var Ee={};T(Ee,{ServeScript:()=>Y,default:()=>Os});var Nt,Ss,At,Y,Os,Pe=c(()=>{"use strict";r();Nt=require("@empjs/server");Q();K();w();Ss=new Nt.ProdServer,At=0,Y=class extends P{async run(){At=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Ss.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),X(Date.now()-At),await p.empConfig.lifeCycle.afterServe()}},Os=new Y});var Ft={};T(Ft,{default:()=>Es});var Mt,ke,Es,Gt=c(()=>{"use strict";r();Mt=require("@rspack/core");Q();E();K();w();ke=class extends P{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(()=>(Pe(),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(),(0,Mt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
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 $t(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Es=new ke});var ks={};T(ks,{defineConfig:()=>Ps,empHelper:()=>le,rspack:()=>It.rspack,runScript:()=>$e,store:()=>p});module.exports=Xt(ks);r();var It=require("@rspack/core");r();var zt=l(require("process"),1),k=require("commander");w();function $e(){k.program.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),k.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-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(()=>(Rt(),Lt));await e.setup("dev",s)}),k.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(()=>(Gt(),Ft));await e.setup("build",s)}),k.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(()=>(Pe(),Ee));await e.setup("serve",s)}),k.program.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),k.program.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),k.program.parse(zt.default.argv)}w();F();function Ps(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.d.cts CHANGED
@@ -188,7 +188,7 @@ declare class StoreServer {
188
188
  */
189
189
  setupOnStore(): Promise<void>;
190
190
  startOpen(): void;
191
- getcert(): Promise<[Buffer, Buffer]>;
191
+ getcert(): Promise<any>;
192
192
  private setHttps;
193
193
  private setAutoDevBase;
194
194
  private setPort;
package/dist/index.d.ts CHANGED
@@ -188,7 +188,7 @@ declare class StoreServer {
188
188
  */
189
189
  setupOnStore(): Promise<void>;
190
190
  startOpen(): void;
191
- getcert(): Promise<[Buffer, Buffer]>;
191
+ getcert(): Promise<any>;
192
192
  private setHttps;
193
193
  private setAutoDevBase;
194
194
  private setPort;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
- var bt=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)bt(s,t,{get:e[t],enumerable:!0})};import{fileURLToPath as vt}from"url";import Ct from"path";var Pe,wt,c,l,r=m(()=>{"use strict";Pe=()=>vt(import.meta.url),wt=()=>Ct.dirname(Pe()),c=wt(),l=Pe()});import d from"chalk";var xt,S,St,Ot,Et,Z,z,Pt,kt,T,ee,$t,te,D,h,L=m(()=>{"use strict";r();xt=d.hex("#1abc9c"),S=d.hex("#16a085"),St=d.hex("#2ecc71"),Ot=d.hex("#27ae60"),Et=d.hex("#e74c3c"),Z=d.hex("#c0392b"),z=d.hex("#f1c40f"),Pt=d.hex("#f39c12"),kt=d.hex("#3498db"),T=d.hex("#2980b9"),ee=d.hex("#ecf0f1"),$t=d.hex("#fd79a8"),te=d.hex("#e84393"),D=d.hex("#7f8c8d"),h={lightGreen:xt,green:S,lightCyan:St,cyan:Ot,lightRed:Et,red:Z,yellow:z,orange:Pt,lightBlue:kt,blue:T,white:ee,lightMagenta:$t,magenta:te,gray:D}});var se,n,E=m(()=>{"use strict";r();L();se=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
+ var bt=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)bt(s,t,{get:e[t],enumerable:!0})};import{fileURLToPath as vt}from"url";import Ct from"path";var Pe,wt,c,l,r=m(()=>{"use strict";Pe=()=>vt(import.meta.url),wt=()=>Ct.dirname(Pe()),c=wt(),l=Pe()});import d from"chalk";var xt,S,St,Ot,Et,Z,z,Pt,kt,T,ee,$t,te,D,h,L=m(()=>{"use strict";r();xt=d.hex("#1abc9c"),S=d.hex("#16a085"),St=d.hex("#2ecc71"),Ot=d.hex("#27ae60"),Et=d.hex("#e74c3c"),Z=d.hex("#c0392b"),z=d.hex("#f1c40f"),Pt=d.hex("#f39c12"),kt=d.hex("#3498db"),T=d.hex("#2980b9"),ee=d.hex("#ecf0f1"),$t=d.hex("#fd79a8"),te=d.hex("#e84393"),D=d.hex("#7f8c8d"),h={lightGreen:xt,green:S,lightCyan:St,cyan:Ot,lightRed:Et,red:Z,yellow:z,orange:Pt,lightBlue:kt,blue:T,white:ee,lightMagenta:$t,magenta:te,gray:D}});var se,n,E=m(()=>{"use strict";r();L();se=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:o}){this.brandName=` [${e}] `,this.fullName=` ${o} `,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
3
  `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
4
4
  `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
5
5
  `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
@@ -7,11 +7,11 @@ var bt=Object.defineProperty;var b=(s=>typeof require<"u"?require:typeof Proxy<"
7
7
  `)};red=e=>{console.log(`${h.lightRed(this.brandName)}${h.red(` ${e} `)}
8
8
  `)};sysError=e=>{console.log(`${h.lightRed(" System Error Tips ")}${h.red(` ${e} `)}
9
9
  `)};link=e=>h.blue(e);title=e=>{console.log(`${this.fullName}${h.yellow.underline(`${e}`)}
10
- `)}},n=new se});var pe={};F(pe,{clearConsole:()=>oe,deepAssign:()=>y,ensureArray:()=>Rt,getLanIp:()=>$,getPkgVersion:()=>ie,importJsVm:()=>ne,jsonFilter:()=>At,timeFormat:()=>I,vCompare:()=>re});import{ip as jt}from"address";import Tt from"chalk";import{gateway4sync as Dt}from"default-gateway";import Lt from"fs-extra";function oe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(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]=y(a,o);continue}s[i]=t[i]}return s}var $,ie,Rt,At,re,I,ne,v=m(()=>{"use strict";r();$=()=>{let{int:s}=Dt();return jt(s||"")||"127.0.0.1"},ie=s=>{try{let{version:e}=Lt.readJSONSync(s);return e}catch{return}};Rt=s=>Array.isArray(s)?s:[s],At=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),re=(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 g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),A=i.length>u?i[u]:0,f=isNaN(Number(A))?A.charCodeAt():Number(A);if(O<f){a=-1;break}else if(O>f){a=1;break}}return a},I=s=>{s=s/1e3;let e=i=>Tt.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`},ne=s=>`data:text/javascript,${s}`});var ke={};F(ke,{chalk:()=>Nt,color:()=>h,glob:()=>B,logger:()=>n,utils:()=>pe});import Nt from"chalk";import{glob as B}from"glob";var M=m(()=>{"use strict";r();L();v();E()});import Ft from"node:fs";import Mt from"path";import{createJiti as Gt}from"jiti";var zt,$e,je,It,Te=m(()=>{"use strict";r();C();E();zt=["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=Gt(l,{interopDefault:!0}),je=async()=>It(),It=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of zt){let t=Mt.resolve(p.root,e);if(Ft.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var U,De=m(()=>{"use strict";r();U=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()}}});import Bt from"node:fs";var ae,Le,Re=m(()=>{"use strict";r();M();Te();v();De();ae=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 U(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={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1},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,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}},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:!0,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)}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 y({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(){n.time("[store][empConfig]SyncEmpOptions");let e=await je();if(!e||!Bt.existsSync(e))return;let t=await $e(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},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 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}},Le=new ae});import Ut from"fs-extra";var le,Ae,Ne=m(()=>{"use strict";r();le=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Ut.exists(e)){let 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})}},Ae=new le});var ce,Fe,Me=m(()=>{"use strict";r();ce=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||{sass:{}};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"}}}})}},Fe=new ce});import me from"html-webpack-plugin";function Jt(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
- `);return ne(s)}var J,G,H=m(()=>{"use strict";r();v();C();J=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Jt(),{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=>{me.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 w from"node:path";var ue,Ge,ze=m(()=>{"use strict";r();M();H();ue=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,"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(w.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(w.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(me,[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=w.join(this.store.appSrc,e),i=w.join(t,"**","*.{ts,tsx,jsx,js}"),o=await B([i],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${w.sep}`,"")),o.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},w.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await B([e],{windowsPathsNoEscape:!0});if(t[0]){let i=w.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(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)}},Ge=new ue});import Ie from"node:path";var he,Be,Ue=m(()=>{"use strict";r();v();he=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.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:y(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",Ie.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=ie(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ie.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.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"}}}})}},Be=new he});import Je from"fs";import R from"@rspack/core";var fe,He,_e=m(()=>{"use strict";r();H();fe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor()];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(J)}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"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(R.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Je.existsSync(e)&&Je.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(R.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(R.ProgressPlugin,[{template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u2592\u2592"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(R.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(R.LightningCssMinimizerRspackPlugin,[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(R.SourceMapDevToolPlugin,[e])}},He=new fe});var ge,We,qe=m(()=>{"use strict";r();Ne();Me();ze();Ue();_e();ge=class{store;async setup(e){this.store=e;let t=[Ae.setup(this.store),Be.setup(this.store),He.setup(this.store),Ge.setup(this.store),Fe.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()}},We=new ge});import Ht from"net";import _t from"os";async function Xe(s,e="localhost"){if(s!==Wt&&(s<Ve||s>de))throw new Error(`Port number must lie between ${Ve} and ${de}`);let t=s,i=qt(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=de;)try{return await Xt(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ve,de,Wt,qt,Vt,Xt,Qe=m(()=>{"use strict";r();Ve=1024,de=65535,Wt=443,qt=()=>{let s=_t.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},Vt=(s,e)=>new Promise((t,i)=>{let o=Ht.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),Xt=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Vt(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import Ke from"url";import Qt from"chalk";var ye,_,Ye=m(()=>{"use strict";r();L();v();ye=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:D("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",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=$;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ke.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ke.format({protocol:t,hostname:e,port:Qt.bold(i),pathname:o})}},_=new ye});import{exec as Kt}from"node:child_process";import{promisify as Yt}from"node:util";var et,Ze,Zt,es,tt,st=m(()=>{"use strict";r();C();E();et=Yt(Kt),Ze=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Zt=async()=>{let s=process.env.BROWSER;if(!s||!Ze.includes(s)){let{stdout:e}=await et("ps cax");s=Ze.find(t=>e.includes(t))}return s},es=async s=>{if(process.platform==="darwin")try{let t=await Zt();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}},tt=es});import it from"node:fs/promises";var W,ot=m(()=>{"use strict";r();M();L();Qe();Ye();st();v();W=class{ip=$();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.setHttps(),await this.setAutoDevBase()}get config(){return{}}async setupOnStore(){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!==this.port&&this.setPort(e.empConfig.server.port),_.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=_.prettyPrintUrl("localhost")):(this.urls=_.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)}
12
- `)),this.isOpenBrower&&tt(this.url)}getcert(){let{store:e}=this;return Promise.all([it.readFile(e.resource.key),it.readFile(e.resource.cert)])}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",await this.setPort(e.empOptions.server?.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))}async setPort(e){this.port=e||8e3,this.port=await Xe(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var rt,nt=m(()=>{"use strict";r();rt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});import ts from"node:fs/promises";import x from"node:path";import ss from"node:util";import is from"webpack-chain";var be,p,C=m(()=>{"use strict";r();E();v();Re();qe();ot();nt();H();be=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(c,l).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=rt;server=new W(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Le,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new is,await We.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let 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=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}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=x.join(this.root,this.debug.showRsconfig);ts.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(ss.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.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=re;deepAssign=y;getLanIp=$;injectTags(e=[],t="",i=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,i])}},p=new be});import os from"node:fs";import P from"node:path";import{gzipSizeSync as rs}from"gzip-size";function us(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let g=t[u],O=a;return g&&(O=a.length<g?a+" ".repeat(g-a.length):a),`${o+O} `}," ");console.log(T.bold(i))}async function pt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>ls(f.name)).map(ms);i.sort((f,N)=>f.size-N.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),a=Math.max(...i.map(f=>(f.folder+P.sep+f.name).length));us(a,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:N}=f,{name:gt,folder:dt,gzipSizeLabel:yt}=f,Se=(dt+P.sep+gt).length,Oe=N.length;if(u+=f.size,g+=f.gzippedSize,Oe<o){let Y=" ".repeat(o-Oe);N+=Y}let Ee=D(f.folder+P.sep)+hs(f.name);if(Se<a){let Y=" ".repeat(a-Se);Ee+=Y}n.info(` ${Ee} ${D(N)} ${yt}`)});let O=`${T.bold("Total size:")} ${q(u)}`,A=`${T.bold("Gzipped size:")} ${q(g)}`;n.info(`
10
+ `)}},n=new se});var pe={};F(pe,{clearConsole:()=>ie,deepAssign:()=>y,ensureArray:()=>Rt,getLanIp:()=>$,getPkgVersion:()=>oe,importJsVm:()=>ne,jsonFilter:()=>At,timeFormat:()=>I,vCompare:()=>re});import{ip as jt}from"address";import Tt from"chalk";import{gateway4sync as Dt}from"default-gateway";import Lt from"fs-extra";function ie(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let o in t){let i=t[o],a=s[o];if(Object(i)==i&&Object(a)===a){s[o]=y(a,i);continue}s[o]=t[o]}return s}var $,oe,Rt,At,re,I,ne,v=m(()=>{"use strict";r();$=()=>{let{int:s}=Dt();return jt(s||"")||"127.0.0.1"},oe=s=>{try{let{version:e}=Lt.readJSONSync(s);return e}catch{return}};Rt=s=>Array.isArray(s)?s:[s],At=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,o)=>(t[o]=s[o],t),{}),re=(s="",e="")=>{let t=s.replace("^","").split("."),o=e.replace("^","").split("."),i=Math.max(t.length,o.length),a=0;for(let u=0;u<i;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),A=o.length>u?o[u]:0,f=isNaN(Number(A))?A.charCodeAt():Number(A);if(O<f){a=-1;break}else if(O>f){a=1;break}}return a},I=s=>{s=s/1e3;let e=o=>Tt.bold(o);if(s<1)return`${s*1e3} ms`;if(s<10){let o=s>=.01?2:3;return`${e(s.toFixed(o))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},ne=s=>`data:text/javascript,${s}`});var ke={};F(ke,{chalk:()=>Nt,color:()=>h,glob:()=>B,logger:()=>n,utils:()=>pe});import Nt from"chalk";import{glob as B}from"glob";var M=m(()=>{"use strict";r();L();v();E()});import Ft from"node:fs";import Mt from"path";import{createJiti as Gt}from"jiti";var zt,$e,je,It,Te=m(()=>{"use strict";r();C();E();zt=["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=Gt(l,{interopDefault:!0}),je=async()=>It(),It=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of zt){let t=Mt.resolve(p.root,e);if(Ft.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var U,De=m(()=>{"use strict";r();U=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()}}});import Bt from"node:fs";var ae,Le,Re=m(()=>{"use strict";r();M();Te();v();De();ae=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},y(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 U(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:o,appEntry:i}=this.store.empOptions;t&&(this.appSrc=t),o&&(this.base=o),i&&(this.appEntry=i)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1},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,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:!1,setupExitSignals:!0,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}},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:o,staticDir:i}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${i}js/[name]${e}.js`,cssFilename:`${i}css/[name]${t}.css`,cssChunkFilename:`${i}css/[name]${t}.css`,assetModuleFilename:`${i}${o}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0,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)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",o={};return Object.keys(e).map(i=>{t==="all"?(o[`import.meta.env.${i}`]=JSON.stringify(e[i]),o[`process.env.${i}`]=JSON.stringify(e[i])):t==="esm"?o[`import.meta.env.${i}`]=JSON.stringify(e[i]):t==="cjs"?o[`process.env.${i}`]=JSON.stringify(e[i]):t==="none"&&(o[`${i}`]=JSON.stringify(e[i]))}),o}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return y({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(){n.time("[store][empConfig]SyncEmpOptions");let e=await je();if(!e||!Bt.existsSync(e))return;let t=await $e(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),o={and:[],not:[]};return t.defaultExclude===!0&&o.and.push(/(node_modules|bower_components)/),t?.exclude&&(o.and=o.and.concat(t.exclude)),e?.include&&(o.not=t.include),o}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Le=new ae});import Ut from"fs-extra";var le,Ae,Ne=m(()=>{"use strict";r();le=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,css:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Ut.exists(e)){let o={tsConfig:e};this.store.merge({resolve:o})}}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})}},Ae=new le});var ce,Fe,Me=m(()=>{"use strict";r();ce=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,o={},{sass:i}=this.store.empConfig.css||{sass:{}};i.mode==="modern"&&(o.implementation=i.implementation?i.implementation:b.resolve("sass-embedded"),o.api="modern-compiler",o.sourceMap=this.store.empConfig.build.sourcemap,i.sassOptions&&(o.sassOptions=i.sassOptions)),typeof i.warnRuleAsWarning<"u"&&(o.warnRuleAsWarning=i.warnRuleAsWarning),typeof i.webpackImporter<"u"&&(o.webpackImporter=i.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:b.resolve("sass-loader"),options:o}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,o={loader:b.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:o},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},Fe=new ce});import me from"html-webpack-plugin";function Jt(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
+ `);return ne(s)}var J,G,H=m(()=>{"use strict";r();v();C();J=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Jt(),{name:void 0}).apply(e)}},G=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",o=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=o}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{me.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async o=>(this.chunk&&!o.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(i=>{let{pos:a,...u}=i;(a==="body"?o.bodyTags:o.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o))})}}});import w from"node:path";var ue,Ge,ze=m(()=>{"use strict";r();M();H();ue=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,"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(w.extname(e),"").replace(`${this.store.empConfig.appSrc}${w.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,o){o=o||this.store.resolve(w.join(this.store.empConfig.appSrc,e));let i=this.setChunk(e),a=[o];this.entriesConfig[i]={entry:{[i]:a},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(me,[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=w.join(this.store.appSrc,e),o=w.join(t,"**","*.{ts,tsx,jsx,js}"),i=await B([o],{windowsPathsNoEscape:!0});i=i.map(a=>a.replace(`${t}${w.sep}`,"")),i.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},w.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await B([e],{windowsPathsNoEscape:!0});if(t[0]){let o=w.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(o,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)}},Ge=new ue});import Ie from"node:path";var he,Be,Ue=m(()=>{"use strict";r();v();he=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.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:o}=this.store.empConfig.build,{externalHelpers:i}=o;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:i,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:y(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",Ie.dirname(b.resolve("@swc/helpers/package.json"))),this.coreJs.path=b.resolve("core-js/package.json");let t=oe(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Ie.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:o}=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:{[o.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[o.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.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"}}}})}},Be=new he});import Je from"fs";import R from"@rspack/core";var fe,He,_e=m(()=>{"use strict";r();H();fe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor()];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(J)}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"}])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(R.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Je.existsSync(e)&&Je.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(R.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin(this.store.chainName.plugin.progress).use(R.ProgressPlugin,[{template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u2592\u2592"}])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(R.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(R.LightningCssMinimizerRspackPlugin,[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(R.SourceMapDevToolPlugin,[e])}},He=new fe});var ge,We,qe=m(()=>{"use strict";r();Ne();Me();ze();Ue();_e();ge=class{store;async setup(e){this.store=e;let t=[Ae.setup(this.store),Be.setup(this.store),He.setup(this.store),Ge.setup(this.store),Fe.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()}},We=new ge});import Ht from"net";import _t from"os";async function Xe(s,e="localhost"){if(s!==Wt&&(s<Ve||s>de))throw new Error(`Port number must lie between ${Ve} and ${de}`);let t=s,o=qt(),i;e&&!o.has(e)?i=new Set([e]):i=o;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=de;)try{return await Xt(t,i)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ve,de,Wt,qt,Vt,Xt,Qe=m(()=>{"use strict";r();Ve=1024,de=65535,Wt=443,qt=()=>{let s=_t.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let o of t)e.add(o.address);return e},Vt=(s,e)=>new Promise((t,o)=>{let i=Ht.createServer();i.unref(),i.on("error",o),i.listen(s,e,()=>{let{port:a}=i.address();i.close(()=>{t(a)})})}),Xt=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let o of e)try{await Vt(s,o)}catch(i){if(!t.has(i.code))throw i}return s}});import Ke from"url";import Qt from"chalk";var ye,_,Ye=m(()=>{"use strict";r();L();v();ye=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:D("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",o;if(t){o="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 o=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(o),this.urls.localUrlForBrowser=this.formatUrl(o)}getLanIp=$;formatUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return Ke.format({protocol:t,hostname:e,port:o,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return Ke.format({protocol:t,hostname:e,port:Qt.bold(o),pathname:i})}},_=new ye});import{exec as Kt}from"node:child_process";import{promisify as Yt}from"node:util";var et,Ze,Zt,es,tt,st=m(()=>{"use strict";r();C();E();et=Yt(Kt),Ze=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Zt=async()=>{let s=process.env.BROWSER;if(!s||!Ze.includes(s)){let{stdout:e}=await et("ps cax");s=Ze.find(t=>e.includes(t))}return s},es=async s=>{if(process.platform==="darwin")try{let t=await Zt();if(t){let o=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await et(o,{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=es});import ot from"node:fs/promises";var W,it=m(()=>{"use strict";r();M();L();Qe();Ye();st();v();W=class{ip=$();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.setHttps(),await this.setAutoDevBase()}get config(){return{}}async setupOnStore(){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!==this.port&&this.setPort(e.empConfig.server.port),_.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=_.prettyPrintUrl("localhost")):(this.urls=_.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)}
12
+ `)),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[o,i]=await Promise.all([ot.readFile(e.resource.key),ot.readFile(e.resource.cert)]);return{key:o,cert:i}}setHttps(){let{store:e}=this,{server:t,https:o}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||o===!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",await this.setPort(e.empOptions.server?.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))}async setPort(e){this.port=e||8e3,this.port=await Xe(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var rt,nt=m(()=>{"use strict";r();rt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});import ts from"node:fs/promises";import x from"node:path";import ss from"node:util";import os from"webpack-chain";var be,p,C=m(()=>{"use strict";r();E();v();Re();qe();it();nt();H();be=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(c,l).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=rt;server=new W(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;async setup(e,t){n.time("[store]Setup"),await this.initVars(e,t),this.empConfig=Le,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new os,await We.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let o=b(this.empResolve("package.json")),i=b(this.resolve("package.json"));this.empPkg={...this.empPkg,...o},this.pkg={...this.pkg,...i},this.resource.dir=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}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=x.join(this.root,this.debug.showRsconfig);ts.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(ss.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.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=re;deepAssign=y;getLanIp=$;injectTags(e=[],t="",o=""){this.chain.plugin(`${G}-${t}`).use(G,[e,t,o])}},p=new be});import is from"node:fs";import P from"node:path";import{gzipSizeSync as rs}from"gzip-size";function us(s,e){let t=[s,e],o=["File","Size","Gzipped"].reduce((i,a,u)=>{let g=t[u],O=a;return g&&(O=a.length<g?a+" ".repeat(g-a.length):a),`${i+O} `}," ");console.log(T.bold(o))}async function pt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),o=e.assets.filter(f=>ls(f.name)).map(ms);o.sort((f,N)=>f.size-N.size);let i=Math.max(...o.map(f=>f.sizeLabel.length)),a=Math.max(...o.map(f=>(f.folder+P.sep+f.name).length));us(a,i);let u=0,g=0;o.forEach(f=>{let{sizeLabel:N}=f,{name:gt,folder:dt,gzipSizeLabel:yt}=f,Se=(dt+P.sep+gt).length,Oe=N.length;if(u+=f.size,g+=f.gzippedSize,Oe<i){let Y=" ".repeat(i-Oe);N+=Y}let Ee=D(f.folder+P.sep)+hs(f.name);if(Se<a){let Y=" ".repeat(a-Se);Ee+=Y}n.info(` ${Ee} ${D(N)} ${yt}`)});let O=`${T.bold("Total size:")} ${q(u)}`,A=`${T.bold("Gzipped size:")} ${q(g)}`;n.info(`
13
13
  ${O}
14
14
  ${A}
15
15
  `),n.info(`${S("\u2713")} Ready in ${I(Number(e.time))}
16
- `)}function V(s=0){n.info(`${S("\u2713")} Ready in ${I(Number(s))}`)}var ns,ps,as,ls,cs,ms,q,hs,X=m(()=>{"use strict";r();L();C();E();v();ns=/\.html$/,ps=/\.(?:js|mjs|cjs|jsx)$/,as=/\.css$/,ls=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),cs=s=>s>300*1e3?Z:s>100*1e3?z:ee,ms=s=>{let e=s.name.split("?")[0],t=q(s.size),i=P.basename(e),o=P.join(P.basename(p.empConfig.build.outDir),P.dirname(e)),a=os.readFileSync(P.join(p.empConfig.build.outDir,e)),u=a.length,g=rs(a),O=cs(g)(q(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};q=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},hs=s=>ps.test(s)?z(s):as.test(s)?S(s):ns.test(s)?T(s):te(s)});var k,Q=m(()=>{"use strict";r();E();v();C();k=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&oe(),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 lt={};F(lt,{default:()=>ds});import{DevServer as fs}from"@empjs/server";import{rspack as gs}from"@rspack/core";var at,ve,ds,ct=m(()=>{"use strict";r();X();v();Q();C();at=new fs,ve=class extends k{async getRspackDevConfig(){let e=y(p.rsConfig,{stats:{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}}),{devServer:t}=e;if(p.server.isHttps&&!t.server){let[i,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 at.setConfig(t);let i=gs(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await at.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});V(t.time)}},ds=new ve});var Ce={};F(Ce,{ServeScript:()=>K,default:()=>vs});import{ProdServer as ys}from"@empjs/server";var bs,mt,K,vs,we=m(()=>{"use strict";r();X();Q();C();bs=new ys,mt=0,K=class extends k{async run(){mt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await bs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),V(Date.now()-mt),await p.empConfig.lifeCycle.afterServe()}},vs=new K});var ut={};F(ut,{default:()=>ws});import{rspack as Cs}from"@rspack/core";var xe,ws,ht=m(()=>{"use strict";r();X();E();Q();C();xe=class extends k{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(we(),Ce));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(),Cs(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 pt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},ws=new xe});r();import{rspack as cr}from"@rspack/core";r();C();import xs from"node:process";import{program as j}from"commander";function ft(){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(()=>(ct(),lt));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(()=>(ht(),ut));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(()=>(we(),Ce));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(xs.argv)}C();M();function hr(s){return s}export{hr as defineConfig,ke as empHelper,cr as rspack,ft as runScript,p as store};
16
+ `)}function V(s=0){n.info(`${S("\u2713")} Ready in ${I(Number(s))}`)}var ns,ps,as,ls,cs,ms,q,hs,X=m(()=>{"use strict";r();L();C();E();v();ns=/\.html$/,ps=/\.(?:js|mjs|cjs|jsx)$/,as=/\.css$/,ls=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),cs=s=>s>300*1e3?Z:s>100*1e3?z:ee,ms=s=>{let e=s.name.split("?")[0],t=q(s.size),o=P.basename(e),i=P.join(P.basename(p.empConfig.build.outDir),P.dirname(e)),a=is.readFileSync(P.join(p.empConfig.build.outDir,e)),u=a.length,g=rs(a),O=cs(g)(q(g));return{size:u,folder:i,name:o,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};q=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},hs=s=>ps.test(s)?z(s):as.test(s)?S(s):ns.test(s)?T(s):te(s)});var k,Q=m(()=>{"use strict";r();E();v();C();k=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&ie(),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 lt={};F(lt,{default:()=>ds});import{DevServer as fs}from"@empjs/server";import{rspack as gs}from"@rspack/core";var at,ve,ds,ct=m(()=>{"use strict";r();X();v();Q();C();at=new fs,ve=class extends k{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=y(p.rsConfig,{stats:this.stats}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:o,cert:i}=await p.server.getcert();t.server={type:"https",options:{key:o,cert:i}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await at.beforeCompiler(t);let o=gs(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await at.setup(o,t,p,async i=>{this.showTimeDone(i),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&o.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});V(t.time)}},ds=new ve});var Ce={};F(Ce,{ServeScript:()=>K,default:()=>vs});import{ProdServer as ys}from"@empjs/server";var bs,mt,K,vs,we=m(()=>{"use strict";r();X();Q();C();bs=new ys,mt=0,K=class extends k{async run(){mt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await bs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),V(Date.now()-mt),await p.empConfig.lifeCycle.afterServe()}},vs=new K});var ut={};F(ut,{default:()=>ws});import{rspack as Cs}from"@rspack/core";var xe,ws,ht=m(()=>{"use strict";r();X();E();Q();C();xe=class extends k{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(we(),Ce));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(),Cs(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 pt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},ws=new xe});r();import{rspack as cr}from"@rspack/core";r();C();import xs from"node:process";import{program as j}from"commander";function ft(){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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(ct(),lt));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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(ht(),ut));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(()=>(we(),Ce));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(xs.argv)}C();M();function hr(s){return s}export{hr as defineConfig,ke as empHelper,cr as rspack,ft as runScript,p as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.2.0-beta.1",
3
+ "version": "3.2.1",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -84,7 +84,7 @@
84
84
  "typescript-plugin-css-modules": "^5.1.0",
85
85
  "webpack-bundle-analyzer": "^4.10.2",
86
86
  "webpack-chain": "^6.5.1",
87
- "@empjs/server": "^3.2.0-beta.1"
87
+ "@empjs/server": "^3.2.1"
88
88
  },
89
89
  "scripts": {
90
90
  "dev": "tsup --watch --env.ENV dev",