@likec4/mcp 1.49.0 → 1.51.0
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/README.md +11 -1
- package/dist/THIRD-PARTY-LICENSES.md +108 -5
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
- package/dist/_chunks/libs/@logtape/logtape.mjs +1 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -7
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -0
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/_chunks/libs/chevrotain.mjs +35 -35
- package/dist/_chunks/libs/chokidar.mjs +2 -2
- package/dist/_chunks/libs/citty.mjs +1 -1
- package/dist/_chunks/libs/isexe.mjs +1 -0
- package/dist/_chunks/libs/langium.mjs +18 -17
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +2 -2
- package/dist/_chunks/libs/mdast-util-gfm.mjs +9 -9
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +7 -7
- package/dist/_chunks/libs/merge-error-cause.mjs +1 -1
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -1
- package/dist/_chunks/libs/mnemonist.mjs +1 -1
- package/dist/_chunks/libs/nano-spawn.mjs +3 -0
- package/dist/_chunks/libs/pathe.mjs +1 -1
- package/dist/_chunks/libs/remeda.mjs +2 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -0
- package/dist/_chunks/libs/unified.mjs +1 -1
- package/dist/_chunks/libs/which.mjs +1 -0
- package/dist/index.mjs +755 -67
- package/package.json +15 -13
- package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as e from"node:path";import{join as t,relative as n,resolve as r,sep as i}from"node:path";import{lstat as a,open as o,readdir as s,realpath as c,stat as l}from"node:fs/promises";import{stat as u,unwatchFile as d,watch as f,watchFile as p}from"node:fs";import{EventEmitter as ee}from"node:events";import{Readable as te}from"node:stream";import{type as ne}from"node:os";const m={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},h={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:m.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(h);const g=`READDIRP_RECURSIVE_ERROR`,re=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,g]),_=[m.DIR_TYPE,m.EVERYTHING_TYPE,m.FILE_DIR_TYPE,m.FILE_TYPE],v=new Set([m.DIR_TYPE,m.EVERYTHING_TYPE,m.FILE_DIR_TYPE]),y=new Set([m.EVERYTHING_TYPE,m.FILE_DIR_TYPE,m.FILE_TYPE]),b=e=>re.has(e.code),x=process.platform===`win32`,S=e=>!0,C=e=>{if(e===void 0)return S;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return S};var ie=class extends te{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...h,...e},{root:n,type:i}=t;this._fileFilter=C(t.fileFilter),this._directoryFilter=C(t.directoryFilter);let o=t.lstat?a:l;x?this._stat=e=>o(e,{bigint:!0}):this._stat=o,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:h.depth,this._wantsDir=i?v.has(i):!1,this._wantsFile=i?y.has(i):!1,this._wantsEverything=i===m.EVERYTHING_TYPE,this._root=r(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,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,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await s(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,i){let a,o=this._isDirent?e.name:e;try{let s=r(t(i,o));a={path:n(this._root,s),fullPath:s,basename:o},a[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(e){this._onError(e);return}return a}_onError(e){b(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 t=e.fullPath;try{let e=await c(t),n=await a(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===i){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=g,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function ae(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=m.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!_.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${_.join(`, `)}`);return t.root=e,new ie(t)}const w=()=>{},T=process.platform,E=T===`win32`,oe=T===`darwin`,se=T===`linux`,D=T===`freebsd`,O=ne()===`OS400`,k={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},A=k,ce={lstat:a,stat:l},j=`listeners`,M=`errHandlers`,N=`rawEmitters`,le=[j,M,N],ue=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`.split(`.`)),de=t=>ue.has(e.extname(t).slice(1).toLowerCase()),P=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},F=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},I=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},L=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},R=e=>e instanceof Set?e.size===0:!e,z=new Map;function B(t,n,r,i,a){let o=(n,i)=>{r(t),a(n,i,{watchedPath:t}),i&&t!==i&&V(e.resolve(t,i),j,e.join(t,i))};try{return f(t,{persistent:n.persistent},o)}catch(e){i(e);return}}const V=(e,t,n,r,i)=>{let a=z.get(e);a&&P(a[t],e=>{e(n,r,i)})},H=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:s}=r,c=z.get(t),l;if(!n.persistent)return l=B(e,n,i,a,s),l?l.close.bind(l):void 0;if(c)F(c,j,i),F(c,M,a),F(c,N,s);else{if(l=B(e,n,V.bind(null,t,j),a,V.bind(null,t,N)),!l)return;l.on(A.ERROR,async n=>{let r=V.bind(null,t,M);if(c&&(c.watcherUnusable=!0),E&&n.code===`EPERM`)try{await(await o(e,`r`)).close(),r(n)}catch{}else r(n)}),c={listeners:i,errHandlers:a,rawEmitters:s,watcher:l},z.set(t,c)}return()=>{L(c,j,i),L(c,M,a),L(c,N,s),R(c.listeners)&&(c.watcher.close(),z.delete(t),le.forEach(I(c)),c.watcher=void 0,Object.freeze(c))}},U=new Map,fe=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=U.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(d(t),o=void 0),o?(F(o,j,i),F(o,N,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:p(t,n,(n,r)=>{P(o.rawEmitters,e=>{e(A.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&P(o.listeners,t=>t(e,n))})},U.set(t,o)),()=>{L(o,j,i),L(o,N,a),R(o.listeners)&&(U.delete(t),d(t),o.options=o.watcher=void 0,Object.freeze(o))}};var pe=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(t,n){let r=this.fsw.options,i=e.dirname(t),a=e.basename(t);this.fsw._getWatchedDir(i).add(a);let o=e.resolve(t),s={persistent:r.persistent};n||=w;let c;return r.usePolling?(s.interval=r.interval!==r.binaryInterval&&de(a)?r.binaryInterval:r.interval,c=fe(t,o,s,{listener:n,rawEmitter:this.fsw._emitRaw})):c=H(t,o,s,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),c}_handleFile(t,n,r){if(this.fsw.closed)return;let i=e.dirname(t),a=e.basename(t),o=this.fsw._getWatchedDir(i),s=n;if(o.has(a))return;let c=async(e,n)=>{if(this.fsw._throttle(`watch`,t,5)){if(!n||n.mtimeMs===0)try{let n=await l(t);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==s.mtimeMs)&&this.fsw._emit(A.CHANGE,t,n),(oe||se||D)&&s.ino!==n.ino){this.fsw._closeFile(e),s=n;let r=this._watchWithNodeFs(t,c);r&&this.fsw._addPathCloser(e,r)}else s=n}catch{this.fsw._remove(i,a)}else if(o.has(a)){let e=n.atimeMs,r=n.mtimeMs;(!e||e<=r||r!==s.mtimeMs)&&this.fsw._emit(A.CHANGE,t,n),s=n}}},u=this._watchWithNodeFs(t,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(A.ADD,t,0))return;this.fsw._emit(A.ADD,t,n)}return u}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await c(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(A.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(A.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,n,r,i,a,o,s){t=e.join(t,``);let c=i?`${t}:${i}`:t;if(s=this.fsw._throttle(`readdir`,c,1e3),!s)return;let l=this.fsw._getWatchedDir(r.path),u=new Set,d=this.fsw._readdirp(t,{fileFilter:e=>r.filterPath(e),directoryFilter:e=>r.filterDir(e)});if(d)return d.on(`data`,async s=>{if(this.fsw.closed){d=void 0;return}let c=s.path,f=e.join(t,c);if(u.add(c),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,t,f,c))){if(this.fsw.closed){d=void 0;return}(c===i||!i&&!l.has(c))&&(this.fsw._incrReadyCount(),f=e.join(a,e.relative(a,f)),this._addToNodeFs(f,n,r,o+1))}}).on(A.ERROR,this._boundHandleError),new Promise((e,n)=>{if(!d)return n();d.once(`end`,()=>{if(this.fsw.closed){d=void 0;return}let n=s?s.clear():!1;e(void 0),l.getChildren().filter(e=>e!==t&&!u.has(e)).forEach(e=>{this.fsw._remove(t,e)}),d=void 0,n&&this._handleRead(t,!1,r,i,a,o,s)})})}async _handleDir(t,n,r,i,a,o,s){let c=this.fsw._getWatchedDir(e.dirname(t)),l=c.has(e.basename(t));!(r&&this.fsw.options.ignoreInitial)&&!a&&!l&&this.fsw._emit(A.ADD_DIR,t,n),c.add(e.basename(t)),this.fsw._getWatchedDir(t);let u,d=this.fsw.options.depth;if((d==null||i<=d)&&!this.fsw._symlinkPaths.has(s)){if(!a&&(await this._handleRead(t,r,o,a,t,i,void 0),this.fsw.closed))return;u=this._watchWithNodeFs(t,(e,n)=>{n&&n.mtimeMs===0||this._handleRead(e,!1,o,a,t,i,void 0)})}return u}async _addToNodeFs(t,n,r,i,a){let o=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return o(),!1;let s=this.fsw._getWatchHelpers(t);r&&(s.filterPath=e=>r.filterPath(e),s.filterDir=e=>r.filterDir(e));try{let r=await ce[s.statMethod](s.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(s.watchPath,r))return o(),!1;let l=this.fsw.options.followSymlinks,u;if(r.isDirectory()){let o=e.resolve(t),d=l?await c(t):t;if(this.fsw.closed||(u=await this._handleDir(s.watchPath,r,n,i,a,s,d),this.fsw.closed))return;o!==d&&d!==void 0&&this.fsw._symlinkPaths.set(o,d)}else if(r.isSymbolicLink()){let a=l?await c(t):t;if(this.fsw.closed)return;let o=e.dirname(s.watchPath);if(this.fsw._getWatchedDir(o).add(s.watchPath),this.fsw._emit(A.ADD,s.watchPath,r),u=await this._handleDir(o,r,n,i,t,s,a),this.fsw.closed)return;a!==void 0&&this.fsw._symlinkPaths.set(e.resolve(t),a)}else u=this._handleFile(s.watchPath,r,n);return o(),u&&this.fsw._addPathCloser(t,u),!1}catch(e){if(this.fsw._handleError(e))return o(),t}}};
|
|
1
|
+
import*as e from"node:path";import{join as t,relative as n,resolve as r,sep as i}from"node:path";import{EventEmitter as a}from"node:events";import{lstat as o,open as s,readdir as c,realpath as l,stat as u}from"node:fs/promises";import{type as d}from"node:os";import{stat as f,unwatchFile as p,watch as m,watchFile as ee}from"node:fs";import{Readable as te}from"node:stream";const h={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},g={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:h.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(g);const _=`READDIRP_RECURSIVE_ERROR`,ne=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,_]),v=[h.DIR_TYPE,h.EVERYTHING_TYPE,h.FILE_DIR_TYPE,h.FILE_TYPE],re=new Set([h.DIR_TYPE,h.EVERYTHING_TYPE,h.FILE_DIR_TYPE]),y=new Set([h.EVERYTHING_TYPE,h.FILE_DIR_TYPE,h.FILE_TYPE]),b=e=>ne.has(e.code),x=process.platform===`win32`,S=e=>!0,C=e=>{if(e===void 0)return S;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return S};var ie=class extends te{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...g,...e},{root:n,type:i}=t;this._fileFilter=C(t.fileFilter),this._directoryFilter=C(t.directoryFilter);let a=t.lstat?o:u;x?this._stat=e=>a(e,{bigint:!0}):this._stat=a,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:g.depth,this._wantsDir=i?re.has(i):!1,this._wantsFile=i?y.has(i):!1,this._wantsEverything=i===h.EVERYTHING_TYPE,this._root=r(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,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,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await c(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,i){let a,o=this._isDirent?e.name:e;try{let s=r(t(i,o));a={path:n(this._root,s),fullPath:s,basename:o},a[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(e){this._onError(e);return}return a}_onError(e){b(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 t=e.fullPath;try{let e=await l(t),n=await o(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===i){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=_,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function ae(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=h.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!v.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${v.join(`, `)}`);return t.root=e,new ie(t)}const w=()=>{},T=process.platform,E=T===`win32`,D=T===`darwin`,oe=T===`linux`,se=T===`freebsd`,O=d()===`OS400`,k={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},A=k,ce={lstat:o,stat:u},j=`listeners`,M=`errHandlers`,N=`rawEmitters`,le=[j,M,N],ue=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`.split(`.`)),de=t=>ue.has(e.extname(t).slice(1).toLowerCase()),P=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},F=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},I=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},L=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},R=e=>e instanceof Set?e.size===0:!e,z=new Map;function B(t,n,r,i,a){let o=(n,i)=>{r(t),a(n,i,{watchedPath:t}),i&&t!==i&&V(e.resolve(t,i),j,e.join(t,i))};try{return m(t,{persistent:n.persistent},o)}catch(e){i(e);return}}const V=(e,t,n,r,i)=>{let a=z.get(e);a&&P(a[t],e=>{e(n,r,i)})},H=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,c=z.get(t),l;if(!n.persistent)return l=B(e,n,i,a,o),l?l.close.bind(l):void 0;if(c)F(c,j,i),F(c,M,a),F(c,N,o);else{if(l=B(e,n,V.bind(null,t,j),a,V.bind(null,t,N)),!l)return;l.on(A.ERROR,async n=>{let r=V.bind(null,t,M);if(c&&(c.watcherUnusable=!0),E&&n.code===`EPERM`)try{await(await s(e,`r`)).close(),r(n)}catch{}else r(n)}),c={listeners:i,errHandlers:a,rawEmitters:o,watcher:l},z.set(t,c)}return()=>{L(c,j,i),L(c,M,a),L(c,N,o),R(c.listeners)&&(c.watcher.close(),z.delete(t),le.forEach(I(c)),c.watcher=void 0,Object.freeze(c))}},U=new Map,fe=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=U.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(p(t),o=void 0),o?(F(o,j,i),F(o,N,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:ee(t,n,(n,r)=>{P(o.rawEmitters,e=>{e(A.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&P(o.listeners,t=>t(e,n))})},U.set(t,o)),()=>{L(o,j,i),L(o,N,a),R(o.listeners)&&(U.delete(t),p(t),o.options=o.watcher=void 0,Object.freeze(o))}};var pe=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(t,n){let r=this.fsw.options,i=e.dirname(t),a=e.basename(t);this.fsw._getWatchedDir(i).add(a);let o=e.resolve(t),s={persistent:r.persistent};n||=w;let c;return r.usePolling?(s.interval=r.interval!==r.binaryInterval&&de(a)?r.binaryInterval:r.interval,c=fe(t,o,s,{listener:n,rawEmitter:this.fsw._emitRaw})):c=H(t,o,s,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),c}_handleFile(t,n,r){if(this.fsw.closed)return;let i=e.dirname(t),a=e.basename(t),o=this.fsw._getWatchedDir(i),s=n;if(o.has(a))return;let c=async(e,n)=>{if(this.fsw._throttle(`watch`,t,5)){if(!n||n.mtimeMs===0)try{let n=await u(t);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==s.mtimeMs)&&this.fsw._emit(A.CHANGE,t,n),(D||oe||se)&&s.ino!==n.ino){this.fsw._closeFile(e),s=n;let r=this._watchWithNodeFs(t,c);r&&this.fsw._addPathCloser(e,r)}else s=n}catch{this.fsw._remove(i,a)}else if(o.has(a)){let e=n.atimeMs,r=n.mtimeMs;(!e||e<=r||r!==s.mtimeMs)&&this.fsw._emit(A.CHANGE,t,n),s=n}}},l=this._watchWithNodeFs(t,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(A.ADD,t,0))return;this.fsw._emit(A.ADD,t,n)}return l}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await l(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(A.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(A.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,n,r,i,a,o,s){t=e.join(t,``);let c=i?`${t}:${i}`:t;if(s=this.fsw._throttle(`readdir`,c,1e3),!s)return;let l=this.fsw._getWatchedDir(r.path),u=new Set,d=this.fsw._readdirp(t,{fileFilter:e=>r.filterPath(e),directoryFilter:e=>r.filterDir(e)});if(d)return d.on(`data`,async s=>{if(this.fsw.closed){d=void 0;return}let c=s.path,f=e.join(t,c);if(u.add(c),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,t,f,c))){if(this.fsw.closed){d=void 0;return}(c===i||!i&&!l.has(c))&&(this.fsw._incrReadyCount(),f=e.join(a,e.relative(a,f)),this._addToNodeFs(f,n,r,o+1))}}).on(A.ERROR,this._boundHandleError),new Promise((e,n)=>{if(!d)return n();d.once(`end`,()=>{if(this.fsw.closed){d=void 0;return}let n=s?s.clear():!1;e(void 0),l.getChildren().filter(e=>e!==t&&!u.has(e)).forEach(e=>{this.fsw._remove(t,e)}),d=void 0,n&&this._handleRead(t,!1,r,i,a,o,s)})})}async _handleDir(t,n,r,i,a,o,s){let c=this.fsw._getWatchedDir(e.dirname(t)),l=c.has(e.basename(t));!(r&&this.fsw.options.ignoreInitial)&&!a&&!l&&this.fsw._emit(A.ADD_DIR,t,n),c.add(e.basename(t)),this.fsw._getWatchedDir(t);let u,d=this.fsw.options.depth;if((d==null||i<=d)&&!this.fsw._symlinkPaths.has(s)){if(!a&&(await this._handleRead(t,r,o,a,t,i,void 0),this.fsw.closed))return;u=this._watchWithNodeFs(t,(e,n)=>{n&&n.mtimeMs===0||this._handleRead(e,!1,o,a,t,i,void 0)})}return u}async _addToNodeFs(t,n,r,i,a){let o=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return o(),!1;let s=this.fsw._getWatchHelpers(t);r&&(s.filterPath=e=>r.filterPath(e),s.filterDir=e=>r.filterDir(e));try{let r=await ce[s.statMethod](s.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(s.watchPath,r))return o(),!1;let c=this.fsw.options.followSymlinks,u;if(r.isDirectory()){let o=e.resolve(t),d=c?await l(t):t;if(this.fsw.closed||(u=await this._handleDir(s.watchPath,r,n,i,a,s,d),this.fsw.closed))return;o!==d&&d!==void 0&&this.fsw._symlinkPaths.set(o,d)}else if(r.isSymbolicLink()){let a=c?await l(t):t;if(this.fsw.closed)return;let o=e.dirname(s.watchPath);if(this.fsw._getWatchedDir(o).add(s.watchPath),this.fsw._emit(A.ADD,s.watchPath,r),u=await this._handleDir(o,r,n,i,t,s,a),this.fsw.closed)return;a!==void 0&&this.fsw._symlinkPaths.set(e.resolve(t),a)}else u=this._handleFile(s.watchPath,r,n);return o(),u&&this.fsw._addPathCloser(t,u),!1}catch(e){if(this.fsw._handleError(e))return o(),t}}};
|
|
2
2
|
/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
|
|
3
|
-
const me=/\\/g,W=/\/\//g,he=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ge=/^\.[/\\]/;function G(e){return Array.isArray(e)?e:[e]}const K=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function _e(t){return typeof t==`function`?t:typeof t==`string`?e=>t===e:t instanceof RegExp?e=>t.test(e):typeof t==`object`&&t?n=>{if(t.path===n)return!0;if(t.recursive){let r=e.relative(t.path,n);return r?!r.startsWith(`..`)&&!e.isAbsolute(r):!1}return!1}:()=>!1}function ve(t){if(typeof t!=`string`)throw Error(`string expected`);t=e.normalize(t),t=t.replace(/\\/g,`/`);let n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(W,`/`),n&&(t=`/`+t),t}function q(e,t,n){let r=ve(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function ye(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=G(e).map(e=>_e(e));return t==null?(e,t)=>q(n,e,t):q(n,t)}const J=e=>{let t=G(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(X)},Y=e=>{let t=e.replace(me,`/`),n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(W,`/`),n&&(t=`/`+t),t},X=t=>Y(e.normalize(Y(t))),Z=(t=``)=>n=>typeof n==`string`?X(e.isAbsolute(n)?n:e.join(t,n)):n,be=(t,n)=>e.isAbsolute(t)?t:e.join(n,t),Q=Object.freeze(new Set);var xe=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(t){let{items:n}=this;if(!n||(n.delete(t),n.size>0))return;let r=this.path;try{await
|
|
3
|
+
const me=/\\/g,W=/\/\//g,he=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ge=/^\.[/\\]/;function G(e){return Array.isArray(e)?e:[e]}const K=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function _e(t){return typeof t==`function`?t:typeof t==`string`?e=>t===e:t instanceof RegExp?e=>t.test(e):typeof t==`object`&&t?n=>{if(t.path===n)return!0;if(t.recursive){let r=e.relative(t.path,n);return r?!r.startsWith(`..`)&&!e.isAbsolute(r):!1}return!1}:()=>!1}function ve(t){if(typeof t!=`string`)throw Error(`string expected`);t=e.normalize(t),t=t.replace(/\\/g,`/`);let n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(W,`/`),n&&(t=`/`+t),t}function q(e,t,n){let r=ve(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function ye(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=G(e).map(e=>_e(e));return t==null?(e,t)=>q(n,e,t):q(n,t)}const J=e=>{let t=G(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(X)},Y=e=>{let t=e.replace(me,`/`),n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(W,`/`),n&&(t=`/`+t),t},X=t=>Y(e.normalize(Y(t))),Z=(t=``)=>n=>typeof n==`string`?X(e.isAbsolute(n)?n:e.join(t,n)):n,be=(t,n)=>e.isAbsolute(t)?t:e.join(n,t),Q=Object.freeze(new Set);var xe=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(t){let{items:n}=this;if(!n||(n.delete(t),n.size>0))return;let r=this.path;try{await c(r)}catch{this._removeWatcher&&this._removeWatcher(e.dirname(r),e.basename(r))}}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=w,this.items=Q,Object.freeze(this)}},Se=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,n,r){this.fsw=r;let i=t;this.path=t=t.replace(ge,``),this.watchPath=i,this.fullWatchPath=e.resolve(i),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=n,this.statMethod=n?`stat`:`lstat`}entryPath(t){return e.join(this.watchPath,e.relative(this.watchPath,t.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},$=class extends a{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;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,n={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?G(e.ignored):G([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};O&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=w,this._readyEmitted=!0,process.nextTick(()=>this.emit(k.READY)))},this._emitRaw=(...e)=>this.emit(k.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new pe(this),Object.freeze(r)}_addIgnoredPath(e){if(K(e)){for(let t of this._ignoredPaths)if(K(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)K(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(t,n,r){let{cwd:i}=this.options;this.closed=!1,this._closePromise=void 0;let a=J(t);return i&&(a=a.map(e=>be(e,i))),a.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=a.length,Promise.all(a.map(async e=>{let t=await this._nodeFsHandler._addToNodeFs(e,!r,void 0,0,n);return t&&this._emitReady(),t})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(e.dirname(t),e.basename(n||t))})}),this}unwatch(t){if(this.closed)return this;let n=J(t),{cwd:r}=this.options;return n.forEach(t=>{!e.isAbsolute(t)&&!this._closers.has(t)&&(r&&(t=e.join(r,t)),t=e.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,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(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((n,r)=>{let i=(this.options.cwd?e.relative(this.options.cwd,r):r)||`.`;t[i]=n.getChildren().sort()}),t}emitWithAll(e,t){this.emit(e,...t),e!==k.ERROR&&this.emit(k.ALL,e,...t)}async _emit(t,n,r){if(this.closed)return;let i=this.options;E&&(n=e.normalize(n)),i.cwd&&(n=e.relative(i.cwd,n));let a=[n];r!=null&&a.push(r);let o=i.awaitWriteFinish,s;if(o&&(s=this._pendingWrites.get(n)))return s.lastChange=new Date,this;if(i.atomic){if(t===k.UNLINK)return this._pendingUnlinks.set(n,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(k.ALL,...e),this._pendingUnlinks.delete(t)})},typeof i.atomic==`number`?i.atomic:100),this;t===k.ADD&&this._pendingUnlinks.has(n)&&(t=k.CHANGE,this._pendingUnlinks.delete(n))}if(o&&(t===k.ADD||t===k.CHANGE)&&this._readyEmitted)return this._awaitWriteFinish(n,o.stabilityThreshold,t,(e,n)=>{e?(t=k.ERROR,a[0]=e,this.emitWithAll(t,a)):n&&(a.length>1?a[1]=n:a.push(n),this.emitWithAll(t,a))}),this;if(t===k.CHANGE&&!this._throttle(k.CHANGE,n,50))return this;if(i.alwaysStat&&r===void 0&&(t===k.ADD||t===k.ADD_DIR||t===k.CHANGE)){let t=i.cwd?e.join(i.cwd,n):n,r;try{r=await u(t)}catch{}if(!r||this.closed)return;a.push(r)}return this.emitWithAll(t,a),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(k.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,n,r,i){let a=this.options.awaitWriteFinish;if(typeof a!=`object`)return;let o=a.pollInterval,s,c=t;this.options.cwd&&!e.isAbsolute(t)&&(c=e.join(this.options.cwd,t));let l=new Date,u=this._pendingWrites;function d(e){f(c,(r,a)=>{if(r||!u.has(t)){r&&r.code!==`ENOENT`&&i(r);return}let c=Number(new Date);e&&a.size!==e.size&&(u.get(t).lastChange=c),c-u.get(t).lastChange>=n?(u.delete(t),i(void 0,a)):s=setTimeout(d,o,a)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(s),r)}),s=setTimeout(d,o))}_isIgnored(e,t){if(this.options.atomic&&he.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(Z(e));this._userIgnored=ye([...[...this._ignoredPaths].map(Z(e)),...t],void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Se(e,this.options.followSymlinks,this)}_getWatchedDir(t){let n=e.resolve(t);return this._watched.has(n)||this._watched.set(n,new xe(n,this._boundRemove)),this._watched.get(n)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(t,n,r){let i=e.join(t,n),a=e.resolve(i);if(r??=this._watched.has(i)||this._watched.has(a),!this._throttle(`remove`,i,100))return;!r&&this._watched.size===1&&this.add(t,n,!0),this._getWatchedDir(i).getChildren().forEach(e=>this._remove(i,e));let o=this._getWatchedDir(t),s=o.has(n);o.remove(n),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let c=i;if(this.options.cwd&&(c=e.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(c)&&this._pendingWrites.get(c).cancelWait()===k.ADD)return;this._watched.delete(i),this._watched.delete(a);let l=r?k.UNLINK_DIR:k.UNLINK;s&&!this._isIgnored(i)&&this._emit(l,i),this._closePath(i)}_closePath(t){this._closeFile(t);let n=e.dirname(t);this._getWatchedDir(n).remove(e.basename(t))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=ae(e,{type:k.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function Ce(e,t={}){let n=new $(t);return n.add(e),n}var we={watch:Ce,FSWatcher:$};export{we as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{parseArgs as e}from"node:util";const t=/\d/,n=[`-`,`_`,`/`,`.`];function r(e=``){if(!t.test(e))return e!==e.toLowerCase()}function i(e,t){let i=t??n,a=[];if(!e||typeof e!=`string`)return a;let o=``,s,c;for(let t of e){let e=i.includes(t);if(e===!0){a.push(o),o=``,s=void 0;continue}let n=r(t);if(c===!1){if(s===!1&&n===!0){a.push(o),o=t,s=n;continue}if(s===!0&&n===!1&&o.length>1){let e=o.at(-1);a.push(o.slice(0,Math.max(0,o.length-1))),o=e+t,s=n;continue}}o+=t,s=n,c=e}return a.push(o),a}function a(e){return e?e[0].toUpperCase()+e.slice(1):``}function o(e){return e?e[0].toLowerCase()+e.slice(1):``}function s(e,t){return e?(Array.isArray(e)?e:i(e)).map(e=>a(t?.normalize?e.toLowerCase():e)).join(``):``}function c(e,t){return o(s(e||``,t))}function l(e,t){return e?(Array.isArray(e)?e:i(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function u(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function d(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
|
|
2
|
-
`)}function f(e){return typeof e==`function`?e():e}var p=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function m(t=[],n={}){let r=new Set(n.boolean||[]),i=new Set(n.string||[]),a=n.alias||{},o=n.default||{},s=new Map,c=new Map;for(let[e,t]of Object.entries(a)){let n=t;for(let t of n)s.set(e,t),c.has(t)||c.set(t,[]),c.get(t).push(e),s.set(t,e),c.has(e)||c.set(e,[]),c.get(e).push(t)}let l={};function u(e){if(r.has(e))return`boolean`;let t=c.get(e)||[];for(let e of t)if(r.has(e))return`boolean`;return`string`}let d=new Set([...r,...i,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let e of d)l[e]||(l[e]={type:u(e),default:o[e]});for(let[e,t]of s.entries())e.length===1&&l[t]&&!l[t].short&&(l[t].short=e);let f=[],p={};for(let e=0;e<t.length;e++){let n=t[e];if(n===`--`){f.push(...t.slice(e));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0;continue}f.push(n)}let m;try{m=e({args:f,options:Object.keys(l).length>0?l:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values))h[e]=t;for(let[e]of Object.entries(p))h[e]=!1;for(let[e,t]of s.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]);return h}const h=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),g=(e,t=39)=>n=>h?n:`\u001B[${e}m${n}\u001B[${t}m`,_=g(1,22),v=g(36),y=g(90),b=g(4,24);function x(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=S(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=c(e.name),r=l(e.name);if(t!==e.name||r!==e.name){let i=u(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=m(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[c(t)]??e[l(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new p(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new p(`Invalid value for argument: ${v(`--${e.name}`)} (${v(t)}). Expected one of: ${n.map(e=>v(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new p(`Missing required argument: --${e.name}`,`EARG`);return o}function S(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:u(r.alias)});return t}function C(e){return e}async function w(e,t){let n=await f(e.args||{}),r=x(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e};typeof e.setup==`function`&&await e.setup(i);let a;try{let n=await f(e.subCommands);if(n&&Object.keys(n).length>0){let r=t.rawArgs.findIndex(e=>!e.startsWith(`-`)),i=t.rawArgs[r];if(i){if(!n[i])throw new p(`Unknown command ${v(i)}`,`E_UNKNOWN_COMMAND`);let e=await f(n[i]);e&&await w(e,{rawArgs:t.rawArgs.slice(r+1)})}else if(!e.run)throw new p(`No command specified.`,`E_NO_COMMAND`)}typeof e.run==`function`&&(a=await e.run(i))}finally{typeof e.cleanup==`function`&&await e.cleanup(i)}return{result:a}}async function T(e,t,n){let r=await f(e.subCommands);if(r&&Object.keys(r).length>0){let n=t.findIndex(e=>!e.startsWith(`-`)),i=t[n],a=await f(r[i]);if(a)return T(a,t.slice(n+1),e)}return[e,n]}async function E(e,t){try{console.log(await O(e,t)+`
|
|
2
|
+
`)}function f(e){return typeof e==`function`?e():e}var p=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function m(t=[],n={}){let r=new Set(n.boolean||[]),i=new Set(n.string||[]),a=n.alias||{},o=n.default||{},s=new Map,c=new Map;for(let[e,t]of Object.entries(a)){let n=t;for(let t of n)s.set(e,t),c.has(t)||c.set(t,[]),c.get(t).push(e),s.set(t,e),c.has(e)||c.set(e,[]),c.get(e).push(t)}let l={};function u(e){if(r.has(e))return`boolean`;let t=c.get(e)||[];for(let e of t)if(r.has(e))return`boolean`;return`string`}let d=new Set([...r,...i,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let e of d)l[e]||(l[e]={type:u(e),default:o[e]});for(let[e,t]of s.entries())e.length===1&&l[t]&&!l[t].short&&(l[t].short=e);let f=[],p={};for(let e=0;e<t.length;e++){let n=t[e];if(n===`--`){f.push(...t.slice(e));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0;continue}f.push(n)}let m;try{m=e({args:f,options:Object.keys(l).length>0?l:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values))h[e]=t;for(let[e]of Object.entries(p)){h[e]=!1;let t=s.get(e);t&&(h[t]=!1);let n=c.get(e);if(n)for(let e of n)h[e]=!1}for(let[e,t]of s.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]);return h}const h=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),g=(e,t=39)=>n=>h?n:`\u001B[${e}m${n}\u001B[${t}m`,_=g(1,22),v=g(36),y=g(90),b=g(4,24);function x(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=S(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=c(e.name),r=l(e.name);if(t!==e.name||r!==e.name){let i=u(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=m(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[c(t)]??e[l(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new p(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new p(`Invalid value for argument: ${v(`--${e.name}`)} (${v(t)}). Expected one of: ${n.map(e=>v(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new p(`Missing required argument: --${e.name}`,`EARG`);return o}function S(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:u(r.alias)});return t}function C(e){return e}async function w(e,t){let n=await f(e.args||{}),r=x(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e};typeof e.setup==`function`&&await e.setup(i);let a;try{let n=await f(e.subCommands);if(n&&Object.keys(n).length>0){let r=t.rawArgs.findIndex(e=>!e.startsWith(`-`)),i=t.rawArgs[r];if(i){if(!n[i])throw new p(`Unknown command ${v(i)}`,`E_UNKNOWN_COMMAND`);let e=await f(n[i]);e&&await w(e,{rawArgs:t.rawArgs.slice(r+1)})}else if(!e.run)throw new p(`No command specified.`,`E_NO_COMMAND`)}typeof e.run==`function`&&(a=await e.run(i))}finally{typeof e.cleanup==`function`&&await e.cleanup(i)}return{result:a}}async function T(e,t,n){let r=await f(e.subCommands);if(r&&Object.keys(r).length>0){let n=t.findIndex(e=>!e.startsWith(`-`)),i=t[n],a=await f(r[i]);if(a)return T(a,t.slice(n+1),e)}return[e,n]}async function E(e,t){try{console.log(await O(e,t)+`
|
|
3
3
|
`)}catch(e){console.error(e)}}const D=/^no[-A-Z]/;async function O(e,t){let n=await f(e.meta||{}),r=S(await f(e.args||{})),i=await f(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0,r=e.default?`="${e.default}"`:``;s.push([v(t+r),e.description||``,e.valueHint?`<${e.valueHint}>`:``]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+(e.type===`string`&&(e.valueHint||e.default)?`=${e.valueHint?`<${e.valueHint}>`:`"${e.default||``}"`}`:``)+(e.type===`enum`&&e.options?`=<${e.options.join(`|`)}>`:``);if(o.push([v(n+(t?` (required)`:``)),e.description||``]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!D.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([v(n+(t?` (required)`:``)),e.negativeDescription||``])}t&&l.push(n)}if(e.subCommands){let t=[],n=await f(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await f((await f(r))?.meta);n?.hidden||(c.push([v(e),n?.description||``]),t.push(e))}l.push(t.join(`|`))}let u=[],p=n.version||i.version;u.push(y(`${n.description} (${a+(p?` v${p}`:``)})`),``);let m=o.length>0||s.length>0;return u.push(`${b(_(`USAGE`))} ${v(`${a}${m?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(b(_(`ARGUMENTS`)),``),u.push(d(s,` `)),u.push(``)),o.length>0&&(u.push(b(_(`OPTIONS`)),``),u.push(d(o,` `)),u.push(``)),c.length>0&&(u.push(b(_(`COMMANDS`)),``),u.push(d(c,` `)),u.push(``,`Use ${v(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
4
4
|
`)}async function k(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||E;try{if(n.includes(`--help`)||n.includes(`-h`))await r(...await T(e,n)),process.exit(0);else if(n.length===1&&n[0]===`--version`){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new p(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await w(e,{rawArgs:n})}catch(t){t instanceof p?(await r(...await T(e,n)),console.error(t.message)):console.error(t,`
|
|
5
5
|
`),process.exit(1)}}export{k as n,C as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"../rolldown-runtime.mjs";import{statSync as n}from"fs";import{stat as r}from"fs/promises";var i=t({isexe:()=>a,sync:()=>o}),a,o,s,c,l=e((()=>{a=async(e,t={})=>{let{ignoreErrors:n=!1}=t;try{return s(await r(e),t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},o=(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return s(n(e),t)}catch(e){let t=e;if(r||t.code===`EACCES`)return!1;throw t}},s=(e,t)=>e.isFile()&&c(e,t),c=(e,t)=>{let n=t.uid??process.getuid?.(),r=t.groups??process.getgroups?.()??[],i=t.gid??process.getgid?.()??r[0];if(n===void 0||i===void 0)throw Error(`cannot get uid or gid`);let a=new Set([i,...r]),o=e.mode,s=e.uid,c=e.gid;return!!(o&1||o&8&&a.has(c)||o&64&&s===n||o&72&&n===0)}})),u=t({isexe:()=>d,sync:()=>f}),d,f,p,m,h=e((()=>{d=async(e,t={})=>{let{ignoreErrors:n=!1}=t;try{return m(await r(e),e,t)}catch(e){let t=e;if(n||t.code===`EACCES`)return!1;throw t}},f=(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return m(n(e),e,t)}catch(e){let t=e;if(r||t.code===`EACCES`)return!1;throw t}},p=(e,t)=>{let{pathExt:n=process.env.PATHEXT||``}=t,r=n.split(`;`);if(r.indexOf(``)!==-1)return!0;for(let t=0;t<r.length;t++){let n=r[t].toLowerCase(),i=e.substring(e.length-n.length).toLowerCase();if(n&&i===n)return!0}return!1},m=(e,t,n)=>e.isFile()&&p(t,n)})),g=e((()=>{})),_=t({isexe:()=>y,posix:()=>i,sync:()=>b,win32:()=>u}),v,y,b,x=e((()=>{l(),h(),g(),v=(process.env._ISEXE_TEST_PLATFORM_||process.platform)===`win32`?u:i,y=v.isexe,b=v.sync}));export{_ as n,x as t};
|