@empjs/cli 3.12.5-beta.3 → 4.0.0-alpha.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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/346.js +10 -0
  3. package/dist/627.js +5 -0
  4. package/dist/build.js +1 -0
  5. package/dist/dev.js +2 -0
  6. package/dist/dev.js.LICENSE.txt +1 -0
  7. package/dist/helper/buildPrint.d.ts +41 -0
  8. package/dist/helper/chalk.d.ts +3 -0
  9. package/dist/helper/color.d.ts +31 -0
  10. package/dist/helper/compilerWatcher.d.ts +5 -0
  11. package/dist/helper/empRoot.d.ts +1 -0
  12. package/dist/helper/getPort.d.ts +6 -0
  13. package/dist/helper/hmr/client.d.ts +0 -0
  14. package/dist/helper/hmr/config.d.ts +0 -0
  15. package/dist/helper/hmr/index.d.ts +0 -0
  16. package/dist/helper/hmr/overlay.d.ts +0 -0
  17. package/dist/helper/hmr/process-update.d.ts +0 -0
  18. package/dist/helper/hono.d.ts +0 -0
  19. package/dist/helper/index.d.ts +6 -0
  20. package/dist/helper/ipAddress.d.ts +27 -0
  21. package/dist/helper/loadConfig.d.ts +5 -0
  22. package/dist/helper/logger.d.ts +27 -0
  23. package/dist/helper/nodePolyfill.d.ts +1 -0
  24. package/dist/helper/openBrowser.d.ts +2 -0
  25. package/dist/helper/utils.d.ts +15 -0
  26. package/dist/index.d.ts +16 -841
  27. package/dist/index.js +1 -22
  28. package/dist/script/base.d.ts +6 -0
  29. package/dist/script/build.d.ts +15 -0
  30. package/dist/script/dev.d.ts +30 -0
  31. package/dist/script/index.d.ts +1 -0
  32. package/dist/script/serve.d.ts +7 -0
  33. package/dist/serve.js +1 -0
  34. package/dist/server/connect/dev.d.ts +9 -0
  35. package/dist/server/connect/prod.d.ts +3 -0
  36. package/dist/server/express/dev.d.ts +0 -0
  37. package/dist/server/express/prod.d.ts +0 -0
  38. package/dist/server/hono/dev.d.ts +0 -0
  39. package/dist/server/hono/devServer/devMiddleware.d.ts +0 -0
  40. package/dist/server/hono/prod.d.ts +0 -0
  41. package/dist/server/index.d.ts +3 -0
  42. package/dist/server/types.d.ts +3 -0
  43. package/dist/server.js +1 -0
  44. package/dist/store/chain.d.ts +41 -0
  45. package/dist/store/empConfig.d.ts +75 -0
  46. package/dist/store/index.d.ts +179 -0
  47. package/dist/store/lifeCycle.d.ts +57 -0
  48. package/dist/store/rspack/builtInPlugin.d.ts +16 -0
  49. package/dist/store/rspack/common.d.ts +21 -0
  50. package/dist/store/rspack/css.d.ts +10 -0
  51. package/dist/store/rspack/entries.d.ts +44 -0
  52. package/dist/store/rspack/index.d.ts +7 -0
  53. package/dist/store/rspack/module.d.ts +22 -0
  54. package/dist/store/rspack/plugin.d.ts +19 -0
  55. package/dist/store/server.d.ts +39 -0
  56. package/dist/types/config.d.ts +413 -0
  57. package/dist/types/env.d.ts +3 -0
  58. package/dist/types/plugin.d.ts +6 -0
  59. package/package.json +14 -19
  60. package/dist/index.cjs +0 -22
  61. package/dist/index.d.cts +0 -841
