@empjs/cli 3.11.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
`)};red=e=>{console.log(`${x.lightRed(this.brandName)}${x.red(` ${e} `)}
|
|
7
7
|
`)};sysError=e=>{console.log(`${x.lightRed(" System Error Tips ")}${x.red(` ${e} `)}
|
|
8
8
|
`)};link=e=>x.blue(e);title=e=>{console.log(`${this.fullName}${x.yellow.underline(`${e}`)}
|
|
9
|
-
`)}},h=new oe});var it={};X(it,{clearConsole:()=>tt,deepAssign:()=>T,ensureArray:()=>Cr,getLanIp:()=>q,getPkgVersion:()=>et,importJsVm:()=>st,jsonFilter:()=>Er,timeFormat:()=>Se,vCompare:()=>xe});function tt(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function T(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=T(o,r);continue}s[i]=t[i]}return s}var ls,cs,ps,hs,q,et,Cr,Er,xe,Se,st,$=w(()=>{"use strict";p();ls=require("address"),cs=d(require("chalk"),1),ps=require("default-gateway"),hs=d(require("fs-extra"),1),q=()=>{let s="127.0.0.1";try{let{int:e}=(0,ps.gateway4sync)();return(0,ls.ip)(e||"")||s}catch{return s}},et=s=>{try{let{version:e}=hs.default.readJSONSync(s);return e}catch{return}};Cr=s=>Array.isArray(s)?s:[s],Er=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),xe=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,c=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<c){o=-1;break}else if(l>c){o=1;break}}return o},Se=s=>{s=s/1e3;let e=i=>cs.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},st=s=>`data:text/javascript,${s}`});var rt={};X(rt,{chalk:()=>fs.default,color:()=>x,glob:()=>ne.glob,logger:()=>h,utils:()=>it});var fs,ne,te=w(()=>{"use strict";p();fs=d(require("chalk"),1),ne=require("glob");ee();L();$()});var ot,us,nt,Pr,ms,ds,gs,ys,ke=w(()=>{"use strict";p();ot=d(require("fs"),1),us=require("jiti"),nt=d(require("path"),1);I();ze();L();Pr=["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"],ms=(0,us.createJiti)(__filename,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:me.version}),ds=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=Pr.map(r=>nt.default.resolve(g.root,r)),t=await Promise.all(e.map(r=>ot.default.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},gs=async()=>{let s=nt.default.join(g.root,"tsconfig.json");return await ot.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},ys=()=>{let s=[__filename];return g.rootPaths.pkg&&s.push(g.rootPaths.pkg),g.rootPaths.empConfig&&s.push(g.rootPaths.empConfig),g.rootPaths.tsConfig&&s.push(g.rootPaths.tsConfig),s}});var at,ws,lt=w(()=>{"use strict";p();at=d(require("@empjs/chain"),1),ws={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Oe,vs=w(()=>{"use strict";p();Oe=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 ct,bs,Cs=w(()=>{"use strict";p();te();ke();$();vs();ct=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},T(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Oe(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return T({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(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await ms(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},bs=new ct});var Es,pt,Ps,_s=w(()=>{"use strict";p();Es=d(require("fs-extra"),1);ke();pt=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:ys(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,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 Es.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"all",minSize:2e4,minChunks:1,automaticNameDelimiter:"-",cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,name:"vendor",priority:-10,reuseExistingChunk:!0},default:{minChunks:2,priority:-20,reuseExistingChunk:!0}}}};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})}},Ps=new pt});var ht,xs,Ss=w(()=>{"use strict";p();ht=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:require.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},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"}}}})}},xs=new ht});function _r(){let s=[`import 'core-js/${g.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
9
|
+
`)}},h=new oe});var it={};X(it,{clearConsole:()=>tt,deepAssign:()=>T,ensureArray:()=>Cr,getLanIp:()=>q,getPkgVersion:()=>et,importJsVm:()=>st,jsonFilter:()=>Er,timeFormat:()=>Se,vCompare:()=>xe});function tt(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function T(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=T(o,r);continue}s[i]=t[i]}return s}var ls,cs,ps,hs,q,et,Cr,Er,xe,Se,st,$=w(()=>{"use strict";p();ls=require("address"),cs=d(require("chalk"),1),ps=require("default-gateway"),hs=d(require("fs-extra"),1),q=()=>{let s="127.0.0.1";try{let{int:e}=(0,ps.gateway4sync)();return(0,ls.ip)(e||"")||s}catch{return s}},et=s=>{try{let{version:e}=hs.default.readJSONSync(s);return e}catch{return}};Cr=s=>Array.isArray(s)?s:[s],Er=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),xe=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,c=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<c){o=-1;break}else if(l>c){o=1;break}}return o},Se=s=>{s=s/1e3;let e=i=>cs.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},st=s=>`data:text/javascript,${s}`});var rt={};X(rt,{chalk:()=>fs.default,color:()=>x,glob:()=>ne.glob,logger:()=>h,utils:()=>it});var fs,ne,te=w(()=>{"use strict";p();fs=d(require("chalk"),1),ne=require("glob");ee();L();$()});var ot,us,nt,Pr,ms,ds,gs,ys,ke=w(()=>{"use strict";p();ot=d(require("fs"),1),us=require("jiti"),nt=d(require("path"),1);I();ze();L();Pr=["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"],ms=(0,us.createJiti)(__filename,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:me.version}),ds=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=Pr.map(r=>nt.default.resolve(g.root,r)),t=await Promise.all(e.map(r=>ot.default.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},gs=async()=>{let s=nt.default.join(g.root,"tsconfig.json");return await ot.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},ys=()=>{let s=[__filename];return g.rootPaths.pkg&&s.push(g.rootPaths.pkg),g.rootPaths.empConfig&&s.push(g.rootPaths.empConfig),g.rootPaths.tsConfig&&s.push(g.rootPaths.tsConfig),s}});var at,ws,lt=w(()=>{"use strict";p();at=d(require("@empjs/chain"),1),ws={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Oe,vs=w(()=>{"use strict";p();Oe=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 ct,bs,Cs=w(()=>{"use strict";p();te();ke();$();vs();ct=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},T(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Oe(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return T({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(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await ms(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},bs=new ct});var Es,pt,Ps,_s=w(()=>{"use strict";p();Es=d(require("fs-extra"),1);ke();pt=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:ys(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,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 Es.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"all",minSize:2e4,minChunks:1,automaticNameDelimiter:"-",cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,name:"vendor",priority:-10,reuseExistingChunk:!0},default:{minChunks:2,priority:-20,reuseExistingChunk:!0}}}};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})}},Ps=new pt});var ht,xs,Ss=w(()=>{"use strict";p();ht=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:require.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},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"}}}})}},xs=new ht});function _r(){let s=[`import 'core-js/${g.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
10
|
`);return st(s)}var Te,De,ae,Re=w(()=>{"use strict";p();Te=d(require("html-webpack-plugin"),1);$();I();De=class{constructor(){}apply(e){let{webpack:t}=e;g.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,_r(),{name:void 0}).apply(e)}},ae=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{Te.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});var R,ft,ks,Os=w(()=>{"use strict";p();R=d(require("path"),1);te();Re();ft=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(R.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${R.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(R.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(Te.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(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=R.default.join(this.store.appSrc,e),i=R.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,ne.glob)([i],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${R.default.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},R.default.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=R.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),i=await(0,ne.glob)([t],{windowsPathsNoEscape:!0});if(i[0]){let r=R.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(r,this.store.empConfig.html,i[0])}h.timeEnd(e)}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)}},ks=new ft});var ut,mt,Ds,Ts=w(()=>{"use strict";p();ut=d(require("path"),1);$();mt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:T(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",ut.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=et(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ut.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ds=new mt});var M,dt,Rs,js,gt,As,Ns=w(()=>{"use strict";p();M=d(require("@rspack/core"),1),dt=d(require("fs"),1),Rs=d(require("path"),1),js=require("ts-checker-rspack-plugin");Re();gt=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];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(De)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(js.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");dt.default.existsSync(e)&&dt.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.default.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.default.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=Rs.default.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.default.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},As=new gt});var yt,Fs,Ls=w(()=>{"use strict";p();_s();Ss();Os();Ts();Ns();yt=class{store;async setup(e){this.store=e;let t=[Ps.setup(this.store),Ds.setup(this.store),As.setup(this.store),ks.setup(this.store),xs.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()}},Fs=new yt});async function je(s,e=void 0){if(s!==xr&&(s<$s||s>wt))throw new Error(`Port number must lie between ${$s} and ${wt}`);let t=s,i=Sr(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=wt;)try{return await Or(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var Is,Ms,$s,wt,xr,Sr,kr,Or,zs=w(()=>{"use strict";p();Is=d(require("net"),1),Ms=d(require("os"),1),$s=1024,wt=65535,xr=443,Sr=()=>{let s=Ms.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},kr=(s,e)=>new Promise((t,i)=>{let r=Is.default.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),Or=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await kr(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});var Hs,vt,bt,Ae,Ws=w(()=>{"use strict";p();Hs=d(require("chalk"),1);ee();vt=d(require("url"),1);$();bt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:Z("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=q;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:Hs.default.bold(i),pathname:r})}},Ae=new bt});var Us,Bs,Js,Gs,Dr,Tr,Vs,Ys=w(()=>{"use strict";p();Us=require("child_process"),Bs=require("util");I();L();Js=(0,Bs.promisify)(Us.exec),Gs=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Dr=async()=>{let s=process.env.BROWSER;if(!s||!Gs.includes(s)){let{stdout:e}=await Js("ps cax");s=Gs.find(t=>e.includes(t))}return s},Tr=async s=>{if(process.platform==="darwin")try{let t=await Dr();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Js(i,{cwd:g.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Vs=Tr});var Ct,Ne,qs=w(()=>{"use strict";p();Ct=d(require("fs/promises"),1);te();ee();zs();Ws();Ys();$();Ne=class{ip=q();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 je(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 je(e.empConfig.server.port)),Ae.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Ae.prettyPrintUrl("localhost")):(this.urls=Ae.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(this.publicPath)}`)):(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(e.lanUrlForTerminal)}
|
|
11
11
|
`)),this.isOpenBrower&&Vs(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([Ct.default.readFile(e.resource.key),Ct.default.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await je(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 Xs,j,Ks,Et,Pt,g,I=w(()=>{"use strict";p();Xs=d(require("fs/promises"),1),j=d(require("path"),1),Ks=d(require("util"),1),Et=require("@rspack/core");ke();L();$();lt();Cs();Ls();qs();lt();Re();Pt=class{rspack=Et.rspack;rspackVersion=Et.rspack.rspackVersion;isOldRspack=xe(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=j.default.resolve(__dirname,__filename).replace(`${j.default.sep}dist${j.default.sep}index.js`,"");empSource=j.default.resolve(this.empRoot,"dist");resolve=e=>j.default.isAbsolute(e)?e:j.default.resolve(this.root,e);empResolve=e=>j.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=ws;server=new Ne(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;cliOptions;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};beforeSetup;afterSetup;async setup(e,t){this.cliAction=e||this.cliAction,this.cliOptions=t||this.cliOptions;let i="store.setup";h.time(i),this.beforeSetup&&await this.beforeSetup();let[r,o]=await Promise.all([ds(),gs()]);this.rootPaths.empConfig=r,this.rootPaths.tsConfig=o,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(this.cliAction,this.cliOptions),this.empConfig=bs,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new at.default,await Fs.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),this.afterSetup&&await this.afterSetup(),h.timeEnd(i),this.debug.clearLog&&tt()}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=j.default.join(this.empRoot,"resource"),this.resource.cert=j.default.join(this.resource.dir,"emp.cert"),this.resource.key=j.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)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),h.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,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=j.default.join(this.root,this.debug.showRsconfig);Xs.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"?T(e,this.debug.showRsconfig):e;console.log(h.link("[Compile Config]")),console.log(Ks.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=xe;deepAssign=T;getLanIp=q;injectTags(e=[],t="",i=""){this.chain.plugin(`${ae}-${t}`).use(ae,[e,t,i])}},g=new Pt});function $r(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,o,a)=>{let n=t[a],l=o;return n&&(l=o.length<n?o+" ".repeat(n-o.length):o),`${r+l} `}," ");console.log(Q.bold(i))}async function ei(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(c=>Nr(c.name)).map(Lr);i.sort((c,m)=>c.size-m.size);let r=Math.max(...i.map(c=>c.sizeLabel.length)),o=Math.max(...i.map(c=>(c.folder+W.default.sep+c.name).length));$r(o,r);let a=0,n=0;i.forEach(c=>{let{sizeLabel:m}=c,{name:u,folder:b,gzipSizeLabel:C}=c,E=(b+W.default.sep+u).length,O=m.length;if(a+=c.size,n+=c.gzippedSize,O<r){let A=" ".repeat(r-O);m+=A}let S=Z(c.folder+W.default.sep)+Ir(c.name);if(E<o){let A=" ".repeat(o-E);S+=A}h.info(` ${S} ${Z(m)} ${C}`)});let l=`${Q.bold("Total size:")} ${Fe(a)}`,f=`${Q.bold("Gzipped size:")} ${Fe(n)}`;h.info(`
|
|
12
12
|
${l}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var Vs=Object.defineProperty;var k=(s=>typeof require<"u"?require:typeof Proxy<"
|
|
|
7
7
|
`)};red=e=>{console.log(`${_.lightRed(this.brandName)}${_.red(` ${e} `)}
|
|
8
8
|
`)};sysError=e=>{console.log(`${_.lightRed(" System Error Tips ")}${_.red(` ${e} `)}
|
|
9
9
|
`)};link=e=>_.blue(e);title=e=>{console.log(`${this.fullName}${_.yellow.underline(`${e}`)}
|
|
10
|
-
`)}},h=new ye});var Ke={};Z(Ke,{clearConsole:()=>qe,deepAssign:()=>R,ensureArray:()=>sr,getLanIp:()=>U,getPkgVersion:()=>Ye,importJsVm:()=>Xe,jsonFilter:()=>ir,timeFormat:()=>ve,vCompare:()=>we});import{ip as Qi}from"address";import Zi from"chalk";import{gateway4sync as er}from"default-gateway";import tr from"fs-extra";function qe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function R(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=R(o,r);continue}s[i]=t[i]}return s}var U,Ye,sr,ir,we,ve,Xe,$=v(()=>{"use strict";c();U=()=>{let s="127.0.0.1";try{let{int:e}=er();return Qi(e||"")||s}catch{return s}},Ye=s=>{try{let{version:e}=tr.readJSONSync(s);return e}catch{return}};sr=s=>Array.isArray(s)?s:[s],ir=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),we=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},ve=s=>{s=s/1e3;let e=i=>Zi.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},Xe=s=>`data:text/javascript,${s}`});var Bt={};Z(Bt,{chalk:()=>rr,color:()=>_,glob:()=>be,logger:()=>h,utils:()=>Ke});import rr from"chalk";import{glob as be}from"glob";var K=v(()=>{"use strict";c();X();L();$()});import Jt from"fs";import{createJiti as or}from"jiti";import Vt from"path";var nr,Yt,qt,Xt,Kt,Ce=v(()=>{"use strict";c();I();Ae();L();nr=["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"],Yt=or(g,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:ae.version}),qt=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=nr.map(r=>Vt.resolve(d.root,r)),t=await Promise.all(e.map(r=>Jt.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},Xt=async()=>{let s=Vt.join(d.root,"tsconfig.json");return await Jt.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Kt=()=>{let s=[g];return d.rootPaths.pkg&&s.push(d.rootPaths.pkg),d.rootPaths.empConfig&&s.push(d.rootPaths.empConfig),d.rootPaths.tsConfig&&s.push(d.rootPaths.tsConfig),s}});import Qt from"@empjs/chain";var Zt,Qe=v(()=>{"use strict";c();Zt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Ee,es=v(()=>{"use strict";c();Ee=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 Ze,ts,ss=v(()=>{"use strict";c();K();Ce();$();es();Ze=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},R(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Ee(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return R({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(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await Yt(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},ts=new Ze});import ar from"fs-extra";var et,is,rs=v(()=>{"use strict";c();Ce();et=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Kt(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,lazyBarrel:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,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 ar.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"all",minSize:2e4,minChunks:1,automaticNameDelimiter:"-",cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,name:"vendor",priority:-10,reuseExistingChunk:!0},default:{minChunks:2,priority:-20,reuseExistingChunk:!0}}}};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})}},is=new et});var tt,os,ns=v(()=>{"use strict";c();tt=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:k.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:k.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:k.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},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"}}}})}},os=new tt});import st from"html-webpack-plugin";function lr(){let s=[`import 'core-js/${d.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
|
+
`)}},h=new ye});var Ke={};Z(Ke,{clearConsole:()=>qe,deepAssign:()=>R,ensureArray:()=>sr,getLanIp:()=>U,getPkgVersion:()=>Ye,importJsVm:()=>Xe,jsonFilter:()=>ir,timeFormat:()=>ve,vCompare:()=>we});import{ip as Qi}from"address";import Zi from"chalk";import{gateway4sync as er}from"default-gateway";import tr from"fs-extra";function qe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function R(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=R(o,r);continue}s[i]=t[i]}return s}var U,Ye,sr,ir,we,ve,Xe,$=v(()=>{"use strict";c();U=()=>{let s="127.0.0.1";try{let{int:e}=er();return Qi(e||"")||s}catch{return s}},Ye=s=>{try{let{version:e}=tr.readJSONSync(s);return e}catch{return}};sr=s=>Array.isArray(s)?s:[s],ir=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),we=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},ve=s=>{s=s/1e3;let e=i=>Zi.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},Xe=s=>`data:text/javascript,${s}`});var Bt={};Z(Bt,{chalk:()=>rr,color:()=>_,glob:()=>be,logger:()=>h,utils:()=>Ke});import rr from"chalk";import{glob as be}from"glob";var K=v(()=>{"use strict";c();X();L();$()});import Jt from"fs";import{createJiti as or}from"jiti";import Vt from"path";var nr,Yt,qt,Xt,Kt,Ce=v(()=>{"use strict";c();I();Ae();L();nr=["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"],Yt=or(g,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:ae.version}),qt=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=nr.map(r=>Vt.resolve(d.root,r)),t=await Promise.all(e.map(r=>Jt.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},Xt=async()=>{let s=Vt.join(d.root,"tsconfig.json");return await Jt.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Kt=()=>{let s=[g];return d.rootPaths.pkg&&s.push(d.rootPaths.pkg),d.rootPaths.empConfig&&s.push(d.rootPaths.empConfig),d.rootPaths.tsConfig&&s.push(d.rootPaths.tsConfig),s}});import Qt from"@empjs/chain";var Zt,Qe=v(()=>{"use strict";c();Zt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Ee,es=v(()=>{"use strict";c();Ee=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 Ze,ts,ss=v(()=>{"use strict";c();K();Ce();$();es();Ze=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},R(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Ee(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return R({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(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await Yt(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}},ts=new Ze});import ar from"fs-extra";var et,is,rs=v(()=>{"use strict";c();Ce();et=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:Kt(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,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 ar.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"all",minSize:2e4,minChunks:1,automaticNameDelimiter:"-",cacheGroups:{vendors:{test:/[\\/]node_modules[\\/]/,name:"vendor",priority:-10,reuseExistingChunk:!0},default:{minChunks:2,priority:-20,reuseExistingChunk:!0}}}};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})}},is=new et});var tt,os,ns=v(()=>{"use strict";c();tt=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:k.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:k.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:k.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},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"}}}})}},os=new tt});import st from"html-webpack-plugin";function lr(){let s=[`import 'core-js/${d.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
11
|
`);return Xe(s)}var Pe,se,xe=v(()=>{"use strict";c();$();I();Pe=class{constructor(){}apply(e){let{webpack:t}=e;d.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,lr(),{name:void 0}).apply(e)}},se=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{st.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});import N from"path";var it,as,ls=v(()=>{"use strict";c();K();xe();it=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(N.extname(e),"").replace(`${this.store.empConfig.appSrc}${N.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(N.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(N.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(N.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(st,[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(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=N.join(this.store.appSrc,e),i=N.join(t,"**","*.{ts,tsx,jsx,js}"),r=await be([i],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${N.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},N.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=N.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),i=await be([t],{windowsPathsNoEscape:!0});if(i[0]){let r=N.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(r,this.store.empConfig.html,i[0])}h.timeEnd(e)}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)}},as=new it});import ps from"path";var rt,cs,hs=v(()=>{"use strict";c();$();rt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:R(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",ps.dirname(k.resolve("@swc/helpers/package.json"))),this.coreJs.path=k.resolve("core-js/package.json");let t=Ye(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ps.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},cs=new rt});import M from"@rspack/core";import fs from"fs";import pr from"path";import{TsCheckerRspackPlugin as cr}from"ts-checker-rspack-plugin";var ot,us,ms=v(()=>{"use strict";c();xe();ot=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];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(Pe)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(cr,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");fs.existsSync(e)&&fs.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=k("@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(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=pr.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},us=new ot});var nt,ds,gs=v(()=>{"use strict";c();rs();ns();ls();hs();ms();nt=class{store;async setup(e){this.store=e;let t=[is.setup(this.store),cs.setup(this.store),us.setup(this.store),as.setup(this.store),os.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()}},ds=new nt});import hr from"net";import fr from"os";async function _e(s,e=void 0){if(s!==ur&&(s<ys||s>at))throw new Error(`Port number must lie between ${ys} and ${at}`);let t=s,i=mr(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=at;)try{return await gr(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var ys,at,ur,mr,dr,gr,ws=v(()=>{"use strict";c();ys=1024,at=65535,ur=443,mr=()=>{let s=fr.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},dr=(s,e)=>new Promise((t,i)=>{let r=hr.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),gr=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await dr(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});import yr from"chalk";import vs from"url";var lt,Se,bs=v(()=>{"use strict";c();X();$();lt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:q("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=U;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:yr.bold(i),pathname:r})}},Se=new lt});import{exec as wr}from"child_process";import{promisify as vr}from"util";var Es,Cs,br,Cr,Ps,xs=v(()=>{"use strict";c();I();L();Es=vr(wr),Cs=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],br=async()=>{let s=process.env.BROWSER;if(!s||!Cs.includes(s)){let{stdout:e}=await Es("ps cax");s=Cs.find(t=>e.includes(t))}return s},Cr=async s=>{if(process.platform==="darwin")try{let t=await br();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Es(i,{cwd:d.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Ps=Cr});import _s from"fs/promises";var ke,Ss=v(()=>{"use strict";c();K();X();ws();bs();xs();$();ke=class{ip=U();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 _e(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 _e(e.empConfig.server.port)),Se.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Se.prettyPrintUrl("localhost")):(this.urls=Se.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(h.info(`${z("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${z("\u279C")} Network: ${h.link(this.publicPath)}`)):(h.info(`${z("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${z("\u279C")} Network: ${h.link(e.lanUrlForTerminal)}
|
|
12
12
|
`)),this.isOpenBrower&&Ps(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([_s.readFile(e.resource.key),_s.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await _e(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import Er from"fs/promises";import F from"path";import Pr from"util";import{rspack as ks}from"@rspack/core";var pt,d,I=v(()=>{"use strict";c();Ce();L();$();Qe();ss();gs();Ss();Qe();xe();pt=class{rspack=ks;rspackVersion=ks.rspackVersion;isOldRspack=we(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=F.resolve(w,g).replace(`${F.sep}dist${F.sep}index.js`,"");empSource=F.resolve(this.empRoot,"dist");resolve=e=>F.isAbsolute(e)?e:F.resolve(this.root,e);empResolve=e=>F.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Zt;server=new ke(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;cliOptions;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};beforeSetup;afterSetup;async setup(e,t){this.cliAction=e||this.cliAction,this.cliOptions=t||this.cliOptions;let i="store.setup";h.time(i),this.beforeSetup&&await this.beforeSetup();let[r,o]=await Promise.all([qt(),Xt()]);this.rootPaths.empConfig=r,this.rootPaths.tsConfig=o,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(this.cliAction,this.cliOptions),this.empConfig=ts,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Qt,await ds.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),this.afterSetup&&await this.afterSetup(),h.timeEnd(i),this.debug.clearLog&&qe()}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=k(this.empResolve("package.json")),r=k(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=F.join(this.empRoot,"resource"),this.resource.cert=F.join(this.resource.dir,"emp.cert"),this.resource.key=F.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)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),h.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,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=F.join(this.root,this.debug.showRsconfig);Er.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"?R(e,this.debug.showRsconfig):e;console.log(h.link("[Compile Config]")),console.log(Pr.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=we;deepAssign=R;getLanIp=U;injectTags(e=[],t="",i=""){this.chain.plugin(`${se}-${t}`).use(se,[e,t,i])}},d=new pt});import xr from"fs";import H from"path";import B from"chalk";import{gzipSizeSync as _r}from"gzip-size";function jr(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,o,a)=>{let n=t[a],l=o;return n&&(l=o.length<n?o+" ".repeat(n-o.length):o),`${r+l} `}," ");console.log(Y.bold(i))}async function Os(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(p=>Dr(p.name)).map(Rr);i.sort((p,m)=>p.size-m.size);let r=Math.max(...i.map(p=>p.sizeLabel.length)),o=Math.max(...i.map(p=>(p.folder+H.sep+p.name).length));jr(o,r);let a=0,n=0;i.forEach(p=>{let{sizeLabel:m}=p,{name:u,folder:b,gzipSizeLabel:C}=p,E=(b+H.sep+u).length,D=m.length;if(a+=p.size,n+=p.gzippedSize,D<r){let j=" ".repeat(r-D);m+=j}let S=q(p.folder+H.sep)+Ar(p.name);if(E<o){let j=" ".repeat(o-E);S+=j}h.info(` ${S} ${q(m)} ${C}`)});let l=`${Y.bold("Total size:")} ${Oe(a)}`,f=`${Y.bold("Gzipped size:")} ${Oe(n)}`;h.info(`
|
|
13
13
|
${l}
|