@empjs/cli 3.2.9-hotfix.1 → 3.2.9-hotfix.3

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