UNPKG

nx-mesh

Version:
7 lines (6 loc) 37.1 kB
var Et=Object.create;var V=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ft=(t,e)=>{for(var i in e)V(t,i,{get:e[i],enumerable:!0})},je=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Tt(e))!_t.call(t,s)&&s!==i&&V(t,s,{get:()=>e[s],enumerable:!(r=Wt(e,s))||r.enumerable});return t};var xt=(t,e,i)=>(i=t!=null?Et(Ot(t)):{},je(e||!t||!t.__esModule?V(i,"default",{value:t,enumerable:!0}):i,t)),bt=t=>je(V({},"__esModule",{value:!0}),t);var $e=N((xr,Le)=>{var A=require("constants"),It=process.cwd,X=null,jt=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return X||(X=It.call(process)),X};try{process.cwd()}catch{}typeof process.chdir=="function"&&(we=process.chdir,process.chdir=function(t){X=null,we.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,we));var we;Le.exports=Ct;function Ct(t){A.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||i(t),t.chown=n(t.chown),t.fchown=n(t.fchown),t.lchown=n(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=s(t.chmodSync),t.fchmodSync=s(t.fchmodSync),t.lchmodSync=s(t.lchmodSync),t.stat=c(t.stat),t.fstat=c(t.fstat),t.lstat=c(t.lstat),t.statSync=h(t.statSync),t.fstatSync=h(t.fstatSync),t.lstatSync=h(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(a,f,d){d&&process.nextTick(d)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(a,f,d,u){u&&process.nextTick(u)},t.lchownSync=function(){}),jt==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:function(a){function f(d,u,m){var S=Date.now(),l=0;a(d,u,function g(y){if(y&&(y.code==="EACCES"||y.code==="EPERM")&&Date.now()-S<6e4){setTimeout(function(){t.stat(u,function(O,G){O&&O.code==="ENOENT"?a(d,u,g):m(y)})},l),l<100&&(l+=10);return}m&&m(y)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,a),f}(t.rename)),t.read=typeof t.read!="function"?t.read:function(a){function f(d,u,m,S,l,g){var y;if(g&&typeof g=="function"){var O=0;y=function(G,Ae,Ie){if(G&&G.code==="EAGAIN"&&O<10)return O++,a.call(t,d,u,m,S,l,y);g.apply(this,arguments)}}return a.call(t,d,u,m,S,l,y)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,a),f}(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:function(a){return function(f,d,u,m,S){for(var l=0;;)try{return a.call(t,f,d,u,m,S)}catch(g){if(g.code==="EAGAIN"&&l<10){l++;continue}throw g}}}(t.readSync);function e(a){a.lchmod=function(f,d,u){a.open(f,A.O_WRONLY|A.O_SYMLINK,d,function(m,S){if(m){u&&u(m);return}a.fchmod(S,d,function(l){a.close(S,function(g){u&&u(l||g)})})})},a.lchmodSync=function(f,d){var u=a.openSync(f,A.O_WRONLY|A.O_SYMLINK,d),m=!0,S;try{S=a.fchmodSync(u,d),m=!1}finally{if(m)try{a.closeSync(u)}catch{}else a.closeSync(u)}return S}}function i(a){A.hasOwnProperty("O_SYMLINK")&&a.futimes?(a.lutimes=function(f,d,u,m){a.open(f,A.O_SYMLINK,function(S,l){if(S){m&&m(S);return}a.futimes(l,d,u,function(g){a.close(l,function(y){m&&m(g||y)})})})},a.lutimesSync=function(f,d,u){var m=a.openSync(f,A.O_SYMLINK),S,l=!0;try{S=a.futimesSync(m,d,u),l=!1}finally{if(l)try{a.closeSync(m)}catch{}else a.closeSync(m)}return S}):a.futimes&&(a.lutimes=function(f,d,u,m){m&&process.nextTick(m)},a.lutimesSync=function(){})}function r(a){return a&&function(f,d,u){return a.call(t,f,d,function(m){p(m)&&(m=null),u&&u.apply(this,arguments)})}}function s(a){return a&&function(f,d){try{return a.call(t,f,d)}catch(u){if(!p(u))throw u}}}function n(a){return a&&function(f,d,u,m){return a.call(t,f,d,u,function(S){p(S)&&(S=null),m&&m.apply(this,arguments)})}}function o(a){return a&&function(f,d,u){try{return a.call(t,f,d,u)}catch(m){if(!p(m))throw m}}}function c(a){return a&&function(f,d,u){typeof d=="function"&&(u=d,d=null);function m(S,l){l&&(l.uid<0&&(l.uid+=4294967296),l.gid<0&&(l.gid+=4294967296)),u&&u.apply(this,arguments)}return d?a.call(t,f,d,m):a.call(t,f,m)}}function h(a){return a&&function(f,d){var u=d?a.call(t,f,d):a.call(t,f);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}}function p(a){if(!a||a.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(a.code==="EINVAL"||a.code==="EPERM"))}}});var Ye=N((br,Ge)=>{var ze=require("stream").Stream;Ge.exports=Dt;function Dt(t){return{ReadStream:e,WriteStream:i};function e(r,s){if(!(this instanceof e))return new e(r,s);ze.call(this);var n=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,s=s||{};for(var o=Object.keys(s),c=0,h=o.length;c<h;c++){var p=o[c];this[p]=s[p]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){n._read()});return}t.open(this.path,this.flags,this.mode,function(a,f){if(a){n.emit("error",a),n.readable=!1;return}n.fd=f,n.emit("open",f),n._read()})}function i(r,s){if(!(this instanceof i))return new i(r,s);ze.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var n=Object.keys(s),o=0,c=n.length;o<c;o++){var h=n[o];this[h]=s[h]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ke=N((kr,Ue)=>{"use strict";Ue.exports=$t;var Lt=Object.getPrototypeOf||function(t){return t.__proto__};function $t(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:Lt(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}});var Je=N((Mr,Se)=>{var F=require("fs"),zt=$e(),Gt=Ye(),Yt=Ke(),Q=require("util"),R,ee;typeof Symbol=="function"&&typeof Symbol.for=="function"?(R=Symbol.for("graceful-fs.queue"),ee=Symbol.for("graceful-fs.previous")):(R="___graceful-fs.queue",ee="___graceful-fs.previous");function Ut(){}function Ve(t,e){Object.defineProperty(t,R,{get:function(){return e}})}var I=Ut;Q.debuglog?I=Q.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(I=function(){var t=Q.format.apply(Q,arguments);t="GFS4: "+t.split(/\n/).join(` GFS4: `),console.error(t)});F[R]||(He=global[R]||[],Ve(F,He),F.close=function(t){function e(i,r){return t.call(F,i,function(s){s||Be(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(e,ee,{value:t}),e}(F.close),F.closeSync=function(t){function e(i){t.apply(F,arguments),Be()}return Object.defineProperty(e,ee,{value:t}),e}(F.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){I(F[R]),require("assert").equal(F[R].length,0)}));var He;global[R]||Ve(global,F[R]);Se.exports=ye(Yt(F));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!F.__patched&&(Se.exports=ye(F),F.__patched=!0);function ye(t){zt(t),t.gracefulify=ye,t.createReadStream=Ae,t.createWriteStream=Ie;var e=t.readFile;t.readFile=i;function i(w,E,v){return typeof E=="function"&&(v=E,E=null),k(w,E,v);function k(M,b,_,x){return e(M,b,function(W){W&&(W.code==="EMFILE"||W.code==="ENFILE")?D([k,[M,b,_],W,x||Date.now(),Date.now()]):typeof _=="function"&&_.apply(this,arguments)})}}var r=t.writeFile;t.writeFile=s;function s(w,E,v,k){return typeof v=="function"&&(k=v,v=null),M(w,E,v,k);function M(b,_,x,W,q){return r(b,_,x,function(T){T&&(T.code==="EMFILE"||T.code==="ENFILE")?D([M,[b,_,x,W],T,q||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var n=t.appendFile;n&&(t.appendFile=o);function o(w,E,v,k){return typeof v=="function"&&(k=v,v=null),M(w,E,v,k);function M(b,_,x,W,q){return n(b,_,x,function(T){T&&(T.code==="EMFILE"||T.code==="ENFILE")?D([M,[b,_,x,W],T,q||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var c=t.copyFile;c&&(t.copyFile=h);function h(w,E,v,k){return typeof v=="function"&&(k=v,v=0),M(w,E,v,k);function M(b,_,x,W,q){return c(b,_,x,function(T){T&&(T.code==="EMFILE"||T.code==="ENFILE")?D([M,[b,_,x,W],T,q||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}var p=t.readdir;t.readdir=f;var a=/^v[0-5]\./;function f(w,E,v){typeof E=="function"&&(v=E,E=null);var k=a.test(process.version)?function(_,x,W,q){return p(_,M(_,x,W,q))}:function(_,x,W,q){return p(_,x,M(_,x,W,q))};return k(w,E,v);function M(b,_,x,W){return function(q,T){q&&(q.code==="EMFILE"||q.code==="ENFILE")?D([k,[b,_,x],q,W||Date.now(),Date.now()]):(T&&T.sort&&T.sort(),typeof x=="function"&&x.call(this,q,T))}}}if(process.version.substr(0,4)==="v0.8"){var d=Gt(t);g=d.ReadStream,O=d.WriteStream}var u=t.ReadStream;u&&(g.prototype=Object.create(u.prototype),g.prototype.open=y);var m=t.WriteStream;m&&(O.prototype=Object.create(m.prototype),O.prototype.open=G),Object.defineProperty(t,"ReadStream",{get:function(){return g},set:function(w){g=w},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return O},set:function(w){O=w},enumerable:!0,configurable:!0});var S=g;Object.defineProperty(t,"FileReadStream",{get:function(){return S},set:function(w){S=w},enumerable:!0,configurable:!0});var l=O;Object.defineProperty(t,"FileWriteStream",{get:function(){return l},set:function(w){l=w},enumerable:!0,configurable:!0});function g(w,E){return this instanceof g?(u.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function y(){var w=this;le(w.path,w.flags,w.mode,function(E,v){E?(w.autoClose&&w.destroy(),w.emit("error",E)):(w.fd=v,w.emit("open",v),w.read())})}function O(w,E){return this instanceof O?(m.apply(this,arguments),this):O.apply(Object.create(O.prototype),arguments)}function G(){var w=this;le(w.path,w.flags,w.mode,function(E,v){E?(w.destroy(),w.emit("error",E)):(w.fd=v,w.emit("open",v))})}function Ae(w,E){return new t.ReadStream(w,E)}function Ie(w,E){return new t.WriteStream(w,E)}var St=t.open;t.open=le;function le(w,E,v,k){return typeof v=="function"&&(k=v,v=null),M(w,E,v,k);function M(b,_,x,W,q){return St(b,_,x,function(T,pr){T&&(T.code==="EMFILE"||T.code==="ENFILE")?D([M,[b,_,x,W],T,q||Date.now(),Date.now()]):typeof W=="function"&&W.apply(this,arguments)})}}return t}function D(t){I("ENQUEUE",t[0].name,t[1]),F[R].push(t),ve()}var Z;function Be(){for(var t=Date.now(),e=0;e<F[R].length;++e)F[R][e].length>2&&(F[R][e][3]=t,F[R][e][4]=t);ve()}function ve(){if(clearTimeout(Z),Z=void 0,F[R].length!==0){var t=F[R].shift(),e=t[0],i=t[1],r=t[2],s=t[3],n=t[4];if(s===void 0)I("RETRY",e.name,i),e.apply(null,i);else if(Date.now()-s>=6e4){I("TIMEOUT",e.name,i);var o=i.pop();typeof o=="function"&&o.call(null,r)}else{var c=Date.now()-n,h=Math.max(n-s,1),p=Math.min(h*1.2,100);c>=p?(I("RETRY",e.name,i),e.apply(null,i.concat([s]))):F[R].push(t)}Z===void 0&&(Z=setTimeout(ve,0))}}});var Qe=N((qr,Xe)=>{"use strict";var Kt=require("path");Xe.exports=(t,e)=>{let i=new Map;for(let[n,o]of t)i.set(n,{filePath:n,parent:void 0,children:void 0,entries:1,active:!0,value:o});let r=i.size;for(let n of i.values()){let o=Kt.dirname(n.filePath);if(o!==n.filePath){let c=i.get(o);if(c===void 0)c={filePath:o,parent:void 0,children:[n],entries:n.entries,active:!1,value:void 0},i.set(o,c),n.parent=c;else{n.parent=c,c.children===void 0?c.children=[n]:c.children.push(n);do c.entries+=n.entries,c=c.parent;while(c)}}}for(;r>e;){let n=r-e,o,c=1/0;for(let f of i.values()){if(f.entries<=1||!f.children||!f.parent||f.children.length===0||f.children.length===1&&!f.value)continue;let d=f.entries-1>=n?f.entries-1-n:n-f.entries+1+e*.3;d<c&&(o=f,c=d)}if(!o)break;let h=o.entries-1;o.active=!0,o.entries=1,r-=h;let p=o.parent;for(;p;)p.entries-=h,p=p.parent;let a=new Set(o.children);for(let f of a)if(f.active=!1,f.entries=0,f.children)for(let d of f.children)a.add(d)}let s=new Map;for(let n of i.values()){if(!n.active)continue;let o=new Map,c=new Set([n]);for(let h of c)if(!(h.active&&h!==n)){if(h.value)if(Array.isArray(h.value))for(let p of h.value)o.set(p,h.filePath);else o.set(h.value,h.filePath);if(h.children)for(let p of h.children)c.add(p)}s.set(n.filePath,o)}return s}});var Fe=N(ie=>{"use strict";var et=require("fs"),re=require("path"),{EventEmitter:Ht}=require("events"),Bt=Qe(),tt=require("os").platform()==="darwin",Vt=require("os").platform()==="win32",Jt=tt||Vt,Ze=+process.env.WATCHPACK_WATCHER_LIMIT||(tt?2e3:1e4),te=!!process.env.WATCHPACK_RECURSIVE_WATCHER_LOGGING,We=!1,L=0,Y=new Map,U=new Map,K=new Map,j=new Map,Te=class{constructor(e){this.filePath=e,this.watchers=new Set,this.watcher=void 0;try{let i=et.watch(e);this.watcher=i,i.on("change",(r,s)=>{for(let n of this.watchers)n.emit("change",r,s)}),i.on("error",r=>{for(let s of this.watchers)s.emit("error",r)})}catch(i){process.nextTick(()=>{for(let r of this.watchers)r.emit("error",i)})}L++}add(e){j.set(e,this),this.watchers.add(e)}remove(e){this.watchers.delete(e),this.watchers.size===0&&(K.delete(this.filePath),L--,this.watcher&&this.watcher.close())}getWatchers(){return this.watchers}},Oe=class{constructor(e){this.rootPath=e,this.mapWatcherToPath=new Map,this.mapPathToWatchers=new Map,this.watcher=void 0;try{let i=et.watch(e,{recursive:!0});this.watcher=i,i.on("change",(r,s)=>{if(s){let n=re.dirname(s),o=this.mapPathToWatchers.get(n);if(te&&process.stderr.write(`[watchpack] dispatch ${r} event in recursive watcher (${this.rootPath}) for '${s}' to ${o?o.size:0} watchers `),o===void 0)return;for(let c of o)c.emit("change",r,re.basename(s))}else{te&&process.stderr.write(`[watchpack] dispatch ${r} event in recursive watcher (${this.rootPath}) to all watchers `);for(let n of this.mapWatcherToPath.keys())n.emit("change",r)}}),i.on("error",r=>{for(let s of this.mapWatcherToPath.keys())s.emit("error",r)})}catch(i){process.nextTick(()=>{for(let r of this.mapWatcherToPath.keys())r.emit("error",i)})}L++,te&&process.stderr.write(`[watchpack] created recursive watcher at ${e} `)}add(e,i){j.set(i,this);let r=e.slice(this.rootPath.length+1)||".";this.mapWatcherToPath.set(i,r);let s=this.mapPathToWatchers.get(r);if(s===void 0){let n=new Set;n.add(i),this.mapPathToWatchers.set(r,n)}else s.add(i)}remove(e){let i=this.mapWatcherToPath.get(e);if(!i)return;this.mapWatcherToPath.delete(e);let r=this.mapPathToWatchers.get(i);r.delete(e),r.size===0&&this.mapPathToWatchers.delete(i),this.mapWatcherToPath.size===0&&(U.delete(this.rootPath),L--,this.watcher&&this.watcher.close(),te&&process.stderr.write(`[watchpack] closed recursive watcher at ${this.rootPath} `))}getWatchers(){return this.mapWatcherToPath}},_e=class extends Ht{close(){if(Y.has(this)){Y.delete(this);return}j.get(this).remove(this),j.delete(this)}},Ee=t=>{let e=K.get(t);if(e!==void 0)return e;let i=new Te(t);return K.set(t,i),i},Xt=t=>{let e=U.get(t);if(e!==void 0)return e;let i=new Oe(t);return U.set(t,i),i},rt=()=>{let t=new Map,e=(r,s)=>{let n=t.get(s);n===void 0?t.set(s,r):Array.isArray(n)?n.push(r):t.set(s,[n,r])};for(let[r,s]of Y)e(r,s);if(Y.clear(),!Jt||Ze-L>=t.size){for(let[r,s]of t){let n=Ee(r);if(Array.isArray(s))for(let o of s)n.add(o);else n.add(s)}return}for(let r of U.values())for(let[s,n]of r.getWatchers())e(s,re.join(r.rootPath,n));for(let r of K.values())for(let s of r.getWatchers())e(s,r.filePath);let i=Bt(t,Ze*.9);for(let[r,s]of i)if(s.size===1)for(let[n,o]of s){let c=Ee(o),h=j.get(n);h!==c&&(c.add(n),h!==void 0&&h.remove(n))}else{let n=new Set(s.values());if(n.size>1){let o=Xt(r);for(let[c,h]of s){let p=j.get(c);p!==o&&(o.add(h,c),p!==void 0&&p.remove(c))}}else for(let o of n){let c=Ee(o);for(let h of s.keys()){let p=j.get(h);p!==c&&(c.add(h),p!==void 0&&p.remove(h))}}}};ie.watch=t=>{let e=new _e,i=K.get(t);if(i!==void 0)return i.add(e),e;let r=t;for(;;){let s=U.get(r);if(s!==void 0)return s.add(t,e),e;let n=re.dirname(r);if(n===r)break;r=n}return Y.set(e,t),We||rt(),e};ie.batch=t=>{We=!0;try{t()}finally{We=!1,rt()}};ie.getNumberOfWatchers=()=>L});var ct=N((Pr,ke)=>{"use strict";var ot=require("events").EventEmitter,se=Je(),H=require("path"),Qt=Fe(),z=Object.freeze({}),P=2e3,it=require("os").platform()==="darwin",B=process.env.WATCHPACK_POLLING,st=`${+B}`===B?+B:!!B&&B!=="false";function $(t){return t.toLowerCase()}function Zt(t,e){return function(){if(--t===0)return e()}}var xe=class extends ot{constructor(e,i,r){super(),this.directoryWatcher=e,this.path=i,this.startTime=r&&+r}checkStartTime(e,i){let r=this.startTime;return typeof r!="number"?!i:r<=e}close(){this.emit("closed")}},be=class extends ot{constructor(e,i,r){super(),st&&(r.poll=st),this.watcherManager=e,this.options=r,this.path=i,this.files=new Map,this.filesWithoutCase=new Map,this.directories=new Map,this.lastWatchEvent=0,this.initialScan=!0,this.ignored=r.ignored||(()=>!1),this.nestedWatching=!1,this.polledWatching=typeof r.poll=="number"?r.poll:r.poll?5007:!1,this.timeout=void 0,this.initialScanRemoved=new Set,this.initialScanFinished=void 0,this.watchers=new Map,this.parentWatcher=null,this.refs=0,this._activeEvents=new Map,this.closed=!1,this.scanning=!1,this.scanAgain=!1,this.scanAgainInitial=!1,this.createWatcher(),this.doScan(!0)}createWatcher(){try{this.polledWatching?this.watcher={close:()=>{this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0)}}:(it&&this.watchInParentDirectory(),this.watcher=Qt.watch(this.path),this.watcher.on("change",this.onWatchEvent.bind(this)),this.watcher.on("error",this.onWatcherError.bind(this)))}catch(e){this.onWatcherError(e)}}forEachWatcher(e,i){let r=this.watchers.get($(e));if(r!==void 0)for(let s of r)i(s)}setMissing(e,i,r){this.initialScan&&this.initialScanRemoved.add(e);let s=this.directories.get(e);if(s&&(this.nestedWatching&&s.close(),this.directories.delete(e),this.forEachWatcher(e,o=>o.emit("remove",r)),i||this.forEachWatcher(this.path,o=>o.emit("change",e,null,r,i))),this.files.get(e)){this.files.delete(e);let o=$(e),c=this.filesWithoutCase.get(o)-1;c<=0?(this.filesWithoutCase.delete(o),this.forEachWatcher(e,h=>h.emit("remove",r))):this.filesWithoutCase.set(o,c),i||this.forEachWatcher(this.path,h=>h.emit("change",e,null,r,i))}}setFileTime(e,i,r,s,n){let o=Date.now();if(this.ignored(e))return;let c=this.files.get(e),h,p;if(r)h=Math.min(o,i)+P,p=P;else if(h=o,p=0,c&&c.timestamp===i&&i+P<o)return;if(!(s&&c&&c.timestamp===i)){if(this.files.set(e,{safeTime:h,accuracy:p,timestamp:i}),c)r||this.forEachWatcher(e,a=>a.emit("change",i,n));else{let a=$(e),f=this.filesWithoutCase.get(a);this.filesWithoutCase.set(a,(f||0)+1),f!==void 0&&this.doScan(!1),this.forEachWatcher(e,d=>{(!r||d.checkStartTime(h,r))&&d.emit("change",i,n)})}this.forEachWatcher(this.path,a=>{(!r||a.checkStartTime(h,r))&&a.emit("change",e,h,n,r)})}}setDirectory(e,i,r,s){if(!this.ignored(e)){if(e===this.path)r||this.forEachWatcher(this.path,n=>n.emit("change",e,i,s,r));else if(!this.directories.get(e)){let o=Date.now();this.nestedWatching?this.createNestedWatcher(e):this.directories.set(e,!0);let c;r?c=Math.min(o,i)+P:c=o,this.forEachWatcher(e,h=>{(!r||h.checkStartTime(c,!1))&&h.emit("change",i,s)}),this.forEachWatcher(this.path,h=>{(!r||h.checkStartTime(c,r))&&h.emit("change",e,c,s,r)})}}}createNestedWatcher(e){let i=this.watcherManager.watchDirectory(e,1);i.on("change",(r,s,n,o)=>{this.forEachWatcher(this.path,c=>{(!o||c.checkStartTime(s,o))&&c.emit("change",r,s,n,o)})}),this.directories.set(e,i)}setNestedWatching(e){if(this.nestedWatching!==!!e)if(this.nestedWatching=!!e,this.nestedWatching)for(let i of this.directories.keys())this.createNestedWatcher(i);else for(let[i,r]of this.directories)r.close(),this.directories.set(i,!0)}watch(e,i){let r=$(e),s=this.watchers.get(r);s===void 0&&(s=new Set,this.watchers.set(r,s)),this.refs++;let n=new xe(this,e,i);n.on("closed",()=>{if(--this.refs<=0){this.close();return}s.delete(n),s.size===0&&(this.watchers.delete(r),this.path===e&&this.setNestedWatching(!1))}),s.add(n);let o;if(e===this.path){this.setNestedWatching(!0),o=this.lastWatchEvent;for(let c of this.files.values())ne(c),o=Math.max(o,c.safeTime)}else{let c=this.files.get(e);c?(ne(c),o=c.safeTime):o=0}return o?o>=i&&process.nextTick(()=>{this.closed||(e===this.path?n.emit("change",e,o,"watch (outdated on attach)",!0):n.emit("change",o,"watch (outdated on attach)",!0))}):this.initialScan?this.initialScanRemoved.has(e)&&process.nextTick(()=>{this.closed||n.emit("remove")}):!this.directories.has(e)&&n.checkStartTime(this.initialScanFinished,!1)&&process.nextTick(()=>{this.closed||n.emit("initial-missing","watch (missing on attach)")}),n}onWatchEvent(e,i){if(this.closed)return;if(!i){this.doScan(!1);return}let r=H.join(this.path,i);if(!this.ignored(r))if(this._activeEvents.get(i)===void 0){this._activeEvents.set(i,!1);let s=()=>{this.closed||(this._activeEvents.set(i,!1),se.lstat(r,(n,o)=>{if(!this.closed){if(this._activeEvents.get(i)===!0){process.nextTick(s);return}this._activeEvents.delete(i),n&&(n.code!=="ENOENT"&&n.code!=="EPERM"&&n.code!=="EBUSY"?this.onStatsError(n):i===H.basename(this.path)&&(se.existsSync(this.path)||this.onDirectoryRemoved("stat failed"))),this.lastWatchEvent=Date.now(),o?o.isDirectory()?this.setDirectory(r,+o.birthtime||1,!1,e):(o.isFile()||o.isSymbolicLink())&&(o.mtime&&nt(o.mtime),this.setFileTime(r,+o.mtime||+o.ctime||1,!1,!1,e)):this.setMissing(r,!1,e)}}))};process.nextTick(s)}else this._activeEvents.set(i,!0)}onWatcherError(e){this.closed||e&&(e.code!=="EPERM"&&e.code!=="ENOENT"&&console.error("Watchpack Error (watcher): "+e),this.onDirectoryRemoved("watch error"))}onStatsError(e){e&&console.error("Watchpack Error (stats): "+e)}onScanError(e){e&&console.error("Watchpack Error (initial scan): "+e),this.onScanFinished()}onScanFinished(){this.polledWatching&&(this.timeout=setTimeout(()=>{this.closed||this.doScan(!1)},this.polledWatching))}onDirectoryRemoved(e){this.watcher&&(this.watcher.close(),this.watcher=null),this.watchInParentDirectory();let i=`directory-removed (${e})`;for(let r of this.directories.keys())this.setMissing(r,null,i);for(let r of this.files.keys())this.setMissing(r,null,i)}watchInParentDirectory(){if(!this.parentWatcher){let e=H.dirname(this.path);if(H.dirname(e)===e)return;this.parentWatcher=this.watcherManager.watchFile(this.path,1),this.parentWatcher.on("change",(i,r)=>{this.closed||((!it||this.polledWatching)&&this.parentWatcher&&(this.parentWatcher.close(),this.parentWatcher=null),this.watcher||(this.createWatcher(),this.doScan(!1),this.forEachWatcher(this.path,s=>s.emit("change",this.path,i,r,!1))))}),this.parentWatcher.on("remove",()=>{this.onDirectoryRemoved("parent directory removed")})}}doScan(e){if(this.scanning){this.scanAgain?e||(this.scanAgainInitial=!1):(this.scanAgain=!0,this.scanAgainInitial=e);return}this.scanning=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),process.nextTick(()=>{this.closed||se.readdir(this.path,(i,r)=>{if(this.closed)return;if(i){if(i.code==="ENOENT"||i.code==="EPERM"?this.onDirectoryRemoved("scan readdir failed"):this.onScanError(i),this.initialScan=!1,this.initialScanFinished=Date.now(),e)for(let o of this.watchers.values())for(let c of o)c.checkStartTime(this.initialScanFinished,!1)&&c.emit("initial-missing","scan (parent directory missing in initial scan)");this.scanAgain?(this.scanAgain=!1,this.doScan(this.scanAgainInitial)):this.scanning=!1;return}let s=new Set(r.map(o=>H.join(this.path,o.normalize("NFC"))));for(let o of this.files.keys())s.has(o)||this.setMissing(o,e,"scan (missing)");for(let o of this.directories.keys())s.has(o)||this.setMissing(o,e,"scan (missing)");if(this.scanAgain){this.scanAgain=!1,this.doScan(e);return}let n=Zt(s.size+1,()=>{if(!this.closed){if(this.initialScan=!1,this.initialScanRemoved=null,this.initialScanFinished=Date.now(),e){let o=new Map(this.watchers);o.delete($(this.path));for(let c of s)o.delete($(c));for(let c of o.values())for(let h of c)h.checkStartTime(this.initialScanFinished,!1)&&h.emit("initial-missing","scan (missing in initial scan)")}this.scanAgain?(this.scanAgain=!1,this.doScan(this.scanAgainInitial)):(this.scanning=!1,this.onScanFinished())}});for(let o of s)se.lstat(o,(c,h)=>{if(!this.closed){if(c){c.code==="ENOENT"||c.code==="EPERM"||c.code==="EACCES"||c.code==="EBUSY"?this.setMissing(o,e,"scan ("+c.code+")"):this.onScanError(c),n();return}h.isFile()||h.isSymbolicLink()?(h.mtime&&nt(h.mtime),this.setFileTime(o,+h.mtime||+h.ctime||1,e,!0,"scan (file)")):h.isDirectory()&&(!e||!this.directories.has(o))&&this.setDirectory(o,+h.birthtime||1,e,"scan (dir)"),n()}});n()})})}getTimes(){let e=Object.create(null),i=this.lastWatchEvent;for(let[r,s]of this.files)ne(s),i=Math.max(i,s.safeTime),e[r]=Math.max(s.safeTime,s.timestamp);if(this.nestedWatching){for(let r of this.directories.values()){let s=r.directoryWatcher.getTimes();for(let n of Object.keys(s)){let o=s[n];i=Math.max(i,o),e[n]=o}}e[this.path]=i}if(!this.initialScan)for(let r of this.watchers.values())for(let s of r){let n=s.path;Object.prototype.hasOwnProperty.call(e,n)||(e[n]=null)}return e}collectTimeInfoEntries(e,i){let r=this.lastWatchEvent;for(let[s,n]of this.files)ne(n),r=Math.max(r,n.safeTime),e.set(s,n);if(this.nestedWatching){for(let s of this.directories.values())r=Math.max(r,s.directoryWatcher.collectTimeInfoEntries(e,i));e.set(this.path,z),i.set(this.path,{safeTime:r})}else{for(let s of this.directories.keys())e.set(s,z),i.has(s)||i.set(s,z);e.set(this.path,z),i.set(this.path,z)}if(!this.initialScan)for(let s of this.watchers.values())for(let n of s){let o=n.path;e.has(o)||e.set(o,null)}return r}close(){if(this.closed=!0,this.initialScan=!1,this.watcher&&(this.watcher.close(),this.watcher=null),this.nestedWatching){for(let e of this.directories.values())e.close();this.directories.clear()}this.parentWatcher&&(this.parentWatcher.close(),this.parentWatcher=null),this.emit("closed")}};ke.exports=be;ke.exports.EXISTANCE_ONLY_TIME_ENTRY=z;function ne(t){t.accuracy>P&&(t.safeTime=t.safeTime-t.accuracy+P,t.accuracy=P)}function nt(t){t&&(P>1&&t%1!==0?P=1:P>10&&t%10!==0?P=10:P>100&&t%100!==0?P=100:P>1e3&&t%1e3!==0&&(P=1e3))}});var ht=N((Nr,Me)=>{"use strict";var er=require("path"),tr=ct(),oe=class{constructor(e){this.options=e,this.directoryWatchers=new Map}getDirectoryWatcher(e){let i=this.directoryWatchers.get(e);if(i===void 0){let r=new tr(this,e,this.options);return this.directoryWatchers.set(e,r),r.on("closed",()=>{this.directoryWatchers.delete(e)}),r}return i}watchFile(e,i){let r=er.dirname(e);return r===e?null:this.getDirectoryWatcher(r).watch(e,i)}watchDirectory(e,i){return this.getDirectoryWatcher(e).watch(e,i)}},at=new WeakMap;Me.exports=t=>{let e=at.get(t);if(e!==void 0)return e;let i=new oe(t);return at.set(t,i),i};Me.exports.WatcherManager=oe});var ut=N((Ar,lt)=>{"use strict";var rr=require("fs"),ce=require("path"),ft=new Set(["EINVAL","ENOENT"]);process.platform==="win32"&&ft.add("UNKNOWN");var qe=class{constructor(){this.cache=new Map}resolve(e){let i=this.cache.get(e);if(i!==void 0)return i;let r=ce.dirname(e);if(r===e){let o=Object.freeze([e]);return this.cache.set(e,o),o}let s=this.resolve(r),n=e;if(s[0]!==r){let o=ce.basename(e);n=ce.resolve(s[0],o)}try{let o=rr.readlinkSync(n),c=ce.resolve(s[0],o),h=this.resolve(c),p;if(h.length>1&&s.length>1){let a=new Set(h);a.add(n);for(let f=1;f<s.length;f++)a.add(s[f]);p=Object.freeze(Array.from(a))}else s.length>1?(p=s.slice(),p[0]=h[0],p.push(n),Object.freeze(p)):h.length>1?(p=h.slice(),p.push(n),Object.freeze(p)):p=Object.freeze([h[0],n]);return this.cache.set(e,p),p}catch(o){if(!ft.has(o.code))throw o;let c=s.slice();return c[0]=n,Object.freeze(c),this.cache.set(e,c),c}}};lt.exports=qe});var pt=N((Ir,dt)=>{dt.exports=function(t,e){if(typeof t!="string")throw new TypeError("Expected a string");for(var i=String(t),r="",s=e?!!e.extended:!1,n=e?!!e.globstar:!1,o=!1,c=e&&typeof e.flags=="string"?e.flags:"",h,p=0,a=i.length;p<a;p++)switch(h=i[p],h){case"/":case"$":case"^":case"+":case".":case"(":case")":case"=":case"!":case"|":r+="\\"+h;break;case"?":if(s){r+=".";break}case"[":case"]":if(s){r+=h;break}case"{":if(s){o=!0,r+="(";break}case"}":if(s){o=!1,r+=")";break}case",":if(o){r+="|";break}r+="\\"+h;break;case"*":for(var f=i[p-1],d=1;i[p+1]==="*";)d++,p++;var u=i[p+1];if(!n)r+=".*";else{var m=d>1&&(f==="/"||f===void 0)&&(u==="/"||u===void 0);m?(r+="((?:[^/]*(?:/|$))*)",p++):r+="([^/]*)"}break;default:r+=h}return(!c||!~c.indexOf("g"))&&(r="^"+r+"$"),new RegExp(r,c)}});var yt=N((jr,wt)=>{"use strict";var ir=ht(),sr=ut(),nr=require("events").EventEmitter,or=pt(),cr=Fe(),ae=[],ar={};function he(t,e){for(let i of t){let r=i.watcher;e.has(r.directoryWatcher)||e.add(r.directoryWatcher)}}var gt=t=>{let e=or(t,{globstar:!0,extended:!0}).source;return e.slice(0,e.length-1)+"(?:$|\\/)"},hr=t=>{if(Array.isArray(t)){let e=new RegExp(t.map(i=>gt(i)).join("|"));return i=>e.test(i.replace(/\\/g,"/"))}else if(typeof t=="string"){let e=new RegExp(gt(t));return i=>e.test(i.replace(/\\/g,"/"))}else{if(t instanceof RegExp)return e=>t.test(e.replace(/\\/g,"/"));if(t instanceof Function)return t;if(t)throw new Error(`Invalid option for 'ignored': ${t}`);return()=>!1}},fr=t=>({followSymlinks:!!t.followSymlinks,ignored:hr(t.ignored),poll:t.poll}),mt=new WeakMap,lr=t=>{let e=mt.get(t);if(e!==void 0)return e;let i=fr(t);return mt.set(t,i),i},Re=class{constructor(e,i,r){this.files=Array.isArray(r)?r:[r],this.watcher=i,i.on("initial-missing",s=>{for(let n of this.files)e._missing.has(n)||e._onRemove(n,n,s)}),i.on("change",(s,n)=>{for(let o of this.files)e._onChange(o,s,o,n)}),i.on("remove",s=>{for(let n of this.files)e._onRemove(n,n,s)})}update(e){Array.isArray(e)?this.files=e:this.files.length!==1?this.files=[e]:this.files[0]!==e&&(this.files[0]=e)}close(){this.watcher.close()}},Pe=class{constructor(e,i,r){this.directories=Array.isArray(r)?r:[r],this.watcher=i,i.on("initial-missing",s=>{for(let n of this.directories)e._onRemove(n,n,s)}),i.on("change",(s,n,o)=>{for(let c of this.directories)e._onChange(c,n,s,o)}),i.on("remove",s=>{for(let n of this.directories)e._onRemove(n,n,s)})}update(e){Array.isArray(e)?this.directories=e:this.directories.length!==1?this.directories=[e]:this.directories[0]!==e&&(this.directories[0]=e)}close(){this.watcher.close()}},Ne=class extends nr{constructor(e){super(),e||(e=ar),this.options=e,this.aggregateTimeout=typeof e.aggregateTimeout=="number"?e.aggregateTimeout:200,this.watcherOptions=lr(e),this.watcherManager=ir(this.watcherOptions),this.fileWatchers=new Map,this.directoryWatchers=new Map,this._missing=new Set,this.startTime=void 0,this.paused=!1,this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,this.aggregateTimer=void 0,this._onTimeout=this._onTimeout.bind(this)}watch(e,i,r){let s,n,o,c;i?(s=e,n=i,o=ae,c=r):{files:s=ae,directories:n=ae,missing:o=ae,startTime:c}=e,this.paused=!1;let h=this.fileWatchers,p=this.directoryWatchers,a=this.watcherOptions.ignored,f=l=>!a(l),d=(l,g,y)=>{let O=l.get(g);O===void 0?l.set(g,y):Array.isArray(O)?O.push(y):l.set(g,[O,y])},u=new Map,m=new Map,S=new Set;if(this.watcherOptions.followSymlinks){let l=new sr;for(let g of s)if(f(g))for(let y of l.resolve(g))(g===y||f(y))&&d(u,y,g);for(let g of o)if(f(g))for(let y of l.resolve(g))(g===y||f(y))&&(S.add(g),d(u,y,g));for(let g of n)if(f(g)){let y=!0;for(let O of l.resolve(g))f(O)&&d(y?m:u,O,g),y=!1}}else{for(let l of s)f(l)&&d(u,l,l);for(let l of o)f(l)&&(S.add(l),d(u,l,l));for(let l of n)f(l)&&d(m,l,l)}for(let[l,g]of h){let y=u.get(l);y===void 0?(g.close(),h.delete(l)):(g.update(y),u.delete(l))}for(let[l,g]of p){let y=m.get(l);y===void 0?(g.close(),p.delete(l)):(g.update(y),m.delete(l))}cr.batch(()=>{for(let[l,g]of u){let y=this.watcherManager.watchFile(l,c);y&&h.set(l,new Re(this,y,g))}for(let[l,g]of m){let y=this.watcherManager.watchDirectory(l,c);y&&p.set(l,new Pe(this,y,g))}}),this._missing=S,this.startTime=c}close(){this.paused=!0,this.aggregateTimer&&clearTimeout(this.aggregateTimer);for(let e of this.fileWatchers.values())e.close();for(let e of this.directoryWatchers.values())e.close();this.fileWatchers.clear(),this.directoryWatchers.clear()}pause(){this.paused=!0,this.aggregateTimer&&clearTimeout(this.aggregateTimer)}getTimes(){let e=new Set;he(this.fileWatchers.values(),e),he(this.directoryWatchers.values(),e);let i=Object.create(null);for(let r of e){let s=r.getTimes();for(let n of Object.keys(s))i[n]=s[n]}return i}getTimeInfoEntries(){let e=new Map;return this.collectTimeInfoEntries(e,e),e}collectTimeInfoEntries(e,i){let r=new Set;he(this.fileWatchers.values(),r),he(this.directoryWatchers.values(),r);let s={value:0};for(let n of r)n.collectTimeInfoEntries(e,i,s)}getAggregated(){this.aggregateTimer&&(clearTimeout(this.aggregateTimer),this.aggregateTimer=void 0);let e=this.aggregatedChanges,i=this.aggregatedRemovals;return this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,{changes:e,removals:i}}_onChange(e,i,r,s){r=r||e,this.paused||(this.emit("change",r,i,s),this.aggregateTimer&&clearTimeout(this.aggregateTimer),this.aggregateTimer=setTimeout(this._onTimeout,this.aggregateTimeout)),this.aggregatedRemovals.delete(e),this.aggregatedChanges.add(e)}_onRemove(e,i,r){i=i||e,this.paused||(this.emit("remove",i,r),this.aggregateTimer&&clearTimeout(this.aggregateTimer),this.aggregateTimer=setTimeout(this._onTimeout,this.aggregateTimeout)),this.aggregatedChanges.delete(e),this.aggregatedRemovals.add(e)}_onTimeout(){this.aggregateTimer=void 0;let e=this.aggregatedChanges,i=this.aggregatedRemovals;this.aggregatedChanges=new Set,this.aggregatedRemovals=new Set,this.emit("aggregated",e,i)}};wt.exports=Ne});var dr={};Ft(dr,{createPackageJson:()=>At,getMeshPackages:()=>de,getPackageVersions:()=>pe,getSourceFile:()=>ge,getWildcardPackages:()=>me,meshPackages:()=>ue,watcher:()=>ur});module.exports=bt(dr);var C=require("@nrwl/devkit"),De=require("node:path");var kt=["@graphql-mesh/cli","@graphql-mesh/cross-helpers","@graphql-mesh/merger-bare","@graphql-mesh/runtime","@graphql-mesh/store","@graphql-mesh/types","@graphql-mesh/utils"],Mt=["@graphql-mesh/graphql","@graphql-mesh/grpc","@graphql-mesh/json-schema","@graphql-mesh/mongoose","@graphql-mesh/mysql","@graphql-mesh/neo4j","@graphql-mesh/new-openapi","@graphql-mesh/odata","@graphql-mesh/openapi","@graphql-mesh/postgraphile","@graphql-mesh/soap","@graphql-mesh/thrift","@graphql-mesh/tuql"],qt=["@graphql-mesh/transform-cache","@graphql-mesh/transform-encapsulate","@graphql-mesh/transform-federation","@graphql-mesh/transform-filter-schema","@graphql-mesh/transform-hoist-field","@graphql-mesh/transform-mock","@graphql-mesh/transform-naming-convention","@graphql-mesh/transform-prefix","@graphql-mesh/transform-prune","@graphql-mesh/transform-rename","@graphql-mesh/transform-replace-field","@graphql-mesh/transform-resolvers-composition","@graphql-mesh/transform-snapshot"],Rt=["@graphql-mesh/cache-file","@graphql-mesh/cache-localforage","@graphql-mesh/cache-redis"],Pt=["@graphql-mesh/plugin-mock","@graphql-mesh/plugin-snapshot"],Nt=["@graphql-codegen/cli","@graphql-codegen/client-preset"],ue=[...Rt,...Nt,...Pt,...Mt,...qt,...kt];var de=(t,e)=>{let i=[];return e.forEach(r=>{t.indexOf(r)>-1&&i.push(r)}),i};var pe=(t,e)=>{if(e===void 0)return{};let i={};return t.forEach(r=>{let s=e[`npm:${r}`];s&&(i[r]=s.data.version)}),i};var Ce=require("node:fs/promises"),J=require("node:path"),ge=async t=>{let{root:e,dir:i,sourcePath:r}=Object.assign({sourcePath:".mesh/index.ts"},t),s=(0,J.resolve)(e,i),n=(0,J.join)(s,r);return await(0,Ce.readFile)(n,"utf8")};var me=t=>Object.keys(t).filter(e=>t[e]==="*");async function At(t,e){if(e.projectName===void 0)throw new Error("project name is undefined");let i=(0,C.readCachedProjectGraph)(),r=(0,C.createPackageJson)(e.projectName,i,{root:e.root});r.name||(r.name=e.projectName),r.scripts||(r.scripts={}),r.scripts.start="graphql-mesh start",r.devDependencies||(r.devDependencies={});let s=await ge({dir:t.dir,root:e.root}),n=["@graphql-mesh/cli","graphql",...de(s,ue)];r.dependencies&&(n=[...n,...me(r.dependencies)]),r.dependencies={...r.dependencies,...pe(n,i.externalNodes)};let o=(0,De.join)(t.outputPath,"package.json");return(0,C.writeJsonFile)(o,r),{outputFile:o,packageJson:r}}var fe=require("@nrwl/devkit"),vt=xt(yt());async function ur(t,e){let{dir:i,watch:r,...s}=e;if(r===!0){let n=new vt.default({...s,ignored:[".eslintrc.json",".swcrc","**/.codegen","**/.git","**/.mesh","**/node_modules","jest.config.ts","project.json"]});n.watch({directories:[i],startTime:0}),n.on("aggregated",async()=>{await t(),fe.logger.info(""),fe.logger.info(""),fe.logger.info("Watching for changes...")}),await new Promise(()=>{})}else await t()}0&&(module.exports={createPackageJson,getMeshPackages,getPackageVersions,getSourceFile,getWildcardPackages,meshPackages,watcher});