@empjs/cli 3.12.0 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -13
- package/dist/index.js +6 -6
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var Ri=Object.create;var ue=Object.defineProperty;var ji=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ni=Object.prototype.hasOwnProperty;var w=(s,e)=>()=>(s&&(e=s(s=0)),e);var X=(s,e)=>{for(var t in e)ue(s,t,{get:e[t],enumerable:!0})},Ft=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ai(e))!Ni.call(s,r)&&r!==t&&ue(s,r,{get:()=>e[r],enumerable:!(i=ji(e,r))||i.enumerable});return s};var d=(s,e,t)=>(t=s!=null?Ri(Li(s)):{},Ft(e||!s||!s.__esModule?ue(t,"default",{value:s,enumerable:!0}):t,s)),Fi=s=>Ft(ue({},"__esModule",{value:!0}),s);var c=w(()=>{"use strict"});var me,ze=w(()=>{me={name:"@empjs/cli",version:"3.12.0",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",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"}}});function Wt(s,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=T.FILE_DIR_TYPE),t&&(e.type=t),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!$t.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${$t.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=s,new We(e)}var z,zt,H,T,He,Ht,Ii,$t,Mi,zi,Hi,Wi,It,Mt,We,Gt=w(()=>{"use strict";c();z=require("fs/promises"),zt=require("stream"),H=require("path"),T={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},He={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:T.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(He);Ht="READDIRP_RECURSIVE_ERROR",Ii=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ht]),$t=[T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE],Mi=new Set([T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE]),zi=new Set([T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE]),Hi=s=>Ii.has(s.code),Wi=process.platform==="win32",It=s=>!0,Mt=s=>{if(s===void 0)return It;if(typeof s=="function")return s;if(typeof s=="string"){let e=s.trim();return t=>t.basename===e}if(Array.isArray(s)){let e=s.map(t=>t.trim());return t=>e.some(i=>t.basename===i)}return It},We=class extends zt.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...He,...e},{root:i,type:r}=t;this._fileFilter=Mt(t.fileFilter),this._directoryFilter=Mt(t.directoryFilter);let o=t.lstat?z.lstat:z.stat;Wi?this._stat=a=>o(a,{bigint:!0}):this._stat=o,this._maxDepth=t.depth??He.depth,this._wantsDir=r?Mi.has(r):!1,this._wantsFile=r?zi.has(r):!1,this._wantsEverything=r===T.EVERYTHING_TYPE,this._root=(0,H.resolve)(i),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,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,i=t&&t.files;if(i&&i.length>0){let{path:r,depth:o}=t,a=i.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 i;try{i=await(0,z.readdir)(e,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:t,path:e}}async _formatEntry(e,t){let i,r=this._isDirent?e.name:e;try{let o=(0,H.resolve)((0,H.join)(t,r));i={path:(0,H.relative)(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return i}_onError(e){Hi(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 i=e.fullPath;try{let r=await(0,z.realpath)(i),o=await(0,z.lstat)(r);if(o.isFile())return"file";if(o.isDirectory()){let a=r.length;if(i.startsWith(r)&&i.substr(a,1)===H.sep){let n=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return n.code=Ht,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()}}});function Ut(s,e,t,i,r){let o=(a,n)=>{t(s),r(a,n,{watchedPath:s}),n&&s!==n&&ye(P.resolve(s,n),V,P.join(s,n))};try{return(0,Y.watch)(s,{persistent:e.persistent},o)}catch(a){i(a);return}}var Y,N,P,Bt,Gi,Be,Jt,ve,be,Je,Ui,Bi,Ji,Vt,_,L,Vi,Yi,V,de,K,qi,Xi,Ki,Ue,ie,Qi,re,Yt,ge,ye,Zi,Ge,er,we,qt=w(()=>{"use strict";c();Y=require("fs"),N=require("fs/promises"),P=d(require("path"),1),Bt=require("os"),Gi="data",Be="end",Jt="close",ve=()=>{},be=process.platform,Je=be==="win32",Ui=be==="darwin",Bi=be==="linux",Ji=be==="freebsd",Vt=(0,Bt.type)()==="OS400",_={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},L=_,Vi="watch",Yi={lstat:N.lstat,stat:N.stat},V="listeners",de="errHandlers",K="rawEmitters",qi=[V,de,K],Xi=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"]),Ki=s=>Xi.has(P.extname(s).slice(1).toLowerCase()),Ue=(s,e)=>{s instanceof Set?s.forEach(e):e(s)},ie=(s,e,t)=>{let i=s[e];i instanceof Set||(s[e]=i=new Set([i])),i.add(t)},Qi=s=>e=>{let t=s[e];t instanceof Set?t.clear():delete s[e]},re=(s,e,t)=>{let i=s[e];i instanceof Set?i.delete(t):i===t&&delete s[e]},Yt=s=>s instanceof Set?s.size===0:!s,ge=new Map;ye=(s,e,t,i,r)=>{let o=ge.get(s);o&&Ue(o[e],a=>{a(t,i,r)})},Zi=(s,e,t,i)=>{let{listener:r,errHandler:o,rawEmitter:a}=i,n=ge.get(e),l;if(!t.persistent)return l=Ut(s,t,r,o,a),l?l.close.bind(l):void 0;if(n)ie(n,V,r),ie(n,de,o),ie(n,K,a);else{if(l=Ut(s,t,ye.bind(null,e,V),o,ye.bind(null,e,K)),!l)return;l.on(L.ERROR,async f=>{let p=ye.bind(null,e,de);if(n&&(n.watcherUnusable=!0),Je&&f.code==="EPERM")try{await(await(0,N.open)(s,"r")).close(),p(f)}catch{}else p(f)}),n={listeners:r,errHandlers:o,rawEmitters:a,watcher:l},ge.set(e,n)}return()=>{re(n,V,r),re(n,de,o),re(n,K,a),Yt(n.listeners)&&(n.watcher.close(),ge.delete(e),qi.forEach(Qi(n)),n.watcher=void 0,Object.freeze(n))}},Ge=new Map,er=(s,e,t,i)=>{let{listener:r,rawEmitter:o}=i,a=Ge.get(e),n=a&&a.options;return n&&(n.persistent<t.persistent||n.interval>t.interval)&&((0,Y.unwatchFile)(e),a=void 0),a?(ie(a,V,r),ie(a,K,o)):(a={listeners:r,rawEmitters:o,options:t,watcher:(0,Y.watchFile)(e,t,(l,f)=>{Ue(a.rawEmitters,m=>{m(L.CHANGE,e,{curr:l,prev:f})});let p=l.mtimeMs;(l.size!==f.size||p>f.mtimeMs||p===0)&&Ue(a.listeners,m=>m(s,l))})},Ge.set(e,a)),()=>{re(a,V,r),re(a,K,o),Yt(a.listeners)&&(Ge.delete(e),(0,Y.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},we=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let i=this.fsw.options,r=P.dirname(e),o=P.basename(e);this.fsw._getWatchedDir(r).add(o);let n=P.resolve(e),l={persistent:i.persistent};t||(t=ve);let f;if(i.usePolling){let p=i.interval!==i.binaryInterval;l.interval=p&&Ki(o)?i.binaryInterval:i.interval,f=er(e,n,l,{listener:t,rawEmitter:this.fsw._emitRaw})}else f=Zi(e,n,l,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return f}_handleFile(e,t,i){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,m)=>{if(this.fsw._throttle(Vi,e,5)){if(!m||m.mtimeMs===0)try{let u=await(0,N.stat)(e);if(this.fsw.closed)return;let b=u.atimeMs,C=u.mtimeMs;if((!b||b<=C||C!==n.mtimeMs)&&this.fsw._emit(L.CHANGE,e,u),(Ui||Bi||Ji)&&n.ino!==u.ino){this.fsw._closeFile(p),n=u;let E=this._watchWithNodeFs(e,l);E&&this.fsw._addPathCloser(p,E)}else n=u}catch{this.fsw._remove(r,o)}else if(a.has(o)){let u=m.atimeMs,b=m.mtimeMs;(!u||u<=b||b!==n.mtimeMs)&&this.fsw._emit(L.CHANGE,e,m),n=m}}},f=this._watchWithNodeFs(e,l);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(L.ADD,e,0))return;this.fsw._emit(L.ADD,e,t)}return f}async _handleSymlink(e,t,i,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(0,N.realpath)(i)}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(L.CHANGE,i,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(o,n),this.fsw._emit(L.ADD,i,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,t,i,r,o,a,n){if(e=P.join(e,""),n=this.fsw._throttle("readdir",e,1e3),!n)return;let l=this.fsw._getWatchedDir(i.path),f=new Set,p=this.fsw._readdirp(e,{fileFilter:m=>i.filterPath(m),directoryFilter:m=>i.filterDir(m)});if(p)return p.on(Gi,async m=>{if(this.fsw.closed){p=void 0;return}let u=m.path,b=P.join(e,u);if(f.add(u),!(m.stats.isSymbolicLink()&&await this._handleSymlink(m,e,b,u))){if(this.fsw.closed){p=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),b=P.join(o,P.relative(o,b)),this._addToNodeFs(b,t,i,a+1))}}).on(L.ERROR,this._boundHandleError),new Promise((m,u)=>{if(!p)return u();p.once(Be,()=>{if(this.fsw.closed){p=void 0;return}let b=n?n.clear():!1;m(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,i,r,o,a,n)})})}async _handleDir(e,t,i,r,o,a,n){let l=this.fsw._getWatchedDir(P.dirname(e)),f=l.has(P.basename(e));!(i&&this.fsw.options.ignoreInitial)&&!o&&!f&&this.fsw._emit(L.ADD_DIR,e,t),l.add(P.basename(e)),this.fsw._getWatchedDir(e);let p,m,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(n)){if(!o&&(await this._handleRead(e,i,a,o,e,r,p),this.fsw.closed))return;m=this._watchWithNodeFs(e,(b,C)=>{C&&C.mtimeMs===0||this._handleRead(b,!1,a,o,e,r,p)})}return m}async _addToNodeFs(e,t,i,r,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let n=this.fsw._getWatchHelpers(e);i&&(n.filterPath=l=>i.filterPath(l),n.filterDir=l=>i.filterDir(l));try{let l=await Yi[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 m=P.resolve(e),u=f?await(0,N.realpath)(e):e;if(this.fsw.closed||(p=await this._handleDir(n.watchPath,l,t,r,o,n,u),this.fsw.closed))return;m!==u&&u!==void 0&&this.fsw._symlinkPaths.set(m,u)}else if(l.isSymbolicLink()){let m=f?await(0,N.realpath)(e):e;if(this.fsw.closed)return;let u=P.dirname(n.watchPath);if(this.fsw._getWatchedDir(u).add(n.watchPath),this.fsw._emit(L.ADD,n.watchPath,l),p=await this._handleDir(u,l,t,r,e,n,m),this.fsw.closed)return;m!==void 0&&this.fsw._symlinkPaths.set(P.resolve(e),m)}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}}}});function Ce(s){return Array.isArray(s)?s:[s]}function ar(s){return typeof s=="function"?s:typeof s=="string"?e=>s===e:s instanceof RegExp?e=>s.test(e):typeof s=="object"&&s!==null?e=>{if(s.path===e)return!0;if(s.recursive){let t=y.relative(s.path,e);return t?!t.startsWith("..")&&!y.isAbsolute(t):!1}return!1}:()=>!1}function lr(s){if(typeof s!="string")throw new Error("string expected");s=y.normalize(s),s=s.replace(/\\/g,"/");let e=!1;s.startsWith("//")&&(e=!0);let t=/\/\//;for(;s.match(t);)s=s.replace(t,"/");return e&&(s="/"+s),s}function Kt(s,e,t){let i=lr(e);for(let r=0;r<s.length;r++){let o=s[r];if(o(i,t))return!0}return!1}function pr(s,e){if(s==null)throw new TypeError("anymatch: specify first argument");let i=Ce(s).map(r=>ar(r));return e==null?(r,o)=>Kt(i,r,o):Kt(i,e)}function mr(s,e={}){let t=new Ee(e);return t.add(s),t}var ts,Pe,ss,y,Ve,tr,is,sr,ir,rr,Xt,or,nr,Ye,Qt,Zt,rs,es,cr,hr,qe,fr,ur,Xe,Ee,os,ns=w(()=>{"use strict";c();ts=require("fs"),Pe=require("fs/promises"),ss=require("events"),y=d(require("path"),1);Gt();qt();Ve="/",tr="//",is=".",sr="..",ir="string",rr=/\\/g,Xt=/\/\//,or=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,nr=/^\.[/\\]/;Ye=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Qt=s=>{let e=Ce(s).flat();if(!e.every(t=>typeof t===ir))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(rs)},Zt=s=>{let e=s.replace(rr,Ve),t=!1;for(e.startsWith(tr)&&(t=!0);e.match(Xt);)e=e.replace(Xt,Ve);return t&&(e=Ve+e),e},rs=s=>Zt(y.normalize(Zt(s))),es=(s="")=>e=>typeof e=="string"?rs(y.isAbsolute(e)?e:y.join(s,e)):e,cr=(s,e)=>y.isAbsolute(s)?s:y.join(e,s),hr=Object.freeze(new Set),qe=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==is&&e!==sr&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let i=this.path;try{await(0,Pe.readdir)(i)}catch{this._removeWatcher&&this._removeWatcher(y.dirname(i),y.basename(i))}}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=ve,this.items=hr,Object.freeze(this)}},fr="stat",ur="lstat",Xe=class{constructor(e,t,i){this.fsw=i;let r=e;this.path=e=e.replace(nr,""),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?fr:ur}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 i=this.entryPath(e);return this.fsw._isntIgnored(i,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Ee=class extends ss.EventEmitter{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,i={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?Ce(e.ignored):Ce([]),awaitWriteFinish:t===!0?i:typeof t=="object"?{...i,...t}:!1};Vt&&(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=ve,this._readyEmitted=!0,process.nextTick(()=>this.emit(_.READY)))},this._emitRaw=(...l)=>this.emit(_.RAW,...l),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new we(this),Object.freeze(r)}_addIgnoredPath(e){if(Ye(e)){for(let t of this._ignoredPaths)if(Ye(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)Ye(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let o=Qt(e);return r&&(o=o.map(a=>cr(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,!i,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=Qt(e),{cwd:i}=this.options;return t.forEach(r=>{!y.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=y.join(i,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(i=>{let r=i();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,i)=>{let o=(this.options.cwd?y.relative(this.options.cwd,i):i)||is;e[o]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==_.ERROR&&this.emit(_.ALL,e,...t)}async _emit(e,t,i){if(this.closed)return;let r=this.options;Je&&(t=y.normalize(t)),r.cwd&&(t=y.relative(r.cwd,t));let o=[t];i!=null&&o.push(i);let a=r.awaitWriteFinish,n;if(a&&(n=this._pendingWrites.get(t)))return n.lastChange=new Date,this;if(r.atomic){if(e===_.UNLINK)return this._pendingUnlinks.set(t,[e,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((l,f)=>{this.emit(...l),this.emit(_.ALL,...l),this._pendingUnlinks.delete(f)})},typeof r.atomic=="number"?r.atomic:100),this;e===_.ADD&&this._pendingUnlinks.has(t)&&(e=_.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===_.ADD||e===_.CHANGE)&&this._readyEmitted){let l=(f,p)=>{f?(e=_.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===_.CHANGE&&!this._throttle(_.CHANGE,t,50))return this;if(r.alwaysStat&&i===void 0&&(e===_.ADD||e===_.ADD_DIR||e===_.CHANGE)){let l=r.cwd?y.join(r.cwd,t):t,f;try{f=await(0,Pe.stat)(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(_.ERROR,e),e||this.closed}_throttle(e,t,i){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,i);let l={timeoutObject:a,clear:n,count:0};return r.set(t,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,i,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 m(u){(0,ts.stat)(l,(b,C)=>{if(b||!p.has(e)){b&&b.code!=="ENOENT"&&r(b);return}let E=Number(new Date);u&&C.size!==u.size&&(p.get(e).lastChange=E);let O=p.get(e);E-O.lastChange>=t?(p.delete(e),r(void 0,C)):n=setTimeout(m,a,C)})}p.has(e)||(p.set(e,{lastChange:f,cancelWait:()=>(p.delete(e),clearTimeout(n),i)}),n=setTimeout(m,a))}_isIgnored(e,t){if(this.options.atomic&&or.test(e))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(es(i)),n=[...[...this._ignoredPaths].map(es(i)),...o];this._userIgnored=pr(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Xe(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=y.resolve(e);return this._watched.has(t)||this._watched.set(t,new qe(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,i){let r=y.join(e,t),o=y.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));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()===_.ADD)return;this._watched.delete(r),this._watched.delete(o);let m=i?_.UNLINK_DIR:_.UNLINK;f&&!this._isIgnored(r)&&this._emit(m,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(i=>i()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let i=this._closers.get(e);i||(i=[],this._closers.set(e,i)),i.push(t)}_readdirp(e,t){if(this.closed)return;let i={type:_.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=Wt(e,i);return this._streams.add(r),r.once(Jt,()=>{r=void 0}),r.once(Be,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};os={watch:mr,FSWatcher:Ee}});var k,dr,G,gr,yr,wr,Ke,_e,vr,br,Q,Qe,Cr,Ze,Z,x,ee=w(()=>{"use strict";c();k=d(require("chalk"),1),dr=k.default.hex("#1abc9c"),G=k.default.hex("#16a085"),gr=k.default.hex("#2ecc71"),yr=k.default.hex("#27ae60"),wr=k.default.hex("#e74c3c"),Ke=k.default.hex("#c0392b"),_e=k.default.hex("#f1c40f"),vr=k.default.hex("#f39c12"),br=k.default.hex("#3498db"),Q=k.default.hex("#2980b9"),Qe=k.default.hex("#ecf0f1"),Cr=k.default.hex("#fd79a8"),Ze=k.default.hex("#e84393"),Z=k.default.hex("#7f8c8d"),x={lightGreen:dr,green:G,lightCyan:gr,cyan:yr,lightRed:wr,red:Ke,yellow:_e,orange:vr,lightBlue:br,blue:Q,white:Qe,lightMagenta:Cr,magenta:Ze,gray:Z}});var as,oe,h,F=w(()=>{"use strict";c();ee();as=!1,oe=class{brandName="";fullName="";logLevel=as?"debug":"info";isLogTime=as;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,this.fullName=x.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(`${x.lightBlue(this.brandName)}${x.blue(` ${e} `)}
|
|
2
|
-
`)};cyan=e=>{console.log(`${
|
|
3
|
-
`)};magenta=e=>{console.log(`${
|
|
4
|
-
`)};green=e=>{console.log(`${
|
|
5
|
-
`)};yellow=e=>{console.log(`${
|
|
6
|
-
`)};red=e=>{console.log(`${
|
|
7
|
-
`)};sysError=e=>{console.log(`${
|
|
8
|
-
`)};link=e=>
|
|
9
|
-
`)}},h=new oe});var it={};X(it,{clearConsole:()=>tt,deepAssign:()=>D,ensureArray:()=>Er,getLanIp:()=>q,getPkgVersion:()=>et,importJsVm:()=>st,jsonFilter:()=>Pr,timeFormat:()=>Se,vCompare:()=>xe});function tt(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function D(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=D(o,r);continue}s[i]=t[i]}return s}var ls,ps,cs,hs,q,et,Er,Pr,xe,Se,st,$=w(()=>{"use strict";c();ls=require("address"),ps=d(require("chalk"),1),cs=require("default-gateway"),hs=d(require("fs-extra"),1),q=()=>{let s="127.0.0.1";try{let{int:e}=(0,cs.gateway4sync)();return(0,ls.ip)(e||"")||s}catch{return s}},et=s=>{try{let{version:e}=hs.default.readJSONSync(s);return e}catch{return}};Er=s=>Array.isArray(s)?s:[s],Pr=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),xe=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},Se=s=>{s=s/1e3;let e=i=>ps.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},st=s=>`data:text/javascript,${s}`});var rt={};X(rt,{chalk:()=>fs.default,color:()=>x,glob:()=>ne.glob,logger:()=>h,utils:()=>it});var fs,ne,te=w(()=>{"use strict";c();fs=d(require("chalk"),1),ne=require("glob");ee();F();$()});var ot,us,nt,_r,ms,ds,gs,ys,ke=w(()=>{"use strict";c();ot=d(require("fs"),1),us=require("jiti"),nt=d(require("path"),1);I();ze();F();_r=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],ms=(0,us.createJiti)(__filename,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:me.version}),ds=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=_r.map(r=>nt.default.resolve(g.root,r)),t=await Promise.all(e.map(r=>ot.default.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},gs=async()=>{let s=nt.default.join(g.root,"tsconfig.json");return await ot.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},ys=()=>{let s=[__filename];return g.rootPaths.pkg&&s.push(g.rootPaths.pkg),g.rootPaths.empConfig&&s.push(g.rootPaths.empConfig),g.rootPaths.tsConfig&&s.push(g.rootPaths.tsConfig),s}});var at,ws,lt=w(()=>{"use strict";c();at=d(require("@empjs/chain"),1),ws={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Oe,vs=w(()=>{"use strict";c();Oe=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var pt,bs,Cs=w(()=>{"use strict";c();te();ke();$();vs();pt=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},D(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Oe(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return D({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await ms(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}showLogTitle(e){this.store.empOptions.showLogTitle?this.store.empOptions.showLogTitle(e):h.title(`${e.cliAction}`)}},bs=new pt});var Es,ct,Ps,_s=w(()=>{"use strict";c();Es=d(require("fs-extra"),1);ke();ct=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:ys(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Es.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"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})}},Ps=new ct});var ht,xs,Ss=w(()=>{"use strict";c();ht=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:require.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},xs=new ht});function xr(){let s=[`import 'core-js/${g.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
|
-
`);return st(s)}var De,Te,ae,Re=w(()=>{"use strict";c();De=d(require("html-webpack-plugin"),1);$();I();Te=class{constructor(){}apply(e){let{webpack:t}=e;g.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,xr(),{name:void 0}).apply(e)}},ae=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{De.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});var R,ft,ks,Os=w(()=>{"use strict";c();R=d(require("path"),1);te();Re();ft=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(R.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${R.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(R.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(De.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=R.default.join(this.store.appSrc,e),i=R.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,ne.glob)([i],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${R.default.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},R.default.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=R.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),i=await(0,ne.glob)([t],{windowsPathsNoEscape:!0});if(i[0]){let r=R.default.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(r,this.store.empConfig.html,i[0])}h.timeEnd(e)}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},ks=new ft});var ut,mt,Ts,Ds=w(()=>{"use strict";c();ut=d(require("path"),1);$();mt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:D(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",ut.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=et(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ut.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ts=new mt});var M,dt,Rs,js,gt,As,Ls=w(()=>{"use strict";c();M=d(require("@rspack/core"),1),dt=d(require("fs"),1),Rs=d(require("path"),1),js=require("ts-checker-rspack-plugin");Re();gt=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(Te)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(js.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");dt.default.existsSync(e)&&dt.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.default.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.default.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=Rs.default.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.default.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},As=new gt});var yt,Ns,Fs=w(()=>{"use strict";c();_s();Ss();Os();Ds();Ls();yt=class{store;async setup(e){this.store=e;let t=[Ps.setup(this.store),Ts.setup(this.store),As.setup(this.store),ks.setup(this.store),xs.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},Ns=new yt});async function je(s,e=void 0){if(s!==Sr&&(s<$s||s>wt))throw new Error(`Port number must lie between ${$s} and ${wt}`);let t=s,i=kr(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=wt;)try{return await Tr(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var Is,Ms,$s,wt,Sr,kr,Or,Tr,zs=w(()=>{"use strict";c();Is=d(require("net"),1),Ms=d(require("os"),1),$s=1024,wt=65535,Sr=443,kr=()=>{let s=Ms.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Or=(s,e)=>new Promise((t,i)=>{let r=Is.default.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),Tr=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Or(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});var Hs,vt,bt,Ae,Ws=w(()=>{"use strict";c();Hs=d(require("chalk"),1);ee();vt=d(require("url"),1);$();bt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:Z("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=q;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:Hs.default.bold(i),pathname:r})}},Ae=new bt});var Us,Bs,Js,Gs,Dr,Rr,Vs,Ys=w(()=>{"use strict";c();Us=require("child_process"),Bs=require("util");I();F();Js=(0,Bs.promisify)(Us.exec),Gs=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Dr=async()=>{let s=process.env.BROWSER;if(!s||!Gs.includes(s)){let{stdout:e}=await Js("ps cax");s=Gs.find(t=>e.includes(t))}return s},Rr=async s=>{if(process.platform==="darwin")try{let t=await Dr();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Js(i,{cwd:g.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Vs=Rr});var Ct,Le,qs=w(()=>{"use strict";c();Ct=d(require("fs/promises"),1);te();ee();zs();Ws();Ys();$();Le=class{ip=q();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await je(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await je(e.empConfig.server.port)),Ae.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Ae.prettyPrintUrl("localhost")):(this.urls=Ae.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(this.publicPath)}`)):(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(e.lanUrlForTerminal)}
|
|
11
|
-
`)),this.isOpenBrower&&Vs(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([Ct.default.readFile(e.resource.key),Ct.default.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await je(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Xs,j,Ks,Et,Pt,g,I=w(()=>{"use strict";c();Xs=d(require("fs/promises"),1),j=d(require("path"),1),Ks=d(require("util"),1),Et=require("@rspack/core");ke();
|
|
1
|
+
"use strict";var ji=Object.create;var ue=Object.defineProperty;var Ai=Object.getOwnPropertyDescriptor;var Li=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,Ni=Object.prototype.hasOwnProperty;var w=(s,e)=>()=>(s&&(e=s(s=0)),e);var K=(s,e)=>{for(var t in e)ue(s,t,{get:e[t],enumerable:!0})},Nt=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Li(e))!Ni.call(s,r)&&r!==t&&ue(s,r,{get:()=>e[r],enumerable:!(i=Ai(e,r))||i.enumerable});return s};var d=(s,e,t)=>(t=s!=null?ji(Fi(s)):{},Nt(e||!s||!s.__esModule?ue(t,"default",{value:s,enumerable:!0}):t,s)),$i=s=>Nt(ue({},"__esModule",{value:!0}),s);var c=w(()=>{"use strict"});var me,ze=w(()=>{me={name:"@empjs/cli",version:"3.12.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"}}});function Wt(s,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=T.FILE_DIR_TYPE),t&&(e.type=t),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!$t.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${$t.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=s,new We(e)}var z,zt,H,T,He,Ht,Mi,$t,zi,Hi,Wi,Gi,It,Mt,We,Gt=w(()=>{"use strict";c();z=require("fs/promises"),zt=require("stream"),H=require("path"),T={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},He={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:T.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(He);Ht="READDIRP_RECURSIVE_ERROR",Mi=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ht]),$t=[T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE],zi=new Set([T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE]),Hi=new Set([T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE]),Wi=s=>Mi.has(s.code),Gi=process.platform==="win32",It=s=>!0,Mt=s=>{if(s===void 0)return It;if(typeof s=="function")return s;if(typeof s=="string"){let e=s.trim();return t=>t.basename===e}if(Array.isArray(s)){let e=s.map(t=>t.trim());return t=>e.some(i=>t.basename===i)}return It},We=class extends zt.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...He,...e},{root:i,type:r}=t;this._fileFilter=Mt(t.fileFilter),this._directoryFilter=Mt(t.directoryFilter);let o=t.lstat?z.lstat:z.stat;Gi?this._stat=a=>o(a,{bigint:!0}):this._stat=o,this._maxDepth=t.depth??He.depth,this._wantsDir=r?zi.has(r):!1,this._wantsFile=r?Hi.has(r):!1,this._wantsEverything=r===T.EVERYTHING_TYPE,this._root=(0,H.resolve)(i),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,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,i=t&&t.files;if(i&&i.length>0){let{path:r,depth:o}=t,a=i.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 i;try{i=await(0,z.readdir)(e,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:t,path:e}}async _formatEntry(e,t){let i,r=this._isDirent?e.name:e;try{let o=(0,H.resolve)((0,H.join)(t,r));i={path:(0,H.relative)(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return i}_onError(e){Wi(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 i=e.fullPath;try{let r=await(0,z.realpath)(i),o=await(0,z.lstat)(r);if(o.isFile())return"file";if(o.isDirectory()){let a=r.length;if(i.startsWith(r)&&i.substr(a,1)===H.sep){let n=new Error(`Circular symlink detected: "${i}" points to "${r}"`);return n.code=Ht,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()}}});function Ut(s,e,t,i,r){let o=(a,n)=>{t(s),r(a,n,{watchedPath:s}),n&&s!==n&&ye(P.resolve(s,n),V,P.join(s,n))};try{return(0,Y.watch)(s,{persistent:e.persistent},o)}catch(a){i(a);return}}var Y,F,P,Bt,Ui,Be,Jt,ve,be,Je,Bi,Ji,Vi,Vt,x,L,Yi,qi,V,de,Q,Xi,Ki,Qi,Ue,ie,Zi,re,Yt,ge,ye,er,Ge,tr,we,qt=w(()=>{"use strict";c();Y=require("fs"),F=require("fs/promises"),P=d(require("path"),1),Bt=require("os"),Ui="data",Be="end",Jt="close",ve=()=>{},be=process.platform,Je=be==="win32",Bi=be==="darwin",Ji=be==="linux",Vi=be==="freebsd",Vt=(0,Bt.type)()==="OS400",x={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},L=x,Yi="watch",qi={lstat:F.lstat,stat:F.stat},V="listeners",de="errHandlers",Q="rawEmitters",Xi=[V,de,Q],Ki=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"]),Qi=s=>Ki.has(P.extname(s).slice(1).toLowerCase()),Ue=(s,e)=>{s instanceof Set?s.forEach(e):e(s)},ie=(s,e,t)=>{let i=s[e];i instanceof Set||(s[e]=i=new Set([i])),i.add(t)},Zi=s=>e=>{let t=s[e];t instanceof Set?t.clear():delete s[e]},re=(s,e,t)=>{let i=s[e];i instanceof Set?i.delete(t):i===t&&delete s[e]},Yt=s=>s instanceof Set?s.size===0:!s,ge=new Map;ye=(s,e,t,i,r)=>{let o=ge.get(s);o&&Ue(o[e],a=>{a(t,i,r)})},er=(s,e,t,i)=>{let{listener:r,errHandler:o,rawEmitter:a}=i,n=ge.get(e),l;if(!t.persistent)return l=Ut(s,t,r,o,a),l?l.close.bind(l):void 0;if(n)ie(n,V,r),ie(n,de,o),ie(n,Q,a);else{if(l=Ut(s,t,ye.bind(null,e,V),o,ye.bind(null,e,Q)),!l)return;l.on(L.ERROR,async f=>{let p=ye.bind(null,e,de);if(n&&(n.watcherUnusable=!0),Je&&f.code==="EPERM")try{await(await(0,F.open)(s,"r")).close(),p(f)}catch{}else p(f)}),n={listeners:r,errHandlers:o,rawEmitters:a,watcher:l},ge.set(e,n)}return()=>{re(n,V,r),re(n,de,o),re(n,Q,a),Yt(n.listeners)&&(n.watcher.close(),ge.delete(e),Xi.forEach(Zi(n)),n.watcher=void 0,Object.freeze(n))}},Ge=new Map,tr=(s,e,t,i)=>{let{listener:r,rawEmitter:o}=i,a=Ge.get(e),n=a&&a.options;return n&&(n.persistent<t.persistent||n.interval>t.interval)&&((0,Y.unwatchFile)(e),a=void 0),a?(ie(a,V,r),ie(a,Q,o)):(a={listeners:r,rawEmitters:o,options:t,watcher:(0,Y.watchFile)(e,t,(l,f)=>{Ue(a.rawEmitters,m=>{m(L.CHANGE,e,{curr:l,prev:f})});let p=l.mtimeMs;(l.size!==f.size||p>f.mtimeMs||p===0)&&Ue(a.listeners,m=>m(s,l))})},Ge.set(e,a)),()=>{re(a,V,r),re(a,Q,o),Yt(a.listeners)&&(Ge.delete(e),(0,Y.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},we=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let i=this.fsw.options,r=P.dirname(e),o=P.basename(e);this.fsw._getWatchedDir(r).add(o);let n=P.resolve(e),l={persistent:i.persistent};t||(t=ve);let f;if(i.usePolling){let p=i.interval!==i.binaryInterval;l.interval=p&&Qi(o)?i.binaryInterval:i.interval,f=tr(e,n,l,{listener:t,rawEmitter:this.fsw._emitRaw})}else f=er(e,n,l,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return f}_handleFile(e,t,i){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,m)=>{if(this.fsw._throttle(Yi,e,5)){if(!m||m.mtimeMs===0)try{let u=await(0,F.stat)(e);if(this.fsw.closed)return;let b=u.atimeMs,C=u.mtimeMs;if((!b||b<=C||C!==n.mtimeMs)&&this.fsw._emit(L.CHANGE,e,u),(Bi||Ji||Vi)&&n.ino!==u.ino){this.fsw._closeFile(p),n=u;let E=this._watchWithNodeFs(e,l);E&&this.fsw._addPathCloser(p,E)}else n=u}catch{this.fsw._remove(r,o)}else if(a.has(o)){let u=m.atimeMs,b=m.mtimeMs;(!u||u<=b||b!==n.mtimeMs)&&this.fsw._emit(L.CHANGE,e,m),n=m}}},f=this._watchWithNodeFs(e,l);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(L.ADD,e,0))return;this.fsw._emit(L.ADD,e,t)}return f}async _handleSymlink(e,t,i,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(0,F.realpath)(i)}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(L.CHANGE,i,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(o,n),this.fsw._emit(L.ADD,i,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,t,i,r,o,a,n){if(e=P.join(e,""),n=this.fsw._throttle("readdir",e,1e3),!n)return;let l=this.fsw._getWatchedDir(i.path),f=new Set,p=this.fsw._readdirp(e,{fileFilter:m=>i.filterPath(m),directoryFilter:m=>i.filterDir(m)});if(p)return p.on(Ui,async m=>{if(this.fsw.closed){p=void 0;return}let u=m.path,b=P.join(e,u);if(f.add(u),!(m.stats.isSymbolicLink()&&await this._handleSymlink(m,e,b,u))){if(this.fsw.closed){p=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),b=P.join(o,P.relative(o,b)),this._addToNodeFs(b,t,i,a+1))}}).on(L.ERROR,this._boundHandleError),new Promise((m,u)=>{if(!p)return u();p.once(Be,()=>{if(this.fsw.closed){p=void 0;return}let b=n?n.clear():!1;m(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,i,r,o,a,n)})})}async _handleDir(e,t,i,r,o,a,n){let l=this.fsw._getWatchedDir(P.dirname(e)),f=l.has(P.basename(e));!(i&&this.fsw.options.ignoreInitial)&&!o&&!f&&this.fsw._emit(L.ADD_DIR,e,t),l.add(P.basename(e)),this.fsw._getWatchedDir(e);let p,m,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(n)){if(!o&&(await this._handleRead(e,i,a,o,e,r,p),this.fsw.closed))return;m=this._watchWithNodeFs(e,(b,C)=>{C&&C.mtimeMs===0||this._handleRead(b,!1,a,o,e,r,p)})}return m}async _addToNodeFs(e,t,i,r,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let n=this.fsw._getWatchHelpers(e);i&&(n.filterPath=l=>i.filterPath(l),n.filterDir=l=>i.filterDir(l));try{let l=await qi[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 m=P.resolve(e),u=f?await(0,F.realpath)(e):e;if(this.fsw.closed||(p=await this._handleDir(n.watchPath,l,t,r,o,n,u),this.fsw.closed))return;m!==u&&u!==void 0&&this.fsw._symlinkPaths.set(m,u)}else if(l.isSymbolicLink()){let m=f?await(0,F.realpath)(e):e;if(this.fsw.closed)return;let u=P.dirname(n.watchPath);if(this.fsw._getWatchedDir(u).add(n.watchPath),this.fsw._emit(L.ADD,n.watchPath,l),p=await this._handleDir(u,l,t,r,e,n,m),this.fsw.closed)return;m!==void 0&&this.fsw._symlinkPaths.set(P.resolve(e),m)}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}}}});function Ce(s){return Array.isArray(s)?s:[s]}function lr(s){return typeof s=="function"?s:typeof s=="string"?e=>s===e:s instanceof RegExp?e=>s.test(e):typeof s=="object"&&s!==null?e=>{if(s.path===e)return!0;if(s.recursive){let t=y.relative(s.path,e);return t?!t.startsWith("..")&&!y.isAbsolute(t):!1}return!1}:()=>!1}function pr(s){if(typeof s!="string")throw new Error("string expected");s=y.normalize(s),s=s.replace(/\\/g,"/");let e=!1;s.startsWith("//")&&(e=!0);let t=/\/\//;for(;s.match(t);)s=s.replace(t,"/");return e&&(s="/"+s),s}function Kt(s,e,t){let i=pr(e);for(let r=0;r<s.length;r++){let o=s[r];if(o(i,t))return!0}return!1}function cr(s,e){if(s==null)throw new TypeError("anymatch: specify first argument");let i=Ce(s).map(r=>lr(r));return e==null?(r,o)=>Kt(i,r,o):Kt(i,e)}function dr(s,e={}){let t=new Ee(e);return t.add(s),t}var ts,Pe,ss,y,Ve,sr,is,ir,rr,or,Xt,nr,ar,Ye,Qt,Zt,rs,es,hr,fr,qe,ur,mr,Xe,Ee,os,ns=w(()=>{"use strict";c();ts=require("fs"),Pe=require("fs/promises"),ss=require("events"),y=d(require("path"),1);Gt();qt();Ve="/",sr="//",is=".",ir="..",rr="string",or=/\\/g,Xt=/\/\//,nr=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ar=/^\.[/\\]/;Ye=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Qt=s=>{let e=Ce(s).flat();if(!e.every(t=>typeof t===rr))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(rs)},Zt=s=>{let e=s.replace(or,Ve),t=!1;for(e.startsWith(sr)&&(t=!0);e.match(Xt);)e=e.replace(Xt,Ve);return t&&(e=Ve+e),e},rs=s=>Zt(y.normalize(Zt(s))),es=(s="")=>e=>typeof e=="string"?rs(y.isAbsolute(e)?e:y.join(s,e)):e,hr=(s,e)=>y.isAbsolute(s)?s:y.join(e,s),fr=Object.freeze(new Set),qe=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==is&&e!==ir&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let i=this.path;try{await(0,Pe.readdir)(i)}catch{this._removeWatcher&&this._removeWatcher(y.dirname(i),y.basename(i))}}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=ve,this.items=fr,Object.freeze(this)}},ur="stat",mr="lstat",Xe=class{constructor(e,t,i){this.fsw=i;let r=e;this.path=e=e.replace(ar,""),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?ur:mr}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 i=this.entryPath(e);return this.fsw._isntIgnored(i,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Ee=class extends ss.EventEmitter{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,i={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?Ce(e.ignored):Ce([]),awaitWriteFinish:t===!0?i:typeof t=="object"?{...i,...t}:!1};Vt&&(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=ve,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 we(this),Object.freeze(r)}_addIgnoredPath(e){if(Ye(e)){for(let t of this._ignoredPaths)if(Ye(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)Ye(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,i){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let o=Qt(e);return r&&(o=o.map(a=>hr(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,!i,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=Qt(e),{cwd:i}=this.options;return t.forEach(r=>{!y.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=y.join(i,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(i=>{let r=i();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,i)=>{let o=(this.options.cwd?y.relative(this.options.cwd,i):i)||is;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,i){if(this.closed)return;let r=this.options;Je&&(t=y.normalize(t)),r.cwd&&(t=y.relative(r.cwd,t));let o=[t];i!=null&&o.push(i);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&&i===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(0,Pe.stat)(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,i){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,i);let l={timeoutObject:a,clear:n,count:0};return r.set(t,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,i,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 m(u){(0,ts.stat)(l,(b,C)=>{if(b||!p.has(e)){b&&b.code!=="ENOENT"&&r(b);return}let E=Number(new Date);u&&C.size!==u.size&&(p.get(e).lastChange=E);let O=p.get(e);E-O.lastChange>=t?(p.delete(e),r(void 0,C)):n=setTimeout(m,a,C)})}p.has(e)||(p.set(e,{lastChange:f,cancelWait:()=>(p.delete(e),clearTimeout(n),i)}),n=setTimeout(m,a))}_isIgnored(e,t){if(this.options.atomic&&nr.test(e))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(es(i)),n=[...[...this._ignoredPaths].map(es(i)),...o];this._userIgnored=cr(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Xe(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=y.resolve(e);return this._watched.has(t)||this._watched.set(t,new qe(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,i){let r=y.join(e,t),o=y.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));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 m=i?x.UNLINK_DIR:x.UNLINK;f&&!this._isIgnored(r)&&this._emit(m,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(i=>i()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let i=this._closers.get(e);i||(i=[],this._closers.set(e,i)),i.push(t)}_readdirp(e,t){if(this.closed)return;let i={type:x.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=Wt(e,i);return this._streams.add(r),r.once(Jt,()=>{r=void 0}),r.once(Be,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};os={watch:dr,FSWatcher:Ee}});var k,gr,G,yr,wr,vr,Ke,xe,br,Cr,Z,Qe,Er,Ze,ee,_,te=w(()=>{"use strict";c();k=d(require("chalk"),1),gr=k.default.hex("#1abc9c"),G=k.default.hex("#16a085"),yr=k.default.hex("#2ecc71"),wr=k.default.hex("#27ae60"),vr=k.default.hex("#e74c3c"),Ke=k.default.hex("#c0392b"),xe=k.default.hex("#f1c40f"),br=k.default.hex("#f39c12"),Cr=k.default.hex("#3498db"),Z=k.default.hex("#2980b9"),Qe=k.default.hex("#ecf0f1"),Er=k.default.hex("#fd79a8"),Ze=k.default.hex("#e84393"),ee=k.default.hex("#7f8c8d"),_={lightGreen:gr,green:G,lightCyan:yr,cyan:wr,lightRed:vr,red:Ke,yellow:xe,orange:br,lightBlue:Cr,blue:Z,white:Qe,lightMagenta:Er,magenta:Ze,gray:ee}});var as,oe,h,N=w(()=>{"use strict";c();te();as=!1,oe=class{brandName="";fullName="";logLevel=as?"debug":"info";isLogTime=as;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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} `)}
|
|
2
|
+
`)};cyan=e=>{console.log(`${_.lightCyan(this.brandName)}${_.cyan(` ${e} `)}
|
|
3
|
+
`)};magenta=e=>{console.log(`${_.lightMagenta(this.brandName)}${_.magenta(` ${e} `)}
|
|
4
|
+
`)};green=e=>{console.log(`${_.lightGreen(this.brandName)}${_.green(` ${e} `)}
|
|
5
|
+
`)};yellow=e=>{console.log(`${_.yellow(this.brandName)}${_.orange(` ${e} `)}
|
|
6
|
+
`)};red=e=>{console.log(`${_.lightRed(this.brandName)}${_.red(` ${e} `)}
|
|
7
|
+
`)};sysError=e=>{console.log(`${_.lightRed(" System Error Tips ")}${_.red(` ${e} `)}
|
|
8
|
+
`)};link=e=>_.blue(e);title=e=>{console.log(`${this.fullName}${_.yellow.underline(`${e}`)}
|
|
9
|
+
`)}},h=new oe});var it={};K(it,{clearConsole:()=>tt,deepAssign:()=>D,ensureArray:()=>Pr,getLanIp:()=>q,getPkgVersion:()=>et,importJsVm:()=>st,jsonFilter:()=>xr,timeFormat:()=>Se,vCompare:()=>_e});function tt(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function D(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=D(o,r);continue}s[i]=t[i]}return s}var ls,ps,cs,hs,q,et,Pr,xr,_e,Se,st,$=w(()=>{"use strict";c();ls=require("address"),ps=d(require("chalk"),1),cs=require("default-gateway"),hs=d(require("fs-extra"),1),q=()=>{let s="127.0.0.1";try{let{int:e}=(0,cs.gateway4sync)();return(0,ls.ip)(e||"")||s}catch{return s}},et=s=>{try{let{version:e}=hs.default.readJSONSync(s);return e}catch{return}};Pr=s=>Array.isArray(s)?s:[s],xr=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),_e=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},Se=s=>{s=s/1e3;let e=i=>ps.default.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},st=s=>`data:text/javascript,${s}`});var rt={};K(rt,{chalk:()=>fs.default,color:()=>_,glob:()=>ne.glob,logger:()=>h,utils:()=>it});var fs,ne,se=w(()=>{"use strict";c();fs=d(require("chalk"),1),ne=require("glob");te();N();$()});var ot,us,nt,_r,ms,ds,gs,ys,ke=w(()=>{"use strict";c();ot=d(require("fs"),1),us=require("jiti"),nt=d(require("path"),1);I();ze();N();_r=["emp-config.ts","emp-config.js","emp.config.ts","emp.config.js","emp-config.mjs","emp-config.cjs","emp-config.mts","emp-config.cts","emp.config.mjs","emp.config.cjs","emp.config.mts","emp.config.cts"],ms=(0,us.createJiti)(__filename,{interopDefault:!0,fsCache:!0,moduleCache:!0,cacheVersion:me.version}),ds=async()=>{let s="store.getEmpConfigPath";h.time(s);let e=_r.map(r=>nt.default.resolve(g.root,r)),t=await Promise.all(e.map(r=>ot.default.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},gs=async()=>{let s=nt.default.join(g.root,"tsconfig.json");return await ot.default.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},ys=()=>{let s=[__filename];return g.rootPaths.pkg&&s.push(g.rootPaths.pkg),g.rootPaths.empConfig&&s.push(g.rootPaths.empConfig),g.rootPaths.tsConfig&&s.push(g.rootPaths.tsConfig),s}});var at,ws,lt=w(()=>{"use strict";c();at=d(require("@empjs/chain"),1),ws={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Oe,vs=w(()=>{"use strict";c();Oe=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var pt,bs,Cs=w(()=>{"use strict";c();se();ke();$();vs();pt=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},D(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Oe(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return D({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await ms(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}showLogTitle(e){this.store.empOptions.showLogTitle?this.store.empOptions.showLogTitle(e):h.title(`${e.cliAction}`)}},bs=new pt});var Es,ct,Ps,xs=w(()=>{"use strict";c();Es=d(require("fs-extra"),1);ke();ct=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization(),this.checkTsconfig()];await Promise.all(t)}get cache(){if(this.store.empConfig.cache===!1)return!1;let e={type:this.store.empConfig.cache==="persistent"?"persistent":"memory",buildDependencies:ys(),version:this.store.empConfig.server.port?`${this.store.empPkg.version}_${this.store.empConfig.server.port}`:this.store.empPkg.version};return typeof this.store.empConfig.cache=="object"&&(e=this.store.deepAssign(e,this.store.empConfig.cache)),e}get name(){let e=this.store.empConfig.server.port?`_${this.store.empConfig.server.port}`:"";return this.store.pkg.name+e}async common(){this.store.merge({name:this.name,node:{global:!0},experiments:{nativeWatcher:!0,outputModule:this.store.empConfig.isESM,topLevelAwait:!0,asyncWebAssembly:!0,css:!0,rspackFuture:{bundlerInfo:{force:!1}},cache:this.cache,incremental:"advance-silent",parallelLoader:!0},lazyCompilation:this.store.isDev,target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:!!this.store.empConfig.cache,devtool:this.store.empConfig.build.sourcemap.js,output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals,ignoreWarnings:this.store.empConfig.ignoreWarnings,watchOptions:{ignored:["**/node_modules/**","**/@mf-types/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await Es.default.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"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})}},Ps=new ct});var ht,_s,Ss=w(()=>{"use strict";c();ht=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let{rule:e,use:t}=this.store.chainName,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:require.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:require.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:require.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},_s=new ht});function Sr(){let s=[`import 'core-js/${g.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
10
|
+
`);return st(s)}var De,Te,ae,Re=w(()=>{"use strict";c();De=d(require("html-webpack-plugin"),1);$();I();Te=class{constructor(){}apply(e){let{webpack:t}=e;g.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,Sr(),{name:void 0}).apply(e)}},ae=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{De.default.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});var R,ft,ks,Os=w(()=>{"use strict";c();R=d(require("path"),1);se();Re();ft=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(R.default.extname(e),"").replace(`${this.store.empConfig.appSrc}${R.default.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(R.default.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(R.default.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(De.default,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=R.default.join(this.store.appSrc,e),i=R.default.join(t,"**","*.{ts,tsx,jsx,js}"),r=await(0,ne.glob)([i],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${R.default.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},R.default.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=R.default.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),i=await(0,ne.glob)([t],{windowsPathsNoEscape:!0});if(i[0]){let r=R.default.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(r,this.store.empConfig.html,i[0])}h.timeEnd(e)}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},ks=new ft});var ut,mt,Ts,Ds=w(()=>{"use strict";c();ut=d(require("path"),1);$();mt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:D(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",ut.default.dirname(require.resolve("@swc/helpers/package.json"))),this.coreJs.path=require.resolve("core-js/package.json");let t=et(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ut.default.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},Ts=new mt});var M,dt,Rs,js,gt,As,Ls=w(()=>{"use strict";c();M=d(require("@rspack/core"),1),dt=d(require("fs"),1),Rs=d(require("path"),1),js=require("ts-checker-rspack-plugin");Re();gt=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(Te)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(js.TsCheckerRspackPlugin,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.default.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");dt.default.existsSync(e)&&dt.default.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.default.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.default.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.default.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M.default;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=require("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.default.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.default.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.default.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=Rs.default.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.default.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},As=new gt});var yt,Fs,Ns=w(()=>{"use strict";c();xs();Ss();Os();Ds();Ls();yt=class{store;async setup(e){this.store=e;let t=[Ps.setup(this.store),Ts.setup(this.store),As.setup(this.store),ks.setup(this.store),_s.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},Fs=new yt});async function je(s,e=void 0){if(s!==kr&&(s<$s||s>wt))throw new Error(`Port number must lie between ${$s} and ${wt}`);let t=s,i=Or(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=wt;)try{return await Dr(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var Is,Ms,$s,wt,kr,Or,Tr,Dr,zs=w(()=>{"use strict";c();Is=d(require("net"),1),Ms=d(require("os"),1),$s=1024,wt=65535,kr=443,Or=()=>{let s=Ms.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},Tr=(s,e)=>new Promise((t,i)=>{let r=Is.default.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),Dr=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await Tr(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});var Hs,vt,bt,Ae,Ws=w(()=>{"use strict";c();Hs=d(require("chalk"),1);te();vt=d(require("url"),1);$();bt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:ee("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=q;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vt.default.format({protocol:t,hostname:e,port:Hs.default.bold(i),pathname:r})}},Ae=new bt});var Us,Bs,Js,Gs,Rr,jr,Vs,Ys=w(()=>{"use strict";c();Us=require("child_process"),Bs=require("util");I();N();Js=(0,Bs.promisify)(Us.exec),Gs=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Rr=async()=>{let s=process.env.BROWSER;if(!s||!Gs.includes(s)){let{stdout:e}=await Js("ps cax");s=Gs.find(t=>e.includes(t))}return s},jr=async s=>{if(process.platform==="darwin")try{let t=await Rr();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Js(i,{cwd:g.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Vs=jr});var Ct,Le,qs=w(()=>{"use strict";c();Ct=d(require("fs/promises"),1);se();te();zs();Ws();Ys();$();Le=class{ip=q();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await je(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await je(e.empConfig.server.port)),Ae.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Ae.prettyPrintUrl("localhost")):(this.urls=Ae.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(this.publicPath)}`)):(h.info(`${G("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${G("\u279C")} Network: ${h.link(e.lanUrlForTerminal)}
|
|
11
|
+
`)),this.isOpenBrower&&Vs(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([Ct.default.readFile(e.resource.key),Ct.default.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await je(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});var Xs,j,Ks,Et,Pt,g,I=w(()=>{"use strict";c();Xs=d(require("fs/promises"),1),j=d(require("path"),1),Ks=d(require("util"),1),Et=require("@rspack/core");ke();N();$();lt();Cs();Ns();qs();lt();Re();Pt=class{rspack=Et.rspack;rspackVersion=Et.rspack.rspackVersion;isOldRspack=_e(this.rspackVersion,"1.0.0")===-1;empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=j.default.resolve(__dirname,__filename).replace(`${j.default.sep}dist${j.default.sep}index.js`,"");empSource=j.default.resolve(this.empRoot,"dist");resolve=e=>j.default.isAbsolute(e)?e:j.default.resolve(this.root,e);empResolve=e=>j.default.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=ws;server=new Le(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;cliOptions;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};beforeSetup;afterSetup;async setup(e,t){this.cliAction=e||this.cliAction,this.cliOptions=t||this.cliOptions;let i="store.setup";h.time(i),this.beforeSetup&&await this.beforeSetup();let[r,o]=await Promise.all([ds(),gs()]);this.rootPaths.empConfig=r,this.rootPaths.tsConfig=o,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(this.cliAction,this.cliOptions),this.empConfig=bs,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new at.default,await Fs.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),this.afterSetup&&await this.afterSetup(),h.timeEnd(i),this.debug.clearLog&&tt()}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=require(this.empResolve("package.json")),r=require(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=j.default.join(this.empRoot,"resource"),this.resource.cert=j.default.join(this.resource.dir,"emp.cert"),this.resource.key=j.default.join(this.resource.dir,"emp.key")}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir)}loggerExtensionName="";setLoggerExtensionName(e){this.loggerExtensionName=e}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.debug.loggerLevel&&(e=this.debug.loggerLevel),h.setup({fullName:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}${this.loggerExtensionName?" "+this.loggerExtensionName:""}`,brandName:"EMP",logLevel:e})}merge(e){this.chain.merge(e)}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.debug.showRsconfig)if(typeof this.debug.showRsconfig=="string"){let e=j.default.join(this.root,this.debug.showRsconfig);Xs.default.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?D(e,this.debug.showRsconfig):e;console.log(h.link("[Compile Config]")),console.log(Ks.default.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=_e;deepAssign=D;getLanIp=q;injectTags(e=[],t="",i=""){this.chain.plugin(`${ae}-${t}`).use(ae,[e,t,i])}},g=new Pt});function Mr(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,o,a)=>{let n=t[a],l=o;return n&&(l=o.length<n?o+" ".repeat(n-o.length):o),`${r+l} `}," ");console.log(Z.bold(i))}async function ei(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(p=>Nr(p.name)).map(Ir);i.sort((p,m)=>p.size-m.size);let r=Math.max(...i.map(p=>p.sizeLabel.length)),o=Math.max(...i.map(p=>(p.folder+W.default.sep+p.name).length));Mr(o,r);let a=0,n=0;i.forEach(p=>{let{sizeLabel:m}=p,{name:u,folder:b,gzipSizeLabel:C}=p,E=(b+W.default.sep+u).length,O=m.length;if(a+=p.size,n+=p.gzippedSize,O<r){let A=" ".repeat(r-O);m+=A}let S=ee(p.folder+W.default.sep)+zr(p.name);if(E<o){let A=" ".repeat(o-E);S+=A}h.info(` ${S} ${ee(m)} ${C}`)});let l=`${Z.bold("Total size:")} ${Fe(a)}`,f=`${Z.bold("Gzipped size:")} ${Fe(n)}`;h.info(`
|
|
12
12
|
${l}
|
|
13
13
|
${f}
|
|
14
14
|
`),h.info(`${U.default.green("ready ")}Built in ${Se(Number(e.time))}
|
|
15
|
-
`)}function
|
|
16
|
-
`),g.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 ei(t),this.startServe(),await g.empConfig.lifeCycle.afterBulid()})}},
|
|
15
|
+
`)}function Ne(s,e){let t=s==="start"?U.default.cyan("start "):U.default.green("ready ");console.log(t+U.default.white(e))}function ti(s=0,e="Ready"){h.info(`${U.default.green("ready ")}${e} in ${Se(Number(s))}`)}function si(s="build"){Ne("start",`${s} Started...`)}function ii(s){let e=s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Ne("ready",`built in ${U.default.bold((e.time/1e3).toFixed(2))} s`)}function ri(s="build started..."){Ne("start",s)}function oi(s,e="built"){let t;typeof s=="number"?t=(s/1e3).toFixed(2):t=((s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0})).time/1e3).toFixed(2),Ne("ready",`${e} in ${U.default.bold(t)} s`)}var Qs,W,U,Zs,Ar,Lr,Fr,Nr,$r,Ir,Fe,zr,le=w(()=>{"use strict";c();Qs=d(require("fs"),1),W=d(require("path"),1),U=d(require("chalk"),1),Zs=require("gzip-size");te();I();N();$();Ar=/\.html$/,Lr=/\.(?:js|mjs|cjs|jsx)$/,Fr=/\.css$/,Nr=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),$r=s=>s>300*1e3?Ke:s>100*1e3?xe:Qe,Ir=s=>{let e=s.name.split("?")[0],t=Fe(s.size),i=W.default.basename(e),r=W.default.join(W.default.basename(g.empConfig.build.outDir),W.default.dirname(e)),o=Qs.default.readFileSync(W.default.join(g.empConfig.build.outDir,e)),a=o.length,n=(0,Zs.gzipSizeSync)(o),l=$r(n)(Fe(n));return{size:a,folder:r,name:i,gzippedSize:n,sizeLabel:t,gzipSizeLabel:l}};Fe=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},zr=s=>Lr.test(s)?xe(s):Fr.test(s)?G(s):Ar.test(s)?Z(s):Ze(s)});function xt(s,e){return s.map(t=>{let i=pe.default.relative(e,t);return _t.default.dim(pe.default.dirname(i)+pe.default.sep)+_t.default.dim(pe.default.basename(i))})}function ni(s,e){let t="emp:compiler",i=new Set,r=new Map,o=!1,a=new Set,n=!1,l=s.options.context||process.cwd(),f=u=>Hr.test(u)&&!Wr.test(u),p=u=>{let b=new Set,C=new Set;if(u.modifiedFiles||u.removedFiles){if(u.modifiedFiles){for(let E of u.modifiedFiles)if(f(E)){let O=r.get(E)||0,S=Date.now();S-O>300&&(b.add(E),r.set(E,S))}}if(u.removedFiles)for(let E of u.removedFiles)f(E)&&(C.add(E),r.delete(E));return{changed:b,removed:C}}if(u.watchFileSystem?.watcher){let O=u.watchFileSystem.watcher.mtimes||{};for(let S of Object.keys(O)){if(!f(S))continue;let A=O[S],Lt=r.get(S)||0,Ft=Date.now();Lt<A&&Ft-Lt>300&&(b.add(S),r.set(S,Ft))}}return{changed:b,removed:C}};function m(u,b){if(!e.isServerStarted)return;let C=Array.from(u),E=Array.from(b),O=Array.from(a);if(C.length===0&&E.length===0&&O.length===0)return;let S="";if(C.length>0){let A=xt(C,l);S+=`modified ${A.join(", ")}`}if(O.length>0){let A=xt(O,l);S+=`lazyLoaded ${A.join(", ")}`}if(E.length>0){let A=xt(E,l);S+=`removed ${A.join(", ")}`}ri(S)}return s.hooks.watchRun.tap(t,u=>{if(n)return;n=!0,i.clear(),a.clear();let{changed:b,removed:C}=p(u);o=b.size>0||C.size>0,o&&m(b,C),b.forEach(E=>i.add(E))}),s.hooks.done.tap(t,u=>{if(!e.isServerStarted||!o){n=!1;return}(i.size>0||a.size>0)&&(oi(u),o=!1),n=!1}),{cleanup:()=>{i.clear(),r.clear(),a.clear(),o=!1,n=!1}}}var _t,pe,Hr,Wr,ai=w(()=>{"use strict";c();_t=d(require("chalk"),1),pe=d(require("path"),1);le();Hr=/\/src\//,Wr=/node_modules/});var li,B,$e=w(()=>{"use strict";c();li=require("@rspack/core");N();I();B=class{async setup(e,t){let i=`${e}.setup`,r=`${e}.run`;h.time(i),await g.setup(e,t),g.empConfig.showLogTitle({cliAction:e,cliOptions:t,rspackVersion:li.rspackVersion,empVersion:g.empPkg.version}),h.time(r),await this.run(),this.processExit(),h.timeEnd(r),h.timeEnd(i)}async run(){}processExit(){process.on("SIGINT",function(){process.exit()})}}});var pi,ci,ce,hi=w(()=>{"use strict";c();pi=require("@rspack/dev-server"),ci=d(require("connect"),1);N();ce=class{server=null;isServerStarted=!1;async setup(e,t,i,r=()=>{}){if(!t.devServer){h.warn("rspackConfig.devServer need!");return}let o=new pi.RspackDevServer(t.devServer,e);await o.start(),o.middleware?.waitUntilValid(r),this.server=o}async beforeCompiler(e){return e.devServer.app=()=>(0,ci.default)(),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}}});var St,fi,ui,mi,di,gi,yi,kt,wi,vi,X,he,bi=w(()=>{"use strict";c();St=d(require("fs"),1),fi=d(require("fs/promises"),1),ui=d(require("compression"),1),mi=d(require("connect"),1),di=d(require("cors"),1),gi=require("http-proxy-middleware"),yi=d(require("http2"),1),kt=d(require("path"),1),wi=d(require("serve-static"),1),vi=require("url"),X=(0,mi.default)();X.use((0,ui.default)());X.use((0,di.default)());he=class{async setup(e,t=()=>{}){let i="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(i)||(i=r[0]),!St.default.existsSync(e.outDir))return e.logger.sysError(`emp serve must be executed after emp build,${e.outDir} not exist!`);let o=e.resolve(e.rsConfig.output?.path);e.empConfig.server.proxy&&Array.isArray(e.empConfig.server.proxy)&&e.empConfig.server.proxy.forEach(n=>{let{context:l,...f}=n;X.use((0,gi.createProxyMiddleware)({...f,pathFilter:l}))}),X.use((0,wi.default)(o));let a=await fi.default.readFile(kt.default.join(o,`${i}.html`),"utf8");if(X.use((n,l,f)=>{let m=(0,vi.parse)(n.url||"",!0).pathname;if(m&&m!=="/"&&St.default.existsSync(kt.default.join(o,m)))return f();l.setHeader("Content-Type","text/html"),l.end(a)}),e.server.isHttps){let{key:n,cert:l}=await e.server.getcert();yi.default.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:n,cert:l,allowHTTP1:!0},X).listen(e.server.port,t)}else require("http").createServer(X).listen(e.server.port,t)}}});var Ot=w(()=>{"use strict";c();hi();bi()});var Pi={};K(Pi,{default:()=>Gr});var Ci,Ie,Ei,fe,Tt,Gr,xi=w(()=>{"use strict";c();Ci=require("@rspack/core");ns();Ie=d(require("fs"),1),Ei=d(require("path"),1);se();le();ai();$();$e();Ot();I();fe=new ce,Tt=class extends B{closeHooks=[];get stats(){return{all:g.empConfig.debug.devShowAllLog,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0}}async getRspackDevConfig(){let e=D(g.rsConfig,{stats:this.stats,devServer:{open:!1,setupExitSignals:!0,port:g.server.port}}),{devServer:t}=e;if(g.server.isHttps&&(!t.server||t.server.type==="https"&&!t.server.options)){let{key:i,cert:r}=await g.server.getcert();t.server={type:"https",options:{key:i,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async startDevServer(e=!1){try{let{server:t}=g,i=await this.getRspackDevConfig();i=await fe.beforeCompiler(i);let r=(0,Ci.rspack)(i);await g.empConfig.lifeCycle.beforeDevServe(),t.startOpen(),si("DevServer"),await fe.setup(r,i,g,async a=>{fe.isServerStarted=!0,ii(a),await g.empConfig.lifeCycle.afterDevServe()});let o=ni(r,fe);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=Ei.default.resolve(process.cwd(),"emp.config.ts");if(!Ie.default.existsSync(e))return;h.debug("[EMP] Watching for changes in emp.config.ts...");let t=Ie.default.readFileSync(e,"utf-8");os.watch(e,{ignored:/(^|[/\\])\../,persistent:!0}).on("change",async i=>{let r=Ie.default.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: ${i}`),Object.keys(require.cache).forEach(o=>{o.includes("emp.config")&&delete require.cache[o]}),h.debug("[EMP] \u914D\u7F6E\u6587\u4EF6\u5DF2\u53D8\u66F4\uFF0C\u6B63\u5728\u91CD\u542F\u670D\u52A1..."),this.executeCloseHooks(),await fe.close(),await g.setup(),h.debug("[EMP] \u91CD\u542F\u670D\u52A1\u5B8C\u6210\uFF0C\u65B0\u914D\u7F6E\u5982\u4E0B:",g.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=[]}}},Gr=new Tt});var Dt={};K(Dt,{ServeScript:()=>Me,default:()=>Br});var Ur,_i,Me,Br,Rt=w(()=>{"use strict";c();le();$e();Ot();I();Ur=new he,_i=0,Me=class extends B{async run(){_i=Date.now(),await g.empConfig.lifeCycle.beforeServe(),await Ur.setup(g,this.onReady)}onReady=async()=>{g.server.startOpen(),ti(Date.now()-_i,"Server Started"),await g.empConfig.lifeCycle.afterServe()}},Br=new Me});var ki={};K(ki,{default:()=>Jr});var Si,jt,Jr,Oi=w(()=>{"use strict";c();Si=require("@rspack/core");le();N();$e();I();jt=class extends B{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(()=>(Rt(),Dt));await e.setup("serve",g.cliOptions)}async run(){await g.empConfig.lifeCycle.beforeBuild(),this.isWatchMode=!!g.cliOptions.watch,this.isuseServe=!!g.cliOptions.serve,this.rspackConfig=g.rsConfig,this.isWatchMode&&this.watchMode(),(0,Si.rspack)(this.rspackConfig,async(e,t)=>{if(console.log(`
|
|
16
|
+
`),g.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 ei(t),this.startServe(),await g.empConfig.lifeCycle.afterBulid()})}},Jr=new jt});var Yr={};K(Yr,{Logger:()=>oe,color:()=>_,defineConfig:()=>Vr,empHelper:()=>rt,program:()=>Ri.program,rspack:()=>Di.rspack,runScript:()=>At,store:()=>g});module.exports=$i(Yr);c();var Di=require("@rspack/core"),Ri=require("commander");c();var Ti=d(require("process"),1),J=require("commander");ze();async function At(){J.program.version(me.version,"-v, --version").usage("<command> [options]"),J.program.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(xi(),Pi));await e.setup("dev",s)}),J.program.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-rd, --doctor","\u5F00\u542Frsdoctor,\u53EF\u901A\u8FC7debug.rsdoctor\u64CD\u4F5C").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-w, --watch","watch \u6A21\u5F0F").option("-sv, --serve","watch \u6A21\u5F0F\u4E0B\u542F\u52A8serve").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Oi(),ki));await e.setup("build",s)}),J.program.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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Rt(),Dt));await e.setup("serve",s)}),J.program.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(s=>{}),J.program.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(s=>{}),J.program.parse(Ti.default.argv)}I();N();se();function Vr(s){return s}0&&(module.exports={Logger,color,defineConfig,empHelper,program,rspack,runScript,store});
|
|
17
17
|
/*! Bundled license information:
|
|
18
18
|
|
|
19
19
|
chokidar/esm/index.js:
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
|
-
var Vs=Object.defineProperty;var k=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var v=(s,e)=>()=>(s&&(e=s(s=0)),e);var Z=(s,e)=>{for(var t in e)Vs(s,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.0",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",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(s,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=D.FILE_DIR_TYPE),t&&(e.type=t),s){if(typeof s!="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=s,new Fe(e)}var D,Le,_t,oi,Et,ni,ai,li,pi,Pt,xt,Fe,kt=v(()=>{"use strict";c();D={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Le={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:D.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=[D.DIR_TYPE,D.EVERYTHING_TYPE,D.FILE_DIR_TYPE,D.FILE_TYPE],ni=new Set([D.DIR_TYPE,D.EVERYTHING_TYPE,D.FILE_DIR_TYPE]),ai=new Set([D.EVERYTHING_TYPE,D.FILE_DIR_TYPE,D.FILE_TYPE]),li=s=>oi.has(s.code),pi=process.platform==="win32",Pt=s=>!0,xt=s=>{if(s===void 0)return Pt;if(typeof s=="function")return s;if(typeof s=="string"){let e=s.trim();return t=>t.basename===e}if(Array.isArray(s)){let e=s.map(t=>t.trim());return t=>e.some(i=>t.basename===i)}return Pt},Fe=class extends ti{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Le,...e},{root:i,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===D.EVERYTHING_TYPE,this._root=Ct(i),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,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,i=t&&t.files;if(i&&i.length>0){let{path:r,depth:o}=t,a=i.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 i;try{i=await Zs(e,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:t,path:e}}async _formatEntry(e,t){let i,r=this._isDirent?e.name:e;try{let o=Ct(ii(t,r));i={path:si(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return i}_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 i=e.fullPath;try{let r=await ei(i),o=await bt(r);if(o.isFile())return"file";if(o.isDirectory()){let a=r.length;if(i.startsWith(r)&&i.substr(a,1)===ri){let n=new Error(`Circular symlink detected: "${i}" 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 Dt,lstat as ui,realpath as Ne}from"fs/promises";import*as P from"path";import{type as mi}from"os";function Tt(s,e,t,i,r){let o=(a,n)=>{t(s),r(a,n,{watchedPath:s}),n&&s!==n&&ce(P.resolve(s,n),G,P.join(s,n))};try{return hi(s,{persistent:e.persistent},o)}catch(a){i(a);return}}var di,Me,Rt,fe,ue,ze,gi,yi,wi,jt,x,A,vi,bi,G,le,V,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=()=>{},ue=process.platform,ze=ue==="win32",gi=ue==="darwin",yi=ue==="linux",wi=ue==="freebsd",jt=mi()==="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:ui,stat:Dt},G="listeners",le="errHandlers",V="rawEmitters",Ci=[G,le,V],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=s=>Ei.has(P.extname(s).slice(1).toLowerCase()),Ie=(s,e)=>{s instanceof Set?s.forEach(e):e(s)},ee=(s,e,t)=>{let i=s[e];i instanceof Set||(s[e]=i=new Set([i])),i.add(t)},xi=s=>e=>{let t=s[e];t instanceof Set?t.clear():delete s[e]},te=(s,e,t)=>{let i=s[e];i instanceof Set?i.delete(t):i===t&&delete s[e]},At=s=>s instanceof Set?s.size===0:!s,pe=new Map;ce=(s,e,t,i,r)=>{let o=pe.get(s);o&&Ie(o[e],a=>{a(t,i,r)})},_i=(s,e,t,i)=>{let{listener:r,errHandler:o,rawEmitter:a}=i,n=pe.get(e),l;if(!t.persistent)return l=Tt(s,t,r,o,a),l?l.close.bind(l):void 0;if(n)ee(n,G,r),ee(n,le,o),ee(n,V,a);else{if(l=Tt(s,t,ce.bind(null,e,G),o,ce.bind(null,e,V)),!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(s,"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,V,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=(s,e,t,i)=>{let{listener:r,rawEmitter:o}=i,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,V,o)):(a={listeners:r,rawEmitters:o,options:t,watcher:ci(e,t,(l,f)=>{Ie(a.rawEmitters,m=>{m(A.CHANGE,e,{curr:l,prev:f})});let p=l.mtimeMs;(l.size!==f.size||p>f.mtimeMs||p===0)&&Ie(a.listeners,m=>m(s,l))})},$e.set(e,a)),()=>{te(a,G,r),te(a,V,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 i=this.fsw.options,r=P.dirname(e),o=P.basename(e);this.fsw._getWatchedDir(r).add(o);let n=P.resolve(e),l={persistent:i.persistent};t||(t=fe);let f;if(i.usePolling){let p=i.interval!==i.binaryInterval;l.interval=p&&Pi(o)?i.binaryInterval:i.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,i){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,m)=>{if(this.fsw._throttle(vi,e,5)){if(!m||m.mtimeMs===0)try{let u=await Dt(e);if(this.fsw.closed)return;let b=u.atimeMs,C=u.mtimeMs;if((!b||b<=C||C!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,u),(gi||yi||wi)&&n.ino!==u.ino){this.fsw._closeFile(p),n=u;let E=this._watchWithNodeFs(e,l);E&&this.fsw._addPathCloser(p,E)}else n=u}catch{this.fsw._remove(r,o)}else if(a.has(o)){let u=m.atimeMs,b=m.mtimeMs;(!u||u<=b||b!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,m),n=m}}},f=this._watchWithNodeFs(e,l);if(!(i&&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,i,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(i)}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,i,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(o,n),this.fsw._emit(A.ADD,i,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,t,i,r,o,a,n){if(e=P.join(e,""),n=this.fsw._throttle("readdir",e,1e3),!n)return;let l=this.fsw._getWatchedDir(i.path),f=new Set,p=this.fsw._readdirp(e,{fileFilter:m=>i.filterPath(m),directoryFilter:m=>i.filterDir(m)});if(p)return p.on(di,async m=>{if(this.fsw.closed){p=void 0;return}let u=m.path,b=P.join(e,u);if(f.add(u),!(m.stats.isSymbolicLink()&&await this._handleSymlink(m,e,b,u))){if(this.fsw.closed){p=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),b=P.join(o,P.relative(o,b)),this._addToNodeFs(b,t,i,a+1))}}).on(A.ERROR,this._boundHandleError),new Promise((m,u)=>{if(!p)return u();p.once(Me,()=>{if(this.fsw.closed){p=void 0;return}let b=n?n.clear():!1;m(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,i,r,o,a,n)})})}async _handleDir(e,t,i,r,o,a,n){let l=this.fsw._getWatchedDir(P.dirname(e)),f=l.has(P.basename(e));!(i&&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,m,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(n)){if(!o&&(await this._handleRead(e,i,a,o,e,r,p),this.fsw.closed))return;m=this._watchWithNodeFs(e,(b,C)=>{C&&C.mtimeMs===0||this._handleRead(b,!1,a,o,e,r,p)})}return m}async _addToNodeFs(e,t,i,r,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let n=this.fsw._getWatchHelpers(e);i&&(n.filterPath=l=>i.filterPath(l),n.filterDir=l=>i.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 m=P.resolve(e),u=f?await Ne(e):e;if(this.fsw.closed||(p=await this._handleDir(n.watchPath,l,t,r,o,n,u),this.fsw.closed))return;m!==u&&u!==void 0&&this.fsw._symlinkPaths.set(m,u)}else if(l.isSymbolicLink()){let m=f?await Ne(e):e;if(this.fsw.closed)return;let u=P.dirname(n.watchPath);if(this.fsw._getWatchedDir(u).add(n.watchPath),this.fsw._emit(A.ADD,n.watchPath,l),p=await this._handleDir(u,l,t,r,e,n,m),this.fsw.closed)return;m!==void 0&&this.fsw._symlinkPaths.set(P.resolve(e),m)}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 Ti}from"fs/promises";import{EventEmitter as Di}from"events";import*as y from"path";function me(s){return Array.isArray(s)?s:[s]}function $i(s){return typeof s=="function"?s:typeof s=="string"?e=>s===e:s instanceof RegExp?e=>s.test(e):typeof s=="object"&&s!==null?e=>{if(s.path===e)return!0;if(s.recursive){let t=y.relative(s.path,e);return t?!t.startsWith("..")&&!y.isAbsolute(t):!1}return!1}:()=>!1}function Ii(s){if(typeof s!="string")throw new Error("string expected");s=y.normalize(s),s=s.replace(/\\/g,"/");let e=!1;s.startsWith("//")&&(e=!0);let t=/\/\//;for(;s.match(t);)s=s.replace(t,"/");return e&&(s="/"+s),s}function Nt(s,e,t){let i=Ii(e);for(let r=0;r<s.length;r++){let o=s[r];if(o(i,t))return!0}return!1}function Mi(s,e){if(s==null)throw new TypeError("anymatch: specify first argument");let i=me(s).map(r=>$i(r));return e==null?(r,o)=>Nt(i,r,o):Nt(i,e)}function Ui(s,e={}){let t=new de(e);return t.add(s),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=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);$t=s=>{let e=me(s).flat();if(!e.every(t=>typeof t===Ai))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(Ht)},It=s=>{let e=s.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=s=>It(y.normalize(It(s))),Mt=(s="")=>e=>typeof e=="string"?Ht(y.isAbsolute(e)?e:y.join(s,e)):e,zi=(s,e)=>y.isAbsolute(s)?s:y.join(e,s),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 i=this.path;try{await Ti(i)}catch{this._removeWatcher&&this._removeWatcher(y.dirname(i),y.basename(i))}}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,i){this.fsw=i;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 i=this.entryPath(e);return this.fsw._isntIgnored(i,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},de=class extends Di{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,i={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?me(e.ignored):me([]),awaitWriteFinish:t===!0?i:typeof t=="object"?{...i,...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,i){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,!i,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:i}=this.options;return t.forEach(r=>{!y.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=y.join(i,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(i=>{let r=i();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,i)=>{let o=(this.options.cwd?y.relative(this.options.cwd,i):i)||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,i){if(this.closed)return;let r=this.options;ze&&(t=y.normalize(t)),r.cwd&&(t=y.relative(r.cwd,t));let o=[t];i!=null&&o.push(i);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&&i===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,i){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,i);let l={timeoutObject:a,clear:n,count:0};return r.set(t,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,i,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 m(u){ki(l,(b,C)=>{if(b||!p.has(e)){b&&b.code!=="ENOENT"&&r(b);return}let E=Number(new Date);u&&C.size!==u.size&&(p.get(e).lastChange=E);let T=p.get(e);E-T.lastChange>=t?(p.delete(e),r(void 0,C)):n=setTimeout(m,a,C)})}p.has(e)||(p.set(e,{lastChange:f,cancelWait:()=>(p.delete(e),clearTimeout(n),i)}),n=setTimeout(m,a))}_isIgnored(e,t){if(this.options.atomic&&Fi.test(e))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(Mt(i)),n=[...[...this._ignoredPaths].map(Mt(i)),...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,i){let r=y.join(e,t),o=y.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));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 m=i?x.UNLINK_DIR:x.UNLINK;f&&!this._isIgnored(r)&&this._emit(m,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(i=>i()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let i=this._closers.get(e);i||(i=[],this._closers.set(e,i)),i.push(t)}_readdirp(e,t){if(this.closed)return;let i={type:x.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=St(e,i);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,Y,Je,Ki,Ve,q,_,X=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"),Y=O.hex("#2980b9"),Je=O.hex("#ecf0f1"),Ki=O.hex("#fd79a8"),Ve=O.hex("#e84393"),q=O.hex("#7f8c8d"),_={lightGreen:Bi,green:z,lightCyan:Ji,cyan:Vi,lightRed:Yi,red:Be,yellow:ge,orange:qi,lightBlue:Xi,blue:Y,white:Je,lightMagenta:Ki,magenta:Ve,gray:q}});var Ut,ye,h,N=v(()=>{"use strict";c();X();Ut=!1,ye=class{brandName="";fullName="";logLevel=Ut?"debug":"info";isLogTime=Ut;setup({brandName:e,logLevel:t,fullName:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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} `)}
|
|
2
|
+
var Vs=Object.defineProperty;var k=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var v=(s,e)=>()=>(s&&(e=s(s=0)),e);var Z=(s,e)=>{for(var t in e)Vs(s,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.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(s,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=D.FILE_DIR_TYPE),t&&(e.type=t),s){if(typeof s!="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=s,new Le(e)}var D,Fe,_t,oi,Et,ni,ai,li,pi,Pt,xt,Le,kt=v(()=>{"use strict";c();D={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Fe={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:D.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Fe);_t="READDIRP_RECURSIVE_ERROR",oi=new Set(["ENOENT","EPERM","EACCES","ELOOP",_t]),Et=[D.DIR_TYPE,D.EVERYTHING_TYPE,D.FILE_DIR_TYPE,D.FILE_TYPE],ni=new Set([D.DIR_TYPE,D.EVERYTHING_TYPE,D.FILE_DIR_TYPE]),ai=new Set([D.EVERYTHING_TYPE,D.FILE_DIR_TYPE,D.FILE_TYPE]),li=s=>oi.has(s.code),pi=process.platform==="win32",Pt=s=>!0,xt=s=>{if(s===void 0)return Pt;if(typeof s=="function")return s;if(typeof s=="string"){let e=s.trim();return t=>t.basename===e}if(Array.isArray(s)){let e=s.map(t=>t.trim());return t=>e.some(i=>t.basename===i)}return Pt},Le=class extends ti{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Fe,...e},{root:i,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??Fe.depth,this._wantsDir=r?ni.has(r):!1,this._wantsFile=r?ai.has(r):!1,this._wantsEverything=r===D.EVERYTHING_TYPE,this._root=Ct(i),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,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,i=t&&t.files;if(i&&i.length>0){let{path:r,depth:o}=t,a=i.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 i;try{i=await Zs(e,this._rdOptions)}catch(r){this._onError(r)}return{files:i,depth:t,path:e}}async _formatEntry(e,t){let i,r=this._isDirent?e.name:e;try{let o=Ct(ii(t,r));i={path:si(this._root,o),fullPath:o,basename:r},i[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return i}_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 i=e.fullPath;try{let r=await ei(i),o=await bt(r);if(o.isFile())return"file";if(o.isDirectory()){let a=r.length;if(i.startsWith(r)&&i.substr(a,1)===ri){let n=new Error(`Circular symlink detected: "${i}" 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 Dt,lstat as ui,realpath as Ne}from"fs/promises";import*as P from"path";import{type as mi}from"os";function Tt(s,e,t,i,r){let o=(a,n)=>{t(s),r(a,n,{watchedPath:s}),n&&s!==n&&ce(P.resolve(s,n),G,P.join(s,n))};try{return hi(s,{persistent:e.persistent},o)}catch(a){i(a);return}}var di,Me,Rt,fe,ue,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,Ft=v(()=>{"use strict";c();di="data",Me="end",Rt="close",fe=()=>{},ue=process.platform,ze=ue==="win32",gi=ue==="darwin",yi=ue==="linux",wi=ue==="freebsd",jt=mi()==="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:ui,stat:Dt},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=s=>Ei.has(P.extname(s).slice(1).toLowerCase()),Ie=(s,e)=>{s instanceof Set?s.forEach(e):e(s)},ee=(s,e,t)=>{let i=s[e];i instanceof Set||(s[e]=i=new Set([i])),i.add(t)},xi=s=>e=>{let t=s[e];t instanceof Set?t.clear():delete s[e]},te=(s,e,t)=>{let i=s[e];i instanceof Set?i.delete(t):i===t&&delete s[e]},At=s=>s instanceof Set?s.size===0:!s,pe=new Map;ce=(s,e,t,i,r)=>{let o=pe.get(s);o&&Ie(o[e],a=>{a(t,i,r)})},_i=(s,e,t,i)=>{let{listener:r,errHandler:o,rawEmitter:a}=i,n=pe.get(e),l;if(!t.persistent)return l=Tt(s,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=Tt(s,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(s,"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=(s,e,t,i)=>{let{listener:r,rawEmitter:o}=i,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,m=>{m(A.CHANGE,e,{curr:l,prev:f})});let p=l.mtimeMs;(l.size!==f.size||p>f.mtimeMs||p===0)&&Ie(a.listeners,m=>m(s,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 i=this.fsw.options,r=P.dirname(e),o=P.basename(e);this.fsw._getWatchedDir(r).add(o);let n=P.resolve(e),l={persistent:i.persistent};t||(t=fe);let f;if(i.usePolling){let p=i.interval!==i.binaryInterval;l.interval=p&&Pi(o)?i.binaryInterval:i.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,i){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,m)=>{if(this.fsw._throttle(vi,e,5)){if(!m||m.mtimeMs===0)try{let u=await Dt(e);if(this.fsw.closed)return;let b=u.atimeMs,C=u.mtimeMs;if((!b||b<=C||C!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,u),(gi||yi||wi)&&n.ino!==u.ino){this.fsw._closeFile(p),n=u;let E=this._watchWithNodeFs(e,l);E&&this.fsw._addPathCloser(p,E)}else n=u}catch{this.fsw._remove(r,o)}else if(a.has(o)){let u=m.atimeMs,b=m.mtimeMs;(!u||u<=b||b!==n.mtimeMs)&&this.fsw._emit(A.CHANGE,e,m),n=m}}},f=this._watchWithNodeFs(e,l);if(!(i&&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,i,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(i)}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,i,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(o,n),this.fsw._emit(A.ADD,i,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,t,i,r,o,a,n){if(e=P.join(e,""),n=this.fsw._throttle("readdir",e,1e3),!n)return;let l=this.fsw._getWatchedDir(i.path),f=new Set,p=this.fsw._readdirp(e,{fileFilter:m=>i.filterPath(m),directoryFilter:m=>i.filterDir(m)});if(p)return p.on(di,async m=>{if(this.fsw.closed){p=void 0;return}let u=m.path,b=P.join(e,u);if(f.add(u),!(m.stats.isSymbolicLink()&&await this._handleSymlink(m,e,b,u))){if(this.fsw.closed){p=void 0;return}(u===r||!r&&!l.has(u))&&(this.fsw._incrReadyCount(),b=P.join(o,P.relative(o,b)),this._addToNodeFs(b,t,i,a+1))}}).on(A.ERROR,this._boundHandleError),new Promise((m,u)=>{if(!p)return u();p.once(Me,()=>{if(this.fsw.closed){p=void 0;return}let b=n?n.clear():!1;m(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,i,r,o,a,n)})})}async _handleDir(e,t,i,r,o,a,n){let l=this.fsw._getWatchedDir(P.dirname(e)),f=l.has(P.basename(e));!(i&&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,m,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(n)){if(!o&&(await this._handleRead(e,i,a,o,e,r,p),this.fsw.closed))return;m=this._watchWithNodeFs(e,(b,C)=>{C&&C.mtimeMs===0||this._handleRead(b,!1,a,o,e,r,p)})}return m}async _addToNodeFs(e,t,i,r,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let n=this.fsw._getWatchHelpers(e);i&&(n.filterPath=l=>i.filterPath(l),n.filterDir=l=>i.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 m=P.resolve(e),u=f?await Ne(e):e;if(this.fsw.closed||(p=await this._handleDir(n.watchPath,l,t,r,o,n,u),this.fsw.closed))return;m!==u&&u!==void 0&&this.fsw._symlinkPaths.set(m,u)}else if(l.isSymbolicLink()){let m=f?await Ne(e):e;if(this.fsw.closed)return;let u=P.dirname(n.watchPath);if(this.fsw._getWatchedDir(u).add(n.watchPath),this.fsw._emit(A.ADD,n.watchPath,l),p=await this._handleDir(u,l,t,r,e,n,m),this.fsw.closed)return;m!==void 0&&this.fsw._symlinkPaths.set(P.resolve(e),m)}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 Ti}from"fs/promises";import{EventEmitter as Di}from"events";import*as y from"path";function me(s){return Array.isArray(s)?s:[s]}function $i(s){return typeof s=="function"?s:typeof s=="string"?e=>s===e:s instanceof RegExp?e=>s.test(e):typeof s=="object"&&s!==null?e=>{if(s.path===e)return!0;if(s.recursive){let t=y.relative(s.path,e);return t?!t.startsWith("..")&&!y.isAbsolute(t):!1}return!1}:()=>!1}function Ii(s){if(typeof s!="string")throw new Error("string expected");s=y.normalize(s),s=s.replace(/\\/g,"/");let e=!1;s.startsWith("//")&&(e=!0);let t=/\/\//;for(;s.match(t);)s=s.replace(t,"/");return e&&(s="/"+s),s}function Nt(s,e,t){let i=Ii(e);for(let r=0;r<s.length;r++){let o=s[r];if(o(i,t))return!0}return!1}function Mi(s,e){if(s==null)throw new TypeError("anymatch: specify first argument");let i=me(s).map(r=>$i(r));return e==null?(r,o)=>Nt(i,r,o):Nt(i,e)}function Ui(s,e={}){let t=new de(e);return t.add(s),t}var He,Ri,zt,ji,Ai,Fi,Lt,Li,Ni,We,$t,It,Ht,Mt,zi,Hi,Ge,Wi,Gi,Ue,de,Wt,Gt=v(()=>{"use strict";c();kt();Ft();He="/",Ri="//",zt=".",ji="..",Ai="string",Fi=/\\/g,Lt=/\/\//,Li=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Ni=/^\.[/\\]/;We=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);$t=s=>{let e=me(s).flat();if(!e.every(t=>typeof t===Ai))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(Ht)},It=s=>{let e=s.replace(Fi,He),t=!1;for(e.startsWith(Ri)&&(t=!0);e.match(Lt);)e=e.replace(Lt,He);return t&&(e=He+e),e},Ht=s=>It(y.normalize(It(s))),Mt=(s="")=>e=>typeof e=="string"?Ht(y.isAbsolute(e)?e:y.join(s,e)):e,zi=(s,e)=>y.isAbsolute(s)?s:y.join(e,s),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 i=this.path;try{await Ti(i)}catch{this._removeWatcher&&this._removeWatcher(y.dirname(i),y.basename(i))}}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,i){this.fsw=i;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 i=this.entryPath(e);return this.fsw._isntIgnored(i,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},de=class extends Di{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,i={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?me(e.ignored):me([]),awaitWriteFinish:t===!0?i:typeof t=="object"?{...i,...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,i){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,!i,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:i}=this.options;return t.forEach(r=>{!y.isAbsolute(r)&&!this._closers.has(r)&&(i&&(r=y.join(i,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(i=>{let r=i();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,i)=>{let o=(this.options.cwd?y.relative(this.options.cwd,i):i)||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,i){if(this.closed)return;let r=this.options;ze&&(t=y.normalize(t)),r.cwd&&(t=y.relative(r.cwd,t));let o=[t];i!=null&&o.push(i);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&&i===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,i){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,i);let l={timeoutObject:a,clear:n,count:0};return r.set(t,l),l}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,i,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 m(u){ki(l,(b,C)=>{if(b||!p.has(e)){b&&b.code!=="ENOENT"&&r(b);return}let E=Number(new Date);u&&C.size!==u.size&&(p.get(e).lastChange=E);let T=p.get(e);E-T.lastChange>=t?(p.delete(e),r(void 0,C)):n=setTimeout(m,a,C)})}p.has(e)||(p.set(e,{lastChange:f,cancelWait:()=>(p.delete(e),clearTimeout(n),i)}),n=setTimeout(m,a))}_isIgnored(e,t){if(this.options.atomic&&Li.test(e))return!0;if(!this._userIgnored){let{cwd:i}=this.options,o=(this.options.ignored||[]).map(Mt(i)),n=[...[...this._ignoredPaths].map(Mt(i)),...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,i){let r=y.join(e,t),o=y.resolve(r);if(i=i??(this._watched.has(r)||this._watched.has(o)),!this._throttle("remove",r,100))return;!i&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));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 m=i?x.UNLINK_DIR:x.UNLINK;f&&!this._isIgnored(r)&&this._emit(m,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(i=>i()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let i=this._closers.get(e);i||(i=[],this._closers.set(e,i)),i.push(t)}_readdirp(e,t){if(this.closed)return;let i={type:x.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=St(e,i);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:i}){this.brandName=` [${e}] `,this.fullName=` ${i} `,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
3
|
`)};cyan=e=>{console.log(`${_.lightCyan(this.brandName)}${_.cyan(` ${e} `)}
|
|
4
4
|
`)};magenta=e=>{console.log(`${_.lightMagenta(this.brandName)}${_.magenta(` ${e} `)}
|
|
5
5
|
`)};green=e=>{console.log(`${_.lightGreen(this.brandName)}${_.green(` ${e} `)}
|
|
@@ -7,14 +7,14 @@ var Vs=Object.defineProperty;var k=(s=>typeof require<"u"?require:typeof Proxy<"
|
|
|
7
7
|
`)};red=e=>{console.log(`${_.lightRed(this.brandName)}${_.red(` ${e} `)}
|
|
8
8
|
`)};sysError=e=>{console.log(`${_.lightRed(" System Error Tips ")}${_.red(` ${e} `)}
|
|
9
9
|
`)};link=e=>_.blue(e);title=e=>{console.log(`${this.fullName}${_.yellow.underline(`${e}`)}
|
|
10
|
-
`)}},h=new ye});var Ke={};Z(Ke,{clearConsole:()=>qe,deepAssign:()=>R,ensureArray:()=>sr,getLanIp:()=>U,getPkgVersion:()=>Ye,importJsVm:()=>Xe,jsonFilter:()=>ir,timeFormat:()=>ve,vCompare:()=>we});import{ip as Qi}from"address";import Zi from"chalk";import{gateway4sync as er}from"default-gateway";import tr from"fs-extra";function qe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function R(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=R(o,r);continue}s[i]=t[i]}return s}var U,Ye,sr,ir,we,ve,Xe,$=v(()=>{"use strict";c();U=()=>{let s="127.0.0.1";try{let{int:e}=er();return Qi(e||"")||s}catch{return s}},Ye=s=>{try{let{version:e}=tr.readJSONSync(s);return e}catch{return}};sr=s=>Array.isArray(s)?s:[s],ir=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),we=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},ve=s=>{s=s/1e3;let e=i=>Zi.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},Xe=s=>`data:text/javascript,${s}`});var Bt={};Z(Bt,{chalk:()=>rr,color:()=>_,glob:()=>be,logger:()=>h,utils:()=>Ke});import rr from"chalk";import{glob as be}from"glob";var K=v(()=>{"use strict";c();X();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 s="store.getEmpConfigPath";h.time(s);let e=nr.map(r=>Vt.resolve(d.root,r)),t=await Promise.all(e.map(r=>Jt.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},Xt=async()=>{let s=Vt.join(d.root,"tsconfig.json");return await Jt.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Kt=()=>{let s=[g];return d.rootPaths.pkg&&s.push(d.rootPaths.pkg),d.rootPaths.empConfig&&s.push(d.rootPaths.empConfig),d.rootPaths.tsConfig&&s.push(d.rootPaths.tsConfig),s}});import Qt from"@empjs/chain";var Zt,Qe=v(()=>{"use strict";c();Zt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Ee,es=v(()=>{"use strict";c();Ee=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var Ze,ts,ss=v(()=>{"use strict";c();K();Ce();$();es();Ze=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},R(e,t)}get isESM(){return!(["es3","es5"].indexOf(this.store.empConfig.build.target)===1)&&this.store.empConfig.build.useESM}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),await this.setupEmpOptions(),this.lifeCycle=new Ee(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return R({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await Yt(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}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/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ar.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"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,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:k.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:k.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:k.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},os=new tt});import st from"html-webpack-plugin";function lr(){let s=[`import 'core-js/${d.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
|
-
`);return Xe(s)}var Pe,se,xe=v(()=>{"use strict";c();$();I();Pe=class{constructor(){}apply(e){let{webpack:t}=e;d.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,lr(),{name:void 0}).apply(e)}},se=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{st.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});import L from"path";var it,as,ls=v(()=>{"use strict";c();K();xe();it=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),this.prepareAndSetAsset(e),e}prepareAndSetAsset(e){let t=e.chunks?e.chunks[0]:void 0;this.store.injectTags(e.tags,t?`injectTags-${t}`:"injectTags",t),delete e.tags}injectPolyfill(){if(!this.store.empConfig.build.polyfill.entryCdn)return;let e=[{attributes:{src:this.store.empConfig.build.polyfill.entryCdn},tagName:"script",pos:"head"}];this.store.injectTags(e,"injectEMPPolyfill")}setChunk(e){return e.replace(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,i){i=i||this.store.resolve(L.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(st,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=L.join(this.store.appSrc,e),i=L.join(t,"**","*.{ts,tsx,jsx,js}"),r=await be([i],{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}"),i=await be([t],{windowsPathsNoEscape:!0});if(i[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,i[0])}h.timeEnd(e)}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},as=new it});import ps from"path";var rt,cs,hs=v(()=>{"use strict";c();$();rt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:R(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",ps.dirname(k.resolve("@swc/helpers/package.json"))),this.coreJs.path=k.resolve("core-js/package.json");let t=Ye(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ps.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},cs=new rt});import M from"@rspack/core";import fs from"fs";import pr from"path";import{TsCheckerRspackPlugin as cr}from"ts-checker-rspack-plugin";var ot,us,ms=v(()=>{"use strict";c();xe();ot=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(Pe)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(cr,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");fs.existsSync(e)&&fs.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=k("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=pr.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},us=new ot});var nt,ds,gs=v(()=>{"use strict";c();rs();ns();ls();hs();ms();nt=class{store;async setup(e){this.store=e;let t=[is.setup(this.store),cs.setup(this.store),us.setup(this.store),as.setup(this.store),os.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ds=new nt});import hr from"net";import fr from"os";async function _e(s,e=void 0){if(s!==ur&&(s<ys||s>at))throw new Error(`Port number must lie between ${ys} and ${at}`);let t=s,i=mr(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=at;)try{return await gr(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var ys,at,ur,mr,dr,gr,ws=v(()=>{"use strict";c();ys=1024,at=65535,ur=443,mr=()=>{let s=fr.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},dr=(s,e)=>new Promise((t,i)=>{let r=hr.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),gr=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await dr(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});import yr from"chalk";import vs from"url";var lt,Se,bs=v(()=>{"use strict";c();X();$();lt=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:q("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=U;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:yr.bold(i),pathname:r})}},Se=new lt});import{exec as wr}from"child_process";import{promisify as vr}from"util";var Es,Cs,br,Cr,Ps,xs=v(()=>{"use strict";c();I();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 s=process.env.BROWSER;if(!s||!Cs.includes(s)){let{stdout:e}=await Es("ps cax");s=Cs.find(t=>e.includes(t))}return s},Cr=async s=>{if(process.platform==="darwin")try{let t=await br();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Es(i,{cwd:d.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Ps=Cr});import _s from"fs/promises";var ke,Ss=v(()=>{"use strict";c();K();X();ws();bs();xs();$();ke=class{ip=U();host=this.ip;isAutoDevBase=!1;isHttps=!1;httpsType="default";protocol="http";port=8e3;store;publicPath="/";publicHasHttp=!1;isOpenBrower=!1;url="";urls={localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""};constructor(e){this.store=e}async setupOnEmpOptionSync(){this.store.cliAction!=="build"&&(this.port=await _e(this.port),this.setHttps(),await this.setAutoDevBase())}get config(){return{}}async setupOnStore(){if(this.store.cliAction==="build")return;let{store:e}=this;this.publicPath=e.rsConfig.output?.publicPath==="auto"?"/":e.rsConfig.output?.publicPath||"/",this.isOpenBrower=!!e.empConfig.server.open,this.protocol=this.isHttps?"https":"http",this.host=e.empConfig.server.host?e.empConfig.server.host:this.ip,e.empConfig.server.port&&e.empConfig.server.port!==this.port&&(this.port=await _e(e.empConfig.server.port)),Se.setup(this),this.publicPath&&(this.publicPath.indexOf("http://")>-1||this.publicPath.indexOf("https://")>-1)?(this.url=this.publicPath,this.publicHasHttp=!0,this.urls.localUrlForTerminal=Se.prettyPrintUrl("localhost")):(this.urls=Se.urls,this.url=this.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this;this.publicHasHttp?(h.info(`${z("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${z("\u279C")} Network: ${h.link(this.publicPath)}`)):(h.info(`${z("\u279C")} Local: ${h.link(e.localUrlForTerminal)}`),h.info(`${z("\u279C")} Network: ${h.link(e.lanUrlForTerminal)}
|
|
12
|
-
`)),this.isOpenBrower&&Ps(this.url)}async getcert(){let{store:e}=this,t=this.store.rsConfig.devServer||{server:{type:"http"}};if(typeof t.server=="object"&&t.server.type==="https"&&t.server.options&&t.server.options.key&&t.server.options.cert)return t.server.options;let[i,r]=await Promise.all([_s.readFile(e.resource.key),_s.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await _e(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import Er from"fs/promises";import
|
|
10
|
+
`)}},h=new ye});var Ke={};Z(Ke,{clearConsole:()=>qe,deepAssign:()=>R,ensureArray:()=>sr,getLanIp:()=>U,getPkgVersion:()=>Ye,importJsVm:()=>Xe,jsonFilter:()=>ir,timeFormat:()=>ve,vCompare:()=>we});import{ip as Qi}from"address";import Zi from"chalk";import{gateway4sync as er}from"default-gateway";import tr from"fs-extra";function qe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function R(s,...e){for(let t of e)for(let i in t){let r=t[i],o=s[i];if(Object(r)==r&&Object(o)===o){s[i]=R(o,r);continue}s[i]=t[i]}return s}var U,Ye,sr,ir,we,ve,Xe,$=v(()=>{"use strict";c();U=()=>{let s="127.0.0.1";try{let{int:e}=er();return Qi(e||"")||s}catch{return s}},Ye=s=>{try{let{version:e}=tr.readJSONSync(s);return e}catch{return}};sr=s=>Array.isArray(s)?s:[s],ir=(s={},e=[])=>Object.keys(s).filter(t=>!e.includes(t)).reduce((t,i)=>(t[i]=s[i],t),{}),we=(s="",e="")=>{let t=s.replace("^","").split("."),i=e.replace("^","").split("."),r=Math.max(t.length,i.length),o=0;for(let a=0;a<r;a++){let n=t.length>a?t[a]:0,l=isNaN(Number(n))?n.charCodeAt():Number(n),f=i.length>a?i[a]:0,p=isNaN(Number(f))?f.charCodeAt():Number(f);if(l<p){o=-1;break}else if(l>p){o=1;break}}return o},ve=s=>{s=s/1e3;let e=i=>Zi.bold(i);if(s<1)return`${s*1e3} ms`;if(s<10){let i=s>=.01?2:3;return`${e(s.toFixed(i))} s`}if(s<60)return`${e(s.toFixed(1))} s`;let t=s/60;return`${e(t.toFixed(2))} m`},Xe=s=>`data:text/javascript,${s}`});var Bt={};Z(Bt,{chalk:()=>rr,color:()=>_,glob:()=>be,logger:()=>h,utils:()=>Ke});import rr from"chalk";import{glob as be}from"glob";var 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 s="store.getEmpConfigPath";h.time(s);let e=nr.map(r=>Vt.resolve(d.root,r)),t=await Promise.all(e.map(r=>Jt.promises.access(r).then(()=>!0,()=>!1))),i=e.find((r,o)=>t[o]);return h.timeEnd(s),i},Xt=async()=>{let s=Vt.join(d.root,"tsconfig.json");return await Jt.promises.access(s).then(()=>!0,()=>!1)||(s=void 0),s},Kt=()=>{let s=[g];return d.rootPaths.pkg&&s.push(d.rootPaths.pkg),d.rootPaths.empConfig&&s.push(d.rootPaths.empConfig),d.rootPaths.tsConfig&&s.push(d.rootPaths.tsConfig),s}});import Qt from"@empjs/chain";var Zt,Qe=v(()=>{"use strict";c();Zt={rule:{mjs:"mjs",typescript:"typescript",javascript:"javascript",sourceMap:"sourceMapLoader",inline:"inline",raw:"raw",svg:"svg",image:"image",font:"fonts",svga:"svga",sass:"sass",less:"less",css:"css"},use:{swc:"swc",sourceMap:"sourceMapLoader",sass:"sassLoader",less:"lessLoader"},plugin:{tsCheckerRspackPlugin:"TsCheckerRspackPlugin",bundleAnalyzer:"bundleAnalyzerPlugin",define:"definePlugin",copy:"copyRspackPlugin",progress:"progressPlugin",html:{prefix:"html-plugin-"},rsdoctor:"rsdoctor",sourceMapDevTool:"sourceMapDevTool"},minimizer:{minJs:"minJs",minCss:"minCss"}}});var Ee,es=v(()=>{"use strict";c();Ee=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeModule(){this.op.beforeModule&&await this.op.beforeModule()}async afterModule(){this.op.afterModule&&await this.op.afterModule()}async beforeEmpPlugin(){this.op.beforeEmpPlugin&&await this.op.beforeEmpPlugin()}async afterEmpPlugin(){this.op.afterEmpPlugin&&await this.op.afterEmpPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});var Ze,ts,ss=v(()=>{"use strict";c();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:i,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),i&&(this.base=i),r&&(this.appEntry=r)}async setupEmpOptions(){await this.store.server.setupOnEmpOptionSync()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){let e=!1;return this.store.cliOptions.doctor&&(e={}),this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rsdoctor:e,infrastructureLogging:{appendOnly:!0,level:"warn"},newTreeshaking:this.store.empConfig.isESM,devShowAllLog:!1,showScriptDebug:!1,cssChunkingPlugin:!0,warnRuleAsWarning:!0},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"",t={js:this.store.isDev?"cheap-module-source-map":"source-map",css:!1};return this.store.empOptions.build?.sourcemap===!0&&(t.css=!0,t.js=this.store.isDev?"cheap-module-source-map":"source-map"),this.store.empOptions.build?.devtool&&(t.js=this.store.empOptions.build?.devtool),this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:t,minify:!this.store.isDev,minOptions:{},cssminOptions:{},target:"es5",useESM:!1,polyfill:{mode:void 0,entryCdn:void 0,splitChunks:!1,include:[],coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},swcConfig:{},devtool:this.store.isDev?"cheap-module-source-map":"source-map"},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?{}:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{name:"viewport",content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,cache:this.cache!==!1,tags:[]},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.store.empOptions.server?.http2&&(this.store.server.httpsType="h2",delete this.store.empOptions.server.http2),this.assign(e,this.store.empOptions.server)}get css(){return this.assign({sass:{mode:"modern",warnRuleAsWarning:this.store.empConfig.debug.warnRuleAsWarning},less:{lessOptions:{javascriptEnabled:!0,math:"always"}},prifixName:""},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:i,staticDir:r}=this.store.empConfig.build,o={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${i}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!this.store.isDev,uniqueName:this.store.uniqueName};return this.assign(o,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}get tsCheckerRspackPlugin(){let e={};if(this.store.empOptions.tsCheckerRspackPlugin)typeof this.store.empOptions.tsCheckerRspackPlugin=="object"&&(e=this.store.empOptions.tsCheckerRspackPlugin);else return!1;return this.assign({},e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",i={};return Object.keys(e).map(r=>{t==="all"?(i[`import.meta.env.${r}`]=JSON.stringify(e[r]),i[`process.env.${r}`]=JSON.stringify(e[r])):t==="esm"?i[`import.meta.env.${r}`]=JSON.stringify(e[r]):t==="cjs"?i[`process.env.${r}`]=JSON.stringify(e[r]):t==="none"&&(i[`${r}`]=JSON.stringify(e[r]))}),i}get externals(){return this.assign({},this.store.empOptions.externals)}get resolve(){return R({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e="store.jiti.loadConfig.empConfig";if(h.time(e),!this.store.rootPaths.empConfig)return;let{default:t}=await Yt(this.store.rootPaths.empConfig);typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{},h.timeEnd(e)}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),i={and:[],not:[]};return t.defaultExclude===!0&&i.and.push(/(node_modules|bower_components)/),t?.exclude&&(i.and=i.and.concat(t.exclude)),e?.include&&(i.not=t.include),i}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get cache(){return this.store.empOptions.cache===!1?!1:this.store.empOptions.cache?this.store.empOptions.cache:"persistent"}get ignoreWarnings(){return this.store.empOptions.ignoreWarnings?this.store.empOptions.ignoreWarnings:[/Conflicting order/]}get autoPages(){let e;return this.store.empOptions.autoPages&&(e=typeof this.store.empOptions.autoPages=="boolean"?{}:this.store.empOptions.autoPages,e=this.assign({path:"pages"},e)),e}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/**"]}})}async checkTsconfig(){let e=this.store.resolve("tsconfig.json");if(await ar.exists(e)){let i={};this.store.isOldRspack?i.tsConfigPath=e:i.tsConfig=e,this.store.merge({resolve:i})}}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"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,i={},{sass:r}=this.store.empConfig.css;r.mode==="modern"&&(i.implementation=r.implementation?r.implementation:k.resolve("sass-embedded"),i.api="modern-compiler",i.sourceMap=this.store.empConfig.build.sourcemap.css,r.sassOptions&&(i.sassOptions=r.sassOptions)),typeof r.additionalData<"u"&&(i.additionalData=r.additionalData),typeof r.warnRuleAsWarning<"u"&&(i.warnRuleAsWarning=r.warnRuleAsWarning),typeof r.webpackImporter<"u"&&(i.webpackImporter=r.webpackImporter),this.store.chain.merge({module:{rule:{[e.sass]:{test:/\.(sass|scss)$/,use:{[t.sass]:{loader:k.resolve("sass-loader"),options:i}},type:"css/auto"}}}})}async less(){let{rule:e,use:t}=this.store.chainName,{lessOptions:i}=this.store.empConfig.css.less,r={loader:k.resolve("less-loader"),options:{lessOptions:i}};this.store.chain.merge({module:{rule:{[e.less]:{test:/\.less$/,use:{[t.less]:r},type:"css/auto"}}}})}async css(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.css]:{test:/\.css$/,use:{},type:"css/auto"}}}})}},os=new tt});import st from"html-webpack-plugin";function lr(){let s=[`import 'core-js/${d.empConfig.build.polyfill.coreJsFeatures}'`].join(`
|
|
11
|
+
`);return Xe(s)}var Pe,se,xe=v(()=>{"use strict";c();$();I();Pe=class{constructor(){}apply(e){let{webpack:t}=e;d.empConfig.build.polyfill.entryCdn||new t.EntryPlugin(e.context,lr(),{name:void 0}).apply(e)}},se=class{PluginName="HtmlEmpInjectPlugin";chunk="";files=[];constructor(e,t="",i=""){this.PluginName=`${this.PluginName}-${t}`,this.files=e,this.chunk=i}apply(e){e.hooks.compilation.tap(this.PluginName,t=>{st.getHooks(t).alterAssetTagGroups.tapPromise(this.PluginName,async i=>(this.chunk&&!i.plugin.userOptions.chunks?.includes(this.chunk)||this.files.map(r=>{let{pos:o,...a}=r;(o==="body"?i.bodyTags:i.headTags).push({attributes:{},voidTag:!1,meta:{plugin:void 0},tagName:"script",...a})}),i))})}}});import F 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(F.extname(e),"").replace(`${this.store.empConfig.appSrc}${F.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(F.join("template","index.html"))}setFavicion(e){if(e!=="")return e?this.store.resolve(e):this.store.empResolve(F.join("template","favicon.ico"))}setEntryItem(e,t,i){i=i||this.store.resolve(F.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),o=[i];this.entriesConfig[r]={entry:{[r]:o},html:this.setHtmlConfig(t,[r])},this.store.entries[r]=o}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`${this.store.chainName.plugin.html.prefix}${t}`).use(st,[e])}setRspackEntry(e){this.store.merge({entry:e})}async init(){this.injectPolyfill(),this.store.empConfig.autoPages?await this.setAutoPage():(await this.setDefaultEntry(),this.setEntryByConfig())}async setAutoPage(){h.time("setAutoPage");let e=this.store.empConfig.autoPages?.path||"pages",t=F.join(this.store.appSrc,e),i=F.join(t,"**","*.{ts,tsx,jsx,js}"),r=await be([i],{windowsPathsNoEscape:!0});r=r.map(o=>o.replace(`${t}${F.sep}`,"")),r.map(o=>{let a=this.store.empConfig.entries[o]||{};this.setEntryItem(o,{...this.store.empConfig.html,...a},F.join(t,o))}),h.timeEnd("setAutoPage")}async setDefaultEntry(){let e="store.empConfig.setDefaultEntry";h.time(e);let t=F.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}"),i=await be([t],{windowsPathsNoEscape:!0});if(i[0]){let r=F.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(r,this.store.empConfig.html,i[0])}h.timeEnd(e)}setEntryByConfig(){if(Object.keys(this.store.empConfig.entries).length>0)for(let[e,t]of Object.entries(this.store.empConfig.entries))this.setEntryItem(e,{...this.store.empConfig.html,...t})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},as=new it});import ps from"path";var rt,cs,hs=v(()=>{"use strict";c();$();rt=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e,this.swcInitOptions(),await this.run()}async run(){let e=[this.jsDataUrl(),this.files(),this.scripts(),this.rspackGenerator(),this.rspackParser()];await this.store.empConfig.lifeCycle.beforeModule(),await Promise.all(e),await this.store.empConfig.lifeCycle.afterModule()}rspackGenerator(){let e=this.store.empConfig.css?.prifixName?`${this.store.empConfig.css?.prifixName}-`:"",t=this.store.isDev?`${e}[id]-[local]-[hash:base64:8]`:`${e}[local]-[hash:5]`;this.store.chain.merge({module:{generator:{"css/auto":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},css:{exportsOnly:!1,esModule:!0},"css/module":{exportsConvention:"as-is",exportsOnly:!1,localIdentName:t,esModule:!0},json:{JSONParse:!0}}}})}rspackParser(){this.store.chain.merge({module:{parser:{javascript:{dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,url:!0,importMeta:!0},css:{namedExports:!1},"css/auto":{namedExports:!1},"css/module":{namedExports:!1}}}})}get isPolyfill(){return!!this.store.empConfig.build.polyfill.mode}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}swcJsc(e){let{target:t,polyfill:i}=this.store.empConfig.build,{externalHelpers:r}=i;return{parser:this.swcParser(e),transform:{},target:t,externalHelpers:r,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:R(this.swcJsc(e),{...this.store.empConfig.build.swcConfig}),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.polyfill.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill.mode),this.store.empConfig.build.polyfill.mode==="usage"&&(t.env.shippedProposals=!0,t.env.include=this.store.empConfig.build.polyfill.include)),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build.polyfill;e&&this.store.chain.resolve.alias.set("@swc/helpers",ps.dirname(k.resolve("@swc/helpers/package.json"))),this.coreJs.path=k.resolve("core-js/package.json");let t=Ye(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ps.dirname(this.coreJs.path),this.store.empConfig.build.polyfill.mode&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}jsDataUrl(){this.store.chain.module.rule("jsDataUrl").merge({mimetype:{or:["text/javascript","application/javascript"]}}).resolve.set("fullySpecified",!1).end().use("swcJsParser").loader("builtin:swc-loader").options(this.swcJsOptions)}async scripts(){let e=[],{rule:t,use:i}=this.store.chainName;this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{[t.mjs]:{test:/\.m?js/,resolve:{fullySpecified:!1}},[t.typescript]:{test:/\.(ts|tsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcTsOptions}}},[t.javascript]:{test:/\.((m|c)?js|jsx)$/,exclude:e,use:{[i.swc]:{loader:"builtin:swc-loader",options:this.swcJsOptions}}}}}})}async files(){let{rule:e}=this.store.chainName;this.store.chain.merge({module:{rule:{[e.svg]:{test:/\.svg$/,type:"asset/resource"}}}}),this.store.chain.merge({module:{rule:{[e.inline]:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{[e.raw]:{resourceQuery:/raw/,type:"asset/source"}}}}),this.store.chain.merge({module:{rule:{[e.image]:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},[e.font]:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},[e.svga]:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},cs=new rt});import M from"@rspack/core";import fs from"fs";import pr from"path";import{TsCheckerRspackPlugin as cr}from"ts-checker-rspack-plugin";var ot,us,ms=v(()=>{"use strict";c();xe();ot=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.minify(),this.redoctor(),this.sourceMapDevToolPlugin(),this.tsCheckerRspackPlugin(),this.cssChunkingPlugin(),this.esmLibraryPlugin()];this.beforeLifeCycle(),await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}beforeLifeCycle(){let{store:e}=this;e.empConfig.build.polyfill.mode==="entry"&&e.chain.plugin("empPolyfill").use(Pe)}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin(this.store.chainName.plugin.bundleAnalyzer).use(e,[{analyzerPort:this.store.empConfig.server.port,defaultSizes:"gzip",analyzerHost:this.store.getLanIp()||"127.0.0.1"}])}tsCheckerRspackPlugin(){if(this.store.empConfig.tsCheckerRspackPlugin===!1)return!1;this.store.chain.plugin(this.store.chainName.plugin.tsCheckerRspackPlugin).use(cr,[this.store.empConfig.tsCheckerRspackPlugin])}async define(){this.store.chain.plugin(this.store.chainName.plugin.define).use(M.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");fs.existsSync(e)&&fs.readdirSync(e).length>0&&this.store.chain.plugin(this.store.chainName.plugin.copy).use(M.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve(this.store.empConfig.build.outDir),noErrorOnMissing:!0,globOptions:{ignore:["**/.DS_Store"]}}]}])}async progress(){if(this.store.mode==="development")return;let e={};this.store.isOldRspack||(e={template:"{bar:25.green/white}{spinner:.green}{percent}% {wide_msg:.dim}",tick:void 0,progressChars:"\u25A9\u25A9"}),this.store.chain.plugin(this.store.chainName.plugin.progress).use(M.ProgressPlugin,[e])}minify(){this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minJs).use(M.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]);let{SwcCssMinimizerRspackPlugin:e,LightningCssMinimizerRspackPlugin:t}=M;e?this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(e,[this.store.empConfig.build.cssminOptions]):t&&this.store.chain.optimization.minimizer(this.store.chainName.minimizer.minCss).use(t,[this.store.empConfig.build.cssminOptions])}redoctor(){if(!this.store.empConfig.debug.rsdoctor)return;let{RsdoctorRspackPlugin:e}=k("@rsdoctor/rspack-plugin"),t={};typeof this.store.empConfig.debug.rsdoctor=="object"&&(t=this.store.empConfig.debug.rsdoctor),this.store.chain.plugin(this.store.chainName.plugin.rsdoctor).use(e,[t])}sourceMapDevToolPlugin(){typeof this.store.empConfig.build.sourcemap=="object"&&this.store.empConfig.build.sourcemap?.devToolPluginOptions&&this.store.chain.plugin(this.store.chainName.plugin.sourceMapDevTool).use(M.SourceMapDevToolPlugin,[this.store.empConfig.build.sourcemap.devToolPluginOptions])}circularDependency(){this.store.chain.plugin("circularDependency").use(M.CircularDependencyRspackPlugin,[{}])}cssChunkingPlugin(){this.store.empConfig.debug.cssChunkingPlugin&&this.store.chain.plugin("CssChunkingPlugin").use(M.experiments.CssChunkingPlugin,[{}])}esmLibraryPlugin(){if(!this.store.empConfig.isESM)return;let e=pr.resolve(this.store.root,"src");this.store.chain.plugin("esmLibraryPlugin").use(M.experiments.EsmLibraryPlugin,[{preserveModules:e}]),this.store.chain.optimization.merge({runtimeChunk:!0})}},us=new ot});var nt,ds,gs=v(()=>{"use strict";c();rs();ns();ls();hs();ms();nt=class{store;async setup(e){this.store=e;let t=[is.setup(this.store),cs.setup(this.store),us.setup(this.store),as.setup(this.store),os.setup(this.store)];await Promise.all(t),await this.store.empConfig.lifeCycle.beforeEmpPlugin(),await this.store.empConfig.plugins(),await this.store.empConfig.lifeCycle.afterEmpPlugin(),await this.store.empConfig.chain()}},ds=new nt});import hr from"net";import fr from"os";async function _e(s,e=void 0){if(s!==ur&&(s<ys||s>at))throw new Error(`Port number must lie between ${ys} and ${at}`);let t=s,i=mr(),r;e&&!i.has(e)?r=new Set([e]):r=i;let o=new Set(["EADDRINUSE","EACCES"]);for(;t<=at;)try{return await gr(t,r)}catch(a){if(!o.has(a.code))throw a;t+=1}throw new Error("No available ports found")}var ys,at,ur,mr,dr,gr,ws=v(()=>{"use strict";c();ys=1024,at=65535,ur=443,mr=()=>{let s=fr.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(s))if(t)for(let i of t)e.add(i.address);return e},dr=(s,e)=>new Promise((t,i)=>{let r=hr.createServer();r.unref(),r.on("error",i),r.listen(s,e,()=>{let{port:o}=r.address();r.close(()=>{t(o)})})}),gr=async(s,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let i of e)try{await dr(s,i)}catch(r){if(!t.has(r.code))throw r}return s}});import yr from"chalk";import vs from"url";var lt,Se,bs=v(()=>{"use strict";c();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==="::",i;if(t){i="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else i=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(i),this.urls.localUrlForBrowser=this.formatUrl(i)}getLanIp=U;formatUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:i,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:i,pathname:r}=this.imf;return vs.format({protocol:t,hostname:e,port:yr.bold(i),pathname:r})}},Se=new lt});import{exec as wr}from"child_process";import{promisify as vr}from"util";var Es,Cs,br,Cr,Ps,xs=v(()=>{"use strict";c();I();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 s=process.env.BROWSER;if(!s||!Cs.includes(s)){let{stdout:e}=await Es("ps cax");s=Cs.find(t=>e.includes(t))}return s},Cr=async s=>{if(process.platform==="darwin")try{let t=await br();if(t){let i=`osascript openChrome.applescript "${encodeURI(s)}" "${t}"`;return await Es(i,{cwd:d.resource.dir}),!0}}catch(t){h.debug(t)}try{let{default:t}=await import("open");return await t(s),!0}catch(t){return h.error("Failed to open start URL."),h.error(t),!1}},Ps=Cr});import _s from"fs/promises";var ke,Ss=v(()=>{"use strict";c();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[i,r]=await Promise.all([_s.readFile(e.resource.key),_s.readFile(e.resource.cert)]);return{key:i,cert:r}}setHttps(){let{store:e}=this,{server:t,https:i}=e.empOptions.server||{};this.isHttps=t==="https"||typeof t=="object"&&t.type==="https"||i===!0}async setAutoDevBase(){let{store:e}=this;this.isAutoDevBase=!!e.empOptions.autoDevBase&&e.mode==="development"&&!this.isHttpBase,this.isAutoDevBase&&(this.protocol=this.isHttps?"https":"http",e.empOptions.server?.port&&(this.port=e.empOptions.server.port),this.port=await _e(this.port),e.empOptions.base=`${this.protocol}://${this.host}:${this.port}/`,e.empOptions.server=e.deepAssign({port:this.port,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${this.host}:${this.port}/ws`}},e.empOptions.server))}get isHttpBase(){let e=this.store.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}}});import Er from"fs/promises";import L 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=L.resolve(w,g).replace(`${L.sep}dist${L.sep}index.js`,"");empSource=L.resolve(this.empRoot,"dist");resolve=e=>L.isAbsolute(e)?e:L.resolve(this.root,e);empResolve=e=>L.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};chainName=Zt;server=new ke(this);cacheDir="";mode="development";cliMode="dev";isDev=!0;chain;rsConfig;empOptions={};empConfig;entries={};debug;cliAction;cliOptions;rootPaths={empConfig:void 0,tsConfig:void 0,pkg:void 0};beforeSetup;afterSetup;async setup(e,t){this.cliAction=e||this.cliAction,this.cliOptions=t||this.cliOptions;let i="store.setup";h.time(i),this.beforeSetup&&await this.beforeSetup();let[r,o]=await Promise.all([qt(),Xt()]);this.rootPaths.empConfig=r,this.rootPaths.tsConfig=o,this.rootPaths.pkg=this.resolve("package.json"),await this.initVars(this.cliAction,this.cliOptions),this.empConfig=ts,await this.empConfig.setup(this),this.debug={...this.empConfig.debug},this.initPaths(),this.chain=new Qt,await ds.setup(this),this.setLogger(),this.toConfig(),this.logConfig(),await this.server.setupOnStore(),this.afterSetup&&await this.afterSetup(),h.timeEnd(i),this.debug.clearLog&&qe()}async initVars(e,t){this.cliAction=e,this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development",process.env.NODE_ENV=e==="dev"?"development":"production";let i=k(this.empResolve("package.json")),r=k(this.resolve("package.json"));this.empPkg={...this.empPkg,...i},this.pkg={...this.pkg,...r},this.resource.dir=L.join(this.empRoot,"resource"),this.resource.cert=L.join(this.resource.dir,"emp.cert"),this.resource.key=L.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=L.join(this.root,this.debug.showRsconfig);Er.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{this.debug.clearLog=!1;let e={colors:!0,depth:null},t=typeof this.debug.showRsconfig=="object"?R(e,this.debug.showRsconfig):e;console.log(h.link("[Compile Config]")),console.log(Pr.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 16"]}}get uniqueName(){return this.encodeVarName(this.pkg.name)}encodeVarName(e){return e.replaceAll("/","_").replaceAll("@","_").replaceAll("-","_")}vCompare=we;deepAssign=R;getLanIp=U;injectTags(e=[],t="",i=""){this.chain.plugin(`${se}-${t}`).use(se,[e,t,i])}},d=new pt});import xr from"fs";import H from"path";import B from"chalk";import{gzipSizeSync as _r}from"gzip-size";function jr(s,e){let t=[s,e],i=["File","Size","Gzipped"].reduce((r,o,a)=>{let n=t[a],l=o;return n&&(l=o.length<n?o+" ".repeat(n-o.length):o),`${r+l} `}," ");console.log(q.bold(i))}async function Os(s){let e=s.toJson({all:!1,assets:!0,timings:!0}),i=e.assets.filter(p=>Tr(p.name)).map(Rr);i.sort((p,m)=>p.size-m.size);let r=Math.max(...i.map(p=>p.sizeLabel.length)),o=Math.max(...i.map(p=>(p.folder+H.sep+p.name).length));jr(o,r);let a=0,n=0;i.forEach(p=>{let{sizeLabel:m}=p,{name:u,folder:b,gzipSizeLabel:C}=p,E=(b+H.sep+u).length,T=m.length;if(a+=p.size,n+=p.gzippedSize,T<r){let j=" ".repeat(r-T);m+=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(m)} ${C}`)});let l=`${q.bold("Total size:")} ${Oe(a)}`,f=`${q.bold("Gzipped size:")} ${Oe(n)}`;h.info(`
|
|
13
13
|
${l}
|
|
14
14
|
${f}
|
|
15
15
|
`),h.info(`${B.green("ready ")}Built in ${ve(Number(e.time))}
|
|
16
|
-
`)}function Te(s,e){let t=s==="start"?B.cyan("start "):B.green("ready ");console.log(t+B.white(e))}function Ts(s=0,e="Ready"){h.info(`${B.green("ready ")}${e} in ${ve(Number(s))}`)}function Ds(s="build"){Te("start",`${s} Started...`)}function Rs(s){let e=s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Te("ready",`built in ${B.bold((e.time/1e3).toFixed(2))} s`)}function js(s="build started..."){Te("start",s)}function As(s,e="built"){let t;typeof s=="number"?t=(s/1e3).toFixed(2):t=((s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0})).time/1e3).toFixed(2),Te("ready",`${e} in ${B.bold(t)} s`)}var Sr,kr,Or,Tr,Dr,Rr,Oe,Ar,ie=v(()=>{"use strict";c();
|
|
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()})}},
|
|
16
|
+
`)}function Te(s,e){let t=s==="start"?B.cyan("start "):B.green("ready ");console.log(t+B.white(e))}function Ts(s=0,e="Ready"){h.info(`${B.green("ready ")}${e} in ${ve(Number(s))}`)}function Ds(s="build"){Te("start",`${s} Started...`)}function Rs(s){let e=s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});Te("ready",`built in ${B.bold((e.time/1e3).toFixed(2))} s`)}function js(s="build started..."){Te("start",s)}function As(s,e="built"){let t;typeof s=="number"?t=(s/1e3).toFixed(2):t=((s?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0})).time/1e3).toFixed(2),Te("ready",`${e} in ${B.bold(t)} s`)}var Sr,kr,Or,Tr,Dr,Rr,Oe,Ar,ie=v(()=>{"use strict";c();K();I();N();$();Sr=/\.html$/,kr=/\.(?:js|mjs|cjs|jsx)$/,Or=/\.css$/,Tr=s=>!/\.map$/.test(s)&&!/\.LICENSE\.txt$/.test(s),Dr=s=>s>300*1e3?Be:s>100*1e3?ge:Je,Rr=s=>{let e=s.name.split("?")[0],t=Oe(s.size),i=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=Dr(n)(Oe(n));return{size:a,folder:r,name:i,gzippedSize:n,sizeLabel:t,gzipSizeLabel:l}};Oe=s=>{let e=s/1e3;return`${e.toFixed(e<1?2:1)} kB`},Ar=s=>kr.test(s)?ge(s):Or.test(s)?z(s):Sr.test(s)?q(s):Ve(s)});import Fs from"chalk";import De from"path";function ct(s,e){return s.map(t=>{let i=De.relative(e,t);return Fs.dim(De.dirname(i)+De.sep)+Fs.dim(De.basename(i))})}function Ls(s,e){let t="emp:compiler",i=new Set,r=new Map,o=!1,a=new Set,n=!1,l=s.options.context||process.cwd(),f=u=>Fr.test(u)&&!Lr.test(u),p=u=>{let b=new Set,C=new Set;if(u.modifiedFiles||u.removedFiles){if(u.modifiedFiles){for(let E of u.modifiedFiles)if(f(E)){let T=r.get(E)||0,S=Date.now();S-T>300&&(b.add(E),r.set(E,S))}}if(u.removedFiles)for(let E of u.removedFiles)f(E)&&(C.add(E),r.delete(E));return{changed:b,removed:C}}if(u.watchFileSystem?.watcher){let T=u.watchFileSystem.watcher.mtimes||{};for(let S of Object.keys(T)){if(!f(S))continue;let j=T[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 m(u,b){if(!e.isServerStarted)return;let C=Array.from(u),E=Array.from(b),T=Array.from(a);if(C.length===0&&E.length===0&&T.length===0)return;let S="";if(C.length>0){let j=ct(C,l);S+=`modified ${j.join(", ")}`}if(T.length>0){let j=ct(T,l);S+=`lazyLoaded ${j.join(", ")}`}if(E.length>0){let j=ct(E,l);S+=`removed ${j.join(", ")}`}js(S)}return s.hooks.watchRun.tap(t,u=>{if(n)return;n=!0,i.clear(),a.clear();let{changed:b,removed:C}=p(u);o=b.size>0||C.size>0,o&&m(b,C),b.forEach(E=>i.add(E))}),s.hooks.done.tap(t,u=>{if(!e.isServerStarted||!o){n=!1;return}(i.size>0||a.size>0)&&(As(u),o=!1),n=!1}),{cleanup:()=>{i.clear(),r.clear(),a.clear(),o=!1,n=!1}}}var Fr,Lr,Ns=v(()=>{"use strict";c();ie();Fr=/\/src\//,Lr=/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 i=`${e}.setup`,r=`${e}.run`;h.time(i),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(i)}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,i,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{createProxyMiddleware as Gr}from"http-proxy-middleware";import Ur from"http2";import Ms from"path";import Br from"serve-static";import{parse as Jr}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 i="index",r=Object.keys(e.rsConfig.entry);if(r.length===0)return e.logger.sysError("emp serve must include entry!");if(r.includes(i)||(i=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(Gr({...f,pathFilter:l}))}),J.use(Br(o));let a=await Mr.readFile(Ms.join(o,`${i}.html`),"utf8");if(J.use((n,l,f)=>{let m=Jr(n.url||"",!0).pathname;if(m&&m!=="/"&&Is.existsSync(Ms.join(o,m)))return f();l.setHeader("Content-Type","text/html"),l.end(a)}),e.server.isHttps){let{key:n,cert:l}=await e.server.getcert();Ur.createSecureServer(typeof e.server.isHttps!="boolean"?e.server.isHttps:{key:n,cert:l,allowHTTP1:!0},J).listen(e.server.port,t)}else k("http").createServer(J).listen(e.server.port,t)}}});var ht=v(()=>{"use strict";c();$s();zs()});var Hs={};Z(Hs,{default:()=>qr});import{rspack as Vr}from"@rspack/core";import ft from"fs";import Yr from"path";var ne,ut,qr,Ws=v(()=>{"use strict";c();Gt();Q();ie();Ns();$();Re();ht();I();ne=new re,ut=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:i,cert:r}=await d.server.getcert();t.server={type:"https",options:{key:i,cert:r}}}return Object.hasOwn(t,"https")&&delete t.https,e}async startDevServer(e=!1){try{let{server:t}=d,i=await this.getRspackDevConfig();i=await ne.beforeCompiler(i);let r=Vr(i);await d.empConfig.lifeCycle.beforeDevServe(),t.startOpen(),Ds("DevServer"),await ne.setup(r,i,d,async a=>{ne.isServerStarted=!0,Rs(a),await d.empConfig.lifeCycle.afterDevServe()});let o=Ls(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=Yr.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 i=>{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: ${i}`),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=[]}}},qr=new ut});var mt={};Z(mt,{ServeScript:()=>je,default:()=>Kr});var Xr,Gs,je,Kr,dt=v(()=>{"use strict";c();ie();Re();ht();I();Xr=new oe,Gs=0,je=class extends W{async run(){Gs=Date.now(),await d.empConfig.lifeCycle.beforeServe(),await Xr.setup(d,this.onReady)}onReady=async()=>{d.server.startOpen(),Ts(Date.now()-Gs,"Server Started"),await d.empConfig.lifeCycle.afterServe()}},Kr=new je});var Us={};Z(Us,{default:()=>Zr});import{rspack as Qr}from"@rspack/core";var gt,Zr,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(),mt));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(),Qr(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()})}},Zr=new gt});c();import{rspack as Vl}from"@rspack/core";import{program as ql}from"commander";c();Ae();import eo 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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Ws(),Hs));await e.setup("dev",s)}),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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(Bs(),Us));await e.setup("build",s)}),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",(s,e)=>{let[t,i]=s.split("=");return e[t]=i,e},{}).action(async s=>{let{default:e}=await Promise.resolve().then(()=>(dt(),mt));await e.setup("serve",s)}),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(s=>{}),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(s=>{}),V.parse(eo.argv)}I();N();Q();function Ql(s){return s}export{ye as Logger,_ as color,Ql as defineConfig,Bt as empHelper,ql as program,Vl as rspack,Js as runScript,d as store};
|
|
18
18
|
/*! Bundled license information:
|
|
19
19
|
|
|
20
20
|
chokidar/esm/index.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empjs/cli",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "emp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"glob": "11.0.3",
|
|
114
114
|
"gzip-size": "7.0.0",
|
|
115
115
|
"html-webpack-plugin": "5.6.4",
|
|
116
|
+
"http-proxy-middleware": "^3.0.5",
|
|
116
117
|
"jiti": "2.6.1",
|
|
117
118
|
"less-loader": "^12.2.0",
|
|
118
119
|
"open": "10.2.0",
|