@empjs/cli 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/emp.js CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import {runScript} from '@empjs/cli'
3
+
3
4
  runScript()
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var os=Object.create;var B=Object.defineProperty;var rs=Object.getOwnPropertyDescriptor;var ns=Object.getOwnPropertyNames;var ps=Object.getPrototypeOf,as=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var j=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},Ge=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ns(e))!as.call(s,o)&&o!==t&&B(s,o,{get:()=>e[o],enumerable:!(i=rs(e,o))||i.enumerable});return s};var l=(s,e,t)=>(t=s!=null?os(ps(s)):{},Ge(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),ls=s=>Ge(B({},"__esModule",{value:!0}),s);var r=c(()=>{"use strict"});var d,cs,S,ms,us,hs,re,H,fs,gs,D,ne,ds,pe,R,h,L=c(()=>{"use strict";r();d=l(require("chalk"),1),cs=d.default.hex("#1abc9c"),S=d.default.hex("#16a085"),ms=d.default.hex("#2ecc71"),us=d.default.hex("#27ae60"),hs=d.default.hex("#e74c3c"),re=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),fs=d.default.hex("#f39c12"),gs=d.default.hex("#3498db"),D=d.default.hex("#2980b9"),ne=d.default.hex("#ecf0f1"),ds=d.default.hex("#fd79a8"),pe=d.default.hex("#e84393"),R=d.default.hex("#7f8c8d"),h={lightGreen:cs,green:S,lightCyan:ms,cyan:us,lightRed:hs,red:re,yellow:H,orange:fs,lightBlue:gs,blue:D,white:ne,lightMagenta:ds,magenta:pe,gray:R}});var ae,n,k=c(()=>{"use strict";r();L();ae=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
1
+ "use strict";var rs=Object.create;var B=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var ps=Object.getOwnPropertyNames;var as=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var c=(s,e)=>()=>(s&&(e=s(s=0)),e);var j=(s,e)=>{for(var t in e)B(s,t,{get:e[t],enumerable:!0})},Ue=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ps(e))!ls.call(s,o)&&o!==t&&B(s,o,{get:()=>e[o],enumerable:!(i=ns(e,o))||i.enumerable});return s};var l=(s,e,t)=>(t=s!=null?rs(as(s)):{},Ue(e||!s||!s.__esModule?B(t,"default",{value:s,enumerable:!0}):t,s)),cs=s=>Ue(B({},"__esModule",{value:!0}),s);var r=c(()=>{"use strict"});var d,ms,x,us,hs,fs,ne,H,gs,ds,D,pe,ys,ae,R,h,L=c(()=>{"use strict";r();d=l(require("chalk"),1),ms=d.default.hex("#1abc9c"),x=d.default.hex("#16a085"),us=d.default.hex("#2ecc71"),hs=d.default.hex("#27ae60"),fs=d.default.hex("#e74c3c"),ne=d.default.hex("#c0392b"),H=d.default.hex("#f1c40f"),gs=d.default.hex("#f39c12"),ds=d.default.hex("#3498db"),D=d.default.hex("#2980b9"),pe=d.default.hex("#ecf0f1"),ys=d.default.hex("#fd79a8"),ae=d.default.hex("#e84393"),R=d.default.hex("#7f8c8d"),h={lightGreen:ms,green:x,lightCyan:us,cyan:hs,lightRed:fs,red:ne,yellow:H,orange:gs,lightBlue:ds,blue:D,white:pe,lightMagenta:ys,magenta:ae,gray:R}});var le,n,k=c(()=>{"use strict";r();L();le=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
2
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 ae});var ue={};j(ue,{clearConsole:()=>ce,deepAssign:()=>y,ensureArray:()=>ys,getLanIp:()=>T,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>vs,timeFormat:()=>_,vCompare:()=>J});function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var ze,Ie,Ue,Be,T,le,ys,vs,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),T=()=>{let s="127.0.0.1";try{let{int:e}=(0,Ue.gateway4sync)();return(0,ze.ip)(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=Be.default.readJSONSync(s);return e}catch{return}};ys=s=>Array.isArray(s)?s:[s],vs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,x=isNaN(Number(g))?g.charCodeAt():Number(g),A=i.length>u?i[u]:0,f=isNaN(Number(A))?A.charCodeAt():Number(A);if(x<f){p=-1;break}else if(x>f){p=1;break}}return p},_=s=>{s=s/1e3;let e=i=>Ie.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});var he={};j(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();k()});var Je,_e,Ve,bs,We,qe,Cs,Xe=c(()=>{"use strict";r();Je=l(require("fs"),1),_e=l(require("path"),1),Ve=require("jiti");w();k();bs=["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,Ve.createJiti)(__filename,{interopDefault:!0}),qe=async()=>Cs(),Cs=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of bs){let t=_e.default.resolve(a.root,e);if(Je.default.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Qe=c(()=>{"use strict";r();V=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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return 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||!Ke.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),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},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,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await et.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},tt=new ge});var de,it,ot=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,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},it=new de});function ws(){let s=[`import 'core-js/${a.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
- `);return me(s)}var q,W,z,X=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,ws(),{name:void 0}).apply(e)}},z=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{q.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:p,...u}=o;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var v,ye,rt,nt=c(()=>{"use strict";r();v=l(require("path"),1);G();X();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,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(v.default.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),p=[i];this.entriesConfig[o]={entry:{[o]:p},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(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),i=v.default.join(t,"**","*.{ts,tsx,jsx,js}"),o=await(0,F.glob)([i],{windowsPathsNoEscape:!0});o=o.map(p=>p.replace(`${t}${v.default.sep}`,"")),o.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 i=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(i,this.store.empConfig.html,t[0])}n.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},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.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc: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=le(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:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},pt=new be});var Ce,E,lt,we,ct,mt=c(()=>{"use strict";r();Ce=l(require("fs"),1),E=l(require("@rspack/core"),1),lt=require("ts-checker-rspack-plugin");X();we=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin()];this.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"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(lt.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(E.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(E.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(E.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(E.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=E.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(E.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(E.default.CircularDependencyRspackPlugin,[{}])}},ct=new we});var Se,ut,ht=c(()=>{"use strict";r();st();ot();nt();at();mt();Se=class{store;async setup(e){this.store=e;let t=[tt.setup(this.store),pt.setup(this.store),ct.setup(this.store),rt.setup(this.store),it.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ut=new Se});async function Q(s,e=void 0){if(s!==Ss&&(s<ft||s>xe))throw new Error(`Port number must lie between ${ft} and ${xe}`);let t=s,i=xs(),o;e&&!i.has(e)?o=new Set([e]):o=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=xe;)try{return await ks(t,o)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var gt,dt,ft,xe,Ss,xs,Os,ks,yt=c(()=>{"use strict";r();gt=l(require("net"),1),dt=l(require("os"),1),ft=1024,xe=65535,Ss=443,xs=()=>{let s=dt.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Os=(s,e)=>new Promise((t,i)=>{let o=gt.default.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:p}=o.address();o.close(()=>{t(p)})})}),ks=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Os(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});var Oe,vt,ke,K,bt=c(()=>{"use strict";r();Oe=l(require("url"),1),vt=l(require("chalk"),1);L();C();ke=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==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Oe.default.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Oe.default.format({protocol:t,hostname:e,port:vt.default.bold(i),pathname:o})}},K=new ke});var wt,St,xt,Ct,Es,Ps,Ot,kt=c(()=>{"use strict";r();wt=require("child_process"),St=require("util");w();k();xt=(0,St.promisify)(wt.exec),Ct=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Es=async()=>{let s=process.env.BROWSER;if(!s||!Ct.includes(s)){let{stdout:e}=await xt("ps cax");s=Ct.find(t=>e.includes(t))}return s},Ps=async s=>{if(process.platform==="darwin")try{let t=await Es();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await xt(i,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},Ot=Ps});var Ee,Y,Et=c(()=>{"use strict";r();Ee=l(require("fs/promises"),1);G();L();yt();bt();kt();C();Y=class{ip=T();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Q(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Q(e.empConfig.server.port)),K.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=K.prettyPrintUrl("localhost")):(this.urls=K.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${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&&Ot(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([Ee.default.readFile(e.resource.key),Ee.default.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Q(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Pt,$t=c(()=>{"use strict";r();Pt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Tt,b,jt,Dt,Rt,Pe,a,w=c(()=>{"use strict";r();Tt=l(require("fs/promises"),1),b=l(require("path"),1),jt=l(require("util"),1),Dt=require("@rspack/core");k();C();Ze();ht();Et();Rt=l(require("webpack-chain"),1);$t();X();Pe=class{rspackVersion=Dt.rspack.rspackVersion;isOldRspack=J(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=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 Y(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;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 Rt.default,await ut.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=require(this.empResolve("package.json")),o=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=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);Tt.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.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=J;deepAssign=y;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},a=new Pe});var Lt,Nt,At,Mt,Ft,Gt,$e,N,I,zt=c(()=>{"use strict";r();Lt=l(require("https"),1),Nt=l(require("fs"),1),At=l(require("fs/promises"),1),Mt=l(require("path"),1),Ft=l(require("compression"),1),Gt=l(require("cors"),1),$e=l(require("express"),1),N=(0,$e.default)();N.use((0,Ft.default)());N.use((0,Gt.default)());I=class{async setup(e,t=()=>{}){if(!Nt.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);N.use($e.default.static(i));let o=await At.default.readFile(Mt.default.join(i,"index.html"),"utf8");if(N.get("*",(p,u)=>u.send(o)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();Lt.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:p,cert:u},N).listen(e.server.port,t)}else N.listen(e.server.port,t)}}});var It,U,Ut=c(()=>{"use strict";r();It=require("@rspack/dev-server"),U=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new It.RspackDevServer(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(o),p}async beforeCompiler(e){return e}}});var Te=c(()=>{"use strict";r();zt();Ut()});function Ns(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,p,u)=>{let g=t[u],x=p;return g&&(x=p.length<g?p+" ".repeat(g-p.length):p),`${o+x} `}," ");console.log(D.bold(i))}async function Jt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>Ds(f.name)).map(Ls);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),p=Math.max(...i.map(f=>(f.folder+O.default.sep+f.name).length));Ns(p,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:ts,folder:ss,gzipSizeLabel:is}=f,Ae=(ss+O.default.sep+ts).length,Me=M.length;if(u+=f.size,g+=f.gzippedSize,Me<o){let oe=" ".repeat(o-Me);M+=oe}let Fe=R(f.folder+O.default.sep)+As(f.name);if(Ae<p){let oe=" ".repeat(p-Ae);Fe+=oe}n.info(` ${Fe} ${R(M)} ${is}`)});let x=`${D.bold("Total size:")} ${Z(u)}`,A=`${D.bold("Gzipped size:")} ${Z(g)}`;n.info(`
12
- ${x}
13
- ${A}
14
- `),n.info(`${S("\u2713")} Ready in ${_(Number(e.time))}
15
- `)}function ee(s=0){n.info(`${S("\u2713")} Ready in ${_(Number(s))}`)}var Bt,O,Ht,$s,Ts,js,Ds,Rs,Ls,Z,As,te=c(()=>{"use strict";r();Bt=l(require("fs"),1),O=l(require("path"),1),Ht=require("gzip-size");L();w();k();C();$s=/\.html$/,Ts=/\.(?:js|mjs|cjs|jsx)$/,js=/\.css$/,Ds=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Rs=s=>s>300*1e3?re:s>100*1e3?H:ne,Ls=s=>{let e=s.name.split("?")[0],t=Z(s.size),i=O.default.basename(e),o=O.default.join(O.default.basename(a.empConfig.build.outDir),O.default.dirname(e)),p=Bt.default.readFileSync(O.default.join(a.empConfig.build.outDir,e)),u=p.length,g=(0,Ht.gzipSizeSync)(p),x=Rs(g)(Z(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:x}};Z=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},As=s=>Ts.test(s)?H(s):js.test(s)?S(s):$s.test(s)?D(s):pe(s)});var P,se=c(()=>{"use strict";r();k();C();w();P=class{async setup(e,t){n.time(`[${e}]Setup`),await a.setup(e,t),a.debug.clearLog&&ce(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var Wt={};j(Wt,{default:()=>Ms});var Vt,_t,je,Ms,qt=c(()=>{"use strict";r();Vt=require("@rspack/core");Te();te();C();se();w();_t=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,port:a.server.port}}),{devServer:t}=e;if(a.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await a.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=a,t=await this.getRspackDevConfig();t=await _t.beforeCompiler(t);let i=(0,Vt.rspack)(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await _t.setup(i,t,a,async o=>{this.showTimeDone(o),await a.empConfig.lifeCycle.afterDevServe()}),a.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});ee(t.time)}},Ms=new je});var De={};j(De,{ServeScript:()=>ie,default:()=>Gs});var Fs,Xt,ie,Gs,Re=c(()=>{"use strict";r();te();se();Te();w();Fs=new I,Xt=0,ie=class extends P{async run(){Xt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Fs.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),ee(Date.now()-Xt),await a.empConfig.lifeCycle.afterServe()}},Gs=new ie});var Kt={};j(Kt,{default:()=>zs});var Qt,Le,zs,Yt=c(()=>{"use strict";r();Qt=require("@rspack/core");te();k();se();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,Qt.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 Jt(t),this.startServe(),await a.empConfig.lifeCycle.afterBulid()})}},zs=new Le});var Us={};j(Us,{defineConfig:()=>Is,empHelper:()=>he,rspack:()=>es.rspack,runScript:()=>Ne,store:()=>a});module.exports=ls(Us);r();var es=require("@rspack/core");r();var Zt=l(require("process"),1),$=require("commander");w();function Ne(){$.program.version(a.empPkg.version,"-v, --version").usage("<command> [options]"),$.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(qt(),Wt));await e.setup("dev",s)}),$.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Yt(),Kt));await e.setup("build",s)}),$.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Re(),De));await e.setup("serve",s)}),$.program.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),$.program.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),$.program.parse(Zt.default.argv)}w();G();function Is(s){return s}0&&(module.exports={defineConfig,empHelper,rspack,runScript,store});
9
+ `)}},n=new le});var ce,Be,me,vs,He,Je,_e,Ve,J=c(()=>{"use strict";r();ce=l(require("fs"),1),Be=require("jiti"),me=l(require("path"),1);C();k();vs=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],He=(0,Be.createJiti)(__filename,{interopDefault:!0}),Je=async()=>{n.time("[store]GetEmpConfigPath");let s=vs.map(i=>me.default.resolve(p.root,i)),e=await Promise.all(s.map(i=>ce.default.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,o)=>e[o]);return n.timeEnd("[store]GetEmpConfigPath"),t},_e=async()=>{let s=me.default.join(p.root,"tsconfig.json");return await ce.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ve=()=>{let s=[];return p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ge={};j(ge,{clearConsole:()=>he,deepAssign:()=>y,ensureArray:()=>bs,getLanIp:()=>T,getPkgVersion:()=>ue,importJsVm:()=>fe,jsonFilter:()=>Cs,timeFormat:()=>V,vCompare:()=>_});function he(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],a=s[i];if(Object(o)==o&&Object(a)===a){s[i]=y(a,o);continue}s[i]=t[i]}return s}var We,qe,Xe,Qe,T,ue,bs,Cs,_,V,fe,w=c(()=>{"use strict";r();We=require("address"),qe=l(require("chalk"),1),Xe=require("default-gateway"),Qe=l(require("fs-extra"),1),T=()=>{let s="127.0.0.1";try{let{int:e}=(0,Xe.gateway4sync)();return(0,We.ip)(e||"")||s}catch{return s}},ue=s=>{try{let{version:e}=Qe.default.readJSONSync(s);return e}catch{return}};bs=s=>Array.isArray(s)?s:[s],Cs=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),a=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,S=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(S<f){a=-1;break}else if(S>f){a=1;break}}return a},V=s=>{s=s/1e3;let e=i=>qe.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},fe=s=>`data:text/javascript,${s}`});var de={};j(de,{chalk:()=>Ke.default,color:()=>h,glob:()=>F.glob,logger:()=>n,utils:()=>ge});var Ke,F,G=c(()=>{"use strict";r();Ke=l(require("chalk"),1),F=require("glob");L();k();w()});var W,Ye=c(()=>{"use strict";r();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var ye,Ze,et=c(()=>{"use strict";r();G();J();w();Ye();ye=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 W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(a,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return 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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await He(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Ze=new ye});var tt,ve,st,it=c(()=>{"use strict";r();tt=l(require("fs-extra"),1);J();ve=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}async common(){this.store.merge({name:this.store.pkg.name,node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ve(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await tt.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},st=new ve});var be,ot,rt=c(()=>{"use strict";r();be=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:require.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},ot=new be});function ws(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
10
+ `);return fe(s)}var X,q,z,Q=c(()=>{"use strict";r();X=l(require("html-webpack-plugin"),1);w();C();q=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,ws(),{name:void 0}).apply(e)}},z=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{X.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:a,...u}=o;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});var v,Ce,nt,pt=c(()=>{"use strict";r();v=l(require("path"),1);G();Q();Ce=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(v.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(v.default.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),a=[i];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(X.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=v.default.join(this.store.appSrc,e),i=v.default.join(t,"**","*.{ts,tsx,jsx,js}"),o=await(0,F.glob)([i],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${v.default.sep}`,"")),o.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},v.default.join(t,a))}),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 i=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(i,this.store.empConfig.html,t[0])}n.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},nt=new Ce});var we,xe,at,lt=c(()=>{"use strict";r();we=l(require("path"),1);w();xe=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc: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",we.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=ue(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=we.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},at=new xe});var O,Se,ct,Oe,mt,ut=c(()=>{"use strict";r();O=l(require("@rspack/core"),1),Se=l(require("fs"),1),ct=require("ts-checker-rspack-plugin");Q();Oe=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(ct.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(O.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Se.default.existsSync(e)&&Se.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(O.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(O.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(O.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=O.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(O.default.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(O.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(O.default.experiments.CssChunkingPlugin,[{}])}},mt=new Oe});var Pe,ht,ft=c(()=>{"use strict";r();it();rt();pt();lt();ut();Pe=class{store;async setup(e){this.store=e;let t=[st.setup(this.store),at.setup(this.store),mt.setup(this.store),nt.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()}},ht=new Pe});async function K(s,e=void 0){if(s!==xs&&(s<gt||s>ke))throw new Error(`Port number must lie between ${gt} and ${ke}`);let t=s,i=Ss(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=ke;)try{return await Ps(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var dt,yt,gt,ke,xs,Ss,Os,Ps,vt=c(()=>{"use strict";r();dt=l(require("net"),1),yt=l(require("os"),1),gt=1024,ke=65535,xs=443,Ss=()=>{let s=yt.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Os=(s,e)=>new Promise((t,i)=>{let o=dt.default.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),Ps=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Os(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});var bt,Ee,$e,Y,Ct=c(()=>{"use strict";r();bt=l(require("chalk"),1);L();Ee=l(require("url"),1);w();$e=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==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ee.default.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return Ee.default.format({protocol:t,hostname:e,port:bt.default.bold(i),pathname:o})}},Y=new $e});var xt,St,Ot,wt,ks,Es,Pt,kt=c(()=>{"use strict";r();xt=require("child_process"),St=require("util");C();k();Ot=(0,St.promisify)(xt.exec),wt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ks=async()=>{let s=process.env.BROWSER;if(!s||!wt.includes(s)){let{stdout:e}=await Ot("ps cax");s=wt.find(t=>e.includes(t))}return s},Es=async s=>{if(process.platform==="darwin")try{let t=await ks();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Ot(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},Pt=Es});var Te,Z,Et=c(()=>{"use strict";r();Te=l(require("fs/promises"),1);G();L();vt();Ct();kt();w();Z=class{ip=T();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await K(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await K(e.empConfig.server.port)),Y.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Y.prettyPrintUrl("localhost")):(this.urls=Y.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${x("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${x("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
11
+ `)),this.isOpenBrower&&Pt(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([Te.default.readFile(e.resource.key),Te.default.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await K(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var $t,Tt=c(()=>{"use strict";r();$t={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var jt,b,Dt,Rt,Lt,je,p,C=c(()=>{"use strict";r();jt=l(require("fs/promises"),1),b=l(require("path"),1),Dt=l(require("util"),1),Rt=require("@rspack/core");J();k();w();et();ft();Et();Lt=l(require("webpack-chain"),1);Tt();Q();je=class{rspackVersion=Rt.rspack.rspackVersion;isOldRspack=_(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=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=$t;server=new Z(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,o]=await Promise.all([Je(),_e()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,await this.initVars(e,t),this.empConfig=Ze,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Lt.default,await ht.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=require(this.empResolve("package.json")),o=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=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);jt.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(Dt.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=_;deepAssign=y;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},p=new je});function As(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let g=t[u],S=a;return g&&(S=a.length<g?a+" ".repeat(g-a.length):a),`${o+S} `}," ");console.log(D.bold(i))}async function Mt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>Ds(f.name)).map(Ls);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),a=Math.max(...i.map(f=>(f.folder+P.default.sep+f.name).length));As(a,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:ss,folder:is,gzipSizeLabel:os}=f,Ge=(is+P.default.sep+ss).length,ze=M.length;if(u+=f.size,g+=f.gzippedSize,ze<o){let re=" ".repeat(o-ze);M+=re}let Ie=R(f.folder+P.default.sep)+Ns(f.name);if(Ge<a){let re=" ".repeat(a-Ge);Ie+=re}n.info(` ${Ie} ${R(M)} ${os}`)});let S=`${D.bold("Total size:")} ${ee(u)}`,N=`${D.bold("Gzipped size:")} ${ee(g)}`;n.info(`
12
+ ${S}
13
+ ${N}
14
+ `),n.info(`${x("\u2713")} Ready in ${V(Number(e.time))}
15
+ `)}function te(s=0){n.info(`${x("\u2713")} Ready in ${V(Number(s))}`)}var At,P,Nt,$s,Ts,js,Ds,Rs,Ls,ee,Ns,se=c(()=>{"use strict";r();At=l(require("fs"),1),P=l(require("path"),1),Nt=require("gzip-size");L();C();k();w();$s=/\.html$/,Ts=/\.(?:js|mjs|cjs|jsx)$/,js=/\.css$/,Ds=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Rs=s=>s>300*1e3?ne:s>100*1e3?H:pe,Ls=s=>{let e=s.name.split("?")[0],t=ee(s.size),i=P.default.basename(e),o=P.default.join(P.default.basename(p.empConfig.build.outDir),P.default.dirname(e)),a=At.default.readFileSync(P.default.join(p.empConfig.build.outDir,e)),u=a.length,g=(0,Nt.gzipSizeSync)(a),S=Rs(g)(ee(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:S}};ee=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ns=s=>Ts.test(s)?H(s):js.test(s)?x(s):$s.test(s)?D(s):ae(s)});var E,ie=c(()=>{"use strict";r();k();w();C();E=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&he(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var Ft,I,Gt=c(()=>{"use strict";r();Ft=require("@rspack/dev-server"),I=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new Ft.RspackDevServer(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(o),a}async beforeCompiler(e){return e}}});var zt,It,Ut,Bt,De,Ht,Jt,A,U,_t=c(()=>{"use strict";r();zt=l(require("fs"),1),It=l(require("fs/promises"),1),Ut=l(require("compression"),1),Bt=l(require("cors"),1),De=l(require("express"),1),Ht=l(require("https"),1),Jt=l(require("path"),1),A=(0,De.default)();A.use((0,Ut.default)());A.use((0,Bt.default)());U=class{async setup(e,t=()=>{}){if(!zt.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);A.use(De.default.static(i));let o=await It.default.readFile(Jt.default.join(i,"index.html"),"utf8");if(A.get("*",(a,u)=>u.send(o)),e.server.isHttps){let{key:a,cert:u}=await e.server.getcert();Ht.default.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:a,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});var Re=c(()=>{"use strict";r();Gt();_t()});var qt={};j(qt,{default:()=>Ms});var Wt,Vt,Le,Ms,Xt=c(()=>{"use strict";r();Wt=require("@rspack/core");se();w();ie();Re();C();Vt=new I,Le=class extends E{get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await Vt.beforeCompiler(t);let i=(0,Wt.rspack)(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await Vt.setup(i,t,p,async o=>{this.showTimeDone(o),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});te(t.time)}},Ms=new Le});var Ae={};j(Ae,{ServeScript:()=>oe,default:()=>Gs});var Fs,Qt,oe,Gs,Ne=c(()=>{"use strict";r();se();ie();Re();C();Fs=new U,Qt=0,oe=class extends E{async run(){Qt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Fs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),te(Date.now()-Qt),await p.empConfig.lifeCycle.afterServe()}},Gs=new oe});var Yt={};j(Yt,{default:()=>zs});var Kt,Me,zs,Zt=c(()=>{"use strict";r();Kt=require("@rspack/core");se();k();ie();C();Me=class extends E{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(Ne(),Ae));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),(0,Kt.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
16
+ `),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Mt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},zs=new Me});var Us={};j(Us,{defineConfig:()=>Is,empHelper:()=>de,rspack:()=>ts.rspack,runScript:()=>Fe,store:()=>p});module.exports=cs(Us);r();var ts=require("@rspack/core");r();var es=l(require("process"),1),$=require("commander");C();function Fe(){$.program.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),$.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Xt(),qt));await e.setup("dev",s)}),$.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Zt(),Yt));await e.setup("build",s)}),$.program.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Ne(),Ae));await e.setup("serve",s)}),$.program.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),$.program.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),$.program.parse(es.default.argv)}C();G();function Is(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
@@ -331,6 +331,7 @@ declare class GlobalStore {
331
331
  };
332
332
  debug: EmpConfig['debug'];
333
333
  cliAction: CliActionType;
334
+ rootPaths: StoreRootPaths;
334
335
  setup(cliAction: CliActionType, cliOptions: any): Promise<void>;
335
336
  /**
336
337
  * 初始化 基础变量
@@ -398,6 +399,11 @@ type DebugType = {
398
399
  * @default true
399
400
  */
400
401
  parallelCodeSplitting?: boolean;
402
+ /**
403
+ * https://rspack.rs/zh/plugins/rspack/css-chunking-plugin
404
+ * 启用 CssChunkingPlugin 后,SplitChunksPlugin 将不再处理 CSS 模块。 这意味着 optimization.splitChunks 等配置对 CSS 模块将不再生效,所有 CSS 模块的代码分割逻辑完全由 CssChunkingPlugin 处理。
405
+ */
406
+ cssChunkingPlugin?: boolean;
401
407
  };
