@empjs/cli 3.2.4 → 3.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ss=Object.create;var B=Object.defineProperty;var os=Object.getOwnPropertyDescriptor;var is=Object.getOwnPropertyNames;var rs=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var T=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},Fe=(s,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of is(e))!ns.call(s,i)&&i!==t&&B(s,i,{get:()=>e[i],enumerable:!(o=os(e,i))||o.enumerable});return s};var l=(s,e,t)=>(t=s!=null?ss(rs(s)):{},Fe(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),ps=s=>Fe(B({},"__esModule",{value:!0}),s);var r=c(()=>{"use strict"});var d,as,S,ls,cs,ms,oe,H,us,hs,D,ie,fs,re,R,h,L=c(()=>{"use strict";r();d=l(require("chalk"),1),as=d.default.hex("#1abc9c"),S=d.default.hex("#16a085"),ls=d.default.hex("#2ecc71"),cs=d.default.hex("#27ae60"),ms=d.default.hex("#e74c3c"),oe=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),us=d.default.hex("#f39c12"),hs=d.default.hex("#3498db"),D=d.default.hex("#2980b9"),ie=d.default.hex("#ecf0f1"),fs=d.default.hex("#fd79a8"),re=d.default.hex("#e84393"),R=d.default.hex("#7f8c8d"),h={lightGreen:as,green:S,lightCyan:ls,cyan:cs,lightRed:ms,red:oe,yellow:H,orange:us,lightBlue:hs,blue:D,white:ie,lightMagenta:fs,magenta:re,gray:R}});var ne,n,E=c(()=>{"use strict";r();L();ne=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} `)}
1
+ "use strict";var ss=Object.create;var B=Object.defineProperty;var os=Object.getOwnPropertyDescriptor;var is=Object.getOwnPropertyNames;var rs=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var T=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},Ge=(s,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of is(e))!ns.call(s,i)&&i!==t&&B(s,i,{get:()=>e[i],enumerable:!(o=os(e,i))||o.enumerable});return s};var l=(s,e,t)=>(t=s!=null?ss(rs(s)):{},Ge(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),ps=s=>Ge(B({},"__esModule",{value:!0}),s);var r=c(()=>{"use strict"});var d,as,S,ls,cs,ms,ie,H,us,hs,D,re,fs,ne,R,h,L=c(()=>{"use strict";r();d=l(require("chalk"),1),as=d.default.hex("#1abc9c"),S=d.default.hex("#16a085"),ls=d.default.hex("#2ecc71"),cs=d.default.hex("#27ae60"),ms=d.default.hex("#e74c3c"),ie=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),us=d.default.hex("#f39c12"),hs=d.default.hex("#3498db"),D=d.default.hex("#2980b9"),re=d.default.hex("#ecf0f1"),fs=d.default.hex("#fd79a8"),ne=d.default.hex("#e84393"),R=d.default.hex("#7f8c8d"),h={lightGreen:as,green:S,lightCyan:ls,cyan:cs,lightRed:ms,red:ie,yellow:H,orange:us,lightBlue:hs,blue:D,white:re,lightMagenta:fs,magenta:ne,gray:R}});var pe,n,E=c(()=>{"use strict";r();L();pe=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} `)}
2
2
  `)};cyan=e=>{console.log(`${h.lightCyan(this.brandName)}${h.cyan(` ${e} `)}
3
3
  `)};magenta=e=>{console.log(`${h.lightMagenta(this.brandName)}${h.magenta(` ${e} `)}
4
4
  `)};green=e=>{console.log(`${h.lightGreen(this.brandName)}${h.green(` ${e} `)}