package/dist/index.js CHANGED
@@ -1,22 +1 @@
1
- import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
- var Vs=Object.defineProperty;var k=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var v=(i,e)=>()=>(i&&(e=i(i=0)),e);var Z=(i,e)=>{for(var t in e)Vs(i,t,{get:e[t],enumerable:!0})};import Ys from"path";import{fileURLToPath as qs}from"url";var vt,Xs,w,g,c=v(()=>{"use strict";vt=()=>qs(import.meta.url),Xs=()=>Ys.dirname(vt()),w=Xs(),g=vt()});var ae,Ae=v(()=>{ae={name:"@empjs/cli",version:"3.12.5-beta.1",description:"emp",license:"MIT",type:"module",files:["dist","bin","resource","template","types","tsconfig"],maintainers:["xuhongbin","ckken","doerme"],repository:{type:"git",url:"git+https://github.com/empjs/emp.git",directory:"packages/cli"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},keywords:["rspack","rust","typescript"],bin:{emp:"./bin/emp.js"},main:"dist/index.js",types:"dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.ts",default:"./dist/index.js"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"}},"./emp-tsconfig.json":{default:"./tsconfig/react.json"},"./tsconfig/base":{default:"./tsconfig/base.json"},"./tsconfig/react":{default:"./tsconfig/react.json"},"./tsconfig/vue":{default:"./tsconfig/vue.json"},"./client":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"},"./types/base":{types:"./types/base/index.d.ts",default:"./types/base/index.d.ts"},"./types/vue":{types:"./types/vue/index.d.ts",default:"./types/vue/index.d.ts"},"./types/react":{types:"./types/react/index.d.ts",default:"./types/react/index.d.ts"}},scripts:{dev:"tsup --watch --env.ENV dev",build:"tsup --env.ENV prod","dev-rs":"rslib build --watch --env-mode development","build-rs":"rslib build --env-mode production",ph:"pnpm publish --no-git-checks"},engines:{node:">=18.0.0"},author:"Ken",devDependencies:{"@types/compression":"^1.7.2","@types/connect":"^3.4.38","@types/cors":"^2.8.12","@types/default-gateway":"^7.2.1","@types/fs-extra":"^11.0.4","@types/react":"^18.3.2","@types/serve-static":"^1.15.8","@types/watchpack":"^2.4.3","@types/webpack":"^5.28.4","@types/webpack-bundle-analyzer":"^4.6.2","@types/webpack-sources":"^3.2.2",chokidar:"^4.0.3",vue:"^3.5.21"},dependencies:{"@empjs/chain":"workspace:*","@rsdoctor/rspack-plugin":"1.5.0","@rspack/core":"1.7.4","@rspack/dev-server":"1.2.1","@swc/helpers":"^0.5.18","@vue/tsconfig":"^0.8.1",address:"^2.0.2",chalk:"^5.3.0",commander:"11.1.0",compression:"1.8.1",connect:"3.7.0","core-js":"^3.41.0",cors:"2.8.5","default-gateway":"7.2.2","fs-extra":"11.3.1",glob:"11.0.3","gzip-size":"7.0.0","html-webpack-plugin":"5.6.4","http-proxy-middleware":"^3.0.5",jiti:"2.6.1","less-loader":"^12.2.0",open:"10.2.0","sass-embedded":"1.93.2","sass-loader":"16.0.5","serve-static":"2.2.0","ts-checker-rspack-plugin":"1.1.6","typescript-plugin-css-modules":"5.2.0","webpack-bundle-analyzer":"4.10.2"}}});import{stat as Qs,lstat as bt,readdir as Zs,realpath as ei}from"fs/promises";import{Readable as ti}from"stream";import{resolve as Ct,relative as si,join as ii,sep as ri}from"path";function St(i,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=T.FILE_DIR_TYPE),t&&(e.type=t),i){if(typeof i!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!Et.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${Et.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=i,new Fe(e)}var T,Le,_t,oi,Et,ni,ai,li,pi,Pt,xt,Fe,kt=v(()=>{"use strict";c();T={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Le={root:".",fileFilter:i=>!0,directoryFilter:i=>!0,type:T.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Le);_t="READDIRP_RECURSIVE_ERROR",oi=new Set(["ENOENT","EPERM","EACCES","ELOOP",_t]),Et=[T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE],ni=new Set([T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE]),ai=new Set([T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE]),li=i=>oi.has(i.code),pi=process.platform==="win32",Pt=i=>!0,xt=i=>{if(i===void 0)return Pt;if(typeof i=="function")return i;if(typeof i=="string"){let e=i.trim();return t=>t.basename===e}if(Array.isArray(i)){let e=i.map(t=>t.trim());return t=>e.some(s=>t.basename===s)}return Pt},Fe=class extends ti{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Le,...e},{root:s,type:r}=t;this._fileFilter=xt(t.fileFilter),this._directoryFilter=xt(t.directoryFilter);let o=t.lstat?bt:Qs;pi?this._stat=a=>o(a,{bigint:!0}):this._stat=o,this._maxDepth=t.depth??Le.depth,this._wantsDir=r?ni.has(r):!1,this._wantsFile=r?ai.has(r):!1,this._wantsEverything=r===T.EVERYTHING_TYPE,this._root=Ct(s),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(s,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,s=t&&t.files;if(s&&s.length>0){let{path:r,depth:o}=t,a=s.splice(0,e).map(l=>this._formatEntry(l,r)),n=await Promise.all(a);for(let l of n){if(!l)continue;if(this.destroyed)return;let f=await this._getEntryType(l);f==="directory"&&this._directoryFilter(l)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(l.fullPath,o+1)),this._wantsDir&&(this.push(l),e--)):(f==="file"||this._includeAsFile(l))&&this._fileFilter(l)&&this._wantsFile&&(this.push(l),e--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let s;try{s=await Zs(e,this._rdOptions)}catch(r){this._onError(r)}return{files:s,depth:t,path:e}}async _formatEntry(e,t){let s,r=this._isDirent?e.name:e;try{let o=Ct(ii(t,r));s={path:si(this._root,o),fullPath:o,basename:r},s[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return s}_onError(e){li(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let s=e.fullPath;try{let r=await ei(s),o=await bt(r);if(o.isFile())return"file";if(o.isDirectory()){let a=r.length;if(s.startsWith(r)&&s.substr(a,1)===ri){let n=new Error(`Circular symlink detected: "${s}" points to "${r}"`);return n.code=_t,this._onError(n)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}}});import{watchFile as ci,unwatchFile as Ot,watch as hi}from"fs";import{open as fi,stat as Tt,lstat as mi,realpath as Ne}from"fs/promises";import*as P from"path";import{type as ui}from"os";function Dt(i,e,t,s,r){let o=(a,n)=>{t(i),r(a,n,{watchedPath:i}),n&&i!==n&&ce(P.resolve(i,n),G,P.join(i,n))};try{return hi(i,{persistent:e.persistent},o)}catch(a){s(a);return}}var di,Me,Rt,fe,me,ze,gi,yi,wi,jt,x,A,vi,bi,G,le,Y,Ci,Ei,Pi,Ie,ee,xi,te,At,pe,ce,_i,$e,Si,he,Lt=v(()=>{"use strict";c();di="data",Me="end",Rt="close",fe=()=>{},me=process.platform,ze=me==="win32",gi=me==="darwin",yi=me==="linux",wi=me==="freebsd",jt=ui()==="OS400",x={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},A=x,vi="watch",bi={lstat:mi,stat:Tt},G="listeners",le="errHandlers",Y="rawEmitters",Ci=[G,le,Y],Ei=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Pi=i=>Ei.has(P.extname(i).slice(1).toLowerCase()),Ie=(i,e)=>{i instanceof Set?i.forEach(e):e(i)},ee=(i,e,t)=>{let s=i[e];s instanceof Set||(i[e]=s=new Set([s])),s.add(t)},xi=i=>e=>{let t=i[e];t instanceof Set?t.clear():delete i[e]},te=(i,e,t)=>{let s=i[e];s instanceof Set?s.delete(t):s===t&&delete i[e]},At=i=>i instanceof Set?i.size===0:!i,pe=new Map;ce=(i,e,t,s,r)=>{let o=pe.get(i);o&&Ie(o[e],a=>{a(t,s,r)})},_i=(i,e,t,s)=>{let{listener:r,errHandler:o,rawEmitter:a}=s,n=pe.get(e),l;if(!t.persistent)return l=Dt(i,t,r,o,a),l?l.close.bind(l):void 0;if(n)ee(n,G,r),ee(n,le,o),ee(n,Y,a);else{if(l=Dt(i,t,ce.bind(null,e,G),o,ce.bind(null,e,Y)),!l)return;l.on(A.ERROR,async f=>{let p=ce.bind(null,e,le);if(n&&(n.watcherUnusable=!0),ze&&f.code==="EPERM")try{await(await fi(i,"r")).close(),p(f)}catch{}else p(f)}),n={listeners:r,errHandlers:o,rawEmitters:a,watcher:l},pe.set(e,n)}return()=>{te(n,G,r),te(n,le,o),te(n,Y,a),At(n.listeners)&&(n.watcher.close(),pe.delete(e),Ci.forEach(xi(n)),n.watcher=void 0,Object.freeze(n))}},$e=new Map,Si=(i,e,t,s)=>{let{listener:r,rawEmitter:o}=s,a=$e.get(e),n=a&&a.options;return n&&(n.persistent<t.persistent||n.interval>t.interval)&&(Ot(e),a=void 0),a?(ee(a,G,r),ee(a,Y,o)):(a={listeners:r,rawEmitters:o,options:t,watcher:ci(e,t,(l,f)=>{Ie(a.rawEmitters,u=>{u(A.CHANGE,e,{curr:l,prev:f})});let p=l.mtimeMs;(l.size!==f.size||p>f.mtimeMs||p===0)&&Ie(a.listeners,u=>u(i,l))})},$e.set(e,a)),()=>{te(a,G,r),te(a,Y,o),At(a.listeners)&&($e.delete(e),Ot(e),a.options=a.watcher=void 0,Object.freeze(a))}},he=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let s=this.fsw.options,r=P.dirname(e),o=P.basename(e);this.fsw._getWatchedDir(r).add(o);let n=P.resolve(e),l={persistent:s.persistent};t||(t=fe);let f;if(s.usePolling){let p=s.interval!==s.binaryInterval;l.interval=p&&Pi(o)?s.binaryInterval:s.interval,f=Si(e,n,l,{listener:t,rawEmitter:this.fsw._emitRaw})}else f=_i(e,n,l,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return f}_handleFile(e,t,s){if(this.fsw.closed)return;let r=P.dirname(e),o=P.basename(e),a=this.fsw._getWatchedDir(r),n=t;if(a.has(o))return;let l=async(p,u)=>{if(this.fsw._throttle(vi,e,5)){if(!u||u.mtimeMs===0)try{let m=await Tt(e);if(this.fsw.closed)return;let b=m.atimeMs,C=m.mtimeMs;if((!b||b<=C||C!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,m),(gi||yi||wi)&&n.ino!==m.ino){this.fsw._closeFile(p),n=m;let E=this._watchWithNodeFs(e,l);E&&this.fsw._addPathCloser(p,E)}else n=m}catch{this.fsw._remove(r,o)}else if(a.has(o)){let m=u.atimeMs,b=u.mtimeMs;(!m||m<=b||b!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,u),n=u}}},f=this._watchWithNodeFs(e,l);if(!(s&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(A.ADD,e,0))return;this.fsw._emit(A.ADD,e,t)}return f}async _handleSymlink(e,t,s,r){if(this.fsw.closed)return;let o=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let n;try{n=await Ne(s)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(o)!==n&&(this.fsw._symlinkPaths.set(o,n),this.fsw._emit(A.CHANGE,s,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(o,n),this.fsw._emit(A.ADD,s,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,t,s,r,o,a,n){if(e=P.join(e,""),n=this.fsw._throttle("readdir",e,1e3),!n)return;let l=this.fsw._getWatchedDir(s.path),f=new Set,p=this.fsw._readdirp(e,{fileFilter:u=>s.filterPath(u),directoryFilter:u=>s.filterDir(u)});if(p)return p.on(di,async u=>{if(this.fsw.closed){p=void 0;return}let m=u.path,b=P.join(e,m);if(f.add(m),!(u.stats.isSymbolicLink()&&await this._handleSymlink(u,e,b,m))){if(this.fsw.closed){p=void 0;return}(m===r||!r&&!l.has(m))&&(this.fsw._incrReadyCount(),b=P.join(o,P.relative(o,b)),this._addToNodeFs(b,t,s,a+1))}}).on(A.ERROR,this._boundHandleError),new Promise((u,m)=>{if(!p)return m();p.once(Me,()=>{if(this.fsw.closed){p=void 0;return}let b=n?n.clear():!1;u(void 0),l.getChildren().filter(C=>C!==e&&!f.has(C)).forEach(C=>{this.fsw._remove(e,C)}),p=void 0,b&&this._handleRead(e,!1,s,r,o,a,n)})})}async _handleDir(e,t,s,r,o,a,n){let l=this.fsw._getWatchedDir(P.dirname(e)),f=l.has(P.basename(e));!(s&&this.fsw.options.ignoreInitial)&&!o&&!f&&this.fsw._emit(A.ADD_DIR,e,t),l.add(P.basename(e)),this.fsw._getWatchedDir(e);let p,u,m=this.fsw.options.depth;if((m==null||r<=m)&&!this.fsw._symlinkPaths.has(n)){if(!o&&(await this._handleRead(e,s,a,o,e,r,p),this.fsw.closed))return;u=this._watchWithNodeFs(e,(b,C)=>{C&&C.mtimeMs===0||this._handleRead(b,!1,a,o,e,r,p)})}return u}async _addToNodeFs(e,t,s,r,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let n=this.fsw._getWatchHelpers(e);s&&(n.filterPath=l=>s.filterPath(l),n.filterDir=l=>s.filterDir(l));try{let l=await bi[n.statMethod](n.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(n.watchPath,l))return a(),!1;let f=this.fsw.options.followSymlinks,p;if(l.isDirectory()){let u=P.resolve(e),m=f?await Ne(e):e;if(this.fsw.closed||(p=await this._handleDir(n.watchPath,l,t,r,o,n,m),this.fsw.closed))return;u!==m&&m!==void 0&&this.fsw._symlinkPaths.set(u,m)}else if(l.isSymbolicLink()){let u=f?await Ne(e):e;if(this.fsw.closed)return;let m=P.dirname(n.watchPath);if(this.fsw._getWatchedDir(m).add(n.watchPath),this.fsw._emit(A.ADD,n.watchPath,l),p=await this._handleDir(m,l,t,r,e,n,u),this.fsw.closed)return;u!==void 0&&this.fsw._symlinkPaths.set(P.resolve(e),u)}else p=this._handleFile(n.watchPath,l,t);return a(),p&&this.fsw._addPathCloser(e,p),!1}catch(l){if(this.fsw._handleError(l))return a(),e}}}});import{stat as ki}from"fs";import{stat as Oi,readdir as Di}from"fs/promises";import{EventEmitter as Ti}from"events";import*as y from"path";function ue(i){return Array.isArray(i)?i:[i]}function $i(i){return typeof i=="function"?i:typeof i=="string"?e=>i===e:i instanceof RegExp?e=>i.test(e):typeof i=="object"&&i!==null?e=>{if(i.path===e)return!0;if(i.recursive){let t=y.relative(i.path,e);return t?!t.startsWith("..")&&!y.isAbsolute(t):!1}return!1}:()=>!1}function Ii(i){if(typeof i!="string")throw new Error("string expected");i=y.normalize(i),i=i.replace(/\\/g,"/");let e=!1;i.startsWith("//")&&(e=!0);let t=/\/\//;for(;i.match(t);)i=i.replace(t,"/");return e&&(i="/"+i),i}function Nt(i,e,t){let s=Ii(e);for(let r=0;r<i.length;r++){let o=i[r];if(o(s,t))return!0}return!1}function Mi(i,e){if(i==null)throw new TypeError("anymatch: specify first argument");let s=ue(i).map(r=>$i(r));return e==null?(r,o)=>Nt(s,r,o):Nt(s,e)}function Ui(i,e={}){let t=new de(e);return t.add(i),t}var He,Ri,zt,ji,Ai,Li,Ft,Fi,Ni,We,$t,It,Ht,Mt,zi,Hi,Ge,Wi,Gi,Ue,de,Wt,Gt=v(()=>{"use strict";c();kt();Lt();He="/",Ri="//",zt=".",ji="..",Ai="string",Li=/\\/g,Ft=/\/\//,Fi=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Ni=/^\.[/\\]/;We=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);$t=i=>{let e=ue(i).flat();if(!e.every(t=>typeof t===Ai))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(Ht)},It=i=>{let e=i.replace(Li,He),t=!1;for(e.startsWith(Ri)&&(t=!0);e.match(Ft);)e=e.replace(Ft,He);return t&&(e=He+e),e},Ht=i=>It(y.normalize(It(i))),Mt=(i="")=>e=>typeof e=="string"?Ht(y.isAbsolute(e)?e:y.join(i,e)):e,zi=(i,e)=>y.isAbsolute(i)?i:y.join(e,i),Hi=Object.freeze(new Set),Ge=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==zt&&e!==ji&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let s=this.path;try{await Di(s)}catch{this._removeWatcher&&this._removeWatcher(y.dirname(s),y.basename(s))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=fe,this.items=Hi,Object.freeze(this)}},Wi="stat",Gi="lstat",Ue=class{constructor(e,t,s){this.fsw=s;let r=e;this.path=e=e.replace(Ni,""),this.watchPath=r,this.fullWatchPath=y.resolve(r),this.dirParts=[],this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=t,this.statMethod=t?Wi:Gi}entryPath(e){return y.join(this.watchPath,y.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let s=this.entryPath(e);return this.fsw._isntIgnored(s,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},de=class extends Ti{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,s={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?ue(e.ignored):ue([]),awaitWriteFinish:t===!0?s:typeof t=="object"?{...s,...t}:!1};jt&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let o=process.env.CHOKIDAR_USEPOLLING;if(o!==void 0){let l=o.toLowerCase();l==="false"||l==="0"?r.usePolling=!1:l==="true"||l==="1"?r.usePolling=!0:r.usePolling=!!l}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let n=0;this._emitReady=()=>{n++,n>=this._readyCount&&(this._emitReady=fe,this._readyEmitted=!0,process.nextTick(()=>this.emit(x.READY)))},this._emitRaw=(...l)=>this.emit(x.RAW,...l),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new he(this),Object.freeze(r)}_addIgnoredPath(e){if(We(e)){for(let t of this._ignoredPaths)if(We(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)We(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,s){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let o=$t(e);return r&&(o=o.map(a=>zi(a,r))),o.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=o.length,Promise.all(o.map(async a=>{let n=await this._nodeFsHandler._addToNodeFs(a,!s,void 0,0,t);return n&&this._emitReady(),n})).then(a=>{this.closed||a.forEach(n=>{n&&this.add(y.dirname(n),y.basename(t||n))})}),this}unwatch(e){if(this.closed)return this;let t=$t(e),{cwd:s}=this.options;return t.forEach(r=>{!y.isAbsolute(r)&&!this._closers.has(r)&&(s&&(r=y.join(s,r)),r=y.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(s=>{let r=s();r instanceof Promise&&e.push(r)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,s)=>{let o=(this.options.cwd?y.relative(this.options.cwd,s):s)||zt;e[o]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==x.ERROR&&this.emit(x.ALL,e,...t)}async _emit(e,t,s){if(this.closed)return;let r=this.options;ze&&(t=y.normalize(t)),r.cwd&&(t=y.relative(r.cwd,t));let o=[t];s!=null&&o.push(s);let a=r.awaitWriteFinish,n;if(a&&(n=this._pendingWrites.get(t)))return n.lastChange=new Date,this;if(r.atomic){if(e===x.UNLINK)return this._pendingUnlinks.set(t,[e,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((l,f)=>{this.emit(...l),this.emit(x.ALL,...l),this._pendingUnlinks.delete(f)})},typeof r.atomic=="number"?r.atomic:100),this;e===x.ADD&&this._pendingUnlinks.has(t)&&(e=x.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===x.ADD||e===x.CHANGE)&&this._readyEmitted){let l=(f,p)=>{f?(e=x.ERROR,o[0]=f,this.emitWithAll(e,o)):p&&(o.length>1?o[1]=p:o.push(p),this.emitWithAll(e,o))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,l),this}if(e===x.CHANGE&&!this._throttle(x.CHANGE,t,50))return this;if(r.alwaysStat&&s===void 0&&(e===x.ADD||e===x.ADD_DIR||e===x.CHANGE)){let l=r.cwd?y.join(r.cwd,t):t,f;try{f=await Oi(l)}catch{}if(!f||this.closed)return;o.push(f)}return this.emitWithAll(e,o),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(x.ERROR,e),e||this.closed}_throttle(e,t,s){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw new Error("invalid throttle");let o=r.get(t);if(o)return o.count++,!1;let a,n=()=>{let f=r.get(t),p=f?f.count:0;return r.delete(t),clearTimeout(a),f&&clearTimeout(f.timeoutObject),p};a=setTimeout(n,s);let l={timeoutObject:a,clear:n,count:0};return r.set(t,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,s,r){let o=this.options.awaitWriteFinish;if(typeof o!="object")return;let a=o.pollInterval,n,l=e;this.options.cwd&&!y.isAbsolute(e)&&(l=y.join(this.options.cwd,e));let f=new Date,p=this._pendingWrites;function u(m){ki(l,(b,C)=>{if(b||!p.has(e)){b&&b.code!=="ENOENT"&&r(b);return}let E=Number(new Date);m&&C.size!==m.size&&(p.get(e).lastChange=E);let D=p.get(e);E-D.lastChange>=t?(p.delete(e),r(void 0,C)):n=setTimeout(u,a,C)})}p.has(e)||(p.set(e,{lastChange:f,cancelWait:()=>(p.delete(e),clearTimeout(n),s)}),n=setTimeout(u,a))}_isIgnored(e,t){if(this.options.atomic&&Fi.test(e))return!0;if(!this._userIgnored){let{cwd:s}=this.options,o=(this.options.ignored||[]).map(Mt(s)),n=[...[...this._ignoredPaths].map(Mt(s)),...o];this._userIgnored=Mi(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Ue(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=y.resolve(e);return this._watched.has(t)||this._watched.set(t,new Ge(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,s){let r=y.join(e,t),o=y.resolve(r);if(s=s??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!s&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(m=>this._remove(r,m));let l=this._getWatchedDir(e),f=l.has(t);l.remove(t),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let p=r;if(this.options.cwd&&(p=y.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(p)&&this._pendingWrites.get(p).cancelWait()===x.ADD)return;this._watched.delete(r),this._watched.delete(o);let u=s?x.UNLINK_DIR:x.UNLINK;f&&!this._isIgnored(r)&&this._emit(u,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=y.dirname(e);this._getWatchedDir(t).remove(y.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(s=>s()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let s=this._closers.get(e);s||(s=[],this._closers.set(e,s)),s.push(t)}_readdirp(e,t){if(this.closed)return;let s={type:x.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=St(e,s);return this._streams.add(r),r.once(Rt,()=>{r=void 0}),r.once(Me,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};Wt={watch:Ui,FSWatcher:de}});import O from"chalk";var Bi,z,Ji,Vi,Yi,Be,ge,qi,Xi,q,Je,Ki,Ve,X,_,K=v(()=>{"use strict";c();Bi=O.hex("#1abc9c"),z=O.hex("#16a085"),Ji=O.hex("#2ecc71"),Vi=O.hex("#27ae60"),Yi=O.hex("#e74c3c"),Be=O.hex("#c0392b"),ge=O.hex("#f1c40f"),qi=O.hex("#f39c12"),Xi=O.hex("#3498db"),q=O.hex("#2980b9"),Je=O.hex("#ecf0f1"),Ki=O.hex("#fd79a8"),Ve=O.hex("#e84393"),X=O.hex("#7f8c8d"),_={lightGreen:Bi,green:z,lightCyan:Ji,cyan:Vi,lightRed:Yi,red:Be,yellow:ge,orange:qi,lightBlue:Xi,blue:q,white:Je,lightMagenta:Ki,magenta:Ve,gray:X}});var Ut,ye,h,N=v(()=>{"use strict";c();K();Ut=!1,ye=class{brandName="";fullName="";logLevel=Ut?"debug":"info";isLogTime=Ut;setup({brandName:e,logLevel:t,fullName:s}){this.brandName=` [${e}] `,this.fullName=` ${s} `,this.fullName=_.green.bold(this.fullName),t&&(this.logLevel=t)}time=(...e)=>this.isLogTime&&console.time(...e);timeEnd=(...e)=>this.isLogTime&&console.timeEnd(...e);debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${_.lightBlue(this.brandName)}${_.blue(` ${e} `)}
3
- `)};cyan=e=>{console.log(`${_.lightCyan(this.brandName)}${_.cyan(` ${e} `)}
4
- `)};magenta=e=>{console.log(`${_.lightMagenta(this.brandName)}${_.magenta(` ${e} `)}
5
- `)};green=e=>{console.log(`${_.lightGreen(this.brandName)}${_.green(` ${e} `)}
6
- `)};yellow=e=>{console.log(`${_.yellow(this.brandName)}${_.orange(` ${e} `)}
7
- `)};red=e=>{console.log(`${_.lightRed(this.brandName)}${_.red(` ${e} `)}
8
- `)};sysError=e=>{console.log(`${_.lightRed(" System Error Tips ")}${_.red(` ${e} `)}
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(i,...e){for(let t of e)for(let s in t){let r=t[s],o=i[s];if(Object(r)==r&&Object(o)===o){i[s]=R(o,r);continue}i[s]=t[s]}return i}var U,Ye,sr,ir,we,ve,Xe,$=v(()=>{"use strict";c();U=()=>{let i="127.0.0.1";try{let{int:e}=er();return Qi(e||"")||i}catch{return i}},Ye=i=>{try{let{version:e}=tr.readJSONSync(i);return e}catch{return}};sr=i=>Array.isArray(i)?i:[i],ir=(i={},e=[])=>Object.keys(i).filter(t=>!e.includes(t)).reduce((t,s)=>(t[s]=i[s],t),{}),we=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.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=s.length>a?s[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=i=>{i=i/1e3;let e=s=>Zi.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},Xe=i=>`data:text/javascript,${i}`});var Bt={};Z(Bt,{chalk:()=>rr,color:()=>_,glob:()=>be,logger:()=>h,utils:()=>Ke});import rr from"chalk";import{glob as be}from"glob";var Q=v(()=>{"use strict";c();K();N();$()});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();N();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 i="store.getEmpConfigPath";h.time(i);let e=nr.map(r=>Vt.resolve(d.root,r)),t=await Promise.all(e.map(r=>Jt.promises.access(r).then(()=>!0,()=>!1))),s=e.find((r,o)=>t[o]);return h.timeEnd(i),s},Xt=async()=>{let i=Vt.join(d.root,"tsconfig.json");return await Jt.promises.access(i).then(()=>!0,()=>!1)||(i=void 0),i},Kt=()=>{let i=[g];return d.rootPaths.pkg&&i.push(d.rootPaths.pkg),d.rootPaths.empConfig&&i.push(d.rootPaths.empConfig),d.rootPaths.tsConfig&&i.push(d.rootPaths.tsConfig),i}});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();Q();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:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),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"}};this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2);let t=this.assign(e,this.store.empOptions.server),s=t.host==="0.0.0.0"||t.host==="::",{server:r}=this.store;if(this.store.isDev&&s&&r?.ip){let o=t.client??={};if(!o.webSocketURL){let a=r.isHttps?"wss":"ws",n=t.port??r.port??8e3;o.webSocketURL=`${a}://${r.ip}:${n}/ws`}}return t}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:s,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}${s}/[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",s={};return Object.keys(e).map(r=>{t==="all"?(s[`import.meta.env.${r}`]=JSON.stringify(e[r]),s[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?s[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?s[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(s[`${r}`]=JSON.stringify(e[r]))}),s}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),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}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}showLogTitle(e){this.store.empOptions.showLogTitle?this.store.empOptions.showLogTitle(e):h.title(`${e.cliAction}`)}},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/**","**/*.md"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ar.exists(e)){let s={};this.store.isOldRspack?s.tsConfigPath=e:s.tsConfig=e,this.store.merge({resolve:s})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill.mode==="entry"&&this.store.empConfig.build.polyfill.splitChunks&&!this.store.empConfig.build.polyfill.entryCdn&&(e.splitChunks.cacheGroups.coreJs={test:/[\\/]node_modules[\\/](core-js)[\\/]/,name:"coreJs",chunks:"all",enforce:!0}),this.store.chain.merge({optimization:e})}},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,s={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(s.implementation=r.implementation?r.implementation:k.resolve("sass-embedded"),s.api="modern-compiler",s.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(s.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(s.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(s.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(s.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:k.resolve("sass-loader"),options:s}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:s}=this.store.empConfig.css.less,r={loader:k.resolve("less-loader"),options:{lessOptions:s}};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 i=[`import 'core-js/${d.empConfig.build.polyfill.coreJsFeatures}'`].join(`
11
- `);return Xe(i)}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="",s=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=s}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{st.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async s=>(this.chunk&&!s.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?s.bodyTags:s.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),s))})}}});import L from"path";var it,as,ls=v(()=>{"use strict";c();Q();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(L.extname(e),"").replace(`${this.store.empConfig.appSrc}${L.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(L.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(L.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(L.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[s];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=L.join(this.store.appSrc,e),s=L.join(t,"**","*.{ts,tsx,jsx,js}"),r=await be([s],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${L.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},L.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=L.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),s=await be([t],{windowsPathsNoEscape:!0});if(s[0]){let r=L.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,s[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:s}=this.store.empConfig.build,{externalHelpers:r}=s;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:s}=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:{[s.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[s.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,ms,us=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})}},ms=new ot});var nt,ds,gs=v(()=>{"use strict";c();rs();ns();ls();hs();us();nt=class{store;async setup(e){this.store=e;let t=[is.setup(this.store),cs.setup(this.store),ms.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(i,e=void 0){if(i!==mr&&(i<ys||i>at))throw new Error(`Port number must lie between ${ys} and ${at}`);let t=i,s=ur(),r;e&&!s.has(e)?r=new Set([e]):r=s;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,mr,ur,dr,gr,ws=v(()=>{"use strict";c();ys=1024,at=65535,mr=443,ur=()=>{let i=fr.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},dr=(i,e)=>new Promise((t,s)=>{let r=hr.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),gr=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await dr(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import yr from"chalk";import vs from"url";var lt,Se,bs=v(()=>{"use strict";c();K();$();lt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:X("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==="::",s;if(t){s="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 s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp=U;formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:yr.bold(s),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();N();Es=vr(wr),Cs=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],br=async()=>{let i=process.env.BROWSER;if(!i||!Cs.includes(i)){let{stdout:e}=await Es("ps cax");i=Cs.find(t=>e.includes(t))}return i},Cr=async i=>{if(process.platform==="darwin")try{let t=await br();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await Es(s,{cwd:d.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(i),!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();Q();K();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
- `)),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[s,r]=await Promise.all([_s.readFile(e.resource.key),_s.readFile(e.resource.cert)]);return{key:s,cert:r}}setHttps(){let{store:e}=this,{server:t,https:s}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||s===!0}async setAutoDevBase(){let{store:e}=this;if(this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,!this.isAutoDevBase)return;this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await _e(this.port);let t=`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`;e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:t}},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();N();$();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 s="store.setup";h.time(s),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(s),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 s=k(this.empResolve("package.json")),r=k(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},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="",s=""){this.chain.plugin(`${se}-${t}`).use(se,[e,t,s])}},d=new pt});import xr from"fs";import H from"path";import B from"chalk";import{gzipSizeSync as _r}from"gzip-size";function jr(i,e){let t=[i,e],s=["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(s))}async function Os(i){let e=i.toJson({all:!1,assets:!0,timings:!0}),s=e.assets.filter(p=>Dr(p.name)).map(Rr);s.sort((p,u)=>p.size-u.size);let r=Math.max(...s.map(p=>p.sizeLabel.length)),o=Math.max(...s.map(p=>(p.folder+H.sep+p.name).length));jr(o,r);let a=0,n=0;s.forEach(p=>{let{sizeLabel:u}=p,{name:m,folder:b,gzipSizeLabel:C}=p,E=(b+H.sep+m).length,D=u.length;if(a+=p.size,n+=p.gzippedSize,D<r){let j=" ".repeat(r-D);u+=j}let S=X(p.folder+H.sep)+Ar(p.name);if(E<o){let j=" ".repeat(o-E);S+=j}h.info(` ${S} ${X(u)} ${C}`)});let l=`${q.bold("Total size:")} ${Oe(a)}`,f=`${q.bold("Gzipped size:")} ${Oe(n)}`;h.info(`
13
- ${l}
14
- ${f}
15
- `),h.info(`${B.green("ready ")}Built in ${ve(Number(e.time))}
16
- `)}function De(i,e){let t=i==="start"?B.cyan("start "):B.green("ready ");console.log(t+B.white(e))}function Ds(i=0,e="Ready"){h.info(`${B.green("ready ")}${e} in ${ve(Number(i))}`)}function Ts(i="build"){De("start",`${i} Started...`)}function Rs(i){let e=i?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});De("ready",`built in ${B.bold((e.time/1e3).toFixed(2))} s`)}function js(i="build started..."){De("start",i)}function As(i,e="built"){let t;typeof i=="number"?t=(i/1e3).toFixed(2):t=((i?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0})).time/1e3).toFixed(2),De("ready",`${e} in ${B.bold(t)} s`)}var Sr,kr,Or,Dr,Tr,Rr,Oe,Ar,ie=v(()=>{"use strict";c();K();I();N();$();Sr=/\.html$/,kr=/\.(?:js|mjs|cjs|jsx)$/,Or=/\.css$/,Dr=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),Tr=i=>i>300*1e3?Be:i>100*1e3?ge:Je,Rr=i=>{let e=i.name.split("?")[0],t=Oe(i.size),s=H.basename(e),r=H.join(H.basename(d.empConfig.build.outDir),H.dirname(e)),o=xr.readFileSync(H.join(d.empConfig.build.outDir,e)),a=o.length,n=_r(o),l=Tr(n)(Oe(n));return{size:a,folder:r,name:s,gzippedSize:n,sizeLabel:t,gzipSizeLabel:l}};Oe=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ar=i=>kr.test(i)?ge(i):Or.test(i)?z(i):Sr.test(i)?q(i):Ve(i)});import Ls from"chalk";import Te from"path";function ct(i,e){return i.map(t=>{let s=Te.relative(e,t);return Ls.dim(Te.dirname(s)+Te.sep)+Ls.dim(Te.basename(s))})}function Fs(i,e){let t="emp:compiler",s=new Set,r=new Map,o=!1,a=new Set,n=!1,l=i.options.context||process.cwd(),f=m=>Lr.test(m)&&!Fr.test(m),p=m=>{let b=new Set,C=new Set;if(m.modifiedFiles||m.removedFiles){if(m.modifiedFiles){for(let E of m.modifiedFiles)if(f(E)){let D=r.get(E)||0,S=Date.now();S-D>300&&(b.add(E),r.set(E,S))}}if(m.removedFiles)for(let E of m.removedFiles)f(E)&&(C.add(E),r.delete(E));return{changed:b,removed:C}}if(m.watchFileSystem?.watcher){let D=m.watchFileSystem.watcher.mtimes||{};for(let S of Object.keys(D)){if(!f(S))continue;let j=D[S],yt=r.get(S)||0,wt=Date.now();yt<j&&wt-yt>300&&(b.add(S),r.set(S,wt))}}return{changed:b,removed:C}};function u(m,b){if(!e.isServerStarted)return;let C=Array.from(m),E=Array.from(b),D=Array.from(a);if(C.length===0&&E.length===0&&D.length===0)return;let S="";if(C.length>0){let j=ct(C,l);S+=`modified ${j.join(", ")}`}if(D.length>0){let j=ct(D,l);S+=`lazyLoaded ${j.join(", ")}`}if(E.length>0){let j=ct(E,l);S+=`removed ${j.join(", ")}`}js(S)}return i.hooks.watchRun.tap(t,m=>{if(n)return;n=!0,s.clear(),a.clear();let{changed:b,removed:C}=p(m);o=b.size>0||C.size>0,o&&u(b,C),b.forEach(E=>s.add(E))}),i.hooks.done.tap(t,m=>{if(!e.isServerStarted||!o){n=!1;return}(s.size>0||a.size>0)&&(As(m),o=!1),n=!1}),{cleanup:()=>{s.clear(),r.clear(),a.clear(),o=!1,n=!1}}}var Lr,Fr,Ns=v(()=>{"use strict";c();ie();Lr=/\/src\//,Fr=/node_modules/});import{rspackVersion as Nr}from"@rspack/core";var W,Re=v(()=>{"use strict";c();N();I();W=class{async setup(e,t){let s=`${e}.setup`,r=`${e}.run`;h.time(s),await d.setup(e,t),d.empConfig.showLogTitle({cliAction:e,cliOptions:t,rspackVersion:Nr,empVersion:d.empPkg.version}),h.time(r),await this.run(),this.processExit(),h.timeEnd(r),h.timeEnd(s)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});import{RspackDevServer as $r}from"@rspack/dev-server";import Ir from"connect";var re,$s=v(()=>{"use strict";c();N();re=class{server=null;isServerStarted=!1;async setup(e,t,s,r=()=>{}){if(!t.devServer){h.warn("rspackConfig.devServer need!");return}let o=new $r(t.devServer,e);await o.start(),o.middleware?.waitUntilValid(r),this.server=o}async beforeCompiler(e){return e.devServer.app=()=>Ir(),e.devServer.server&&e.devServer.server.type==="https"&&(e.devServer.server.type="http2"),e}async close(){if(h.debug("close dev server"),this.server)try{return await this.server.stop(),this.isServerStarted=!1,this.server=null,!0}catch(e){return h.error("Error closing dev server:",e),!1}return!0}}});import Is from"fs";import Mr from"fs/promises";import zr from"compression";import Hr from"connect";import Wr from"cors";import Gr from"http";import{createProxyMiddleware as Ur}from"http-proxy-middleware";import Br from"https";import Ms from"path";import Jr from"serve-static";import{parse as Vr}from"url";var J,oe,zs=v(()=>{"use strict";c();J=Hr();J.use(zr());J.use(Wr());oe=class{async setup(e,t=()=>{}){let s="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(s)||(s=r[0]),!Is.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);e.empConfig.server.proxy&&Array.isArray(e.empConfig.server.proxy)&&e.empConfig.server.proxy.forEach(n=>{let{context:l,...f}=n;J.use(Ur({...f,pathFilter:l}))}),J.use(Jr(o));let a=await Mr.readFile(Ms.join(o,`${s}.html`),"utf8");if(J.use((n,l,f)=>{let u=Vr(n.url||"",!0).pathname;if(u&&u!=="/"&&Is.existsSync(Ms.join(o,u)))return f();l.setHeader("Content-Type","text/html"),l.end(a)}),e.server.isHttps){let{key:n,cert:l}=await e.server.getcert();Br.createServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:n,cert:l},J).listen(e.server.port,t)}else Gr.createServer(J).listen(e.server.port,t)}}});var ht=v(()=>{"use strict";c();$s();zs()});var Hs={};Z(Hs,{default:()=>Xr});import{rspack as Yr}from"@rspack/core";import ft from"fs";import qr from"path";var ne,mt,Xr,Ws=v(()=>{"use strict";c();Gt();Q();ie();Ns();$();Re();ht();I();ne=new re,mt=class extends W{closeHooks=[];get stats(){return{all:d.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=R(d.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:d.server.port}}),{devServer:t}=e;if(d.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:s,cert:r}=await d.server.getcert();t.server={type:"https",options:{key:s,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async startDevServer(e=!1){try{let{server:t}=d,s=await this.getRspackDevConfig();s=await ne.beforeCompiler(s);let r=Yr(s);await d.empConfig.lifeCycle.beforeDevServe(),t.startOpen(),Ts("DevServer"),await ne.setup(r,s,d,async a=>{ne.isServerStarted=!0,Rs(a),await d.empConfig.lifeCycle.afterDevServe()});let o=Fs(r,ne);this.closeHooks.push(()=>o.cleanup()),e&&h.debug("[EMP] Dev server restarted successfully")}catch(t){h.error(`[EMP] Failed to ${e?"restart":"start"} dev server:`,t)}}watchConfigFile(){let e=qr.resolve(process.cwd(),"emp.config.ts");if(!ft.existsSync(e))return;h.debug("[EMP] Watching for changes in emp.config.ts...");let t=ft.readFileSync(e,"utf-8");Wt.watch(e,{ignored:/(^|[/\\])\../,persistent:!0}).on("change",async s=>{let r=ft.readFileSync(e,"utf-8");if(t===r){h.debug("[EMP] \u914D\u7F6E\u6587\u4EF6\u65E0\u5B9E\u9645\u53D8\u66F4\uFF08\u7A7A\u4FDD\u5B58\uFF09\uFF0C\u8DF3\u8FC7\u91CD\u542F");return}t=r,h.debug(`[EMP] Config file changed: ${s}`),Object.keys(k.cache).forEach(o=>{o.includes("emp.config")&&delete k.cache[o]}),h.debug("[EMP] \u914D\u7F6E\u6587\u4EF6\u5DF2\u53D8\u66F4\uFF0C\u6B63\u5728\u91CD\u542F\u670D\u52A1..."),this.executeCloseHooks(),await ne.close(),await d.setup(),h.debug("[EMP] \u91CD\u542F\u670D\u52A1\u5B8C\u6210\uFF0C\u65B0\u914D\u7F6E\u5982\u4E0B:",d.empConfig.debug),await this.startDevServer(!0)})}async run(){await this.startDevServer(!1),this.watchConfigFile()}lastBuildTime=0;executeCloseHooks(){if(this.closeHooks.length>0){h.debug(`[EMP] \u6267\u884C ${this.closeHooks.length} \u4E2AHook...`);for(let e of this.closeHooks)try{e()}catch(t){h.error("[EMP] \u6267\u884C\u6E05\u7406\u94A9\u5B50\u65F6\u51FA\u9519:",t)}this.closeHooks=[]}}},Xr=new mt});var ut={};Z(ut,{ServeScript:()=>je,default:()=>Qr});var Kr,Gs,je,Qr,dt=v(()=>{"use strict";c();ie();Re();ht();I();Kr=new oe,Gs=0,je=class extends W{async run(){Gs=Date.now(),await d.empConfig.lifeCycle.beforeServe(),await Kr.setup(d,this.onReady)}onReady=async()=>{d.server.startOpen(),Ds(Date.now()-Gs,"Server Started"),await d.empConfig.lifeCycle.afterServe()}},Qr=new je});var Us={};Z(Us,{default:()=>eo});import{rspack as Zr}from"@rspack/core";var gt,eo,Bs=v(()=>{"use strict";c();ie();N();Re();I();gt=class extends W{isWatchMode=!1;rspackConfig;isuseServe=!1;isStartServe=!1;watchMode(){this.isWatchMode&&this.rspackConfig.optimization&&(this.rspackConfig.optimization.moduleIds="named",this.rspackConfig.optimization.chunkIds="named",this.rspackConfig.watch=!0)}async startServe(){if(!this.isuseServe||this.isStartServe)return;this.isStartServe=!0;let{default:e}=await Promise.resolve().then(()=>(dt(),ut));await e.setup("serve",d.cliOptions)}async run(){await d.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!d.cliOptions.watch,this.isuseServe=!!d.cliOptions.serve,this.rspackConfig=d.rsConfig,this.isWatchMode&&this.watchMode(),Zr(this.rspackConfig,async(e,t)=>{if(console.log(`
17
- `),d.debug.showScriptDebug&&console.log(t?.toString()),e!==null){h.error(e.stack||e),e.message&&h.error(e.message);return}if(!t){h.red("Stats is Undefined.");return}t.hasErrors()&&(h.error(t.toString({all:!1,colors:!0,errors:!0})),h.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(h.yellow("Compiled with warnings."),h.warn(t.toString({all:!1,chunks:!1,assets:!1,colors:!0,errors:!0,warnings:!0}))),await Os(t),this.startServe(),await d.empConfig.lifeCycle.afterBulid()})}},eo=new gt});c();import{rspack as ql}from"@rspack/core";import{program as Kl}from"commander";c();Ae();import to from"process";import{program as V}from"commander";async function Js(){V.version(ae.version,"-v, --version").usage("<command> [options]"),V.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Ws(),Hs));await e.setup("dev",i)}),V.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(Bs(),Us));await e.setup("build",i)}),V.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(i,e)=>{let[t,s]=i.split("=");return e[t]=s,e},{}).action(async i=>{let{default:e}=await Promise.resolve().then(()=>(dt(),ut));await e.setup("serve",i)}),V.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(i=>{}),V.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(i=>{}),V.parse(to.argv)}I();N();Q();function ep(i){return i}export{ye as Logger,_ as color,ep as defineConfig,Bt as empHelper,Kl as program,ql as rspack,Js as runScript,d as store};
18
- /*! Bundled license information:
19
-
20
- chokidar/esm/index.js:
21
- (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
22
- */
1
+ import"node:module";import"glob";export{Logger,color,defineConfig,empHelper,program,rspack,runScript,store}from"./346.js";
@@ -0,0 +1,6 @@
1
+ import { CliActionType, CliOptionsType } from '../types/env';
2
+ export declare class BaseScript {
3
+ setup(cliAction?: CliActionType, cliOptions?: CliOptionsType): Promise<void>;
4
+ run(): Promise<void>;
5
+ processExit(): void;
6
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseScript } from './base';
2
+ declare class BuildScript extends BaseScript {
3
+ private isWatchMode;
4
+ private rspackConfig;
5
+ private isuseServe;
6
+ private isStartServe;
7
+ /**
8
+ * 解决 watch mode 报错问题
9
+ */
10
+ private watchMode;
11
+ private startServe;
12
+ run(): Promise<void>;
13
+ }
14
+ declare const _default: BuildScript;
15
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import { BaseScript } from './base';
2
+ declare class DevScript extends BaseScript {
3
+ private closeHooks;
4
+ get stats(): {
5
+ all: boolean;
6
+ colors: boolean;
7
+ assets: boolean;
8
+ chunks: boolean;
9
+ entrypoints: boolean;
10
+ timings: boolean;
11
+ version: boolean;
12
+ errors: boolean;
13
+ warnings: boolean;
14
+ };
15
+ private getRspackDevConfig;
16
+ /**
17
+ * 启动或重启开发服务器
18
+ * @param isRestart 是否为重启操作
19
+ */
20
+ private startDevServer;
21
+ private watchConfigFile;
22
+ run(): Promise<void>;
23
+ private lastBuildTime;
24
+ /**
25
+ * 执行所有关闭钩子函数
26
+ */
27
+ private executeCloseHooks;
28
+ }
29
+ declare const _default: DevScript;
30
+ export default _default;
@@ -0,0 +1 @@
1
+ export default function runScript(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { BaseScript } from './base';
2
+ export declare class ServeScript extends BaseScript {
3
+ run(): Promise<void>;
4
+ onReady: () => Promise<void>;
5
+ }
6
+ declare const _default: ServeScript;
7
+ export default _default;
package/dist/serve.js ADDED
@@ -0,0 +1 @@
1
+ import"node:module";import{timeDone as e,BaseScript as t}from"./627.js";import{ProdServer as r}from"./server.js";import{store as a}from"./346.js";let o=new r,_=0,n=new class extends t{async run(){_=Date.now(),await a.empConfig.lifeCycle.beforeServe(),await o.setup(a,this.onReady)}onReady=async()=>{a.server.startOpen(),e(Date.now()-_,"Server Started"),await a.empConfig.lifeCycle.afterServe()}};export default n;
@@ -0,0 +1,9 @@
1
+ import type { Compiler, GlobalStore, RspackOptions } from '../../index';
2
+ import type { DevServerType } from '../types';
3
+ export declare class DevServer implements DevServerType {
4
+ private server;
5
+ isServerStarted: boolean;
6
+ setup(compiler: Compiler, rspackConfig: RspackOptions, store: GlobalStore, onReady?: (result?: unknown) => void): Promise<void>;
7
+ beforeCompiler(rspackConfig: any): Promise<any>;
8
+ close(): Promise<boolean>;
9
+ }
@@ -0,0 +1,3 @@
1
+ export declare class ProdServer {
2
+ setup(store: any, onReady?: any): Promise<any>;
3
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ import { DevServer } from './connect/dev';
2
+ import { ProdServer } from './connect/prod';
3
+ export { DevServer, ProdServer };
@@ -0,0 +1,3 @@
1
+ export interface DevServerType {
2
+ beforeCompiler: (rspackConfig: any) => Promise<void>;
3
+ }
package/dist/server.js ADDED
@@ -0,0 +1 @@
1
+ import"node:module";import{RspackDevServer as e}from"@rspack/dev-server";import r from"connect";import t from"node:fs";import s from"node:fs/promises";import o from"compression";import i from"cors";import p from"http";import{createProxyMiddleware as v}from"http-proxy-middleware";import n from"https";import m from"path";import a from"serve-static";import{parse as l}from"url";import{logger as d}from"./346.js";class f{server=null;isServerStarted=!1;async setup(r,t,s,o=()=>{}){if(!t.devServer)return void d.warn("rspackConfig.devServer need!");let i=new e(t.devServer,r);await i.start(),i.middleware?.waitUntilValid(o),this.server=i}async beforeCompiler(e){return e.devServer.app=()=>r(),e.devServer.server&&"https"===e.devServer.server.type&&(e.devServer.server.type="http2"),e}async close(){if(d.debug("close dev server"),this.server)try{await this.server.stop(),this.isServerStarted=!1,this.server=null}catch(e){return d.error("Error closing dev server:",e),!1}return!0}}let u=r();u.use(o()),u.use(i());class c{async setup(e,r=()=>{}){let o="index",i=Object.keys(e.rsConfig.entry);if(0===i.length)return e.logger.sysError("emp serve must include entry!");if(i.includes(o)||(o=i[0]),!t.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let d=e.resolve(e.rsConfig.output?.path);e.empConfig.server.proxy&&Array.isArray(e.empConfig.server.proxy)&&e.empConfig.server.proxy.forEach(e=>{let{context:r,...t}=e;u.use(v({...t,pathFilter:r}))}),u.use(a(d));let f=await s.readFile(m.join(d,`${o}.html`),"utf8");if(u.use((e,r,s)=>{let o=l(e.url||"",!0).pathname;if(o&&"/"!==o&&t.existsSync(m.join(d,o)))return s();r.setHeader("Content-Type","text/html"),r.end(f)}),e.server.isHttps){let{key:t,cert:s}=await e.server.getcert();n.createServer("boolean"!=typeof e.server.isHttps?e.server.isHttps:{key:t,cert:s},u).listen(e.server.port,r)}else p.createServer(u).listen(e.server.port,r)}}export{f as DevServer,c as ProdServer};
@@ -0,0 +1,41 @@
1
+ import Chain from '@empjs/chain';
2
+ export { Chain };
3
+ export declare const chainName: {
4
+ rule: {
5
+ mjs: string;
6
+ typescript: string;
7
+ javascript: string;
8
+ sourceMap: string;
9
+ inline: string;
10
+ raw: string;
11
+ svg: string;
12
+ image: string;
13
+ font: string;
14
+ svga: string;
15
+ sass: string;
16
+ less: string;
17
+ css: string;
18
+ };
19
+ use: {
20
+ swc: string;
21
+ sourceMap: string;
22
+ sass: string;
23
+ less: string;
24
+ };
25
+ plugin: {
26
+ tsCheckerRspackPlugin: string;
27
+ bundleAnalyzer: string;
28
+ define: string;
29
+ copy: string;
30
+ progress: string;
31
+ html: {
32
+ prefix: string;
33
+ };
34
+ rsdoctor: string;
35
+ sourceMapDevTool: string;
36
+ };
37
+ minimizer: {
38
+ minJs: string;
39
+ minCss: string;
40
+ };
41
+ };
@@ -0,0 +1,75 @@
1
+ import type { Output } from '@rspack/core';
2
+ import type { GlobalStore } from './';
3
+ import { LifeCycle } from './lifeCycle';
4
+ import type { BuildType, DebugType, HtmlType, RsTarget, ServerType, SourceMapType } from '../types/config';
5
+ export declare class EmpConfig {
6
+ private store;
7
+ /**
8
+ * 项目代码路径
9
+ * @default 'src'
10
+ */
11
+ appSrc: string;
12
+ /**
13
+ * 项目代码入口文件 如 `src/index.js`
14
+ * (*)entries 设置后 该选项失效
15
+ * @default 'index.js'
16
+ */
17
+ appEntry: string;
18
+ /**
19
+ * publicPath 根路径 可参考webpack,业务模式默认为 auto
20
+ * html 部分 publicPath 默认为 undefined,可设置全量域名或子目录适配,也可以单独在html设置 Public
21
+ *
22
+ * @default undefined
23
+ */
24
+ base: string;
25
+ target: RsTarget;
26
+ private assign;
27
+ /**
28
+ * 是否启动 esm 模块
29
+ * @default true
30
+ */
31
+ get isESM(): boolean;
32
+ lifeCycle: LifeCycle;
33
+ setup(store: GlobalStore): Promise<void>;
34
+ /**
35
+ * 同步完所有配置后的处理
36
+ */
37
+ private setupEmpOptions;
38
+ chain(): Promise<void>;
39
+ plugins(): Promise<void>;
40
+ get debug(): Required<DebugType>;
41
+ get build(): Required<BuildType> & {
42
+ sourcemap: SourceMapType;
43
+ };
44
+ get html(): HtmlType;
45
+ get entries(): import("../types/config").EntriesType;
46
+ get server(): ServerType;
47
+ get css(): Required<{
48
+ sass?: import("../types/config").CssSassOptionsType & {
49
+ webpackImporter?: boolean;
50
+ warnRuleAsWarning?: boolean;
51
+ additionalData?: string;
52
+ };
53
+ less?: import("../types/config").CssLessOptionsType;
54
+ prifixName?: string;
55
+ }>;
56
+ get output(): Output;
57
+ get define(): {
58
+ [k: string]: string;
59
+ };
60
+ get tsCheckerRspackPlugin(): {};
61
+ private setDefine;
62
+ get externals(): {};
63
+ get resolve(): import("@rspack/core").ResolveOptions;
64
+ private syncEmpOptions;
65
+ get moduleTransformRule(): any;
66
+ get cacheDir(): string;
67
+ get cache(): boolean | "persistent" | import("@rspack/core").MemoryCacheOptions | import("@rspack/core").PersistentCacheOptions;
68
+ get ignoreWarnings(): import("@rspack/core").IgnoreWarnings;
69
+ get autoPages(): {
70
+ path: string;
71
+ } | undefined;
72
+ showLogTitle(o: any): void;
73
+ }
74
+ declare const _default: EmpConfig;
75
+ export default _default;
@@ -0,0 +1,179 @@
1
+ import type { Configuration as RsConfig, RspackOptions } from '@rspack/core';
2
+ import { deepAssign } from '../helper/utils';
3
+ import { Chain } from './chain';
4
+ import { type EmpConfig } from './empConfig';
5
+ import { StoreServer } from './server';
6
+ import type { EmpOptions, InjectTagsType, StoreRootPaths } from '../types/config';
7
+ import type { CliActionType, CliOptionsType, EMPModeType } from '../types/env';
8
+ export declare class GlobalStore {
9
+ rspack: typeof import("node_modules/@rspack/core/dist/rspack").rspack & typeof import("node_modules/@rspack/core/dist/exports") & {
10
+ rspack: typeof import("node_modules/@rspack/core/dist/rspack").rspack & typeof import("node_modules/@rspack/core/dist/exports") & /*elided*/ any;
11
+ webpack: typeof import("node_modules/@rspack/core/dist/rspack").rspack & typeof import("node_modules/@rspack/core/dist/exports") & /*elided*/ any;
12
+ };
13
+ rspackVersion: string;
14
+ isOldRspack: boolean;
15
+ /**
16
+ * EMP Version
17
+ * @default package version
18
+ */
19
+ empPkg: any;
20
+ /**
21
+ * 项目pkg信息
22
+ */
23
+ pkg: any;
24
+ /**
25
+ * 项目根目录绝对路径
26
+ * @default process.cwd()
27
+ */
28
+ root: string;
29
+ /**
30
+ * emp 内部根路径
31
+ * @default empRoot
32
+ */
33
+ empRoot: string;
34
+ /**
35
+ * emp 执行代码路径
36
+ */
37
+ empSource: string;
38
+ /**
39
+ * 获取项目 根目录绝对路径
40
+ * (*) relativePath 可以是绝对路径
41
+ * @param relativePath
42
+ * @returns
43
+ */
44
+ resolve: (relativePath: string) => string;
45
+ /**
46
+ * 获取项目 emp内部根目录绝对路径
47
+ * @param relativePath
48
+ * @returns
49
+ */
50
+ empResolve: (relativePath: string) => string;
51
+ /**
52
+ * 源码地址 绝对路径
53
+ */
54
+ appSrc: string;
55
+ /**
56
+ * 源码生成目录 绝对路径
57
+ */
58
+ outDir: string;
59
+ /**
60
+ * 静态文件目录 绝对路径
61
+ */
62
+ publicDir: string;
63
+ /**
64
+ * 静态资源
65
+ */
66
+ resource: {
67
+ dir: string;
68
+ key: string;
69
+ cert: string;
70
+ };
71
+ /**
72
+ * chain 配置相关
73
+ */
74
+ chainName: {
75
+ rule: {
76
+ mjs: string;
77
+ typescript: string;
78
+ javascript: string;
79
+ sourceMap: string;
80
+ inline: string;
81
+ raw: string;
82
+ svg: string;
83
+ image: string;
84
+ font: string;
85
+ svga: string;
86
+ sass: string;
87
+ less: string;
88
+ css: string;
89
+ };
90
+ use: {
91
+ swc: string;
92
+ sourceMap: string;
93
+ sass: string;
94
+ less: string;
95
+ };
96
+ plugin: {
97
+ tsCheckerRspackPlugin: string;
98
+ bundleAnalyzer: string;
99
+ define: string;
100
+ copy: string;
101
+ progress: string;
102
+ html: {
103
+ prefix: string;
104
+ };
105
+ rsdoctor: string;
106
+ sourceMapDevTool: string;
107
+ };
108
+ minimizer: {
109
+ minJs: string;
110
+ minCss: string;
111
+ };
112
+ };
113
+ /**
114
+ * server 配置相关
115
+ */
116
+ server: StoreServer;
117
+ /**
118
+ * 缓存目录 绝对路径
119
+ */
120
+ cacheDir: string;
121
+ mode: EMPModeType;
122
+ cliMode: 'dev' | 'prod';
123
+ isDev: boolean;
124
+ /**
125
+ * 项目配置
126
+ */
127
+ chain: Chain;
128
+ rsConfig: RsConfig;
129
+ empOptions: EmpOptions;
130
+ empConfig: EmpConfig;
131
+ entries: {
132
+ [chunkName: string]: RspackOptions['entry'];
133
+ };
134
+ debug: EmpConfig['debug'];
135
+ cliAction: CliActionType;
136
+ cliOptions: CliOptionsType;
137
+ rootPaths: StoreRootPaths;
138
+ beforeSetup?: () => Promise<void> | void;
139
+ afterSetup?: () => Promise<void> | void;
140
+ setup(cliAction?: CliActionType, cliOptions?: any): Promise<void>;
141
+ /**
142
+ * 初始化 基础变量
143
+ * @param mode cli名称
144
+ * @param cliOptions cli配置
145
+ */
146
+ private initVars;
147
+ /**
148
+ * 初始化 基础路径
149
+ */
150
+ private initPaths;
151
+ /**
152
+ * 设置 日志等级
153
+ */
154
+ private loggerExtensionName;
155
+ setLoggerExtensionName(name: string): void;
156
+ setLogger(): void;
157
+ merge(o: RspackOptions): void;
158
+ /**
159
+ * 同步 chain 配置到 rsConfig
160
+ */
161
+ toConfig(): void;
162
+ /**
163
+ * 打印 config
164
+ */
165
+ logConfig(): void;
166
+ get browserslistOptions(): {
167
+ default: string[];
168
+ h5: string[];
169
+ node: string[];
170
+ };
171
+ get uniqueName(): string;
172
+ encodeVarName(name: string): string;
173
+ vCompare: (preVersion?: string, lastVersion?: string) => number;
174
+ deepAssign: typeof deepAssign;
175
+ getLanIp: () => string;
176
+ injectTags(o?: InjectTagsType, name?: string, chunk?: string): void;
177
+ }
178
+ declare const _default: GlobalStore;
179
+ export default _default;