402
408
  type ServerType = DevServer & {
403
409
  /**
@@ -684,6 +690,10 @@ type InjectTagsType = InjectTagsTypeItem[];
684
690
  type InjectTagsTypeItem = {
685
691
  pos?: 'head' | 'body';
686
692
  } & Partial<HtmlTagObject>;
693
+ type StoreRootPaths = {
694
+ tsConfig?: string;
695
+ empConfig?: string;
696
+ };
687
697
 
688
698
  declare function runScript(): void;
689
699
 
package/dist/index.d.ts CHANGED
@@ -331,6 +331,7 @@ declare class GlobalStore {
331
331
  };
332
332
  debug: EmpConfig['debug'];
333
333
  cliAction: CliActionType;
334
+ rootPaths: StoreRootPaths;
334
335
  setup(cliAction: CliActionType, cliOptions: any): Promise<void>;
335
336
  /**
336
337
  * 初始化 基础变量
@@ -398,6 +399,11 @@ type DebugType = {
398
399
  * @default true
399
400
  */
400
401
  parallelCodeSplitting?: boolean;
402
+ /**
403
+ * https://rspack.rs/zh/plugins/rspack/css-chunking-plugin
404
+ * 启用 CssChunkingPlugin 后,SplitChunksPlugin 将不再处理 CSS 模块。 这意味着 optimization.splitChunks 等配置对 CSS 模块将不再生效,所有 CSS 模块的代码分割逻辑完全由 CssChunkingPlugin 处理。
405
+ */
406
+ cssChunkingPlugin?: boolean;
401
407
  };