@@ -6,12 +6,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 ne});var me={};T(me,{clearConsole:()=>ae,deepAssign:()=>y,ensureArray:()=>gs,getLanIp:()=>$,getPkgVersion:()=>pe,importJsVm:()=>ce,jsonFilter:()=>ds,timeFormat:()=>J,vCompare:()=>le});function ae(){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],p=s[o];if(Object(i)==i&&Object(p)===p){s[o]=y(p,i);continue}s[o]=t[o]}return s}var Ge,ze,Ie,Ue,$,pe,gs,ds,le,J,ce,C=c(()=>{"use strict";r();Ge=require("address"),ze=l(require("chalk"),1),Ie=require("default-gateway"),Ue=l(require("fs-extra"),1),$=()=>{let{int:s}=(0,Ie.gateway4sync)();return(0,Ge.ip)(s||"")||"127.0.0.1"},pe=s=>{try{let{version:e}=Ue.default.readJSONSync(s);return e}catch{return}};gs=s=>Array.isArray(s)?s:[s],ds=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,o)=>(t[o]=s[o],t),{}),le=(s="",e="")=>{let t=s.replace("^","").split("."),o=e.replace("^","").split("."),i=Math.max(t.length,o.length),p=0;for(let u=0;u<i;u++){let g=t.length>u?t[u]:0,x=isNaN(Number(g))?g.charCodeAt():Number(g),N=o.length>u?o[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(x<f){p=-1;break}else if(x>f){p=1;break}}return p},J=s=>{s=s/1e3;let e=o=>ze.default.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`},ce=s=>`data:text/javascript,${s}`});var ue={};T(ue,{chalk:()=>Be.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>me});var Be,F,G=c(()=>{"use strict";r();Be=l(require("chalk"),1),F=require("glob");L();C();E()});var He,Je,_e,ys,We,qe,vs,Ve=c(()=>{"use strict";r();He=l(require("fs"),1),Je=l(require("path"),1),_e=require("jiti");w();E();ys=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],We=(0,_e.createJiti)(__filename,{interopDefault:!0}),qe=async()=>vs(),vs=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of ys){let t=Je.default.resolve(a.root,e);if(He.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var _,Xe=c(()=>{"use strict";r();_=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 Qe,he,Ke,Ye=c(()=>{"use strict";r();Qe=l(require("fs"),1);G();Ve();C();Xe();he=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 _(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: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:o,staticDir:i}=this.store.empConfig.build,p={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(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 qe();if(!e||!Qe.default.existsSync(e))return;let t=await We(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}},Ke=new he});var Ze,fe,et,tt=c(()=>{"use strict";r();Ze=l(require("fs-extra"),1),fe=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 Ze.default.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})}},et=new fe});var ge,st,ot=c(()=>{"use strict";r();ge=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:require.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:require.resolve("sass-loader"),options:o}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,o={loader:require.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"}}}})}},st=new ge});function bs(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
- `);return ce(s)}var q,W,z,V=c(()=>{"use strict";r();q=l(require("html-webpack-plugin"),1);C();w();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,bs(),{name:void 0}).apply(e)}},z=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=>{q.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async o=>(this.chunk&&!o.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(i=>{let{pos:p,...u}=i;(p==="body"?o.bodyTags:o.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o))})}}});var v,de,it,rt=c(()=>{"use strict";r();v=l(require("path"),1);G();V();de=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),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(v.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${v.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","favicon.ico"))}setEntryItem(e,t,o){o=o||this.store.resolve(v.default.join(this.store.empConfig.appSrc,e));let i=this.setChunk(e),p=[o];this.entriesConfig[i]={entry:{[i]:p},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(q.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=v.default.join(this.store.appSrc,e),o=v.default.join(t,"**","*.{ts,tsx,jsx,js}"),i=await(0,F.glob)([o],{windowsPathsNoEscape:!0});i=i.map(p=>p.replace(`${t}${v.default.sep}`,"")),i.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},v.default.join(t,p))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=v.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,F.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let o=v.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(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)}},it=new de});var ye,ve,nt,pt=c(()=>{"use strict";r();ye=l(require("path"),1);C();ve=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",ye.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=pe(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ye.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: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"}}}})}},nt=new ve});var be,j,Ce,at,lt=c(()=>{"use strict";r();be=l(require("fs"),1),j=l(require("@rspack/core"),1);V();Ce=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(W)}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");be.default.existsSync(e)&&be.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])}},at=new Ce});var we,ct,mt=c(()=>{"use strict";r();tt();ot();rt();pt();lt();we=class{store;async setup(e){this.store=e;let t=[et.setup(this.store),nt.setup(this.store),at.setup(this.store),it.setup(this.store),st.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ct=new we});async function gt(s,e="localhost"){if(s!==Cs&&(s<ut||s>Se))throw new Error(`Port number must lie between ${ut} and ${Se}`);let t=s,o=ws(),i;e&&!o.has(e)?i=new Set([e]):i=o;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=Se;)try{return await xs(t,i)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var ht,ft,ut,Se,Cs,ws,Ss,xs,dt=c(()=>{"use strict";r();ht=l(require("net"),1),ft=l(require("os"),1),ut=1024,Se=65535,Cs=443,ws=()=>{let s=ft.default.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},Ss=(s,e)=>new Promise((t,o)=>{let i=ht.default.createServer();i.unref(),i.on("error",o),i.listen(s,e,()=>{let{port:p}=i.address();i.close(()=>{t(p)})})}),xs=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let o of e)try{await Ss(s,o)}catch(i){if(!t.has(i.code))throw i}return s}});var xe,yt,Oe,X,vt=c(()=>{"use strict";r();xe=l(require("url"),1),yt=l(require("chalk"),1);L();C();Oe=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:R("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 xe.default.format({protocol:t,hostname:e,port:o,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return xe.default.format({protocol:t,hostname:e,port:yt.default.bold(o),pathname:i})}},X=new Oe});var Ct,wt,St,bt,Os,Es,xt,Ot=c(()=>{"use strict";r();Ct=require("child_process"),wt=require("util");w();E();St=(0,wt.promisify)(Ct.exec),bt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Os=async()=>{let s=process.env.BROWSER;if(!s||!bt.includes(s)){let{stdout:e}=await St("ps cax");s=bt.find(t=>e.includes(t))}return s},Es=async s=>{if(process.platform==="darwin")try{let t=await Os();if(t){let o=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await St(o,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},xt=Es});var Ee,Q,Et=c(()=>{"use strict";r();Ee=l(require("fs/promises"),1);G();L();dt();vt();Ot();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),X.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=X.prettyPrintUrl("localhost")):(this.urls=X.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
11
- `)),this.isOpenBrower&&xt(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([Ee.default.readFile(e.resource.key),Ee.default.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 gt(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Pt,kt=c(()=>{"use strict";r();Pt={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 $t,b,jt,Tt,Pe,a,w=c(()=>{"use strict";r();$t=l(require("fs/promises"),1),b=l(require("path"),1),jt=l(require("util"),1);E();C();Ye();mt();Et();Tt=l(require("webpack-chain"),1);kt();V();Pe=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=b.default.resolve(__dirname,__filename).replace(`${b.default.sep}dist${b.default.sep}index.js`,"");empSource=b.default.resolve(this.empRoot,"dist");resolve=e=>b.default.isAbsolute(e)?e:b.default.resolve(this.root,e);empResolve=e=>b.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Pt;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=Ke,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Tt.default,await ct.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=require(this.empResolve("package.json")),i=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...o},this.pkg={...this.pkg,...i},this.resource.dir=b.default.join(this.empRoot,"resource"),this.resource.cert=b.default.join(this.resource.dir,"emp.cert"),this.resource.key=b.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=b.default.join(this.root,this.debug.showRsconfig);$t.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(jt.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=le;deepAssign=y;getLanIp=$;injectTags(e=[],t="",o=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,o])}},a=new Pe});var Dt,Rt,Lt,At,Nt,Mt,ke,A,I,Ft=c(()=>{"use strict";r();Dt=l(require("https"),1),Rt=l(require("fs"),1),Lt=l(require("fs/promises"),1),At=l(require("path"),1),Nt=l(require("compression"),1),Mt=l(require("cors"),1),ke=l(require("express"),1),A=(0,ke.default)();A.use((0,Nt.default)());A.use((0,Mt.default)());I=class{async setup(e,t=()=>{}){if(!Rt.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);A.use(ke.default.static(o));let i=await Lt.default.readFile(At.default.join(o,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(i)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();Dt.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});var Gt,U,zt=c(()=>{"use strict";r();Gt=require("@rspack/dev-server"),U=class{async setup(e,t,o,i=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new Gt.RspackDevServer(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(i),p}async beforeCompiler(e){return e}}});var $e=c(()=>{"use strict";r();Ft();zt()});function Rs(s,e){let t=[s,e],o=["File","Size","Gzipped"].reduce((i,p,u)=>{let g=t[u],x=p;return g&&(x=p.length<g?p+" ".repeat(g-p.length):p),`${i+x} `}," ");console.log(D.bold(o))}async function Bt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),o=e.assets.filter(f=>js(f.name)).map(Ds);o.sort((f,M)=>f.size-M.size);let i=Math.max(...o.map(f=>f.sizeLabel.length)),p=Math.max(...o.map(f=>(f.folder+O.default.sep+f.name).length));Rs(p,i);let u=0,g=0;o.forEach(f=>{let{sizeLabel:M}=f,{name:Zt,folder:es,gzipSizeLabel:ts}=f,Ae=(es+O.default.sep+Zt).length,Ne=M.length;if(u+=f.size,g+=f.gzippedSize,Ne<i){let se=" ".repeat(i-Ne);M+=se}let Me=R(f.folder+O.default.sep)+Ls(f.name);if(Ae<p){let se=" ".repeat(p-Ae);Me+=se}n.info(` ${Me} ${R(M)} ${ts}`)});let x=`${D.bold("Total size:")} ${K(u)}`,N=`${D.bold("Gzipped size:")} ${K(g)}`;n.info(`
9
+ `)}},n=new pe});var ue={};T(ue,{clearConsole:()=>le,deepAssign:()=>y,ensureArray:()=>gs,getLanIp:()=>$,getPkgVersion:()=>ae,importJsVm:()=>me,jsonFilter:()=>ds,timeFormat:()=>J,vCompare:()=>ce});function le(){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],p=s[o];if(Object(i)==i&&Object(p)===p){s[o]=y(p,i);continue}s[o]=t[o]}return s}var ze,Ie,Ue,Be,$,ae,gs,ds,ce,J,me,C=c(()=>{"use strict";r();ze=require("address"),Ie=l(require("chalk"),1),Ue=require("default-gateway"),Be=l(require("fs-extra"),1),$=()=>{let{int:s}=(0,Ue.gateway4sync)();return(0,ze.ip)(s||"")||"127.0.0.1"},ae=s=>{try{let{version:e}=Be.default.readJSONSync(s);return e}catch{return}};gs=s=>Array.isArray(s)?s:[s],ds=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,o)=>(t[o]=s[o],t),{}),ce=(s="",e="")=>{let t=s.replace("^","").split("."),o=e.replace("^","").split("."),i=Math.max(t.length,o.length),p=0;for(let u=0;u<i;u++){let g=t.length>u?t[u]:0,x=isNaN(Number(g))?g.charCodeAt():Number(g),N=o.length>u?o[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(x<f){p=-1;break}else if(x>f){p=1;break}}return p},J=s=>{s=s/1e3;let e=o=>Ie.default.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`},me=s=>`data:text/javascript,${s}`});var he={};T(he,{chalk:()=>He.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ue});var He,F,G=c(()=>{"use strict";r();He=l(require("chalk"),1),F=require("glob");L();C();E()});var Je,_e,We,ys,qe,Ve,vs,Xe=c(()=>{"use strict";r();Je=l(require("fs"),1),_e=l(require("path"),1),We=require("jiti");w();E();ys=["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"],qe=(0,We.createJiti)(__filename,{interopDefault:!0}),Ve=async()=>vs(),vs=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of ys){let t=_e.default.resolve(a.root,e);if(Je.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var _,Qe=c(()=>{"use strict";r();_=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 Ke,fe,Ye,Ze=c(()=>{"use strict";r();Ke=l(require("fs"),1);G();Xe();C();Qe();fe=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 _(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: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:o,staticDir:i}=this.store.empConfig.build,p={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(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 Ve();if(!e||!Ke.default.existsSync(e))return;let t=await qe(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}},Ye=new fe});var et,ge,tt,st=c(()=>{"use strict";r();et=l(require("fs-extra"),1),ge=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({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 et.default.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})}},tt=new ge});var de,ot,it=c(()=>{"use strict";r();de=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,o={},{sass:i}=this.store.empConfig.css||{sass:{}};i.mode==="modern"&&(o.implementation=i.implementation?i.implementation:require.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:require.resolve("sass-loader"),options:o}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,o={loader:require.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"}}}})}},ot=new de});function bs(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
+ `);return me(s)}var q,W,z,V=c(()=>{"use strict";r();q=l(require("html-webpack-plugin"),1);C();w();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,bs(),{name:void 0}).apply(e)}},z=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=>{q.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async o=>(this.chunk&&!o.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(i=>{let{pos:p,...u}=i;(p==="body"?o.bodyTags:o.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o))})}}});var v,ye,rt,nt=c(()=>{"use strict";r();v=l(require("path"),1);G();V();ye=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(v.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${v.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","favicon.ico"))}setEntryItem(e,t,o){o=o||this.store.resolve(v.default.join(this.store.empConfig.appSrc,e));let i=this.setChunk(e),p=[o];this.entriesConfig[i]={entry:{[i]:p},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(q.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=v.default.join(this.store.appSrc,e),o=v.default.join(t,"**","*.{ts,tsx,jsx,js}"),i=await(0,F.glob)([o],{windowsPathsNoEscape:!0});i=i.map(p=>p.replace(`${t}${v.default.sep}`,"")),i.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},v.default.join(t,p))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=v.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await(0,F.glob)([e],{windowsPathsNoEscape:!0});if(t[0]){let o=v.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(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)}},rt=new ye});var ve,be,pt,at=c(()=>{"use strict";r();ve=l(require("path"),1);C();be=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.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",ve.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ae(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ve.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: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"}}}})}},pt=new be});var Ce,j,we,lt,ct=c(()=>{"use strict";r();Ce=l(require("fs"),1),j=l(require("@rspack/core"),1);V();we=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(W)}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");Ce.default.existsSync(e)&&Ce.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])}},lt=new we});var Se,mt,ut=c(()=>{"use strict";r();st();it();nt();at();ct();Se=class{store;async setup(e){this.store=e;let t=[tt.setup(this.store),pt.setup(this.store),lt.setup(this.store),rt.setup(this.store),ot.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},mt=new Se});async function X(s,e=void 0){if(s!==Cs&&(s<ht||s>xe))throw new Error(`Port number must lie between ${ht} and ${xe}`);let t=s,o=ws(),i;e&&!o.has(e)?i=new Set([e]):i=o;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await xs(t,i)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var ft,gt,ht,xe,Cs,ws,Ss,xs,dt=c(()=>{"use strict";r();ft=l(require("net"),1),gt=l(require("os"),1),ht=1024,xe=65535,Cs=443,ws=()=>{let s=gt.default.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},Ss=(s,e)=>new Promise((t,o)=>{let i=ft.default.createServer();i.unref(),i.on("error",o),i.listen(s,e,()=>{let{port:p}=i.address();i.close(()=>{t(p)})})}),xs=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let o of e)try{await Ss(s,o)}catch(i){if(!t.has(i.code))throw i}return s}});var Oe,yt,Ee,Q,vt=c(()=>{"use strict";r();Oe=l(require("url"),1),yt=l(require("chalk"),1);L();C();Ee=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:R("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 Oe.default.format({protocol:t,hostname:e,port:o,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return Oe.default.format({protocol:t,hostname:e,port:yt.default.bold(o),pathname:i})}},Q=new Ee});var Ct,wt,St,bt,Os,Es,xt,Ot=c(()=>{"use strict";r();Ct=require("child_process"),wt=require("util");w();E();St=(0,wt.promisify)(Ct.exec),bt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Os=async()=>{let s=process.env.BROWSER;if(!s||!bt.includes(s)){let{stdout:e}=await St("ps cax");s=bt.find(t=>e.includes(t))}return s},Es=async s=>{if(process.platform==="darwin")try{let t=await Os();if(t){let o=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await St(o,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},xt=Es});var Pe,K,Et=c(()=>{"use strict";r();Pe=l(require("fs/promises"),1);G();L();dt();vt();Ot();C();K=class{ip=$();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.port=await X(this.port),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&&e.empConfig.server.port!==this.port&&(this.port=await X(e.empConfig.server.port)),Q.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Q.prettyPrintUrl("localhost")):(this.urls=Q.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
11
+ `)),this.isOpenBrower&&xt(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([Pe.default.readFile(e.resource.key),Pe.default.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",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await X(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Pt,kt=c(()=>{"use strict";r();Pt={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 $t,b,jt,Tt,ke,a,w=c(()=>{"use strict";r();$t=l(require("fs/promises"),1),b=l(require("path"),1),jt=l(require("util"),1);E();C();Ze();ut();Et();Tt=l(require("webpack-chain"),1);kt();V();ke=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=b.default.resolve(__dirname,__filename).replace(`${b.default.sep}dist${b.default.sep}index.js`,"");empSource=b.default.resolve(this.empRoot,"dist");resolve=e=>b.default.isAbsolute(e)?e:b.default.resolve(this.root,e);empResolve=e=>b.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Pt;server=new K(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=Ye,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Tt.default,await mt.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=require(this.empResolve("package.json")),i=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...o},this.pkg={...this.pkg,...i},this.resource.dir=b.default.join(this.empRoot,"resource"),this.resource.cert=b.default.join(this.resource.dir,"emp.cert"),this.resource.key=b.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=b.default.join(this.root,this.debug.showRsconfig);$t.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(jt.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.pkg.name.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=ce;deepAssign=y;getLanIp=$;injectTags(e=[],t="",o=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,o])}},a=new ke});var Dt,Rt,Lt,At,Nt,Mt,$e,A,I,Ft=c(()=>{"use strict";r();Dt=l(require("https"),1),Rt=l(require("fs"),1),Lt=l(require("fs/promises"),1),At=l(require("path"),1),Nt=l(require("compression"),1),Mt=l(require("cors"),1),$e=l(require("express"),1),A=(0,$e.default)();A.use((0,Nt.default)());A.use((0,Mt.default)());I=class{async setup(e,t=()=>{}){if(!Rt.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);A.use($e.default.static(o));let i=await Lt.default.readFile(At.default.join(o,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(i)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();Dt.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});var Gt,U,zt=c(()=>{"use strict";r();Gt=require("@rspack/dev-server"),U=class{async setup(e,t,o,i=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new Gt.RspackDevServer(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(i),p}async beforeCompiler(e){return e}}});var je=c(()=>{"use strict";r();Ft();zt()});function Rs(s,e){let t=[s,e],o=["File","Size","Gzipped"].reduce((i,p,u)=>{let g=t[u],x=p;return g&&(x=p.length<g?p+" ".repeat(g-p.length):p),`${i+x} `}," ");console.log(D.bold(o))}async function Bt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),o=e.assets.filter(f=>js(f.name)).map(Ds);o.sort((f,M)=>f.size-M.size);let i=Math.max(...o.map(f=>f.sizeLabel.length)),p=Math.max(...o.map(f=>(f.folder+O.default.sep+f.name).length));Rs(p,i);let u=0,g=0;o.forEach(f=>{let{sizeLabel:M}=f,{name:Zt,folder:es,gzipSizeLabel:ts}=f,Ne=(es+O.default.sep+Zt).length,Me=M.length;if(u+=f.size,g+=f.gzippedSize,Me<i){let oe=" ".repeat(i-Me);M+=oe}let Fe=R(f.folder+O.default.sep)+Ls(f.name);if(Ne<p){let oe=" ".repeat(p-Ne);Fe+=oe}n.info(` ${Fe} ${R(M)} ${ts}`)});let x=`${D.bold("Total size:")} ${Y(u)}`,N=`${D.bold("Gzipped size:")} ${Y(g)}`;n.info(`
12
12
  ${x}
13
13
  ${N}
14
14
  `),n.info(`${S("\u2713")} Ready in ${J(Number(e.time))}
15
- `)}function Y(s=0){n.info(`${S("\u2713")} Ready in ${J(Number(s))}`)}var It,O,Ut,Ps,ks,$s,js,Ts,Ds,K,Ls,Z=c(()=>{"use strict";r();It=l(require("fs"),1),O=l(require("path"),1),Ut=require("gzip-size");L();w();E();C();Ps=/\.html$/,ks=/\.(?:js|mjs|cjs|jsx)$/,$s=/\.css$/,js=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Ts=s=>s>300*1e3?oe:s>100*1e3?H:ie,Ds=s=>{let e=s.name.split("?")[0],t=K(s.size),o=O.default.basename(e),i=O.default.join(O.default.basename(a.empConfig.build.outDir),O.default.dirname(e)),p=It.default.readFileSync(O.default.join(a.empConfig.build.outDir,e)),u=p.length,g=(0,Ut.gzipSizeSync)(p),x=Ts(g)(K(g));return{size:u,folder:i,name:o,gzippedSize:g,sizeLabel:t,gzipSizeLabel:x}};K=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ls=s=>ks.test(s)?H(s):$s.test(s)?S(s):Ps.test(s)?D(s):re(s)});var P,ee=c(()=>{"use strict";r();E();C();w();P=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&ae(),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 _t={};T(_t,{default:()=>As});var Jt,Ht,je,As,Wt=c(()=>{"use strict";r();Jt=require("@rspack/core");$e();Z();C();ee();w();Ht=new U,je=class extends P{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:o,cert:i}=await a.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}=a,t=await this.getRspackDevConfig();t=await Ht.beforeCompiler(t);let o=(0,Jt.rspack)(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Ht.setup(o,t,a,async i=>{this.showTimeDone(i),await a.empConfig.lifeCycle.afterDevServe()}),a.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});Y(t.time)}},As=new je});var Te={};T(Te,{ServeScript:()=>te,default:()=>Ms});var Ns,qt,te,Ms,De=c(()=>{"use strict";r();Z();ee();$e();w();Ns=new I,qt=0,te=class extends P{async run(){qt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Ns.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),Y(Date.now()-qt),await a.empConfig.lifeCycle.afterServe()}},Ms=new te});var Xt={};T(Xt,{default:()=>Fs});var Vt,Re,Fs,Qt=c(()=>{"use strict";r();Vt=require("@rspack/core");Z();E();ee();w();Re=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(()=>(De(),Te));await e.setup("serve",a.cliOptions)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),(0,Vt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
- `),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Bt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Fs=new Re});var zs={};T(zs,{defineConfig:()=>Gs,empHelper:()=>ue,rspack:()=>Yt.rspack,runScript:()=>Le,store:()=>a});module.exports=ps(zs);r();var Yt=require("@rspack/core");r();var Kt=l(require("process"),1),k=require("commander");w();function Le(){k.program.version(a.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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Wt(),_t));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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Qt(),Xt));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(()=>(De(),Te));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(Kt.default.argv)}w();G();function Gs(s){return s}0&&(module.exports={defineConfig,empHelper,rspack,runScript,store});
15
+ `)}function Z(s=0){n.info(`${S("\u2713")} Ready in ${J(Number(s))}`)}var It,O,Ut,Ps,ks,$s,js,Ts,Ds,Y,Ls,ee=c(()=>{"use strict";r();It=l(require("fs"),1),O=l(require("path"),1),Ut=require("gzip-size");L();w();E();C();Ps=/\.html$/,ks=/\.(?:js|mjs|cjs|jsx)$/,$s=/\.css$/,js=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Ts=s=>s>300*1e3?ie:s>100*1e3?H:re,Ds=s=>{let e=s.name.split("?")[0],t=Y(s.size),o=O.default.basename(e),i=O.default.join(O.default.basename(a.empConfig.build.outDir),O.default.dirname(e)),p=It.default.readFileSync(O.default.join(a.empConfig.build.outDir,e)),u=p.length,g=(0,Ut.gzipSizeSync)(p),x=Ts(g)(Y(g));return{size:u,folder:i,name:o,gzippedSize:g,sizeLabel:t,gzipSizeLabel:x}};Y=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ls=s=>ks.test(s)?H(s):$s.test(s)?S(s):Ps.test(s)?D(s):ne(s)});var P,te=c(()=>{"use strict";r();E();C();w();P=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&le(),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 _t={};T(_t,{default:()=>As});var Jt,Ht,Te,As,Wt=c(()=>{"use strict";r();Jt=require("@rspack/core");je();ee();C();te();w();Ht=new U,Te=class extends P{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:a.server.port}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:o,cert:i}=await a.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}=a,t=await this.getRspackDevConfig();t=await Ht.beforeCompiler(t);let o=(0,Jt.rspack)(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Ht.setup(o,t,a,async i=>{this.showTimeDone(i),await a.empConfig.lifeCycle.afterDevServe()}),a.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});Z(t.time)}},As=new Te});var De={};T(De,{ServeScript:()=>se,default:()=>Ms});var Ns,qt,se,Ms,Re=c(()=>{"use strict";r();ee();te();je();w();Ns=new I,qt=0,se=class extends P{async run(){qt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Ns.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),Z(Date.now()-qt),await a.empConfig.lifeCycle.afterServe()}},Ms=new se});var Xt={};T(Xt,{default:()=>Fs});var Vt,Le,Fs,Qt=c(()=>{"use strict";r();Vt=require("@rspack/core");ee();E();te();w();Le=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(()=>(Re(),De));await e.setup("serve",a.cliOptions)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),(0,Vt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
+ `),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Bt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Fs=new Le});var zs={};T(zs,{defineConfig:()=>Gs,empHelper:()=>he,rspack:()=>Yt.rspack,runScript:()=>Ae,store:()=>a});module.exports=ps(zs);r();var Yt=require("@rspack/core");r();var Kt=l(require("process"),1),k=require("commander");w();function Ae(){k.program.version(a.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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Wt(),_t));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,o]=s.split("=");return e[t]=o,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Qt(),Xt));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(()=>(Re(),De));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(Kt.default.argv)}w();G();function Gs(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
@@ -191,7 +191,6 @@ declare class StoreServer {
191
191
  getcert(): Promise<any>;
192
192
  private setHttps;
193
193
  private setAutoDevBase;
194
- private setPort;
195
194
  private get isHttpBase();
196
195
  }
197
196
 
package/dist/index.d.ts CHANGED
@@ -191,7 +191,6 @@ declare class StoreServer {
191
191
  getcert(): Promise<any>;
192
192
  private setHttps;
193
193
  private setAutoDevBase;
194
- private setPort;
195
194
  private get isHttpBase();
196
195
  }
197
196
 
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 Et=Object.defineProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var M=(s,e)=>{for(var t in e)Et(s,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Pt}from"url";import kt from"path";var Te,$t,c,l,r=m(()=>{"use strict";Te=()=>Pt(import.meta.url),$t=()=>kt.dirname(Te()),c=$t(),l=Te()});import d from"chalk";var jt,x,Tt,Dt,Rt,se,U,Lt,At,T,oe,Nt,ie,D,h,R=m(()=>{"use strict";r();jt=d.hex("#1abc9c"),x=d.hex("#16a085"),Tt=d.hex("#2ecc71"),Dt=d.hex("#27ae60"),Rt=d.hex("#e74c3c"),se=d.hex("#c0392b"),U=d.hex("#f1c40f"),Lt=d.hex("#f39c12"),At=d.hex("#3498db"),T=d.hex("#2980b9"),oe=d.hex("#ecf0f1"),Nt=d.hex("#fd79a8"),ie=d.hex("#e84393"),D=d.hex("#7f8c8d"),h={lightGreen:jt,green:x,lightCyan:Tt,cyan:Dt,lightRed:Rt,red:se,yellow:U,orange:Lt,lightBlue:At,blue:T,white:oe,lightMagenta:Nt,magenta:ie,gray:D}});var re,n,E=m(()=>{"use strict";r();R();re=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} `)}
2
+ var Et=Object.defineProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var M=(s,e)=>{for(var t in e)Et(s,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Pt}from"url";import kt from"path";var De,$t,c,l,r=m(()=>{"use strict";De=()=>Pt(import.meta.url),$t=()=>kt.dirname(De()),c=$t(),l=De()});import d from"chalk";var jt,x,Tt,Dt,Rt,oe,U,Lt,At,T,ie,Nt,re,D,h,R=m(()=>{"use strict";r();jt=d.hex("#1abc9c"),x=d.hex("#16a085"),Tt=d.hex("#2ecc71"),Dt=d.hex("#27ae60"),Rt=d.hex("#e74c3c"),oe=d.hex("#c0392b"),U=d.hex("#f1c40f"),Lt=d.hex("#f39c12"),At=d.hex("#3498db"),T=d.hex("#2980b9"),ie=d.hex("#ecf0f1"),Nt=d.hex("#fd79a8"),re=d.hex("#e84393"),D=d.hex("#7f8c8d"),h={lightGreen:jt,green:x,lightCyan:Tt,cyan:Dt,lightRed:Rt,red:oe,yellow:U,orange:Lt,lightBlue:At,blue:T,white:ie,lightMagenta:Nt,magenta:re,gray:D}});var ne,n,E=m(()=>{"use strict";r();R();ne=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 Et=Object.defineProperty;var v=(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 re});var ce={};M(ce,{clearConsole:()=>pe,deepAssign:()=>y,ensureArray:()=>It,getLanIp:()=>$,getPkgVersion:()=>ne,importJsVm:()=>le,jsonFilter:()=>Bt,timeFormat:()=>H,vCompare:()=>ae});import{ip as Ft}from"address";import Mt from"chalk";import{gateway4sync as Gt}from"default-gateway";import zt from"fs-extra";function pe(){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],p=s[o];if(Object(i)==i&&Object(p)===p){s[o]=y(p,i);continue}s[o]=t[o]}return s}var $,ne,It,Bt,ae,H,le,b=m(()=>{"use strict";r();$=()=>{let{int:s}=Gt();return Ft(s||"")||"127.0.0.1"},ne=s=>{try{let{version:e}=zt.readJSONSync(s);return e}catch{return}};It=s=>Array.isArray(s)?s:[s],Bt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,o)=>(t[o]=s[o],t),{}),ae=(s="",e="")=>{let t=s.replace("^","").split("."),o=e.replace("^","").split("."),i=Math.max(t.length,o.length),p=0;for(let u=0;u<i;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=o.length>u?o[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<f){p=-1;break}else if(O>f){p=1;break}}return p},H=s=>{s=s/1e3;let e=o=>Mt.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`},le=s=>`data:text/javascript,${s}`});var De={};M(De,{chalk:()=>Ut,color:()=>h,glob:()=>J,logger:()=>n,utils:()=>ce});import Ut from"chalk";import{glob as J}from"glob";var G=m(()=>{"use strict";r();R();b();E()});import Ht from"node:fs";import Jt from"path";import{createJiti as _t}from"jiti";var Wt,Re,Le,qt,Ae=m(()=>{"use strict";r();C();E();Wt=["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"],Re=_t(l,{interopDefault:!0}),Le=async()=>qt(),qt=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of Wt){let t=Jt.resolve(a.root,e);if(Ht.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var _,Ne=m(()=>{"use strict";r();_=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 Vt from"node:fs";var me,Fe,Me=m(()=>{"use strict";r();G();Ae();b();Ne();me=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 _(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: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:o,staticDir:i}=this.store.empConfig.build,p={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(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 Le();if(!e||!Vt.existsSync(e))return;let t=await Re(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}},Fe=new me});import Xt from"fs-extra";var ue,Ge,ze=m(()=>{"use strict";r();ue=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,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 Xt.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})}},Ge=new ue});var he,Ie,Be=m(()=>{"use strict";r();he=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:v.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:v.resolve("sass-loader"),options:o}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,o={loader:v.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"}}}})}},Ie=new he});import fe from"html-webpack-plugin";function Qt(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
- `);return le(s)}var W,z,q=m(()=>{"use strict";r();b();C();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Qt(),{name:void 0}).apply(e)}},z=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=>{fe.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async o=>(this.chunk&&!o.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(i=>{let{pos:p,...u}=i;(p==="body"?o.bodyTags:o.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o))})}}});import w from"node:path";var ge,Ue,He=m(()=>{"use strict";r();G();q();ge=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),p=[o];this.entriesConfig[i]={entry:{[i]:p},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(fe,[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 J([o],{windowsPathsNoEscape:!0});i=i.map(p=>p.replace(`${t}${w.sep}`,"")),i.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},w.join(t,p))}),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 J([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)}},Ue=new ge});import Je from"node:path";var de,_e,We=m(()=>{"use strict";r();b();de=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",Je.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=ne(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Je.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"}}}})}},_e=new de});import qe from"fs";import L from"@rspack/core";var ye,Ve,Xe=m(()=>{"use strict";r();q();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(W)}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(L.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");qe.existsSync(e)&&qe.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(L.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(L.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(L.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(L.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(L.SourceMapDevToolPlugin,[e])}},Ve=new ye});var ve,Qe,Ke=m(()=>{"use strict";r();ze();Be();He();We();Xe();ve=class{store;async setup(e){this.store=e;let t=[Ge.setup(this.store),_e.setup(this.store),Ve.setup(this.store),Ue.setup(this.store),Ie.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()}},Qe=new ve});import Kt from"net";import Yt from"os";async function Ze(s,e="localhost"){if(s!==Zt&&(s<Ye||s>be))throw new Error(`Port number must lie between ${Ye} and ${be}`);let t=s,o=es(),i;e&&!o.has(e)?i=new Set([e]):i=o;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=be;)try{return await ss(t,i)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ye,be,Zt,es,ts,ss,et=m(()=>{"use strict";r();Ye=1024,be=65535,Zt=443,es=()=>{let s=Yt.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},ts=(s,e)=>new Promise((t,o)=>{let i=Kt.createServer();i.unref(),i.on("error",o),i.listen(s,e,()=>{let{port:p}=i.address();i.close(()=>{t(p)})})}),ss=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let o of e)try{await ts(s,o)}catch(i){if(!t.has(i.code))throw i}return s}});import tt from"url";import os from"chalk";var Ce,V,st=m(()=>{"use strict";r();R();b();Ce=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:D("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",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 tt.format({protocol:t,hostname:e,port:o,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return tt.format({protocol:t,hostname:e,port:os.bold(o),pathname:i})}},V=new Ce});import{exec as is}from"node:child_process";import{promisify as rs}from"node:util";var it,ot,ns,ps,rt,nt=m(()=>{"use strict";r();C();E();it=rs(is),ot=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ns=async()=>{let s=process.env.BROWSER;if(!s||!ot.includes(s)){let{stdout:e}=await it("ps cax");s=ot.find(t=>e.includes(t))}return s},ps=async s=>{if(process.platform==="darwin")try{let t=await ns();if(t){let o=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await it(o,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},rt=ps});import pt from"node:fs/promises";var X,at=m(()=>{"use strict";r();G();R();et();st();nt();b();X=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),V.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=V.prettyPrintUrl("localhost")):(this.urls=V.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)}
12
- `)),this.isOpenBrower&&rt(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([pt.readFile(e.resource.key),pt.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 Ze(this.port,this.host)}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var lt,ct=m(()=>{"use strict";r();lt={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 as from"node:fs/promises";import S from"node:path";import ls from"node:util";import cs from"webpack-chain";var we,a,C=m(()=>{"use strict";r();E();b();Me();Ke();at();ct();q();we=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(c,l).replace(`${S.sep}dist${S.sep}index.js`,"");empSource=S.resolve(this.empRoot,"dist");resolve=e=>S.isAbsolute(e)?e:S.resolve(this.root,e);empResolve=e=>S.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=lt;server=new X(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=Fe,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new cs,await Qe.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=v(this.empResolve("package.json")),i=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...o},this.pkg={...this.pkg,...i},this.resource.dir=S.join(this.empRoot,"resource"),this.resource.cert=S.join(this.resource.dir,"emp.cert"),this.resource.key=S.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=S.join(this.root,this.debug.showRsconfig);as.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(ls.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=ae;deepAssign=y;getLanIp=$;injectTags(e=[],t="",o=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,o])}},a=new we});import ms from"https";import us from"node:fs";import hs from"node:fs/promises";import fs from"path";import gs from"compression";import ds from"cors";import mt from"express";var A,I,ut=m(()=>{"use strict";r();A=mt();A.use(gs());A.use(ds());I=class{async setup(e,t=()=>{}){if(!us.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);A.use(mt.static(o));let i=await hs.readFile(fs.join(o,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(i)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();ms.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});import{RspackDevServer as ys}from"@rspack/dev-server";var B,ht=m(()=>{"use strict";r();B=class{async setup(e,t,o,i=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new ys(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(i),p}async beforeCompiler(e){return e}}});var Se=m(()=>{"use strict";r();ut();ht()});import vs from"node:fs";import P from"node:path";import{gzipSizeSync as bs}from"gzip-size";function Ps(s,e){let t=[s,e],o=["File","Size","Gzipped"].reduce((i,p,u)=>{let g=t[u],O=p;return g&&(O=p.length<g?p+" ".repeat(g-p.length):p),`${i+O} `}," ");console.log(T.bold(o))}async function ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),o=e.assets.filter(f=>xs(f.name)).map(Es);o.sort((f,F)=>f.size-F.size);let i=Math.max(...o.map(f=>f.sizeLabel.length)),p=Math.max(...o.map(f=>(f.folder+P.sep+f.name).length));Ps(p,i);let u=0,g=0;o.forEach(f=>{let{sizeLabel:F}=f,{name:St,folder:xt,gzipSizeLabel:Ot}=f,ke=(xt+P.sep+St).length,$e=F.length;if(u+=f.size,g+=f.gzippedSize,$e<i){let te=" ".repeat(i-$e);F+=te}let je=D(f.folder+P.sep)+ks(f.name);if(ke<p){let te=" ".repeat(p-ke);je+=te}n.info(` ${je} ${D(F)} ${Ot}`)});let O=`${T.bold("Total size:")} ${Q(u)}`,N=`${T.bold("Gzipped size:")} ${Q(g)}`;n.info(`
10
+ `)}},n=new ne});var me={};M(me,{clearConsole:()=>ae,deepAssign:()=>y,ensureArray:()=>It,getLanIp:()=>$,getPkgVersion:()=>pe,importJsVm:()=>ce,jsonFilter:()=>Bt,timeFormat:()=>H,vCompare:()=>le});import{ip as Ft}from"address";import Mt from"chalk";import{gateway4sync as Gt}from"default-gateway";import zt from"fs-extra";function ae(){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],p=s[o];if(Object(i)==i&&Object(p)===p){s[o]=y(p,i);continue}s[o]=t[o]}return s}var $,pe,It,Bt,le,H,ce,b=m(()=>{"use strict";r();$=()=>{let{int:s}=Gt();return Ft(s||"")||"127.0.0.1"},pe=s=>{try{let{version:e}=zt.readJSONSync(s);return e}catch{return}};It=s=>Array.isArray(s)?s:[s],Bt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,o)=>(t[o]=s[o],t),{}),le=(s="",e="")=>{let t=s.replace("^","").split("."),o=e.replace("^","").split("."),i=Math.max(t.length,o.length),p=0;for(let u=0;u<i;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=o.length>u?o[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<f){p=-1;break}else if(O>f){p=1;break}}return p},H=s=>{s=s/1e3;let e=o=>Mt.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`},ce=s=>`data:text/javascript,${s}`});var Re={};M(Re,{chalk:()=>Ut,color:()=>h,glob:()=>J,logger:()=>n,utils:()=>me});import Ut from"chalk";import{glob as J}from"glob";var G=m(()=>{"use strict";r();R();b();E()});import Ht from"node:fs";import Jt from"path";import{createJiti as _t}from"jiti";var Wt,Le,Ae,qt,Ne=m(()=>{"use strict";r();C();E();Wt=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],Le=_t(l,{interopDefault:!0}),Ae=async()=>qt(),qt=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of Wt){let t=Jt.resolve(a.root,e);if(Ht.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var _,Fe=m(()=>{"use strict";r();_=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 Vt from"node:fs";var ue,Me,Ge=m(()=>{"use strict";r();G();Ne();b();Fe();ue=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 _(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: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:o,staticDir:i}=this.store.empConfig.build,p={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(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}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 Ae();if(!e||!Vt.existsSync(e))return;let t=await Le(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}},Me=new ue});import Xt from"fs-extra";var he,ze,Ie=m(()=>{"use strict";r();he=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 Xt.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})}},ze=new he});var fe,Be,Ue=m(()=>{"use strict";r();fe=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:v.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:v.resolve("sass-loader"),options:o}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,o={loader:v.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"}}}})}},Be=new fe});import ge from"html-webpack-plugin";function Qt(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
+ `);return ce(s)}var W,z,q=m(()=>{"use strict";r();b();C();W=class{constructor(){}apply(e){let{webpack:t}=e;a.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Qt(),{name:void 0}).apply(e)}},z=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=>{ge.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async o=>(this.chunk&&!o.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(i=>{let{pos:p,...u}=i;(p==="body"?o.bodyTags:o.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),o))})}}});import w from"node:path";var de,He,Je=m(()=>{"use strict";r();G();q();de=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),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),p=[o];this.entriesConfig[i]={entry:{[i]:p},html:this.setHtmlConfig(t,[i])},this.store.entries[i]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(ge,[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 J([o],{windowsPathsNoEscape:!0});i=i.map(p=>p.replace(`${t}${w.sep}`,"")),i.map(p=>{let u=this.store.empConfig.entries[p]||{};this.setEntryItem(p,{...this.store.empConfig.html,...u},w.join(t,p))}),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 J([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)}},He=new de});import _e from"node:path";var ye,We,qe=m(()=>{"use strict";r();b();ye=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]";this.store.chain.merge({module:{generator:{css:{localIdentName:e},"css/auto":{localIdentName:e},"css/module":{localIdentName:e}}}})}rspackParser(){this.store.chain.merge({module:{parser:{css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.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",_e.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=pe(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=_e.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"}}}})}},We=new ye});import Ve from"fs";import L from"@rspack/core";var ve,Xe,Qe=m(()=>{"use strict";r();q();ve=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(W)}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(L.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Ve.existsSync(e)&&Ve.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(L.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(L.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(L.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(L.LightningCssMinimizerRspackPlugin,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(L.SourceMapDevToolPlugin,[e])}},Xe=new ve});var be,Ke,Ye=m(()=>{"use strict";r();Ie();Ue();Je();qe();Qe();be=class{store;async setup(e){this.store=e;let t=[ze.setup(this.store),We.setup(this.store),Xe.setup(this.store),He.setup(this.store),Be.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()}},Ke=new be});import Kt from"net";import Yt from"os";async function V(s,e=void 0){if(s!==Zt&&(s<Ze||s>Ce))throw new Error(`Port number must lie between ${Ze} and ${Ce}`);let t=s,o=es(),i;e&&!o.has(e)?i=new Set([e]):i=o;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=Ce;)try{return await ss(t,i)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ze,Ce,Zt,es,ts,ss,et=m(()=>{"use strict";r();Ze=1024,Ce=65535,Zt=443,es=()=>{let s=Yt.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},ts=(s,e)=>new Promise((t,o)=>{let i=Kt.createServer();i.unref(),i.on("error",o),i.listen(s,e,()=>{let{port:p}=i.address();i.close(()=>{t(p)})})}),ss=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let o of e)try{await ts(s,o)}catch(i){if(!t.has(i.code))throw i}return s}});import tt from"url";import os from"chalk";var we,X,st=m(()=>{"use strict";r();R();b();we=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 tt.format({protocol:t,hostname:e,port:o,pathname:i})}prettyPrintUrl(e){let{protocol:t,port:o,pathname:i}=this.imf;return tt.format({protocol:t,hostname:e,port:os.bold(o),pathname:i})}},X=new we});import{exec as is}from"node:child_process";import{promisify as rs}from"node:util";var it,ot,ns,ps,rt,nt=m(()=>{"use strict";r();C();E();it=rs(is),ot=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ns=async()=>{let s=process.env.BROWSER;if(!s||!ot.includes(s)){let{stdout:e}=await it("ps cax");s=ot.find(t=>e.includes(t))}return s},ps=async s=>{if(process.platform==="darwin")try{let t=await ns();if(t){let o=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await it(o,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},rt=ps});import pt from"node:fs/promises";var Q,at=m(()=>{"use strict";r();G();R();et();st();nt();b();Q=class{ip=$();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.port=await V(this.port),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&&e.empConfig.server.port!==this.port&&(this.port=await V(e.empConfig.server.port)),X.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=X.prettyPrintUrl("localhost")):(this.urls=X.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)}
12
+ `)),this.isOpenBrower&&rt(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([pt.readFile(e.resource.key),pt.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",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await V(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var lt,ct=m(()=>{"use strict";r();lt={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 as from"node:fs/promises";import S from"node:path";import ls from"node:util";import cs from"webpack-chain";var Se,a,C=m(()=>{"use strict";r();E();b();Ge();Ye();at();ct();q();Se=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=S.resolve(c,l).replace(`${S.sep}dist${S.sep}index.js`,"");empSource=S.resolve(this.empRoot,"dist");resolve=e=>S.isAbsolute(e)?e:S.resolve(this.root,e);empResolve=e=>S.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=lt;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=Me,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new cs,await Ke.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=v(this.empResolve("package.json")),i=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...o},this.pkg={...this.pkg,...i},this.resource.dir=S.join(this.empRoot,"resource"),this.resource.cert=S.join(this.resource.dir,"emp.cert"),this.resource.key=S.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=S.join(this.root,this.debug.showRsconfig);as.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?y(e,this.debug.showRsconfig):e;console.log(n.link("[Compile Config]")),console.log(ls.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=le;deepAssign=y;getLanIp=$;injectTags(e=[],t="",o=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,o])}},a=new Se});import ms from"https";import us from"node:fs";import hs from"node:fs/promises";import fs from"path";import gs from"compression";import ds from"cors";import mt from"express";var A,I,ut=m(()=>{"use strict";r();A=mt();A.use(gs());A.use(ds());I=class{async setup(e,t=()=>{}){if(!us.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);A.use(mt.static(o));let i=await hs.readFile(fs.join(o,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(i)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();ms.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});import{RspackDevServer as ys}from"@rspack/dev-server";var B,ht=m(()=>{"use strict";r();B=class{async setup(e,t,o,i=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new ys(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(i),p}async beforeCompiler(e){return e}}});var xe=m(()=>{"use strict";r();ut();ht()});import vs from"node:fs";import P from"node:path";import{gzipSizeSync as bs}from"gzip-size";function Ps(s,e){let t=[s,e],o=["File","Size","Gzipped"].reduce((i,p,u)=>{let g=t[u],O=p;return g&&(O=p.length<g?p+" ".repeat(g-p.length):p),`${i+O} `}," ");console.log(T.bold(o))}async function ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),o=e.assets.filter(f=>xs(f.name)).map(Es);o.sort((f,F)=>f.size-F.size);let i=Math.max(...o.map(f=>f.sizeLabel.length)),p=Math.max(...o.map(f=>(f.folder+P.sep+f.name).length));Ps(p,i);let u=0,g=0;o.forEach(f=>{let{sizeLabel:F}=f,{name:St,folder:xt,gzipSizeLabel:Ot}=f,$e=(xt+P.sep+St).length,je=F.length;if(u+=f.size,g+=f.gzippedSize,je<i){let se=" ".repeat(i-je);F+=se}let Te=D(f.folder+P.sep)+ks(f.name);if($e<p){let se=" ".repeat(p-$e);Te+=se}n.info(` ${Te} ${D(F)} ${Ot}`)});let O=`${T.bold("Total size:")} ${K(u)}`,N=`${T.bold("Gzipped size:")} ${K(g)}`;n.info(`
13
13
  ${O}
14
14
  ${N}
15
15
  `),n.info(`${x("\u2713")} Ready in ${H(Number(e.time))}
16
- `)}function K(s=0){n.info(`${x("\u2713")} Ready in ${H(Number(s))}`)}var Cs,ws,Ss,xs,Os,Es,Q,ks,Y=m(()=>{"use strict";r();R();C();E();b();Cs=/\.html$/,ws=/\.(?:js|mjs|cjs|jsx)$/,Ss=/\.css$/,xs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Os=s=>s>300*1e3?se:s>100*1e3?U:oe,Es=s=>{let e=s.name.split("?")[0],t=Q(s.size),o=P.basename(e),i=P.join(P.basename(a.empConfig.build.outDir),P.dirname(e)),p=vs.readFileSync(P.join(a.empConfig.build.outDir,e)),u=p.length,g=bs(p),O=Os(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`},ks=s=>ws.test(s)?U(s):Ss.test(s)?x(s):Cs.test(s)?T(s):ie(s)});var k,Z=m(()=>{"use strict";r();E();b();C();k=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&pe(),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 dt={};M(dt,{default:()=>js});import{rspack as $s}from"@rspack/core";var gt,xe,js,yt=m(()=>{"use strict";r();Se();Y();b();Z();C();gt=new B,xe=class extends k{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:o,cert:i}=await a.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}=a,t=await this.getRspackDevConfig();t=await gt.beforeCompiler(t);let o=$s(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await gt.setup(o,t,a,async i=>{this.showTimeDone(i),await a.empConfig.lifeCycle.afterDevServe()}),a.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});K(t.time)}},js=new xe});var Oe={};M(Oe,{ServeScript:()=>ee,default:()=>Ds});var Ts,vt,ee,Ds,Ee=m(()=>{"use strict";r();Y();Z();Se();C();Ts=new I,vt=0,ee=class extends k{async run(){vt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Ts.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),K(Date.now()-vt),await a.empConfig.lifeCycle.afterServe()}},Ds=new ee});var bt={};M(bt,{default:()=>Ls});import{rspack as Rs}from"@rspack/core";var Pe,Ls,Ct=m(()=>{"use strict";r();Y();E();Z();C();Pe=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(()=>(Ee(),Oe));await e.setup("serve",a.cliOptions)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),Rs(this.rspackConfig,async(e,t)=>{if(console.log(`
17
- `),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await ft(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Ls=new Pe});r();import{rspack as Gr}from"@rspack/core";r();C();import As from"node:process";import{program as j}from"commander";function wt(){j.version(a.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(()=>(yt(),dt));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(()=>(Ct(),bt));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(()=>(Ee(),Oe));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(As.argv)}C();G();function Br(s){return s}export{Br as defineConfig,De as empHelper,Gr as rspack,wt as runScript,a as store};
16
+ `)}function Y(s=0){n.info(`${x("\u2713")} Ready in ${H(Number(s))}`)}var Cs,ws,Ss,xs,Os,Es,K,ks,Z=m(()=>{"use strict";r();R();C();E();b();Cs=/\.html$/,ws=/\.(?:js|mjs|cjs|jsx)$/,Ss=/\.css$/,xs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Os=s=>s>300*1e3?oe:s>100*1e3?U:ie,Es=s=>{let e=s.name.split("?")[0],t=K(s.size),o=P.basename(e),i=P.join(P.basename(a.empConfig.build.outDir),P.dirname(e)),p=vs.readFileSync(P.join(a.empConfig.build.outDir,e)),u=p.length,g=bs(p),O=Os(g)(K(g));return{size:u,folder:i,name:o,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};K=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},ks=s=>ws.test(s)?U(s):Ss.test(s)?x(s):Cs.test(s)?T(s):re(s)});var k,ee=m(()=>{"use strict";r();E();b();C();k=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&ae(),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 dt={};M(dt,{default:()=>js});import{rspack as $s}from"@rspack/core";var gt,Oe,js,yt=m(()=>{"use strict";r();xe();Z();b();ee();C();gt=new B,Oe=class extends k{get stats(){return{all:a.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(a.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:a.server.port}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:o,cert:i}=await a.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}=a,t=await this.getRspackDevConfig();t=await gt.beforeCompiler(t);let o=$s(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await gt.setup(o,t,a,async i=>{this.showTimeDone(i),await a.empConfig.lifeCycle.afterDevServe()}),a.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});Y(t.time)}},js=new Oe});var Ee={};M(Ee,{ServeScript:()=>te,default:()=>Ds});var Ts,vt,te,Ds,Pe=m(()=>{"use strict";r();Z();ee();xe();C();Ts=new I,vt=0,te=class extends k{async run(){vt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Ts.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),Y(Date.now()-vt),await a.empConfig.lifeCycle.afterServe()}},Ds=new te});var bt={};M(bt,{default:()=>Ls});import{rspack as Rs}from"@rspack/core";var ke,Ls,Ct=m(()=>{"use strict";r();Z();E();ee();C();ke=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(()=>(Pe(),Ee));await e.setup("serve",a.cliOptions)}async run(){await a.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!a.cliOptions.watch,this.isuseServe=!!a.cliOptions.serve,this.rspackConfig=a.rsConfig,this.isWatchMode&&this.watchMode(),Rs(this.rspackConfig,async(e,t)=>{if(console.log(`
17
+ `),a.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await ft(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},Ls=new ke});r();import{rspack as Gr}from"@rspack/core";r();C();import As from"node:process";import{program as j}from"commander";function wt(){j.version(a.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(()=>(yt(),dt));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(()=>(Ct(),bt));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(()=>(Pe(),Ee));await e.setup("serve",s)}),j.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),j.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),j.parse(As.argv)}C();G();function Br(s){return s}export{Br as defineConfig,Re as empHelper,Gr as rspack,wt as runScript,a as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -86,7 +86,7 @@
86
86
  "jiti": "2.0.0",
87
87
  "less-loader": "^12.2.0",
88
88
  "open": "^10.1.0",
89
- "sass-embedded": "^1.79.4",
89
+ "sass-embedded": "^1.79.5",
90
90
  "sass-loader": "^16.0.2",
91
91
  "typescript-plugin-css-modules": "^5.1.0",
92
92
  "webpack-bundle-analyzer": "^4.10.2",