402
408
  type ServerType = DevServer & {
403
409
  /**
@@ -684,6 +690,10 @@ type InjectTagsType = InjectTagsTypeItem[];
684
690
  type InjectTagsTypeItem = {
685
691
  pos?: 'head' | 'body';
686
692
  } & Partial<HtmlTagObject>;
693
+ type StoreRootPaths = {
694
+ tsConfig?: string;
695
+ empConfig?: string;
696
+ };
687
697
 
688
698
  declare function runScript(): void;
689
699
 
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 kt=Object.defineProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var F=(s,e)=>{for(var t in e)kt(s,t,{get:e[t],enumerable:!0})};import{fileURLToPath as Et}from"url";import Pt from"path";var De,$t,c,l,r=m(()=>{"use strict";De=()=>Et(import.meta.url),$t=()=>Pt.dirname(De()),c=$t(),l=De()});import d from"chalk";var Tt,S,jt,Dt,Rt,oe,U,Nt,At,D,re,Lt,ne,R,h,N=m(()=>{"use strict";r();Tt=d.hex("#1abc9c"),S=d.hex("#16a085"),jt=d.hex("#2ecc71"),Dt=d.hex("#27ae60"),Rt=d.hex("#e74c3c"),oe=d.hex("#c0392b"),U=d.hex("#f1c40f"),Nt=d.hex("#f39c12"),At=d.hex("#3498db"),D=d.hex("#2980b9"),re=d.hex("#ecf0f1"),Lt=d.hex("#fd79a8"),ne=d.hex("#e84393"),R=d.hex("#7f8c8d"),h={lightGreen:Tt,green:S,lightCyan:jt,cyan:Dt,lightRed:Rt,red:oe,yellow:U,orange:Nt,lightBlue:At,blue:D,white:re,lightMagenta:Lt,magenta:ne,gray:R}});var pe,n,k=m(()=>{"use strict";r();N();pe=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
2
+ var Tt=Object.defineProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var F=(s,e)=>{for(var t in e)Tt(s,t,{get:e[t],enumerable:!0})};import jt from"path";import{fileURLToPath as Dt}from"url";var Re,Rt,c,l,r=m(()=>{"use strict";Re=()=>Dt(import.meta.url),Rt=()=>jt.dirname(Re()),c=Rt(),l=Re()});import d from"chalk";var Lt,S,At,Nt,Mt,re,U,Ft,Gt,D,ne,zt,pe,R,h,L=m(()=>{"use strict";r();Lt=d.hex("#1abc9c"),S=d.hex("#16a085"),At=d.hex("#2ecc71"),Nt=d.hex("#27ae60"),Mt=d.hex("#e74c3c"),re=d.hex("#c0392b"),U=d.hex("#f1c40f"),Ft=d.hex("#f39c12"),Gt=d.hex("#3498db"),D=d.hex("#2980b9"),ne=d.hex("#ecf0f1"),zt=d.hex("#fd79a8"),pe=d.hex("#e84393"),R=d.hex("#7f8c8d"),h={lightGreen:Lt,green:S,lightCyan:At,cyan:Nt,lightRed:Mt,red:re,yellow:U,orange:Ft,lightBlue:Gt,blue:D,white:ne,lightMagenta:zt,magenta:pe,gray:R}});var ae,n,P=m(()=>{"use strict";r();L();ae=class{brandName="";fullName="";logLevel="debug";isLogTime=!1;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,this.fullName=h.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.lightBlue(this.brandName)}${h.blue(` ${e} `)}
3
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 kt=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 pe});var me={};F(me,{clearConsole:()=>le,deepAssign:()=>y,ensureArray:()=>It,getLanIp:()=>$,getPkgVersion:()=>ae,importJsVm:()=>ce,jsonFilter:()=>Bt,timeFormat:()=>J,vCompare:()=>H});import{ip as Mt}from"address";import Ft from"chalk";import{gateway4sync as Gt}from"default-gateway";import zt from"fs-extra";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 i in t){let o=t[i],p=s[i];if(Object(o)==o&&Object(p)===p){s[i]=y(p,o);continue}s[i]=t[i]}return s}var $,ae,It,Bt,H,J,ce,b=m(()=>{"use strict";r();$=()=>{let s="127.0.0.1";try{let{int:e}=Gt();return Mt(e||"")||s}catch{return s}},ae=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,i)=>(t[i]=s[i],t),{}),H=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),p=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),L=i.length>u?i[u]:0,f=isNaN(Number(L))?L.charCodeAt():Number(L);if(O<f){p=-1;break}else if(O>f){p=1;break}}return p},J=s=>{s=s/1e3;let e=i=>Ft.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},ce=s=>`data:text/javascript,${s}`});var Re={};F(Re,{chalk:()=>Ut,color:()=>h,glob:()=>_,logger:()=>n,utils:()=>me});import Ut from"chalk";import{glob as _}from"glob";var G=m(()=>{"use strict";r();N();b();k()});import Ht from"node:fs";import Jt from"path";import{createJiti as _t}from"jiti";var Vt,Ne,Ae,Wt,Le=m(()=>{"use strict";r();C();k();Vt=["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"],Ne=_t(l,{interopDefault:!0}),Ae=async()=>Wt(),Wt=()=>{n.time("[store]GetEmpConfigPath");let s;for(let e of Vt){let t=Jt.resolve(a.root,e);if(Ht.existsSync(t)){s=t;break}}return n.timeEnd("[store]GetEmpConfigPath"),s}});var V,Me=m(()=>{"use strict";r();V=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 qt from"node:fs";var ue,Fe,Ge=m(()=>{"use strict";r();G();Le();b();Me();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 V(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,p={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(p,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return 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||!qt.existsSync(e))return;let t=await Ne(e);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Fe=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,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory"},parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Xt.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},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,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:v.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:v.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},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="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{ge.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:p,...u}=o;(p==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import 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,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(w.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),p=[i];this.entriesConfig[o]={entry:{[o]:p},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=p}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(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),i=w.join(t,"**","*.{ts,tsx,jsx,js}"),o=await _([i],{windowsPathsNoEscape:!0});o=o.map(p=>p.replace(`${t}${w.sep}`,"")),o.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 _([e],{windowsPathsNoEscape:!0});if(t[0]){let i=w.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(i,this.store.empConfig.html,t[0])}n.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},He=new de});import _e from"node:path";var ye,Ve,We=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.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc: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=ae(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:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ve=new ye});import qe from"fs";import T from"@rspack/core";import{TsCheckerRspackPlugin as Kt}from"ts-checker-rspack-plugin";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.tsCheckerRspackPlugin()];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"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(Kt,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(T.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(T.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(T.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(T.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=T;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(T.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(T.CircularDependencyRspackPlugin,[{}])}},Xe=new ve});var be,Ke,Ye=m(()=>{"use strict";r();Ie();Ue();Je();We();Qe();be=class{store;async setup(e){this.store=e;let t=[ze.setup(this.store),Ve.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 Yt from"net";import Zt from"os";async function X(s,e=void 0){if(s!==es&&(s<Ze||s>Ce))throw new Error(`Port number must lie between ${Ze} and ${Ce}`);let t=s,i=ts(),o;e&&!i.has(e)?o=new Set([e]):o=i;let p=new Set(["EADDRINUSE","EACCES"]);for(;t<=Ce;)try{return await is(t,o)}catch(u){if(!p.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var Ze,Ce,es,ts,ss,is,et=m(()=>{"use strict";r();Ze=1024,Ce=65535,es=443,ts=()=>{let s=Zt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},ss=(s,e)=>new Promise((t,i)=>{let o=Yt.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:p}=o.address();o.close(()=>{t(p)})})}),is=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await ss(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import tt from"url";import os from"chalk";var we,Q,st=m(()=>{"use strict";r();N();b();we=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==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=$;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return tt.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return tt.format({protocol:t,hostname:e,port:os.bold(i),pathname:o})}},Q=new we});import{exec as rs}from"node:child_process";import{promisify as ns}from"node:util";var ot,it,ps,as,rt,nt=m(()=>{"use strict";r();C();k();ot=ns(rs),it=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ps=async()=>{let s=process.env.BROWSER;if(!s||!it.includes(s)){let{stdout:e}=await ot("ps cax");s=it.find(t=>e.includes(t))}return s},as=async s=>{if(process.platform==="darwin")try{let t=await ps();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await ot(i,{cwd:a.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},rt=as});import pt from"node:fs/promises";var K,at=m(()=>{"use strict";r();G();N();et();st();nt();b();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.store.cliAction!=="build"&&(this.port=await X(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await 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)}
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[i,o]=await Promise.all([pt.readFile(e.resource.key),pt.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await 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 lt,ct=m(()=>{"use strict";r();lt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});import ls from"node:fs/promises";import x from"node:path";import cs from"node:util";import{rspack as ms}from"@rspack/core";import us from"webpack-chain";var xe,a,C=m(()=>{"use strict";r();k();b();Ge();Ye();at();ct();q();xe=class{rspackVersion=ms.rspackVersion;isOldRspack=H(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(c,l).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=lt;server=new K(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;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 us,await Ke.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=v(this.empResolve("package.json")),o=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.join(this.root,this.debug.showRsconfig);ls.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(cs.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=H;deepAssign=y;getLanIp=$;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},a=new xe});import hs from"https";import fs from"node:fs";import gs from"node:fs/promises";import ds from"path";import ys from"compression";import vs from"cors";import mt from"express";var A,I,ut=m(()=>{"use strict";r();A=mt();A.use(ys());A.use(vs());I=class{async setup(e,t=()=>{}){if(!fs.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);A.use(mt.static(i));let o=await gs.readFile(ds.join(i,"index.html"),"utf8");if(A.get("*",(p,u)=>u.send(o)),e.server.isHttps){let{key:p,cert:u}=await e.server.getcert();hs.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 bs}from"@rspack/dev-server";var B,ht=m(()=>{"use strict";r();B=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let p=new bs(t.devServer,e);return await p.start(),p.middleware?.waitUntilValid(o),p}async beforeCompiler(e){return e}}});var Se=m(()=>{"use strict";r();ut();ht()});import Cs from"node:fs";import E from"node:path";import{gzipSizeSync as ws}from"gzip-size";function $s(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,p,u)=>{let g=t[u],O=p;return g&&(O=p.length<g?p+" ".repeat(g-p.length):p),`${o+O} `}," ");console.log(D.bold(i))}async function ft(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>ks(f.name)).map(Ps);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),p=Math.max(...i.map(f=>(f.folder+E.sep+f.name).length));$s(p,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:xt,folder:St,gzipSizeLabel:Ot}=f,$e=(St+E.sep+xt).length,Te=M.length;if(u+=f.size,g+=f.gzippedSize,Te<o){let ie=" ".repeat(o-Te);M+=ie}let je=R(f.folder+E.sep)+Ts(f.name);if($e<p){let ie=" ".repeat(p-$e);je+=ie}n.info(` ${je} ${R(M)} ${Ot}`)});let O=`${D.bold("Total size:")} ${Y(u)}`,L=`${D.bold("Gzipped size:")} ${Y(g)}`;n.info(`
10
+ `)}},n=new ae});import Le from"fs";import{createJiti as It}from"jiti";import Ae from"path";var Bt,Ne,Me,Fe,Ge,H=m(()=>{"use strict";r();b();P();Bt=["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"],Ne=It(l,{interopDefault:!0}),Me=async()=>{n.time("[store]GetEmpConfigPath");let s=Bt.map(i=>Ae.resolve(p.root,i)),e=await Promise.all(s.map(i=>Le.promises.access(i).then(()=>!0,()=>!1))),t=s.find((i,o)=>e[o]);return n.timeEnd("[store]GetEmpConfigPath"),t},Fe=async()=>{let s=Ae.join(p.root,"tsconfig.json");return await Le.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Ge=()=>{let s=[];return p.rootPaths.empConfig&&s.push(p.rootPaths.empConfig),p.rootPaths.tsConfig&&s.push(p.rootPaths.tsConfig),s}});var ue={};F(ue,{clearConsole:()=>ce,deepAssign:()=>y,ensureArray:()=>Vt,getLanIp:()=>T,getPkgVersion:()=>le,importJsVm:()=>me,jsonFilter:()=>Wt,timeFormat:()=>_,vCompare:()=>J});import{ip as Ut}from"address";import Ht from"chalk";import{gateway4sync as Jt}from"default-gateway";import _t from"fs-extra";function ce(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function y(s,...e){for(let t of e)for(let i in t){let o=t[i],a=s[i];if(Object(o)==o&&Object(a)===a){s[i]=y(a,o);continue}s[i]=t[i]}return s}var T,le,Vt,Wt,J,_,me,C=m(()=>{"use strict";r();T=()=>{let s="127.0.0.1";try{let{int:e}=Jt();return Ut(e||"")||s}catch{return s}},le=s=>{try{let{version:e}=_t.readJSONSync(s);return e}catch{return}};Vt=s=>Array.isArray(s)?s:[s],Wt=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),J=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),o=Math.max(t.length,i.length),a=0;for(let u=0;u<o;u++){let g=t.length>u?t[u]:0,O=isNaN(Number(g))?g.charCodeAt():Number(g),N=i.length>u?i[u]:0,f=isNaN(Number(N))?N.charCodeAt():Number(N);if(O<f){a=-1;break}else if(O>f){a=1;break}}return a},_=s=>{s=s/1e3;let e=i=>Ht.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},me=s=>`data:text/javascript,${s}`});var ze={};F(ze,{chalk:()=>qt,color:()=>h,glob:()=>V,logger:()=>n,utils:()=>ue});import qt from"chalk";import{glob as V}from"glob";var G=m(()=>{"use strict";r();L();P();C()});var W,Ie=m(()=>{"use strict";r();W=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var he,Be,Ue=m(()=>{"use strict";r();G();H();C();Ie();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 W(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:o}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),o&&(this.appEntry=o)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={supports:{generateTileGraph:!0}}),this.assign({loggerLevel:"info",clearLog:!1,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,parallelCodeSplitting:!0,cssChunkingPlugin:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:this.store.isDev,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:!1},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:o}=this.store.empConfig.build,a={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${o}js/[name]${e}.js`,cssFilename:`${o}css/[name]${t}.css`,cssChunkFilename:`${o}css/[name]${t}.css`,assetModuleFilename:`${o}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(a,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(o=>{t==="all"?(i[`import.meta.env.${o}`]=JSON.stringify(e[o]),i[`process.env.${o}`]=JSON.stringify(e[o])):t==="esm"?i[`import.meta.env.${o}`]=JSON.stringify(e[o]):t==="cjs"?i[`process.env.${o}`]=JSON.stringify(e[o]):t==="none"&&(i[`${o}`]=JSON.stringify(e[o]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return 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(){if(n.time("[store][empConfig]SyncEmpOptions"),!this.store.rootPaths.empConfig)return;let e=await Ne(this.store.rootPaths.empConfig);typeof e=="function"?this.store.empOptions=await e(this.store):this.store.empOptions=e||{},n.timeEnd("[store][empConfig]SyncEmpOptions")}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},Be=new he});import Xt from"fs-extra";var fe,He,Je=m(()=>{"use strict";r();H();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({name:this.store.pkg.name,node:{global:!0},experiments:{outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:{type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Ge(),version:this.store.empPkg.version},incremental:"advance-silent",parallelCodeSplitting:this.store.empConfig.debug.parallelCodeSplitting,parallelLoader:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap?this.store.empConfig.build.devtool:!1,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Xt.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},He=new fe});var ge,_e,Ve=m(()=>{"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,i={},{sass:o}=this.store.empConfig.css;o.mode==="modern"&&(i.implementation=o.implementation?o.implementation:v.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap,o.sassOptions&&(i.sassOptions=o.sassOptions)),typeof o.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=o.warnRuleAsWarning),typeof o.webpackImporter<"u"&&(i.webpackImporter=o.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:v.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,i={loader:v.resolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:i},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},_e=new ge});import de from"html-webpack-plugin";function Qt(){let s=[`import 'core-js/${p.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
+ `);return me(s)}var q,z,X=m(()=>{"use strict";r();C();b();q=class{constructor(){}apply(e){let{webpack:t}=e;p.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Qt(),{name:void 0}).apply(e)}},z=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{de.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(o=>{let{pos:a,...u}=o;(a==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...u})}),i))})}}});import w from"path";var ye,We,qe=m(()=>{"use strict";r();G();X();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,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(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){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(w.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(w.join(this.store.empConfig.appSrc,e));let o=this.setChunk(e),a=[i];this.entriesConfig[o]={entry:{[o]:a},html:this.setHtmlConfig(t,[o])},this.store.entries[o]=a}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(de,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){n.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=w.join(this.store.appSrc,e),i=w.join(t,"**","*.{ts,tsx,jsx,js}"),o=await V([i],{windowsPathsNoEscape:!0});o=o.map(a=>a.replace(`${t}${w.sep}`,"")),o.map(a=>{let u=this.store.empConfig.entries[a]||{};this.setEntryItem(a,{...this.store.empConfig.html,...u},w.join(t,a))}),n.timeEnd("setAutoPage")}async setDefaultEntry(){n.time("[store][empConfig]SetDefaultEntry");let e=w.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),t=await V([e],{windowsPathsNoEscape:!0});if(t[0]){let i=w.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(i,this.store.empConfig.html,t[0])}n.timeEnd("[store][empConfig]SetDefaultEntry")}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},We=new ye});import Xe from"path";var ve,Qe,Ke=m(()=>{"use strict";r();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.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[path][name]-[local]-[hash:5]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:o}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:o,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc: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",Xe.dirname(v.resolve("@swc/helpers/package.json"))),this.coreJs.path=v.resolve("core-js/package.json");let t=le(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=Xe.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Qe=new ve});import k from"@rspack/core";import Ye from"fs";import{TsCheckerRspackPlugin as Kt}from"ts-checker-rspack-plugin";var be,Ze,et=m(()=>{"use strict";r();X();be=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(q)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(Kt,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(k.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");Ye.existsSync(e)&&Ye.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(k.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(!this.store.empConfig.debug.progress)return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(k.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(k.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=k;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=v("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){if(!this.store.empConfig.build.sourcemap)return;let e={};typeof this.store.empConfig.build.sourcemap=="object"&&(e=this.store.empConfig.build.sourcemap),this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(k.SourceMapDevToolPlugin,[e])}circularDependency(){this.store.chain.plugin("circularDependency").use(k.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(k.experiments.CssChunkingPlugin,[{}])}},Ze=new be});var Ce,tt,st=m(()=>{"use strict";r();Je();Ve();qe();Ke();et();Ce=class{store;async setup(e){this.store=e;let t=[He.setup(this.store),Qe.setup(this.store),Ze.setup(this.store),We.setup(this.store),_e.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},tt=new Ce});import Yt from"net";import Zt from"os";async function Q(s,e=void 0){if(s!==es&&(s<it||s>we))throw new Error(`Port number must lie between ${it} and ${we}`);let t=s,i=ts(),o;e&&!i.has(e)?o=new Set([e]):o=i;let a=new Set(["EADDRINUSE","EACCES"]);for(;t<=we;)try{return await is(t,o)}catch(u){if(!a.has(u.code))throw u;t+=1}throw new Error("No available ports found")}var it,we,es,ts,ss,is,ot=m(()=>{"use strict";r();it=1024,we=65535,es=443,ts=()=>{let s=Zt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},ss=(s,e)=>new Promise((t,i)=>{let o=Yt.createServer();o.unref(),o.on("error",i),o.listen(s,e,()=>{let{port:a}=o.address();o.close(()=>{t(a)})})}),is=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await ss(s,i)}catch(o){if(!t.has(o.code))throw o}return s}});import os from"chalk";import rt from"url";var xe,K,nt=m(()=>{"use strict";r();L();C();xe=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==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=T;formatUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return rt.format({protocol:t,hostname:e,port:i,pathname:o})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:o}=this.imf;return rt.format({protocol:t,hostname:e,port:os.bold(i),pathname:o})}},K=new xe});import{exec as rs}from"child_process";import{promisify as ns}from"util";var at,pt,ps,as,lt,ct=m(()=>{"use strict";r();b();P();at=ns(rs),pt=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],ps=async()=>{let s=process.env.BROWSER;if(!s||!pt.includes(s)){let{stdout:e}=await at("ps cax");s=pt.find(t=>e.includes(t))}return s},as=async s=>{if(process.platform==="darwin")try{let t=await ps();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await at(i,{cwd:p.resource.dir}),!0}}catch(t){n.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return n.error("Failed to open start URL."),n.error(t),!1}},lt=as});import mt from"fs/promises";var Y,ut=m(()=>{"use strict";r();G();L();ot();nt();ct();C();Y=class{ip=T();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await Q(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await Q(e.empConfig.server.port)),K.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=K.prettyPrintUrl("localhost")):(this.urls=K.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(this.publicPath)}`)):(n.info(`${S("\u279C")} Local: ${n.link(e.localUrlForTerminal)}`),n.info(`${S("\u279C")} Network: ${n.link(e.lanUrlForTerminal)}
12
+ `)),this.isOpenBrower&&lt(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,o]=await Promise.all([mt.readFile(e.resource.key),mt.readFile(e.resource.cert)]);return{key:i,cert:o}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await Q(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var ht,ft=m(()=>{"use strict";r();ht={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});import ls from"fs/promises";import x from"path";import cs from"util";import{rspack as ms}from"@rspack/core";import us from"webpack-chain";var Se,p,b=m(()=>{"use strict";r();H();P();C();Ue();st();ut();ft();X();Se=class{rspackVersion=ms.rspackVersion;isOldRspack=J(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=x.resolve(c,l).replace(`${x.sep}dist${x.sep}index.js`,"");empSource=x.resolve(this.empRoot,"dist");resolve=e=>x.isAbsolute(e)?e:x.resolve(this.root,e);empResolve=e=>x.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=ht;server=new Y(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;cliOptions;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;rootPaths={empConfig:void 0,tsConfig:void 0};async setup(e,t){n.time("[store]Setup");let[i,o]=await Promise.all([Me(),Fe()]);this.rootPaths.empConfig=i,this.rootPaths.tsConfig=o,await this.initVars(e,t),this.empConfig=Be,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new us,await tt.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),n.timeEnd("[store]Setup")}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=v(this.empResolve("package.json")),o=v(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...o},this.resource.dir=x.join(this.empRoot,"resource"),this.resource.cert=x.join(this.resource.dir,"emp.cert"),this.resource.key=x.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),n.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=x.join(this.root,this.debug.showRsconfig);ls.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(cs.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=J;deepAssign=y;getLanIp=T;injectTags(e=[],t="",i=""){this.chain.plugin(`${z}-${t}`).use(z,[e,t,i])}},p=new Se});import hs from"fs";import E from"path";import{gzipSizeSync as fs}from"gzip-size";function ws(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((o,a,u)=>{let g=t[u],O=a;return g&&(O=a.length<g?a+" ".repeat(g-a.length):a),`${o+O} `}," ");console.log(D.bold(i))}async function gt(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(f=>vs(f.name)).map(Cs);i.sort((f,M)=>f.size-M.size);let o=Math.max(...i.map(f=>f.sizeLabel.length)),a=Math.max(...i.map(f=>(f.folder+E.sep+f.name).length));ws(a,o);let u=0,g=0;i.forEach(f=>{let{sizeLabel:M}=f,{name:kt,folder:Et,gzipSizeLabel:$t}=f,Te=(Et+E.sep+kt).length,je=M.length;if(u+=f.size,g+=f.gzippedSize,je<o){let oe=" ".repeat(o-je);M+=oe}let De=R(f.folder+E.sep)+xs(f.name);if(Te<a){let oe=" ".repeat(a-Te);De+=oe}n.info(` ${De} ${R(M)} ${$t}`)});let O=`${D.bold("Total size:")} ${Z(u)}`,N=`${D.bold("Gzipped size:")} ${Z(g)}`;n.info(`
13
13
  ${O}
14
- ${L}
15
- `),n.info(`${S("\u2713")} Ready in ${J(Number(e.time))}
16
- `)}function Z(s=0){n.info(`${S("\u2713")} Ready in ${J(Number(s))}`)}var xs,Ss,Os,ks,Es,Ps,Y,Ts,ee=m(()=>{"use strict";r();N();C();k();b();xs=/\.html$/,Ss=/\.(?:js|mjs|cjs|jsx)$/,Os=/\.css$/,ks=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Es=s=>s>300*1e3?oe:s>100*1e3?U:re,Ps=s=>{let e=s.name.split("?")[0],t=Y(s.size),i=E.basename(e),o=E.join(E.basename(a.empConfig.build.outDir),E.dirname(e)),p=Cs.readFileSync(E.join(a.empConfig.build.outDir,e)),u=p.length,g=ws(p),O=Es(g)(Y(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};Y=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ts=s=>Ss.test(s)?U(s):Os.test(s)?S(s):xs.test(s)?D(s):ne(s)});var P,te=m(()=>{"use strict";r();k();b();C();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 dt={};F(dt,{default:()=>Ds});import{rspack as js}from"@rspack/core";var gt,Oe,Ds,yt=m(()=>{"use strict";r();Se();ee();b();te();C();gt=new B,Oe=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:i,cert:o}=await a.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=a,t=await this.getRspackDevConfig();t=await gt.beforeCompiler(t);let i=js(t);await a.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await gt.setup(i,t,a,async o=>{this.showTimeDone(o),await a.empConfig.lifeCycle.afterDevServe()}),a.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Z(t.time)}},Ds=new Oe});var ke={};F(ke,{ServeScript:()=>se,default:()=>Ns});var Rs,vt,se,Ns,Ee=m(()=>{"use strict";r();ee();te();Se();C();Rs=new I,vt=0,se=class extends P{async run(){vt=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await Rs.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),Z(Date.now()-vt),await a.empConfig.lifeCycle.afterServe()}},Ns=new se});var bt={};F(bt,{default:()=>Ls});import{rspack as As}from"@rspack/core";var Pe,Ls,Ct=m(()=>{"use strict";r();ee();k();te();C();Pe=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(()=>(Ee(),ke));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(),As(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 Ur}from"@rspack/core";r();C();import Ms 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,i]=s.split("=");return e[t]=i,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,i]=s.split("=");return e[t]=i,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(),ke));await e.setup("serve",s)}),j.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),j.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),j.parse(Ms.argv)}C();G();function _r(s){return s}export{_r as defineConfig,Re as empHelper,Ur as rspack,wt as runScript,a as store};
14
+ ${N}
15
+ `),n.info(`${S("\u2713")} Ready in ${_(Number(e.time))}
16
+ `)}function ee(s=0){n.info(`${S("\u2713")} Ready in ${_(Number(s))}`)}var gs,ds,ys,vs,bs,Cs,Z,xs,te=m(()=>{"use strict";r();L();b();P();C();gs=/\.html$/,ds=/\.(?:js|mjs|cjs|jsx)$/,ys=/\.css$/,vs=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),bs=s=>s>300*1e3?re:s>100*1e3?U:ne,Cs=s=>{let e=s.name.split("?")[0],t=Z(s.size),i=E.basename(e),o=E.join(E.basename(p.empConfig.build.outDir),E.dirname(e)),a=hs.readFileSync(E.join(p.empConfig.build.outDir,e)),u=a.length,g=fs(a),O=bs(g)(Z(g));return{size:u,folder:o,name:i,gzippedSize:g,sizeLabel:t,gzipSizeLabel:O}};Z=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},xs=s=>ds.test(s)?U(s):ys.test(s)?S(s):gs.test(s)?D(s):pe(s)});var $,se=m(()=>{"use strict";r();P();C();b();$=class{async setup(e,t){n.time(`[${e}]Setup`),await p.setup(e,t),p.debug.clearLog&&ce(),n.title(`${e}`),n.time(`[${e}]Run`),await this.run(),this.processExit(),n.timeEnd(`[${e}]Run`),n.timeEnd(`[${e}]Setup`)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});import{RspackDevServer as Ss}from"@rspack/dev-server";var I,dt=m(()=>{"use strict";r();I=class{async setup(e,t,i,o=()=>{}){if(!t.devServer)return console.warn("rspackConfig.devServer need!");let a=new Ss(t.devServer,e);return await a.start(),a.middleware?.waitUntilValid(o),a}async beforeCompiler(e){return e}}});import Os from"fs";import Ps from"fs/promises";import ks from"compression";import Es from"cors";import yt from"express";import $s from"https";import Ts from"path";var A,B,vt=m(()=>{"use strict";r();A=yt();A.use(ks());A.use(Es());B=class{async setup(e,t=()=>{}){if(!Os.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let i=e.resolve(e.rsConfig.output?.path);A.use(yt.static(i));let o=await Ps.readFile(Ts.join(i,"index.html"),"utf8");if(A.get("*",(a,u)=>u.send(o)),e.server.isHttps){let{key:a,cert:u}=await e.server.getcert();$s.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:a,cert:u},A).listen(e.server.port,t)}else A.listen(e.server.port,t)}}});var Oe=m(()=>{"use strict";r();dt();vt()});var Ct={};F(Ct,{default:()=>Ds});import{rspack as js}from"@rspack/core";var bt,Pe,Ds,wt=m(()=>{"use strict";r();te();C();se();Oe();b();bt=new I,Pe=class extends ${get stats(){return{all:p.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=y(p.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:p.server.port}}),{devServer:t}=e;if(p.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:o}=await p.server.getcert();t.server={type:"https",options:{key:i,cert:o}}}return Object.hasOwn(t,"https")&&delete t.https,e}async run(){let{server:e}=p,t=await this.getRspackDevConfig();t=await bt.beforeCompiler(t);let i=js(t);await p.empConfig.lifeCycle.beforeDevServe(),e.startOpen(),await bt.setup(i,t,p,async o=>{this.showTimeDone(o),await p.empConfig.lifeCycle.afterDevServe()}),p.debug.showPerformance&&i.hooks.afterDone.tap("done",this.showTimeDone)}showTimeDone=e=>{let t=e?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});ee(t.time)}},Ds=new Pe});var ke={};F(ke,{ServeScript:()=>ie,default:()=>Ls});var Rs,xt,ie,Ls,Ee=m(()=>{"use strict";r();te();se();Oe();b();Rs=new B,xt=0,ie=class extends ${async run(){xt=Date.now(),await p.empConfig.lifeCycle.beforeServe(),await Rs.setup(p,this.onReady)}onReady=async()=>{p.server.startOpen(),ee(Date.now()-xt),await p.empConfig.lifeCycle.afterServe()}},Ls=new ie});var St={};F(St,{default:()=>Ns});import{rspack as As}from"@rspack/core";var $e,Ns,Ot=m(()=>{"use strict";r();te();P();se();b();$e=class extends ${isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(Ee(),ke));await e.setup("serve",p.cliOptions)}async run(){await p.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!p.cliOptions.watch,this.isuseServe=!!p.cliOptions.serve,this.rspackConfig=p.rsConfig,this.isWatchMode&&this.watchMode(),As(this.rspackConfig,async(e,t)=>{if(console.log(`
17
+ `),p.debug.showScriptDebug&&console.log(t?.toString()),e!==null){n.error(e.stack||e),e.message&&n.error(e.message);return}if(!t){n.red("Stats is Undefined.");return}t.hasErrors()&&(n.error(t.toString({all:!1,colors:!0,errors:!0})),n.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(n.yellow("Compiled with warnings."),n.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await gt(t),this.startServe(),await p.empConfig.lifeCycle.afterBulid()})}},Ns=new $e});r();import{rspack as Jr}from"@rspack/core";r();b();import Ms from"process";import{program as j}from"commander";function Pt(){j.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),j.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(wt(),Ct));await e.setup("dev",s)}),j.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Ot(),St));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(),ke));await e.setup("serve",s)}),j.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),j.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),j.parse(Ms.argv)}b();G();function Wr(s){return s}export{Wr as defineConfig,ze as empHelper,Jr as rspack,Pt as runScript,p as store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/cli",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "emp",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -68,9 +68,9 @@
68
68
  "tsup": "^8.4.0"
69
69
  },
70
70
  "dependencies": {
71
- "@rsdoctor/rspack-plugin": "1.1.4",
72
- "@rspack/core": "1.4.0",
73
- "@rspack/dev-server": "1.1.3",
71
+ "@rsdoctor/rspack-plugin": "1.1.5",
72
+ "@rspack/core": "1.4.1",
73
+ "@rspack/dev-server": "1.1.1",
74
74
  "@swc/helpers": "^0.5.17",
75
75
  "address": "^2.0.2",
76
76
  "chalk": "^5.3.0",