diff --git a/.changeset/calm-compression-streams.md b/.changeset/calm-compression-streams.md new file mode 100644 index 0000000000..e0d92018b2 --- /dev/null +++ b/.changeset/calm-compression-streams.md @@ -0,0 +1,6 @@ +--- +"pacquet": patch +"@pnpm/pnpr": patch +--- + +Fixed memory exposure and allocation handling vulnerabilities when processing zstd-compressed data [#17388](https://github.com/pnpm/pnpm/pull/17388). diff --git a/.changeset/shared-index-initialization.md b/.changeset/shared-index-initialization.md new file mode 100644 index 0000000000..15b60ce9b5 --- /dev/null +++ b/.changeset/shared-index-initialization.md @@ -0,0 +1,5 @@ +--- +"pacquet": patch +--- + +Concurrent workspace installs no longer lose store-index rows when initializing the shared SQLite index [#17388](https://github.com/pnpm/pnpm/pull/17388). diff --git a/.gitignore b/.gitignore index 3578a55b6a..f4a0e09291 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,3 @@ pnpm/npm/wasm/ pnpr-bins-* # Generated by the `prepare` script of pnpm/esm-loader. -pnpm/crates/deps-restorer/src/cas-loader.mjs.inc diff --git a/Cargo.lock b/Cargo.lock index 08e40dd559..3b52349ed6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1081,9 +1081,9 @@ checksum = "b1b4fe32ea3f2a8d975b6c5cdd3f02ac358f471ca24dbb18d7a4ca58b3193d2d" [[package]] name = "compression-codecs" -version = "0.4.38" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" +checksum = "cae36683101b2899f48bd31f8db9839437356188e3b1ff23096e73dab09ba8fe" dependencies = [ "compression-core", "flate2", @@ -1094,9 +1094,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.32" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" +checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" [[package]] name = "concurrent-queue" @@ -10960,27 +10960,27 @@ dependencies = [ [[package]] name = "zstd" -version = "0.13.3" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +checksum = "db3ae9bf90af6e40197bef767eeefc46ad6397420fe873830bd85e5fbbfb3c70" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.3.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +checksum = "ded520f16b29e1a9b771c722221b2b0a0398c2316d9bb3c42b458a5414d7434b" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.1.0+zstd.1.5.7" +version = "2.1.2+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef0a8027ec3ee71300ab3bcbcd0393f434aa72b91ca6d635a39941deae8eea0" +checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 8783b1341e..2c2fe4b400 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -268,7 +268,7 @@ yamlpath = { version = "1.25.2" } wax = { version = "0.7.0" } which = { version = "8.0.2" } zip = { version = "8", default-features = false, features = ["deflate"] } -zstd = { version = "0.13.3", default-features = false } +zstd = { version = "0.14.3", default-features = false } zune-inflate = { version = "0.2.54" } # Dev dependencies diff --git a/pnpm/crates/deps-restorer/src/cas-loader.mjs.inc b/pnpm/crates/deps-restorer/src/cas-loader.mjs.inc new file mode 100644 index 0000000000..c9c605fb6c --- /dev/null +++ b/pnpm/crates/deps-restorer/src/cas-loader.mjs.inc @@ -0,0 +1,140 @@ +import { createRequire as bootstrapRequire } from 'node:module'; const require = bootstrapRequire(import.meta.url); +var oo=Object.create;var rn=Object.defineProperty;var co=Object.getOwnPropertyDescriptor;var ao=Object.getOwnPropertyNames;var uo=Object.getPrototypeOf,lo=Object.prototype.hasOwnProperty;var b=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var _=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var fo=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ao(e))!lo.call(t,i)&&i!==n&&rn(t,i,{get:()=>e[i],enumerable:!(r=co(e,i))||r.enumerable});return t};var ho=(t,e,n)=>(n=t!=null?oo(uo(t)):{},fo(e||!t||!t.__esModule?rn(n,"default",{value:t,enumerable:!0}):n,t));var tt=_((Fl,sn)=>{"use strict";var po=t=>{let e=!1,n;return()=>(e||(n=t(),e=!0,t=void 0),n)};sn.exports=po});var pn=_((Ol,hn)=>{"use strict";var{nextTick:fn}=b("process"),on=t=>{let e=t.length-1;for(;e>=0;){let n=t.charCodeAt(e);if(n===47||n===92)break;e--}return e<0?"":t.slice(0,e)},je=(t,e,n)=>{if(t.length===1){t[0](e,n),t.length=0;return}let r;for(let i of t)try{i(e,n)}catch(s){r||(r=s)}if(t.length=0,r)throw r},ie,pe=null,ge,ae=[],X=0,cn=[],an=1024,dn=()=>{let t=ie,e=pe,n=ge;if(ie=void 0,pe=null,ge=void 0,X===0){t(e,n);return}let r=ae,i=X;ae=cn,X=0;let s=-3;try{for(t(e,n),s=0;san&&(r.length=an),cn=r}},un=(t,e,n)=>{if(ie===void 0)ie=t,pe=e,ge=n,fn(dn);else{let r=ae;r[X]=t,r[X+1]=e,r[X+2]=n,X+=3}},nt=class{constructor(e,n,r){this._provider=e,this._syncProvider=n,this._providerContext=r,this._activeAsyncOperations=new Map,this.provide=this._provider?(i,s,o)=>{if(typeof s=="function"&&(o=s,s=void 0),typeof i!="string"&&!Buffer.isBuffer(i)&&!(i instanceof URL)&&typeof i!="number"){o(new TypeError("path must be a string, Buffer, URL or number"));return}if(s)return this._provider.call(this._providerContext,i,s,o);let c=this._activeAsyncOperations.get(i);if(c){c.push(o);return}this._activeAsyncOperations.set(i,c=[o]),e(i,(a,f)=>{this._activeAsyncOperations.delete(i),je(c,a,f)})}:null,this.provideSync=this._syncProvider?(i,s)=>this._syncProvider.call(this._providerContext,i,s):null}purge(){}purgeParent(){}},re=0,Ee=1,ln=2,rt=class{constructor(e,n,r,i){this._duration=e,this._provider=n,this._syncProvider=r,this._providerContext=i,this._activeAsyncOperations=new Map,this._data=new Map,this._levels=[];for(let s=0;s<10;s++)this._levels.push(new Set);if(e!==1/0)for(let s=5e3;s{this._activeAsyncOperations.delete(i),this._storeResult(i,c,a),this._enterAsyncMode(),je(o,c,a)})}provideSync(e,n){if(typeof e!="string"&&!Buffer.isBuffer(e)&&!(e instanceof URL)&&typeof e!="number")throw new TypeError("path must be a string");let r=typeof e!="string"?e.toString():e;if(n)return this._syncProvider.call(this._providerContext,e,n);this._mode===Ee&&this._runDecays();let i=this._data.get(r);if(i!==void 0){if(i.err)throw i.err;return i.result}let s=this._activeAsyncOperations.get(r);this._activeAsyncOperations.delete(r);let o;try{o=this._syncProvider.call(this._providerContext,e)}catch(c){throw this._storeResult(r,c,void 0),this._enterSyncModeWhenIdle(),s&&je(s,c,void 0),c}return this._storeResult(r,null,o),this._enterSyncModeWhenIdle(),s&&je(s,null,o),o}purge(e,n){if(e==null){if(this._mode!==re){this._data.clear();for(let i of this._levels)i.clear();this._enterIdleMode()}return}if(n!=null&&n.exact===!0){if(typeof e=="string"||Buffer.isBuffer(e)||e instanceof URL||typeof e=="number"){let i=typeof e!="string"?e.toString():e,s=this._data.get(i);s!==void 0&&(this._data.delete(i),s.level.delete(i))}else for(let i of e){let s=typeof i!="string"?i.toString():i,o=this._data.get(s);o!==void 0&&(this._data.delete(s),o.level.delete(s))}this._data.size===0&&this._enterIdleMode();return}if(typeof e=="string"||Buffer.isBuffer(e)||e instanceof URL||typeof e=="number"){let i=typeof e!="string"?e.toString():e;if(i===""){if(this._mode!==re){this._data.clear();for(let s of this._levels)s.clear();this._enterIdleMode()}return}for(let[s,o]of this._data)s.startsWith(i)&&(this._data.delete(s),o.level.delete(s));this._data.size===0&&this._enterIdleMode()}else{for(let[i,s]of this._data)for(let o of e){let c=typeof o!="string"?o.toString():o;if(i.startsWith(c)){this._data.delete(i),s.level.delete(i);break}}this._data.size===0&&this._enterIdleMode()}}purgeParent(e){if(e==null)this.purge();else if(typeof e=="string"||Buffer.isBuffer(e)||e instanceof URL||typeof e=="number"){let n=typeof e!="string"?e.toString():e;this.purge(on(n))}else{let n=new Set;for(let r of e){let i=typeof r!="string"?r.toString():r;n.add(on(i))}this.purge(n)}}_storeResult(e,n,r){if(this._data.has(e))return;let i=this._levels[this._currentLevel];this._data.set(e,{err:n,result:r,level:i}),i.add(e)}_decayLevel(){let e=(this._currentLevel+1)%this._levels.length,n=this._levels[e];this._currentLevel=e;for(let r of n)this._data.delete(r);n.clear(),this._data.size===0?this._enterIdleMode():this._nextDecay+=this._tickInterval}_runDecays(){for(;this._nextDecay<=Date.now()&&this._mode!==re;)this._decayLevel()}_enterAsyncMode(){let e=0;switch(this._mode){case ln:return;case re:this._nextDecay=Date.now()+this._tickInterval,e=this._tickInterval;break;case Ee:if(this._runDecays(),this._mode===re)return;e=Math.max(0,this._nextDecay-Date.now());break}if(this._mode=ln,this._duration===1/0)return;let n=setTimeout(()=>{this._mode=Ee,this._runDecays()},e);n.unref&&n.unref(),this._timeout=n}_enterSyncModeWhenIdle(){this._mode===re&&(this._mode=Ee,this._nextDecay=Date.now()+this._tickInterval)}_enterIdleMode(){this._mode=re,this._nextDecay=void 0,this._timeout&&clearTimeout(this._timeout)}},ce=(t,e,n,r)=>t>0?new rt(t,e,n,r):new nt(e,n,r);hn.exports=class{constructor(e,n){this.fileSystem=e,this._lstatBackend=ce(n,this.fileSystem.lstat,this.fileSystem.lstatSync,this.fileSystem);let r=this._lstatBackend.provide;this.lstat=r;let i=this._lstatBackend.provideSync;this.lstatSync=i,this._statBackend=ce(n,this.fileSystem.stat,this.fileSystem.statSync,this.fileSystem);let s=this._statBackend.provide;this.stat=s;let o=this._statBackend.provideSync;this.statSync=o,this._readdirBackend=ce(n,this.fileSystem.readdir,this.fileSystem.readdirSync,this.fileSystem);let c=this._readdirBackend.provide;this.readdir=c;let a=this._readdirBackend.provideSync;this.readdirSync=a,this._readFileBackend=ce(n,this.fileSystem.readFile,this.fileSystem.readFileSync,this.fileSystem);let f=this._readFileBackend.provide;this.readFile=f;let u=this._readFileBackend.provideSync;this.readFileSync=u,this._readJsonBackend=ce(n,this.fileSystem.readJson||this.readFile&&((w,A)=>{this.readFile(w,(P,E)=>{if(P)return A(P);if(!E||E.length===0)return A(new Error("No file content"));let k;try{k=JSON.parse(E.toString("utf8"))}catch(N){return A(N)}A(null,k)})}),this.fileSystem.readJsonSync||this.readFileSync&&(w=>{let A=this.readFileSync(w);return JSON.parse(A.toString("utf8"))}),this.fileSystem);let l=this._readJsonBackend.provide;this.readJson=l;let d=this._readJsonBackend.provideSync;this.readJsonSync=d,this._readlinkBackend=ce(n,this.fileSystem.readlink,this.fileSystem.readlinkSync,this.fileSystem);let h=this._readlinkBackend.provide;this.readlink=h;let p=this._readlinkBackend.provideSync;this.readlinkSync=p,this._realpathBackend=ce(n,this.fileSystem.realpath,this.fileSystem.realpathSync,this.fileSystem);let g=this._realpathBackend.provide;this.realpath=g;let y=this._realpathBackend.provideSync;this.realpathSync=y}purge(e,n){this._statBackend.purge(e,n),this._lstatBackend.purge(e,n),n!=null&&n.exact===!0?this._readdirBackend.purge(e,n):this._readdirBackend.purgeParent(e),this._readFileBackend.purge(e,n),this._readlinkBackend.purge(e,n),this._readJsonBackend.purge(e,n),this._realpathBackend.purge(e,n)}}});var yn=_((Ml,gn)=>{var se=b("constants"),go=process.cwd,He=null,yo=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return He||(He=go.call(process)),He};try{process.cwd()}catch{}typeof process.chdir=="function"&&(it=process.chdir,process.chdir=function(t){He=null,it.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,it));var it;gn.exports=mo;function mo(t){se.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||n(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(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=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=c(t.stat),t.fstat=c(t.fstat),t.lstat=c(t.lstat),t.statSync=a(t.statSync),t.fstatSync=a(t.fstatSync),t.lstatSync=a(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,l,d){d&&process.nextTick(d)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,l,d,h){h&&process.nextTick(h)},t.lchownSync=function(){}),yo==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(u){function l(d,h,p){var g=Date.now(),y=0;u(d,h,function w(A){if(A&&(A.code==="EACCES"||A.code==="EPERM"||A.code==="EBUSY")&&Date.now()-g<6e4){setTimeout(function(){t.stat(h,function(P,E){P&&P.code==="ENOENT"?u(d,h,w):p(A)})},y),y<100&&(y+=10);return}p&&p(A)})}return Object.setPrototypeOf&&Object.setPrototypeOf(l,u),l})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(u){function l(d,h,p,g,y,w){var A;if(w&&typeof w=="function"){var P=0;A=function(E,k,N){if(E&&E.code==="EAGAIN"&&P<10)return P++,u.call(t,d,h,p,g,y,A);w.apply(this,arguments)}}return u.call(t,d,h,p,g,y,A)}return Object.setPrototypeOf&&Object.setPrototypeOf(l,u),l})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(u){return function(l,d,h,p,g){for(var y=0;;)try{return u.call(t,l,d,h,p,g)}catch(w){if(w.code==="EAGAIN"&&y<10){y++;continue}throw w}}})(t.readSync);function e(u){u.lchmod=function(l,d,h){u.open(l,se.O_WRONLY|se.O_SYMLINK,d,function(p,g){if(p){h&&h(p);return}u.fchmod(g,d,function(y){u.close(g,function(w){h&&h(y||w)})})})},u.lchmodSync=function(l,d){var h=u.openSync(l,se.O_WRONLY|se.O_SYMLINK,d),p=!0,g;try{g=u.fchmodSync(h,d),p=!1}finally{if(p)try{u.closeSync(h)}catch{}else u.closeSync(h)}return g}}function n(u){se.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(l,d,h,p){u.open(l,se.O_SYMLINK,function(g,y){if(g){p&&p(g);return}u.futimes(y,d,h,function(w){u.close(y,function(A){p&&p(w||A)})})})},u.lutimesSync=function(l,d,h){var p=u.openSync(l,se.O_SYMLINK),g,y=!0;try{g=u.futimesSync(p,d,h),y=!1}finally{if(y)try{u.closeSync(p)}catch{}else u.closeSync(p)}return g}):u.futimes&&(u.lutimes=function(l,d,h,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function r(u){return u&&function(l,d,h){return u.call(t,l,d,function(p){f(p)&&(p=null),h&&h.apply(this,arguments)})}}function i(u){return u&&function(l,d){try{return u.call(t,l,d)}catch(h){if(!f(h))throw h}}}function s(u){return u&&function(l,d,h,p){return u.call(t,l,d,h,function(g){f(g)&&(g=null),p&&p.apply(this,arguments)})}}function o(u){return u&&function(l,d,h){try{return u.call(t,l,d,h)}catch(p){if(!f(p))throw p}}}function c(u){return u&&function(l,d,h){typeof d=="function"&&(h=d,d=null);function p(g,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),h&&h.apply(this,arguments)}return d?u.call(t,l,d,p):u.call(t,l,p)}}function a(u){return u&&function(l,d){var h=d?u.call(t,l,d):u.call(t,l);return h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),h}}function f(u){if(!u||u.code==="ENOSYS")return!0;var l=!process.getuid||process.getuid()!==0;return!!(l&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var wn=_((xl,_n)=>{var mn=b("stream").Stream;_n.exports=_o;function _o(t){return{ReadStream:e,WriteStream:n};function e(r,i){if(!(this instanceof e))return new e(r,i);mn.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var o=Object.keys(i),c=0,a=o.length;cthis.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}t.open(this.path,this.flags,this.mode,function(u,l){if(u){s.emit("error",u),s.readable=!1;return}s.fd=l,s.emit("open",l),s._read()})}function n(r,i){if(!(this instanceof n))return new n(r,i);mn.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),o=0,c=s.length;o= 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 Sn=_((Dl,An)=>{"use strict";An.exports=Ao;var wo=Object.getPrototypeOf||function(t){return t.__proto__};function Ao(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:wo(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}});var $n=_((Cl,ct)=>{var C=b("fs"),So=yn(),Po=wn(),Ro=Sn(),Ie=b("util"),I,We;typeof Symbol=="function"&&typeof Symbol.for=="function"?(I=Symbol.for("graceful-fs.queue"),We=Symbol.for("graceful-fs.previous")):(I="___graceful-fs.queue",We="___graceful-fs.previous");function Eo(){}function En(t,e){Object.defineProperty(t,I,{get:function(){return e}})}var ue=Eo;Ie.debuglog?ue=Ie.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ue=function(){var t=Ie.format.apply(Ie,arguments);t="GFS4: "+t.split(/\n/).join(` +GFS4: `),console.error(t)});C[I]||(Pn=global[I]||[],En(C,Pn),C.close=(function(t){function e(n,r){return t.call(C,n,function(i){i||Rn(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(e,We,{value:t}),e})(C.close),C.closeSync=(function(t){function e(n){t.apply(C,arguments),Rn()}return Object.defineProperty(e,We,{value:t}),e})(C.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ue(C[I]),b("assert").equal(C[I].length,0)}));var Pn;global[I]||En(global,C[I]);ct.exports=st(Ro(C));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!C.__patched&&(ct.exports=st(C),C.__patched=!0);function st(t){So(t),t.gracefulify=st,t.createReadStream=k,t.createWriteStream=N;var e=t.readFile;t.readFile=n;function n(R,O,F){return typeof O=="function"&&(F=O,O=null),j(R,O,F);function j(H,T,x,D){return e(H,T,function(m){m&&(m.code==="EMFILE"||m.code==="ENFILE")?ye([j,[H,T,x],m,D||Date.now(),Date.now()]):typeof x=="function"&&x.apply(this,arguments)})}}var r=t.writeFile;t.writeFile=i;function i(R,O,F,j){return typeof F=="function"&&(j=F,F=null),H(R,O,F,j);function H(T,x,D,m,S){return r(T,x,D,function(M){M&&(M.code==="EMFILE"||M.code==="ENFILE")?ye([H,[T,x,D,m],M,S||Date.now(),Date.now()]):typeof m=="function"&&m.apply(this,arguments)})}}var s=t.appendFile;s&&(t.appendFile=o);function o(R,O,F,j){return typeof F=="function"&&(j=F,F=null),H(R,O,F,j);function H(T,x,D,m,S){return s(T,x,D,function(M){M&&(M.code==="EMFILE"||M.code==="ENFILE")?ye([H,[T,x,D,m],M,S||Date.now(),Date.now()]):typeof m=="function"&&m.apply(this,arguments)})}}var c=t.copyFile;c&&(t.copyFile=a);function a(R,O,F,j){return typeof F=="function"&&(j=F,F=0),H(R,O,F,j);function H(T,x,D,m,S){return c(T,x,D,function(M){M&&(M.code==="EMFILE"||M.code==="ENFILE"||M.code==="EBUSY")?ye([H,[T,x,D,m],M,S||Date.now(),Date.now()]):typeof m=="function"&&m.apply(this,arguments)})}}var f=t.readdir;t.readdir=l;var u=/^v[0-5]\./;function l(R,O,F){typeof O=="function"&&(F=O,O=null);var j=u.test(process.version)?function(x,D,m,S){return f(x,H(x,D,m,S))}:function(x,D,m,S){return f(x,D,H(x,D,m,S))};return j(R,O,F);function H(T,x,D,m){return function(S,M){S&&(S.code==="EMFILE"||S.code==="ENFILE")?ye([j,[T,x,D],S,m||Date.now(),Date.now()]):(M&&M.sort&&M.sort(),typeof D=="function"&&D.call(this,S,M))}}}if(process.version.substr(0,4)==="v0.8"){var d=Po(t);w=d.ReadStream,P=d.WriteStream}var h=t.ReadStream;h&&(w.prototype=Object.create(h.prototype),w.prototype.open=A);var p=t.WriteStream;p&&(P.prototype=Object.create(p.prototype),P.prototype.open=E),Object.defineProperty(t,"ReadStream",{get:function(){return w},set:function(R){w=R},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return P},set:function(R){P=R},enumerable:!0,configurable:!0});var g=w;Object.defineProperty(t,"FileReadStream",{get:function(){return g},set:function(R){g=R},enumerable:!0,configurable:!0});var y=P;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(R){y=R},enumerable:!0,configurable:!0});function w(R,O){return this instanceof w?(h.apply(this,arguments),this):w.apply(Object.create(w.prototype),arguments)}function A(){var R=this;Q(R.path,R.flags,R.mode,function(O,F){O?(R.autoClose&&R.destroy(),R.emit("error",O)):(R.fd=F,R.emit("open",F),R.read())})}function P(R,O){return this instanceof P?(p.apply(this,arguments),this):P.apply(Object.create(P.prototype),arguments)}function E(){var R=this;Q(R.path,R.flags,R.mode,function(O,F){O?(R.destroy(),R.emit("error",O)):(R.fd=F,R.emit("open",F))})}function k(R,O){return new t.ReadStream(R,O)}function N(R,O){return new t.WriteStream(R,O)}var oe=t.open;t.open=Q;function Q(R,O,F,j){return typeof F=="function"&&(j=F,F=null),H(R,O,F,j);function H(T,x,D,m,S){return oe(T,x,D,function(M,Ve){M&&(M.code==="EMFILE"||M.code==="ENFILE")?ye([H,[T,x,D,m],M,S||Date.now(),Date.now()]):typeof m=="function"&&m.apply(this,arguments)})}}return t}function ye(t){ue("ENQUEUE",t[0].name,t[1]),C[I].push(t),ot()}var Ue;function Rn(){for(var t=Date.now(),e=0;e2&&(C[I][e][3]=t,C[I][e][4]=t);ot()}function ot(){if(clearTimeout(Ue),Ue=void 0,C[I].length!==0){var t=C[I].shift(),e=t[0],n=t[1],r=t[2],i=t[3],s=t[4];if(i===void 0)ue("RETRY",e.name,n),e.apply(null,n);else if(Date.now()-i>=6e4){ue("TIMEOUT",e.name,n);var o=n.pop();typeof o=="function"&&o.call(null,r)}else{var c=Date.now()-s,a=Math.max(s-i,1),f=Math.min(a*1.2,100);c>=f?(ue("RETRY",e.name,n),e.apply(null,n.concat([i]))):C[I].push(t)}Ue===void 0&&(Ue=setTimeout(ot,0))}}});var Z=_((Ll,vn)=>{"use strict";vn.exports=function(e,n,r){if(e.length===0)return r();let i=0,s=()=>{let o;return n(e[i++],(c,a)=>{if(c||a!==void 0||i>=e.length)return r(c,a,i);if(o===!1)for(;s(););o=!0},i),o||(o=!1),o};for(;s(););}});var On=_((Tl,kn)=>{"use strict";var Be=Symbol("singleComment"),Fn=Symbol("multiComment"),$o=(t,e,n)=>"",vo=(t,e,n)=>t.slice(e,n).replace(/[^ \t\r\n]/g," "),Fo=(t,e)=>{let n=e-1,r=0;for(;t[n]==="\\";)n-=1,r+=1;return!!(r%2)};function ko(t,{whitespace:e=!0,trailingCommas:n=!1}={}){if(typeof t!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof t}\``);let r=e?vo:$o,i=!1,s=!1,o=0,c="",a="",f=-1;for(let l=0;l{"use strict";var Oo=tt(),Mo=On(),Mn=new WeakMap,xo=Oo(()=>new TextDecoder("utf-8",{ignoreBOM:!0})),xn=t=>typeof t=="string"?t:typeof Buffer<"u"&&Buffer.isBuffer(t)?t.toString("utf8"):xo().decode(t);function Do(t,e,n,r){let{stripComments:i=!1}=n,{readJson:s}=t;if(s&&!i){s(e,(o,c)=>{if(o)return r(o);r(null,c)});return}t.readFile(e,(o,c)=>{if(o)return r(o);let a=c,f=i&&typeof a=="object";if(f){let l=Mn.get(a);if(l!==void 0)return r(null,l)}let u;try{let l=xn(a),d=i?Mo(l,{trailingCommas:!0,whitespace:!0}):l;u=JSON.parse(d)}catch(l){return r(l)}f&&Mn.set(a,u),r(null,u)})}at.exports.decodeText=xn;at.exports.readJson=Do});var le=_((jl,be)=>{"use strict";var Co=Z(),{decodeText:Lo}=qe(),To=47,No=92;function Dn(t){if(t.length<=1)return null;for(let e=t.length-1;e>=0;e--){let n=t.charCodeAt(e);if(n===To||n===No)return t.slice(0,e||1)}return null}function jo(t,e,n,r,i,s){let o=(f,u)=>{let l=t.join(e,f);function d(h,p){if(h)return i.log?i.log(`${l} (directory description file): ${h}`):h.message=`${l} (directory description file): ${h}`,u(h);u(null,{content:p,directory:e,path:l})}t.fileSystem.readJson?t.fileSystem.readJson(l,(h,p)=>{if(h)return typeof h.code<"u"?(i.missingDependencies&&i.missingDependencies.add(l),u()):(i.fileDependencies&&i.fileDependencies.add(l),d(h));i.fileDependencies&&i.fileDependencies.add(l),d(null,p)}):t.fileSystem.readFile(l,(h,p)=>{if(h)return i.missingDependencies&&i.missingDependencies.add(l),u();i.fileDependencies&&i.fileDependencies.add(l);let g;if(p)try{g=JSON.parse(Lo(p))}catch(y){return d(y)}else return d(new Error("No content in file"));d(null,g)})},c,a=(f,u)=>{if(f)return s(f);if(u)return s(null,u);let l=Dn(e);return l?(e=l,c()):s()};c=()=>{if(r&&r.directory===e)return s(null,r);Co(n,o,a)},c()}function Ho(t,e){if(t){if(Array.isArray(e)){let n=t;for(let r=0;r{"use strict";var $e=b("path"),{fileURLToPath:Cn}=b("url"),ut=35,V=47,fe=92,ve=65,Fe=90,lt=97,ft=122,de=46,dt=58,Io=70,Uo=102,Wo=/^file:\//i,me=$e.posix.normalize,ht=$e.win32.normalize,v=Object.freeze({Empty:0,Normal:1,Relative:2,AbsoluteWin:3,AbsolutePosix:4,Internal:5}),Bo=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,qo=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,he=t=>{switch(t.length){case 0:return v.Empty;case 1:{switch(t.charCodeAt(0)){case de:return v.Relative;case V:return v.AbsolutePosix;case ut:return v.Internal}return v.Normal}case 2:{let r=t.charCodeAt(0);switch(r){case de:{switch(t.charCodeAt(1)){case de:case V:return v.Relative}return v.Normal}case V:return v.AbsolutePosix;case ut:return v.Internal}let i=t.charCodeAt(1);return i===dt&&(r>=ve&&r<=Fe||r>=lt&&r<=ft)||r===fe&&i===fe?v.AbsoluteWin:v.Normal}}let e=t.charCodeAt(0);switch(e){case de:{switch(t.charCodeAt(1)){case V:return v.Relative;case de:return t.charCodeAt(2)===V?v.Relative:v.Normal}return v.Normal}case V:return v.AbsolutePosix;case ut:return v.Internal}let n=t.charCodeAt(1);if(n===dt){let r=t.charCodeAt(2);if((r===fe||r===V)&&(e>=ve&&e<=Fe||e>=lt&&e<=ft))return v.AbsoluteWin}return e===fe&&n===fe?v.AbsoluteWin:v.Normal},Ln=t=>{switch(he(t)){case v.Empty:return t;case v.AbsoluteWin:return ht(t);case v.Relative:{let e=me(t);return he(e)===v.Relative?e:`./${e}`}}return me(t)},Tn=(t,e)=>{if(!e)return Ln(t);let n=he(e);switch(n){case v.AbsolutePosix:return me(e);case v.AbsoluteWin:return ht(e)}switch(he(t)){case v.Normal:case v.Relative:case v.AbsolutePosix:return me(`${t}/${e}`);case v.AbsoluteWin:return ht(`${t}\\${e}`)}switch(n){case v.Empty:return t;case v.Relative:{let r=me(t);return he(r)===v.Relative?r:`./${r}`}}return me(t)},Nn=t=>he(t)===v.AbsoluteWin?$e.win32.dirname(t):$e.posix.dirname(t),bo=()=>{let t=new Map;return{fn:(n,r)=>{let i,s=t.get(n);if(s===void 0)t.set(n,s=new Map);else if(i=s.get(r),i!==void 0)return i;return i=Tn(n,r),s.set(r,i),i},cache:t}},Jo=()=>{let t=new Map;return{fn:n=>{let r=t.get(n);if(r!==void 0)return r;let i=Nn(n);return t.set(n,i),i},cache:t}},Go=()=>{let t=new Map;return{fn:(n,r)=>{let i,s=t.get(n);if(s===void 0)t.set(n,s=new Map);else if(i=s.get(r),i!==void 0)return i;return i=$e.basename(n,r),s.set(r,i),i},cache:t}},zo=t=>{let e=t.length;if(e===0||t.charCodeAt(0)!==de)return!1;if(e===1)return!0;let n=t.charCodeAt(1);return n===V?!0:n!==de?!1:e===2?!0:t.charCodeAt(2)===V},pt=t=>{let e=t.charCodeAt(0);return e===fe?!0:t.charCodeAt(1)!==dt?!1:e>=ve&&e<=Fe||e>=lt&&e<=ft},ke=(t,e)=>t===V||e&&t===fe,jn=(t,e)=>{let n=t.length;for(;n>0&&ke(t.charCodeAt(n-1),e);)n--;return n},Ko=(t,e,n)=>n.slice(0,e).replace(/\//g,"\\").toLowerCase()===t.slice(0,e).replace(/\//g,"\\").toLowerCase(),Hn=(t,e,n,r)=>{if(n.length127||o>127)return Ko(t,e,n);let c=s>=ve&&s<=Fe?s+32:s,a=o>=ve&&o<=Fe?o+32:o;if(c!==a)return!1}return!0},Yo=(t,e)=>{let n=pt(t),r=jn(t,n);return Hn(t,r,e,n)?e.length===r||ke(e.charCodeAt(r),n):!1},Qo=(t,e)=>{let n=pt(t),r=jn(t,n);return e.length<=r||!Hn(t,r,e,n)?!1:ke(e.charCodeAt(r),n)},In=t=>{let e=t.charCodeAt(0);return(e===Uo||e===Io)&&Wo.test(t)},Xo=t=>t instanceof URL||In(t)?Cn(t):t;U.exports.PathType=v;U.exports.createCachedBasename=Go;U.exports.createCachedDirname=Jo;U.exports.createCachedJoin=bo;U.exports.deprecatedInvalidSegmentRegEx=Bo;U.exports.dirname=Nn;U.exports.getType=he;U.exports.invalidSegmentRegEx=qo;U.exports.isFileURL=In;U.exports.isInside=Yo;U.exports.isRelativeRequest=zo;U.exports.isSubPath=Qo;U.exports.isWindowsPath=pt;U.exports.join=Tn;U.exports.normalize=Ln;U.exports.toPath=Xo});var Wn=_((Il,Un)=>{"use strict";var{isRelativeRequest:Zo}=J();Un.exports=function(e,n){if(typeof n.__innerRequest=="string"&&n.__innerRequest_request===n.request&&n.__innerRequest_relativePath===n.relativePath)return n.__innerRequest;let r;return n.request?(r=n.request,n.relativePath&&Zo(r)&&(r=e.join(n.relativePath,r))):r=n.relativePath,n.__innerRequest_request=n.request,n.__innerRequest_relativePath=n.relativePath,n.__innerRequest=r}});var bn=_((Wl,qn)=>{"use strict";var Vo=le(),ec=Wn(),Bn=Symbol("NoFieldObject");qn.exports=class{constructor(e,n,r){this.source=e,this.field=n,this.target=r,this._fieldDataCache=new WeakMap}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("AliasFieldPlugin",(r,i,s)=>{if(!r.descriptionFileData)return s();let o=ec(e,r);if(!o)return s();let{descriptionFileData:c}=r,a=this._fieldDataCache.get(c);if(a===void 0){let l=Vo.getField(c,this.field);a=l===null||typeof l!="object"?Bn:l,this._fieldDataCache.set(c,a)}if(a===Bn)return i.log&&i.log(`Field '${this.field}' doesn't contain a valid alias configuration`),s();let f=Object.prototype.hasOwnProperty.call(a,o)?a[o]:o.startsWith("./")?a[o.slice(2)]:void 0;if(f===o||f===void 0)return s();if(f===!1){let l={...r,path:!1};return typeof i.yield=="function"?(i.yield(l),s(null,null)):s(null,l)}let u={...r,path:r.descriptionFileRoot,request:f,fullySpecified:!1};e.doResolve(n,u,`aliased from description file ${r.descriptionFilePath} with mapping '${o}' to '${f}'`,i,(l,d)=>{if(l)return s(l);if(d===void 0)return s(null,null);s(null,d)})})}}});var yt=_((Bl,gt)=>{"use strict";var Jn=Z(),{PathType:Gn,getType:tc}=J(),nc=[],rc={all:nc,byFirstChar:new Map,hasAnyFirstChar:!1,useBuckets:!1};function ic(t,e){if(e.length===0)return rc;let n=Array.from({length:e.length}),r=new Map,i=!1;for(let o=0;o0?a.charCodeAt(0):-1;let g={name:a,nameWithSlash:`${a}/`,alias:c.alias,onlyModule:!!c.onlyModule,absolutePath:f,wildcardPrefix:d,wildcardSuffix:h,firstCharCode:p,arrayAlias:Array.isArray(c.alias)};if(n[o]=g,p===-1)i=!0;else{let y=r.get(p);y===void 0&&(y=[],r.set(p,y)),y.push(g)}}let s=!i&&r.size>=2;return{all:n,byFirstChar:r,hasAnyFirstChar:i,useBuckets:s}}function sc(t,e,n,r,i,s){if(e.all.length===0)return s();let o=r.request||r.path;if(!o)return s();let c=o.charCodeAt(0),a=!!r.request,f;if(e.useBuckets){let u=e.byFirstChar.get(c);if(u===void 0)return s();f=u}else f=e.all;Jn(f,(u,l)=>{let{firstCharCode:d}=u;if(d!==-1&&d!==c)return l();let h=!1,{absolutePath:p}=u,g=o===u.name||!u.onlyModule&&(a&&o.startsWith(u.nameWithSlash)||p!==null&&o.startsWith(p)),y=!u.onlyModule&&u.wildcardPrefix!==null;if(g||y){let w=(P,E)=>{if(P===!1){let N={...r,path:!1};return typeof i.yield=="function"?(i.yield(N),E(null,null)):E(null,N)}let k;if(y&&o.startsWith(u.wildcardPrefix)&&o.endsWith(u.wildcardSuffix)){let N=o.slice(u.wildcardPrefix.length,o.length-u.wildcardSuffix.length);k=P.toString().replace("*",N)}if(g&&o!==P&&!o.startsWith(`${P}/`)){let N=o.slice(u.name.length);k=P+N}if(k!==void 0){h=!0;let N={...r,request:k,fullySpecified:!1};return t.doResolve(n,N,`aliased with mapping '${u.name}': '${P}' to '${k}'`,i,(oe,Q)=>oe?E(oe):Q?E(null,Q):E())}return E()},A=(P,E)=>P?l(P):E?l(null,E):h?l(null,null):l();return u.arrayAlias?Jn(u.alias,w,A):w(u.alias,A)}return l()},s)}gt.exports.aliasResolveHandler=sc;gt.exports.compileAliasOptions=ic});var Kn=_((bl,zn)=>{"use strict";var{aliasResolveHandler:oc,compileAliasOptions:cc}=yt();zn.exports=class{constructor(e,n,r){this.source=e,this.options=Array.isArray(n)?n:[n],this.target=r}apply(e){let n=e.ensureHook(this.target),r=cc(e,this.options);e.getHook(this.source).tapAsync("AliasPlugin",(i,s,o)=>{oc(e,r,n,i,s,o)})}}});var Qn=_((Gl,Yn)=>{"use strict";Yn.exports=class{constructor(e,n,r){this.source=e,this.appending=n,this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("AppendPlugin",(r,i,s)=>{let o={...r,path:r.path+this.appending,relativePath:r.relativePath&&r.relativePath+this.appending};e.doResolve(n,o,this.appending,i,s)})}}});var Zn=_((Kl,Xn)=>{"use strict";Xn.exports=class{constructor(e,n,r,i,s){this.source=e,this.test=n,this.message=r,this.allowAlternatives=i,this.target=s}apply(e){let n=e.ensureHook(this.target),{test:r,message:i,allowAlternatives:s}=this,o=Object.keys(r);e.getHook(this.source).tapAsync("ConditionalPlugin",(c,a,f)=>{for(let u of o)if(c[u]!==r[u])return f();e.doResolve(n,c,i,a,s?f:(u,l)=>{if(u)return f(u);if(l===void 0)return f(null,null);f(null,l)})})}}});var tr=_((Ql,er)=>{"use strict";var Vn=le(),ac=/\\/g;er.exports=class{constructor(e,n,r,i){this.source=e,this.filenames=n,this.pathIsFile=r,this.target=i}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("DescriptionFilePlugin",(r,i,s)=>{let{path:o}=r;if(!o)return s();let c=this.pathIsFile?Vn.cdUp(o):o;if(!c)return s();Vn.loadDescriptionFile(e,c,this.filenames,r.descriptionFilePath?{path:r.descriptionFilePath,content:r.descriptionFileData,directory:r.descriptionFileRoot}:void 0,i,(a,f)=>{if(a)return s(a);if(!f)return i.log&&i.log(`No description file found in ${c} or above`),s();let u=o.slice(f.directory.length),l=`.${u.includes("\\")?u.replace(ac,"/"):u}`,d={...r,descriptionFilePath:f.path,descriptionFileData:f.content,descriptionFileRoot:f.directory,relativePath:l};e.doResolve(n,d,`using description file: ${f.path} (relative path: ${l})`,i,(h,p)=>{if(h)return s(h);if(p===void 0)return s(null,null);s(null,p)})})})}}});var rr=_((Zl,nr)=>{"use strict";nr.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("DirectoryExistsPlugin",(r,i,s)=>{let o=e.fileSystem,c=r.path;if(!c)return s();o.stat(c,(a,f)=>{if(a||!f||!f.isDirectory())return i.missingDependencies&&i.missingDependencies.add(c),i.log&&i.log(a||!f?`${c} doesn't exist`:`${c} is not a directory`),s();i.fileDependencies&&i.fileDependencies.add(c),e.doResolve(n,r,`existing directory ${c}`,i,s)})})}}});var Oe=_((Vl,sr)=>{"use strict";var{fileURLToPath:uc}=b("url"),{isFileURL:lc}=J(),fc=/^(#?(?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/,ir=/\0(.)/g;function dc(t){if(t.length>=4&&t.charCodeAt(1)===92&&t.charCodeAt(3)===92){let e=t.charCodeAt(2);if(e===63||e===46)return 4}return 0}function hc(t){if(!t)return null;if(lc(t)&&(t=uc(t)),t.indexOf("\0")!==-1){let s=fc.exec(t);return s?[s[1].replace(ir,"$1"),s[2]?s[2].replace(ir,"$1"):"",s[3]||""]:null}let n=t.charCodeAt(0)===92?dc(t):0,r=t.indexOf("?",n),i=t.indexOf("#",n||1);return i<0?r<0?[t,"",""]:[t.slice(0,r),t.slice(r),""]:r<0||i{"use strict";var{parseIdentifier:gr}=Oe(),te=47,Je=46,yr=35,pc=/\*/g,gc=/\$/g,or=new WeakMap;function cr(t){let e=or.get(t);return e===void 0&&(e=Object.keys(t),or.set(t,e)),e}var ar=new WeakMap;function yc(t){let e=t,n=ar.get(e);if(n!==void 0)return n;let r=Object.getOwnPropertyNames(t);n=Array.from({length:r.length});for(let i=0;i0&&s.charCodeAt(a-1)===te;n[i]={key:s,patternIndex:o,wildcardPrefix:o===-1?"":s.slice(0,o),wildcardSuffix:o===-1?"":s.slice(o+1),isLegacySubpath:o===-1&&f,isPattern:o!==-1,isSubpathMapping:f,isValidPattern:c}}return ar.set(e,n),n}function ur(t,e){let n=t.indexOf("*"),r=e.indexOf("*"),i=n===-1?t.length:n+1,s=r===-1?e.length:r+1;return i>s?-1:s>i||n===-1?1:r===-1||t.length>e.length?-1:e.length>t.length?1:0}var lr=new WeakMap;function mc(t,e){let n=t.length,r=n>0&&t.charCodeAt(n-1)===te;if(!t.includes("*")&&!r&&Object.prototype.hasOwnProperty.call(e,t))return[e[t],"",!1,!1,t];let s="",o=null,c,a=yc(e);for(let u=0;u0;){let r=n[n.length-1],[i,s,o]=r;for(let c=o;cJSON.stringify(l),a=o.keys.filter(l=>l.charCodeAt(0)===r),f=o.trail[o.trail.length-1],u=a.map(l=>`${c(l)}: { ${c(f)}: ... }`).join(", ");return`the value at ${o.trail.map(c).join(" -> ")} is an object with subpath keys (${a.map(c).join(", ")}), which is not supported - a condition can only map to a target or to further conditions, so those subpaths never match. Put the subpaths at the top level and nest the conditions inside them instead, e.g. { ${u} }.`};function Sc(t){if(typeof t=="string"||Array.isArray(t))return{".":t};let e=Object.keys(t);for(let n=0;nn.length===0?".":`./${n}`,Ac,Pc)};function Rc(t){if(t.charCodeAt(0)!==yr)throw new Error('Request should start with "#"');if(t.length===1)throw new Error("Request should have at least 2 characters");if(t.charCodeAt(t.length-1)===te)throw new Error("Only requesting file allowed");return t.slice(1)}function Ec(t,e){let n=gr(t);if(!n)return;let[r]=n;if(r.charCodeAt(r.length-1)===te!==e)throw new Error(e?`Expecting folder to folder mapping. ${JSON.stringify(t)} should end with "/"`:`Expecting file to file mapping. ${JSON.stringify(t)} should not end with "/"`)}Ge.exports.processImportsField=function(e){return wr(e,n=>`#${n}`,Rc,Ec)}});var Pr=_((nf,Sr)=>{"use strict";var Ar=le(),$c=Z(),{explainSubpathsInConditions:vc,processExportsField:Fc}=_t(),{parseIdentifier:kc}=Oe(),{deprecatedInvalidSegmentRegEx:Oc,invalidSegmentRegEx:Mc}=J();Sr.exports=class{constructor(e,n,r,i,s){this.source=e,this.target=i,this.conditionNames=n,this.fieldName=r,this.restrictions=!!s,this._fieldProcessorCache=new WeakMap}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("ExportsFieldPlugin",(r,i,s)=>{if(!r.descriptionFileData||r.relativePath!=="."||r.request===void 0)return s();let{descriptionFileData:o}=r,c=r.query||r.fragment?(r.request==="."?"./":r.request)+r.query+r.fragment:r.request,a,f;try{let l=this._fieldProcessorCache.get(o);if(l===void 0&&!this._fieldProcessorCache.has(o)){let d=Ar.getField(o,this.fieldName);l=d?Fc(d):null,this._fieldProcessorCache.set(o,l)}if(!l)return s();if(r.directory)return s(new Error(`Resolving to directories is not possible with the exports field (request was ${c}/)`));[a,f]=l(c,this.conditionNames)}catch(l){let d=new Error(`${l.message} (see exports field in ${r.descriptionFilePath})`);return i.log&&i.log(d.message),s(d)}if(a.length===0){let l=[...this.conditionNames],d=l.length===1?`the condition "${l[0]}"`:`the conditions ${JSON.stringify(l)}`,h=vc(Ar.getField(o,this.fieldName),!0);return s(new Error(`"${c}" is not exported under ${d} from package ${r.descriptionFileRoot} (see exports field in ${r.descriptionFilePath})${h?`. In that exports field, ${h}`:""}`))}let u=this.restrictions?{blocked:!1}:void 0;$c(a,(l,d,h)=>{let p=kc(l);if(!p)return d();let[g,y,w]=p;if(!g.startsWith("./"))return a.length===h?d(new Error(`Invalid "exports" target "${l}" defined for "${f}" in the package config ${r.descriptionFilePath}, targets must start with "./"`)):d();let A=g.slice(2);if(Mc.test(A)&&Oc.test(A))return a.length===h?d(new Error(`Invalid "exports" target "${l}" defined for "${f}" in the package config ${r.descriptionFilePath}, targets must start with "./"`)):d();let P={...r,request:void 0,path:e.join(r.descriptionFileRoot,g),relativePath:g,query:y,fragment:w};u&&(P.__restrictionsMarker=u),e.doResolve(n,P,`using exports field: ${l}`,i,(E,k)=>{if(E)return d(E);if(k===void 0)return d(null,null);d(null,k)})},(l,d)=>{if(l)return s(l);if(!d)return u&&u.blocked?s(null,null):s(new Error(`Package path ${c} is exported from package ${r.descriptionFileRoot}, but no valid target file was found (see exports field in ${r.descriptionFilePath})`));u&&delete d.__restrictionsMarker,s(null,d)})})}}});var Er=_((sf,Rr)=>{"use strict";var xc=Z();Rr.exports=class{constructor(e,n,r){this.source=e,this.options=n,this.target=r}apply(e){let n=e.ensureHook(this.target),{extension:r,alias:i}=this.options;e.getHook(this.source).tapAsync("ExtensionAliasPlugin",(s,o,c)=>{let a=s.request!==void 0,f=a?s.request:s.path;if(!f||!f.endsWith(r))return c();let u=typeof i=="string",l=f.slice(0,-r.length),d=!a&&s.relativePath&&s.relativePath.endsWith(r)?s.relativePath.slice(0,-r.length):null,h=(g,y,w)=>{let A=`${l}${g}`,P=a?{...s,request:A,fullySpecified:!0}:{...s,path:A,relativePath:d!==null?`${d}${g}`:s.relativePath,fullySpecified:!0};return e.doResolve(n,P,`aliased from extension alias with mapping '${r}' to '${g}'`,o,(E,k)=>{if(!u&&w)return w!==this.options.alias.length?(o.log&&o.log(`Failed to alias from extension alias with mapping '${r}' to '${g}' for '${A}': ${E}`),y(null,k)):y(E,k);y(E,k)})},p=(g,y)=>g?c(g):y?c(null,y):(u?i===r:i.includes(r))?c():c(null,null);u?h(i,p):i.length>1?xc(i,h,p):h(i[0],p)})}}});var vr=_((cf,$r)=>{"use strict";$r.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target),r=e.fileSystem;e.getHook(this.source).tapAsync("FileExistsPlugin",(i,s,o)=>{let c=i.path;if(!c)return o();r.stat(c,(a,f)=>{if(a||!f||!f.isFile())return s.missingDependencies&&s.missingDependencies.add(c),s.log&&s.log(a||!f?`${c} doesn't exist`:`${c} is not a file`),o();s.fileDependencies&&s.fileDependencies.add(c),e.doResolve(n,i,`existing file: ${c}`,s,o)})})}}});var Or=_((uf,kr)=>{"use strict";var Fr=le(),Dc=Z(),{explainSubpathsInConditions:Cc,processImportsField:Lc}=_t(),{parseIdentifier:Tc}=Oe(),{invalidSegmentRegEx:Nc}=J(),jc=46;kr.exports=class{constructor(e,n,r,i,s){this.source=e,this.targetFile=i,this.targetPackage=s,this.conditionNames=n,this.fieldName=r,this._fieldProcessorCache=new WeakMap}apply(e){let n=e.ensureHook(this.targetFile),r=e.ensureHook(this.targetPackage);e.getHook(this.source).tapAsync("ImportsFieldPlugin",(i,s,o)=>{if(!i.descriptionFileData||i.request===void 0)return o();let{descriptionFileData:c}=i,a=i.query||i.fragment?i.request+i.query+i.fragment:i.request,f,u;try{let l=this._fieldProcessorCache.get(c);if(l===void 0&&!this._fieldProcessorCache.has(c)){let d=Fr.getField(c,this.fieldName);l=d?Lc(d):null,this._fieldProcessorCache.set(c,l)}if(!l)return o();if(i.directory)return o(new Error(`Resolving to directories is not possible with the imports field (request was ${a}/)`));[f,u]=l(a,this.conditionNames)}catch(l){let d=new Error(`${l.message} (see imports field in ${i.descriptionFilePath})`);return s.log&&s.log(d.message),o(d)}if(f.length===0){let l=Cc(Fr.getField(c,this.fieldName),!1);return o(new Error(`Package import ${a} is not imported from package ${i.descriptionFileRoot} (see imports field in ${i.descriptionFilePath})${l?`. In that imports field, ${l}`:""}`))}Dc(f,(l,d,h)=>{let p=Tc(l);if(!p)return d();let[g,y,w]=p;switch(g.charCodeAt(0)){case jc:{let A=g.slice(2);if(Nc.test(A))return f.length===h?d(new Error(`Invalid "imports" target "${l}" defined for "${u}" in the package config ${i.descriptionFilePath}, targets must start with "./"`)):d();let P={...i,request:void 0,path:e.join(i.descriptionFileRoot,g),relativePath:g,query:y,fragment:w};e.doResolve(n,P,`using imports field: ${l}`,s,(E,k)=>{if(E)return d(E);if(k===void 0)return d(null,null);d(null,k)});break}default:{let A={...i,request:g,relativePath:g,fullySpecified:!0,query:y,fragment:w};e.doResolve(r,A,`using imports field: ${l}`,s,(P,E)=>{if(P)return d(P);if(E===void 0)return d(null,null);d(null,E)})}}},(l,d)=>o(l,d||null))})}}});var xr=_((ff,Mr)=>{"use strict";Mr.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("JoinRequestPartPlugin",(r,i,s)=>{let o=r.request||"",c=o.indexOf("/",3);c>=0&&o.charCodeAt(2)===64&&(c=o.indexOf("/",c+1));let a,f,u;c<0?(a=o,f=".",u=!1):(a=o.slice(0,c),f=`.${o.slice(c)}`,u=r.fullySpecified);let l={...r,path:e.join(r.path,a),relativePath:r.relativePath&&e.join(r.relativePath,a),request:f,fullySpecified:u};e.doResolve(n,l,null,i,s)})}}});var Cr=_((hf,Dr)=>{"use strict";Dr.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("JoinRequestPlugin",(r,i,s)=>{let o=r.path,c=r.request,a={...r,path:e.join(o,c),relativePath:r.relativePath&&e.join(r.relativePath,c),request:void 0};e.doResolve(n,a,null,i,s)})}}});var jr=_((gf,Nr)=>{"use strict";var Hc=le(),Lr=Symbol("alreadyTriedMainField"),Tr=Symbol("NoMain");Nr.exports=class{constructor(e,n,r){this.source=e,this.options=n,this.target=r,this._mainModuleCache=new WeakMap}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("MainFieldPlugin",(r,i,s)=>{if(r.path!==r.descriptionFileRoot||r[Lr]===r.descriptionFilePath||!r.descriptionFilePath)return s();let o=r.descriptionFileData,c=this._mainModuleCache.get(o);if(c===void 0){let u=Hc.getField(o,this.options.name);if(!u||typeof u!="string"||u==="."||u==="./")return this._mainModuleCache.set(o,Tr),s();this.options.forceRelative&&!/^\.\.?\//.test(u)&&(u=`./${u}`),c=u,this._mainModuleCache.set(o,c)}else if(c===Tr)return s();let a=e.basename(r.descriptionFilePath),f={...r,request:c,module:!1,directory:c.endsWith("/"),[Lr]:r.descriptionFilePath};return e.doResolve(n,f,`use ${c} from ${this.options.name} in ${a}`,i,s)})}}});var At=_((yf,wt)=>{"use strict";function Ir(t){if(t==="/")return{paths:["/"],segments:[""]};let e=t.split(/(.*?[\\/]+)/),n=[t],r=[e[e.length-1]],i=e[e.length-1];t=t.slice(0,Math.max(0,t.length-i.length-1));for(let s=e.length-2;s>2;s-=2)n.push(t),i=e[s],t=t.slice(0,Math.max(0,t.length-i.length))||"/",r.push(i.slice(0,-1));return[,i]=e,r.push(i),n.push(i),{paths:n,segments:r}}var Hr=new WeakMap;function Ic(t,e){let n=Hr.get(t);if(n===void 0)n=new Map,Hr.set(t,n);else{let o=n.get(e);if(o!==void 0)return o}let{paths:r,segments:i}=Ir(e),s={paths:[...r],segments:[...i]};return n.set(e,s),s}wt.exports=Ir;wt.exports.getPathsCached=Ic});var St=_((mf,Wr)=>{"use strict";var Uc=Z(),{getPathsCached:Wc}=At(),Ur=new WeakMap;function Bc(t,e,n,r,i,s){let o=t.fileSystem,c=r.path,a,f=Ur.get(e);if(f===void 0?(f=new Map,Ur.set(e,f)):a=f.get(c),a===void 0){let{paths:l}=Wc(o,c),d=l.length,h=e.length;a=new Array(d*h);let p=0,g=t.pathCache.join.fn;for(let y=0;y{o.stat(l,(h,p)=>{if(!h&&p&&p.isDirectory()){let g={...r,path:l,request:u,module:!1},y=`looking for modules in ${l}`;return t.doResolve(n,g,y,i,d)}return i.log&&i.log(`${l} doesn't exist or is not a directory`),i.missingDependencies&&i.missingDependencies.add(l),d()})},s)}Wr.exports={modulesResolveHandler:Bc}});var qr=_((wf,Br)=>{"use strict";var{modulesResolveHandler:qc}=St();Br.exports=class{constructor(e,n,r){this.source=e,this.directories=[...n],this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("ModulesInHierarchicalDirectoriesPlugin",(r,i,s)=>{qc(e,this.directories,n,r,i,s)})}}});var Jr=_((Sf,br)=>{"use strict";br.exports=class{constructor(e,n,r){this.source=e,this.path=n,this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("ModulesInRootPlugin",(r,i,s)=>{let o={...r,path:this.path,request:`./${r.request}`,module:!1};e.doResolve(n,o,`looking for modules in ${this.path}`,i,s)})}}});var zr=_((Rf,Gr)=>{"use strict";Gr.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("NextPlugin",(r,i,s)=>{e.doResolve(n,r,null,i,s)})}}});var Yr=_((Ef,Kr)=>{"use strict";var bc=typeof process<"u"&&process.platform==="win32",Jc=/\//g;function Gc(t){let{hostname:e}=t,{pathname:n}=t;for(let s=0;s122||i!==":")throw new TypeError("File URL path must be absolute");return n.slice(1)}function zc(t){if(t.hostname!=="")throw new TypeError('File URL host must be "localhost" or empty');let{pathname:e}=t;for(let n=0;n{"use strict";var Yc=/%/g,Xr=/\\/g,Qc=/\n/g,Xc=/\r/g,Zc=/\t/g,Vc=typeof process<"u"&&process.platform==="win32";function Qr(t,e){return t.includes("%")&&(t=t.replace(Yc,"%25")),!e&&t.includes("\\")&&(t=t.replace(Xr,"%5C")),t.includes(` +`)&&(t=t.replace(Qc,"%0A")),t.includes("\r")&&(t=t.replace(Xc,"%0D")),t.includes(" ")&&(t=t.replace(Zc,"%09")),t}function ea(t,e){let n=e&&e.windows!==void 0?e.windows:Vc;if(n&&t.startsWith("\\\\")){let i=t.indexOf("\\",2);if(i===-1)throw new TypeError(`Missing UNC resource path in file path '${t}'`);if(i===2)throw new TypeError(`Empty UNC servername in file path '${t}'`);let s=new URL("file://");return s.hostname=t.slice(2,i),s.pathname=Qr(t.slice(i).replace(Xr,"/"),n),s}let r=new URL("file://");return r.pathname=Qr(t,n),r}Zr.exports=ea});var ei=_((vf,ze)=>{"use strict";var ta=Yr(),{isInside:na,normalize:ra}=J(),ia=Vr();function ee(t,e){let n=new Error(t);return n.code=e,n}function sa(t,e,n){let r;try{r=new URL(t,e)}catch{throw ee(`Package map entry "${n}" has an invalid "url": ${t}`,"ERR_INVALID_PACKAGE_MAP")}if(r.protocol!=="file:")throw ee(`Package map entry "${n}" must use a "file:" url, received: ${t}`,"ERR_INVALID_PACKAGE_MAP");return ra(ta(r))}function oa(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw ee(`Package map "${e}" must contain a JSON object`,"ERR_INVALID_PACKAGE_MAP");let n=t.packages;if(!n||typeof n!="object"||Array.isArray(n))throw ee(`Package map "${e}" must contain a "packages" object`,"ERR_INVALID_PACKAGE_MAP");let r=ia(e),i=new Map,s=new Map;for(let c of Object.keys(n)){let a=n[c];if(!a||typeof a!="object"||Array.isArray(a))throw ee(`Package map entry "${c}" must be an object`,"ERR_INVALID_PACKAGE_MAP");if(typeof a.url!="string"||a.url==="")throw ee(`Package map entry "${c}" must have a non-empty string "url"`,"ERR_INVALID_PACKAGE_MAP");let f=sa(a.url,r,c),u=new Map,l=a.dependencies;if(l!==void 0){if(!l||typeof l!="object"||Array.isArray(l))throw ee(`Package map entry "${c}" has a non-object "dependencies"`,"ERR_INVALID_PACKAGE_MAP");for(let h of Object.keys(l)){let p=l[h];if(typeof p!="string")throw ee(`Package map entry "${c}" maps "${h}" to a non-string package id`,"ERR_INVALID_PACKAGE_MAP");u.set(h,p)}}i.set(c,{id:c,path:f,dependencies:u});let d=s.get(f);d?d.push(c):s.set(f,[c])}for(let c of i.values())for(let[a,f]of c.dependencies)if(!i.has(f))throw ee(`Package map entry "${c.id}" maps "${a}" to unknown package id "${f}"`,"ERR_INVALID_PACKAGE_MAP");let o=[...s].map(([c,a])=>({path:c,ids:a})).sort((c,a)=>a.path.length-c.path.length);return{packages:i,locations:o}}function ca(t,e){for(let n of t.locations)if(na(n.path,e))return n.ids;return[]}ze.exports.createError=ee;ze.exports.findPackageIds=ca;ze.exports.parsePackageMap=oa});var ri=_((kf,ni)=>{"use strict";var{readJson:aa}=qe(),{createError:Pt,findPackageIds:ua,parsePackageMap:ti}=ei(),la=/^(@[^/]+\/)?[^/]+/;ni.exports=class{constructor(e,n,r,i){this.source=e,this.options=n,this.symlinks=r,this.target=i,this._packageMap=void 0,this._pending=void 0}_getPackageMap(e,n,r){let{configFile:i,packages:s}=this.options;if(i&&n.fileDependencies&&n.fileDependencies.add(i),this._packageMap!==void 0)return r(null,this._packageMap);if(this._pending){this._pending.push(r);return}this._pending=[r];let o=(c,a)=>{let f=this._pending;this._pending=void 0;for(let u of f)u(c,a)};this._resolveConfigFile(e,c=>{if(s){let a;try{a=ti({packages:s},c)}catch(f){return o(f)}return this._packageMap=a,o(null,a)}aa(e.fileSystem,c,{stripComments:!1},(a,f)=>{let u=a||null,l;if(!u)try{l=ti(f,c),this._packageMap=l}catch(d){u=d}o(u,l)})})}_resolveConfigFile(e,n){let{configFile:r}=this.options,{realpath:i}=e.fileSystem;if(!this.symlinks||!i)return n(r);i(r,(s,o)=>{n(s||!o?r:String(o))})}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("PackageMapPlugin",(r,i,s)=>{let o=r.request;if(!o||o.startsWith("node:"))return s();let c=la.exec(o);if(!c)return s();let[a]=c,f=`.${o.slice(a.length)}`;this._getPackageMap(e,i,(u,l)=>{if(u)return s(u);let{packages:d}=l,h=r.path,p=r.context&&r.context.packageId,g=r.packageId!==void 0?r.packageId:p,y;if(g!=null){if(!d.has(g))return s(Pt(`Unknown package id "${g}" for request "${o}"`,"ERR_PACKAGE_MAP_UNKNOWN_PACKAGE"));y=g}else{let k=h===!1?[]:ua(l,h);if(k.length===0)return s(Pt(`Cannot resolve "${o}" from "${h}": the importing file is not inside any package of the package map`,"ERR_PACKAGE_MAP_EXTERNAL_FILE"));if(k.length>1)return s(Pt(`Cannot resolve "${o}" from "${h}": the package ids ${k.map(N=>`"${N}"`).join(", ")} share this location, so the importing package is ambiguous. Propagate the package id of the previous resolution to disambiguate.`,"ERR_PACKAGE_MAP_AMBIGUOUS_PACKAGE"));[y]=k}let A=d.get(y).dependencies.get(a);if(A===void 0)return i.log&&i.log(`"${a}" is not a dependency of package "${y}" in the package map`),s(null,null);let P=d.get(A),E={...r,path:P.path,request:f,packageId:A,fullySpecified:r.fullySpecified&&f!=="."};e.doResolve(n,E,`resolved "${a}" to package "${A}" by the package map`,i,(k,N)=>k?s(k):N?s(null,N):s(null,null))})})}}});var si=_((Mf,ii)=>{"use strict";ii.exports=class{constructor(e,n,r){this.source=e,this.requestOptions=n,this.target=r}apply(e){let n=e.ensureHook(this.target),{requestOptions:r}=this;e.getHook(this.source).tapAsync("ParsePlugin",(i,s,o)=>{let c=e.parse(i.request),a={...i};if(a.request=c.request,a.query=c.query||i.query||"",a.fragment=c.fragment||i.fragment||"",a.module=c.module,a.directory=c.directory,a.file=c.file,a.internal=c.internal,Object.assign(a,r),c&&s.log&&(c.module&&s.log("Parsed request is a module"),c.directory&&s.log("Parsed request is a directory")),a.request&&!a.query&&a.fragment){let f=a.fragment.endsWith("/"),u={...a,directory:f,request:a.request+(a.directory?"/":"")+(f?a.fragment.slice(0,-1):a.fragment),fragment:""};e.doResolve(n,u,null,s,(l,d)=>{if(l)return o(l);if(d)return o(null,d);e.doResolve(n,a,null,s,o)});return}e.doResolve(n,a,null,s,o)})}}});var ci=_((Df,oi)=>{"use strict";oi.exports=class{constructor(e,n,r,i){this.source=e,this.pnpApi=n,this.target=r,this.alternateTarget=i}apply(e){let n=e.ensureHook(this.target),r=e.ensureHook(this.alternateTarget);e.getHook(this.source).tapAsync("PnpPlugin",(i,s,o)=>{let c=i.request;if(!c)return o();let a=`${i.path}/`,f=/^(@[^/]+\/)?[^/]+/.exec(c);if(!f)return o();let[u]=f,l=`.${c.slice(u.length)}`,d,h;try{if(d=this.pnpApi.resolveToUnqualified(u,a,{considerBuiltins:!1}),d===null){e.doResolve(r,i,"issuer is not managed by a pnpapi",s,(g,y)=>g?o(g):y?o(null,y):o(null,null));return}s.fileDependencies&&(h=this.pnpApi.resolveToUnqualified("pnpapi",a,{considerBuiltins:!1}))}catch(g){if(g.code==="MODULE_NOT_FOUND"&&g.pnpCode==="UNDECLARED_DEPENDENCY"){if(s.log){s.log("request is not managed by the pnpapi");for(let y of g.message.split(` +`).filter(Boolean))s.log(` ${y}`)}return o()}return o(g)}if(d===u)return o();h&&s.fileDependencies&&s.fileDependencies.add(h);let p={...i,path:d,request:l,ignoreSymlinks:!0,fullySpecified:i.fullySpecified&&l!=="."};e.doResolve(n,p,`resolved by pnp to ${d}`,s,(g,y)=>g?o(g):y?o(null,y):o(null,null))})}}});var z=_((Cf,fi)=>{"use strict";var fa=b("util"),da=fa.deprecate(()=>{},"Hook.context is deprecated and will be removed");function ai(...t){return this.call=this._createCall("sync"),this.call(...t)}function ui(...t){return this.callAsync=this._createCall("async"),this.callAsync(...t)}function li(...t){return this.promise=this._createCall("promise"),this.promise(...t)}var Ke=class{constructor(e=[],n=void 0){this._args=e,this.name=n,this.taps=[],this.interceptors=[],this._call=ai,this.call=ai,this._callAsync=ui,this.callAsync=ui,this._promise=li,this.promise=li,this._x=void 0,this.compile=this.compile,this.tap=this.tap,this.tapAsync=this.tapAsync,this.tapPromise=this.tapPromise}compile(e){throw new Error("Abstract: should be overridden")}_createCall(e){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:e})}_tap(e,n,r){if(typeof n=="string"){let i=n.trim();if(i==="")throw new Error("Missing name for tap");n={type:e,fn:r,name:i}}else{if(typeof n!="object"||n===null)throw new Error("Invalid tap options");let{name:i}=n;if(typeof i=="string"&&(i=i.trim()),typeof i!="string"||i==="")throw new Error("Missing name for tap");typeof n.context<"u"&&da();let s=!0;for(let o in n)if(o!=="name"){s=!1;break}s?n={type:e,fn:r,name:i}:(n.name=i,n=Object.assign({type:e,fn:r},n))}n=this._runRegisterInterceptors(n),this._insert(n)}tap(e,n){this._tap("sync",e,n)}tapAsync(e,n){this._tap("async",e,n)}tapPromise(e,n){this._tap("promise",e,n)}_runRegisterInterceptors(e){let{interceptors:n}=this,{length:r}=n;if(r===0)return e;for(let i=0;iObject.assign({},e,typeof r=="string"?{name:r}:r);return{name:this.name,tap:(r,i)=>this.tap(n(r),i),tapAsync:(r,i)=>this.tapAsync(n(r),i),tapPromise:(r,i)=>this.tapPromise(n(r),i),intercept:r=>this.intercept(r),isUsed:()=>this.isUsed(),withOptions:r=>this.withOptions(n(r))}}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(e){if(this._resetCompilation(),this.interceptors.push(Object.assign({},e)),e.register)for(let n=0;n0;){s--;let o=n[s];n[s+1]=o;let c=o.stage||0;if(i){if(i.has(o.name)){i.delete(o.name);continue}if(i.size>0)continue}if(!(c>r)){s++;break}}n[s]=e}};Object.setPrototypeOf(Ke.prototype,null);fi.exports=Ke});var K=_((Lf,di)=>{"use strict";var Rt=class{constructor(e){this.config=e,this.options=void 0,this._args=void 0}create(e){this.init(e);let n;switch(e.type){case"sync":n=new Function(this.args(),`"use strict"; +${this.header()}${this.contentWithInterceptors({onError:r=>`throw ${r}; +`,onResult:r=>`return ${r}; +`,resultReturns:!0,onDone:()=>"",rethrowIfPossible:!0})}`);break;case"async":n=new Function(this.args({after:"_callback"}),`"use strict"; +${this.header()}${this.contentWithInterceptors({onError:r=>`_callback(${r}); +`,onResult:r=>`_callback(null, ${r}); +`,onDone:()=>`_callback(); +`})}`);break;case"promise":{let r=!1,i=this.contentWithInterceptors({onError:o=>(r=!0,`_error(${o}); +`),onResult:o=>`_resolve(${o}); +`,onDone:()=>`_resolve(); +`}),s="";s+=`"use strict"; +`,s+=this.header(),s+=`return new Promise((function(_resolve, _reject) { +`,r&&(s+=`var _sync = true; +`,s+=`function _error(_err) { +`,s+=`if(_sync) +`,s+=`_resolve(Promise.resolve().then((function() { throw _err; }))); +`,s+=`else +`,s+=`_reject(_err); +`,s+=`}; +`),s+=i,r&&(s+=`_sync = false; +`),s+=`})); +`,n=new Function(this.args(),s);break}}return this.deinit(),n}setup(e,n){let{taps:r}=n,{length:i}=r,s=Array.from({length:i});for(let o=0;o0){let{onError:n,onResult:r,onDone:i}=e,s="";for(let o=0;o{let c="";for(let a=0;a{let c="";for(let a=0;a{let o="";for(let c=0;c0&&(e+=`var _taps = this.taps; +`,e+=`var _interceptors = this.interceptors; +`),e}needContext(){let{taps:e}=this.options;for(let n=0;ng?"":i(),d="",h=i,p=0;for(let g=a-1;g>=0;g--){let y=g;h!==i&&(c[y].type!=="sync"||p++>20)&&(p=0,d+=`function _next${y}() { +`,d+=h(),d+=`} +`,h=()=>`${u?"return ":""}_next${y}(); +`);let A=h,P=this.callTap(y,{onError:E=>e(y,E,A,l),onResult:n&&(E=>n(y,E,A,l)),onDone:!n&&A,rethrowIfPossible:o&&(f<0||yP}return d+=h(),d}callTapsLooping({onError:e,onDone:n,rethrowIfPossible:r}){if(this.options.taps.length===0)return n();let i=this.options.taps.every(o=>o.type==="sync"),s="";i||(s+=`var _looper = (function() { +`,s+=`var _loopAsync = false; +`),s+=`var _loop; +`,s+=`do { +`,s+=`_loop = false; +`;for(let o=0;o{let u="";return u+=`if(${c} !== undefined) { +`,u+=`_loop = true; +`,i||(u+=`if(_loopAsync) _looper(); +`),u+=f(!0),u+=`} else { +`,u+=a(),u+=`} +`,u},onDone:n&&(()=>{let o="";return o+=`if(!_loop) { +`,o+=n(),o+=`} +`,o}),rethrowIfPossible:r&&i}),s+=`} while(_loop); +`,i||(s+=`_loopAsync = true; +`,s+=`}); +`,s+=`_looper(); +`),s}callTapsParallel({onError:e,onResult:n,onDone:r,rethrowIfPossible:i,onTap:s=(o,c)=>c()}){let{taps:o}=this.options,c=o.length;if(c<=1)return this.callTapsSeries({onError:e,onResult:n,onDone:r,rethrowIfPossible:i});let a=()=>r?`if(--_counter === 0) _done(); +`:"--_counter;",f=l=>l||!r?`_counter = 0; +`:`_counter = 0; +_done(); +`,u="";u+=`do { +`,u+=`var _counter = ${c}; +`,r&&(u+=`var _done = (function() { +`,u+=r(),u+=`}); +`);for(let l=0;lthis.callTap(l,{onError:d=>{let h="";return h+=`if(_counter > 0) { +`,h+=e(l,d,a,f),h+=`} +`,h},onResult:n&&(d=>{let h="";return h+=`if(_counter > 0) { +`,h+=n(l,d,a,f),h+=`} +`,h}),onDone:!n&&(()=>a()),rethrowIfPossible:i}),a,f);return u+=`} while(false); +`,u}args({before:e,after:n}={}){let r=this._joinedArgs;return r===void 0&&(r=this._args.length===0?"":this._args.join(", "),this._joinedArgs=r),!e&&!n?r:r.length===0?e&&n?`${e}, ${n}`:e||n:e&&n?`${e}, ${r}, ${n}`:e?`${e}, ${r}`:`${r}, ${n}`}getTapFn(e){return`_x[${e}]`}getTap(e){return`_taps[${e}]`}getInterceptor(e){return`_interceptors[${e}]`}};di.exports=Rt});var gi=_((Tf,pi)=>{"use strict";var ha=z(),pa=K(),Et=class extends pa{content({onError:e,onResult:n,onDone:r}){let i="";return i+=`var _results = new Array(${this.options.taps.length}); +`,i+=`var _checkDone = function() { +`,i+=`for(var i = 0; i < _results.length; i++) { +`,i+=`var item = _results[i]; +`,i+=`if(item === undefined) return false; +`,i+=`if(item.result !== undefined) { +`,i+=n("item.result"),i+=`return true; +`,i+=`} +`,i+=`if(item.error) { +`,i+=e("item.error"),i+=`return true; +`,i+=`} +`,i+=`} +`,i+=`return false; +`,i+=`} +`,i+=this.callTapsParallel({onError:(s,o,c,a)=>{let f="";return f+=`if(${s} < _results.length && ((_results.length = ${s+1}), (_results[${s}] = { error: ${o} }), _checkDone())) { +`,f+=a(!0),f+=`} else { +`,f+=c(),f+=`} +`,f},onResult:(s,o,c,a)=>{let f="";return f+=`if(${s} < _results.length && (${o} !== undefined && (_results.length = ${s+1}), (_results[${s}] = { result: ${o} }), _checkDone())) { +`,f+=a(!0),f+=`} else { +`,f+=c(),f+=`} +`,f},onTap:(s,o,c,a)=>{let f="";return s>0&&(f+=`if(${s} >= _results.length) { +`,f+=c(),f+=`} else { +`),f+=o(),s>0&&(f+=`} +`),f},onDone:r}),i}},hi=new Et;function ga(t){return hi.setup(this,t),hi.create(t)}function $t(t=[],e=void 0){let n=new ha(t,e);return n.constructor=$t,n.compile=ga,n._call=void 0,n.call=void 0,n}$t.prototype=null;pi.exports=$t});var _i=_((Nf,mi)=>{"use strict";var ya=z(),ma=K(),vt=class extends ma{content({onError:e,onDone:n}){return this.callTapsParallel({onError:(r,i,s,o)=>e(i)+o(!0),onDone:n})}},yi=new vt;function _a(t){return yi.setup(this,t),yi.create(t)}function Ft(t=[],e=void 0){let n=new ya(t,e);return n.constructor=Ft,n.compile=_a,n._call=void 0,n.call=void 0,n}Ft.prototype=null;mi.exports=Ft});var Si=_((jf,Ai)=>{"use strict";var wa=z(),Aa=K(),kt=class extends Aa{content({onError:e,onResult:n,resultReturns:r,onDone:i}){return this.callTapsSeries({onError:(s,o,c,a)=>e(o)+a(!0),onResult:(s,o,c)=>`if(${o} !== undefined) { +${n(o)} +} else { +${c()}} +`,resultReturns:r,onDone:i})}},wi=new kt;function Sa(t){return wi.setup(this,t),wi.create(t)}function Ot(t=[],e=void 0){let n=new wa(t,e);return n.constructor=Ot,n.compile=Sa,n._call=void 0,n.call=void 0,n}Ot.prototype=null;Ai.exports=Ot});var Ei=_((Hf,Ri)=>{"use strict";var Pa=z(),Ra=K(),Mt=class extends Ra{content({onError:e,onDone:n}){return this.callTapsSeries({onError:(r,i,s,o)=>e(i)+o(!0),onDone:n})}},Pi=new Mt;function Ea(t){return Pi.setup(this,t),Pi.create(t)}function xt(t=[],e=void 0){let n=new Pa(t,e);return n.constructor=xt,n.compile=Ea,n._call=void 0,n.call=void 0,n}xt.prototype=null;Ri.exports=xt});var Fi=_((If,vi)=>{"use strict";var $a=z(),va=K(),Dt=class extends va{content({onError:e,onDone:n}){return this.callTapsLooping({onError:(r,i,s,o)=>e(i)+o(!0),onDone:n})}},$i=new Dt;function Fa(t){return $i.setup(this,t),$i.create(t)}function Ct(t=[],e=void 0){let n=new $a(t,e);return n.constructor=Ct,n.compile=Fa,n._call=void 0,n.call=void 0,n}Ct.prototype=null;vi.exports=Ct});var Mi=_((Uf,Oi)=>{"use strict";var ka=z(),Oa=K(),Lt=class extends Oa{content({onError:e,onResult:n,_onDone:r}){return this.callTapsSeries({onError:(i,s,o,c)=>e(s)+c(!0),onResult:(i,s,o)=>{let c="";return c+=`if(${s} !== undefined) { +`,c+=`${this._args[0]} = ${s}; +`,c+=`} +`,c+=o(),c},onDone:()=>n(this._args[0])})}},ki=new Lt;function Ma(t){return ki.setup(this,t),ki.create(t)}function Tt(t=[],e=void 0){if(t.length<1)throw new Error("Waterfall hooks must have at least one argument");let n=new ka(t,e);return n.constructor=Tt,n.compile=Ma,n._call=void 0,n.call=void 0,n}Tt.prototype=null;Oi.exports=Tt});var Di=_((Wf,xi)=>{"use strict";var Nt=b("util"),xa=(t,e)=>e,_e=class{constructor(e,n=void 0){this._map=new Map,this.name=n,this._factory=e,this._interceptors=[]}get(e){return this._map.get(e)}for(e){let n=this._map,r=n.get(e);if(r!==void 0)return r;let i=this._factory(e),s=this._interceptors;for(let o=0;o{"use strict";var jt=class t{constructor(e,n=void 0){this.hooks=e,this.name=n}tap(e,n){let{hooks:r}=this;for(let i=0;in.withOptions(e)),this.name)}};Ci.exports=jt});var ji=_((qf,Ni)=>{"use strict";var Da=z(),Ca=K(),Ht=class extends Ca{content({onError:e,onResult:n,resultReturns:r,onDone:i,rethrowIfPossible:s}){return this.callTapsSeries({onError:(o,c)=>e(c),onResult:(o,c,a)=>`if(${c} !== undefined) { +${n(c)}; +} else { +${a()}} +`,resultReturns:r,onDone:i,rethrowIfPossible:s})}},Ti=new Ht,La=()=>{throw new Error("tapAsync is not supported on a SyncBailHook")},Ta=()=>{throw new Error("tapPromise is not supported on a SyncBailHook")};function Na(t){return Ti.setup(this,t),Ti.create(t)}function It(t=[],e=void 0){let n=new Da(t,e);return n.constructor=It,n.tapAsync=La,n.tapPromise=Ta,n.compile=Na,n}It.prototype=null;Ni.exports=It});var Ui=_((bf,Ii)=>{"use strict";var ja=z(),Ha=K(),Ut=class extends Ha{content({onError:e,onDone:n,rethrowIfPossible:r}){return this.callTapsSeries({onError:(i,s)=>e(s),onDone:n,rethrowIfPossible:r})}},Hi=new Ut,Ia=()=>{throw new Error("tapAsync is not supported on a SyncHook")},Ua=()=>{throw new Error("tapPromise is not supported on a SyncHook")};function Wa(t){return Hi.setup(this,t),Hi.create(t)}function Wt(t=[],e=void 0){let n=new ja(t,e);return n.constructor=Wt,n.tapAsync=Ia,n.tapPromise=Ua,n.compile=Wa,n}Wt.prototype=null;Ii.exports=Wt});var qi=_((Jf,Bi)=>{"use strict";var Ba=z(),qa=K(),Bt=class extends qa{content({onError:e,onDone:n,rethrowIfPossible:r}){return this.callTapsLooping({onError:(i,s)=>e(s),onDone:n,rethrowIfPossible:r})}},Wi=new Bt,ba=()=>{throw new Error("tapAsync is not supported on a SyncLoopHook")},Ja=()=>{throw new Error("tapPromise is not supported on a SyncLoopHook")};function Ga(t){return Wi.setup(this,t),Wi.create(t)}function qt(t=[],e=void 0){let n=new Ba(t,e);return n.constructor=qt,n.tapAsync=ba,n.tapPromise=Ja,n.compile=Ga,n}qt.prototype=null;Bi.exports=qt});var Gi=_((Gf,Ji)=>{"use strict";var za=z(),Ka=K(),bt=class extends Ka{content({onError:e,onResult:n,resultReturns:r,rethrowIfPossible:i}){return this.callTapsSeries({onError:(s,o)=>e(o),onResult:(s,o,c)=>{let a="";return a+=`if(${o} !== undefined) { +`,a+=`${this._args[0]} = ${o}; +`,a+=`} +`,a+=c(),a},onDone:()=>n(this._args[0]),doneReturns:r,rethrowIfPossible:i})}},bi=new bt,Ya=()=>{throw new Error("tapAsync is not supported on a SyncWaterfallHook")},Qa=()=>{throw new Error("tapPromise is not supported on a SyncWaterfallHook")};function Xa(t){return bi.setup(this,t),bi.create(t)}function Jt(t=[],e=void 0){if(t.length<1)throw new Error("Waterfall hooks must have at least one argument");let n=new za(t,e);return n.constructor=Jt,n.tapAsync=Ya,n.tapPromise=Qa,n.compile=Xa,n}Jt.prototype=null;Ji.exports=Jt});var zi=_((zf,q)=>{"use strict";q.exports.AsyncParallelBailHook=gi();q.exports.AsyncParallelHook=_i();q.exports.AsyncSeriesBailHook=Si();q.exports.AsyncSeriesHook=Ei();q.exports.AsyncSeriesLoopHook=Fi();q.exports.AsyncSeriesWaterfallHook=Mi();q.exports.HookMap=Di();q.exports.MultiHook=Li();q.exports.SyncBailHook=ji();q.exports.SyncHook=Ui();q.exports.SyncLoopHook=qi();q.exports.SyncWaterfallHook=Gi();q.exports.__esModule=!0});var Yi=_((Kf,Ki)=>{"use strict";Ki.exports=function(e,n,r){let i=e.log,s;if(i)if(r){let o=!1;s=c=>{o||(i(r),o=!0),i(` ${c}`)}}else s=i;return{log:s,yield:e.yield,fileDependencies:e.fileDependencies,contextDependencies:e.contextDependencies,missingDependencies:e.missingDependencies,stack:n}}});var ns=_((Yf,ts)=>{"use strict";var{AsyncSeriesBailHook:Qi,AsyncSeriesHook:Za,SyncHook:Xi}=zi(),Va=Yi(),{parseIdentifier:eu}=Oe(),{PathType:Me,createCachedBasename:tu,createCachedDirname:nu,createCachedJoin:ru,getType:Ye,isFileURL:iu,normalize:su,toPath:Gt}=J(),ou=Promise.withResolvers?(t,e,n,r,i)=>{let{promise:s,resolve:o,reject:c}=Promise.withResolvers();return t.resolve(e,n,r,i,(a,f)=>{a?c(a):o(f)}),s}:(t,e,n,r,i)=>new Promise((s,o)=>{t.resolve(e,n,r,i,(c,a)=>{c?o(c):s(a)})}),Zi=new WeakMap,Vi=/#/g,xe=class{constructor(e,n,r,i){this.name=e.name,this.path=n.path,this.request=n.request||"",this.query=n.query||"",this.fragment=n.fragment||"",this.directory=!!n.directory,this.module=!!n.module,this.parent=r,this.preSeeded=i}has(e){let n=this;for(;n;){if(n.name===e.name&&n.path===e.path&&n.request===e.request&&n.query===e.query&&n.fragment===e.fragment&&n.directory===e.directory&&n.module===e.module)return!0;n=n.parent}return this.preSeeded!==void 0&&this.preSeeded.has(e.toString())}get size(){let e=this.preSeeded?this.preSeeded.size:0,n=this;for(;n;)e++,n=n.parent;return e}*[Symbol.iterator](){if(this.preSeeded!==void 0)for(let r of this.preSeeded)yield r;let e=[],n=this;for(;n;)e.push(n),n=n.parent;for(let r=e.length-1;r>=0;r--)yield e[r].toString()}toString(){return`${this.name}: (${this.path}) ${this.request}${this.query}${this.fragment}${this.directory?" directory":""}${this.module?" module":""}`}};function es(t){return t.replace(/-([a-z])/g,e=>e.slice(1).toUpperCase())}var zt=class t{static createStackEntry(e,n,r,i){return new xe(e,n,r,i)}constructor(e,n){this.fileSystem=e,this.options=n;let r=Zi.get(e);r||(r={join:ru(),dirname:nu(),basename:tu()},Zi.set(e,r)),this.pathCache=r,this.hooks={resolveStep:new Xi(["hook","request"],"resolveStep"),noResolve:new Xi(["request","error"],"noResolve"),resolve:new Qi(["request","resolveContext"],"resolve"),result:new Za(["result","resolveContext"],"result")}}ensureHook(e){if(typeof e!="string")return e;if(e=es(e),e.startsWith("before"))return this.ensureHook(e[6].toLowerCase()+e.slice(7)).withOptions({stage:-10});if(e.startsWith("after"))return this.ensureHook(e[5].toLowerCase()+e.slice(6)).withOptions({stage:10});let n=this.hooks[e];return n||(this.hooks[e]=new Qi(["request","resolveContext"],e),this.hooks[e])}getHook(e){if(typeof e!="string")return e;if(e=es(e),e.startsWith("before"))return this.getHook(e[6].toLowerCase()+e.slice(7)).withOptions({stage:-10});if(e.startsWith("after"))return this.getHook(e[5].toLowerCase()+e.slice(6)).withOptions({stage:10});let n=this.hooks[e];if(!n)throw new Error(`Hook ${e} doesn't exist`);return n}resolveSync(e,n,r,i){let s,o,c=!1;if(this.resolve(e,n,r,i||{},(a,f)=>{s=a,o=f,c=!0}),!c)throw new Error("Cannot 'resolveSync' because the fileSystem is not sync. Use 'resolve'!");if(s)throw s;if(o===void 0)throw new Error("No result");return o}resolvePromise(e,n,r,i){return ou(this,e,n,r,i||{})}resolve(e,n,r,i,s){if(!(typeof s=="function"&&typeof e=="object"&&e!==null&&typeof i=="object"&&i!==null)){if((typeof e=="string"||e instanceof URL)&&(typeof s!="function"&&(s=i),i=r,r=n,n=e,e={}),typeof i=="function"?(s=i,i={}):(!i||typeof i!="object")&&(i={}),typeof s!="function")throw new TypeError("callback argument is not a function");(!e||typeof e!="object")&&(e={})}if(typeof n!="string")if(n instanceof URL)n=Gt(n);else return s(new Error("path argument is not a string"));else iu(n)&&(n=Gt(n));if(typeof r!="string")if(r instanceof URL)r=Gt(r);else return s(new Error("request argument is not a string"));let o={context:e,path:n,request:r},c,a=!1,f;if(typeof i.yield=="function"){let h=i.yield;c=p=>{h(p),a=!0},f=p=>{p&&c(p),s(null)}}let u=h=>{let p=h.path;if(p===!1)return s(null,!1,h);let g=p.includes("#")?p.replace(Vi,"\0#"):p,y=h.query,w;return y?w=y.includes("#")?y.replace(Vi,"\0#"):y:w="",s(null,`${g}${w}${h.fragment||""}`,h)},l=(h,p)=>{let g=new Error(`Can't ${h}`);return g.details=p.join(` +`),this.hooks.noResolve.call(o,g),s(g)};if(i.log){let h=`resolve '${r}' in '${n}'`,p=i.log,g=[];return this.doResolve(this.hooks.resolve,o,h,{log:y=>{p(y),g.push(y)},yield:c,fileDependencies:i.fileDependencies,contextDependencies:i.contextDependencies,missingDependencies:i.missingDependencies,stack:i.stack},(y,w)=>y?s(y):a||w&&c?f(w):w?u(w):l(h,g))}let d=c?{log:void 0,yield:c,fileDependencies:i.fileDependencies,contextDependencies:i.contextDependencies,missingDependencies:i.missingDependencies,stack:i.stack}:i;return this.doResolve(this.hooks.resolve,o,null,d,(h,p)=>{if(h)return s(h);if(a||p&&c)return f(p);if(p)return u(p);let g=`resolve '${r}' in '${n}'`,y=[];return this.doResolve(this.hooks.resolve,o,g,{log:w=>y.push(w),yield:c,stack:i.stack},(w,A)=>w?s(w):a||A&&c?f(A):l(g,y))})}doResolve(e,n,r,i,s){let o=i.stack,c,a;o instanceof xe?(c=o,a=o.preSeeded):o&&(a=o);let f=t.createStackEntry(e,n,c,a);if(c!==void 0?c.has(f):a!==void 0&&a.has(f.toString())){let u=new Error(`Recursion in resolving +Stack: + ${[...f].join(` + `)}`);return u.recursion=!0,i.log&&i.log("abort resolving because of recursion"),s(u)}if(this.hooks.resolveStep.call(e,n),e.isUsed()){if(!i.log&&o instanceof xe)return i.stack=f,e.callAsync(n,i,(l,d)=>{if(i.stack=o,l)return s(l);if(d)return s(null,d);s()});let u=Va(i,f,r);return e.callAsync(n,u,(l,d)=>{if(l)return s(l);if(d)return s(null,d);s()})}s()}parse(e){let n={request:"",query:"",fragment:"",module:!1,directory:!1,file:!1,internal:!1},r=eu(e);if(!r)return n;if([n.request,n.query,n.fragment]=r,n.request.length>0){let i=Ye(n.request);n.module=i===Me.Normal,n.internal=e===n.request?i===Me.Internal:Ye(e)===Me.Internal,n.directory=n.request.endsWith("/"),n.directory&&(n.request=n.request.slice(0,-1))}return n}isModule(e){return Ye(e)===Me.Normal}isPrivate(e){return Ye(e)===Me.Internal}isDirectory(e){return e.endsWith("/")}normalize(e){return su(e)}join(e,n){return this.pathCache.join.fn(e,n)}dirname(e){return this.pathCache.dirname.fn(e)}basename(e,n){return this.pathCache.basename.fn(e,n)}};ts.exports=zt});var is=_((Xf,rs)=>{"use strict";var{isInside:cu,normalize:au}=J();rs.exports=class{constructor(e,n){this.source=e,this.restrictions=n,this._restrictions=[];for(let r of n)this._restrictions.push(typeof r=="string"?{type:"path",rule:au(r)}:{type:"regexp",rule:r})}apply(e){e.getHook(this.source).tapAsync("RestrictionsPlugin",(n,r,i)=>{if(typeof n.path=="string"){let{path:s}=n;for(let o of this._restrictions){if(o.type==="path"){if(cu(o.rule,s))continue;r.log&&r.log(`${s} is not inside of the restriction ${o.rule}`)}else{if(o.rule.test(s))continue;r.log&&r.log(`${s} doesn't match the restriction ${o.rule}`)}return n.__restrictionsMarker&&(n.__restrictionsMarker.blocked=!0),i(null,null)}}i()})}}});var os=_((Vf,ss)=>{"use strict";ss.exports=class{constructor(e){this.source=e}apply(e){this.source.tapAsync("ResultPlugin",(n,r,i)=>{let s={...n};r.log&&r.log(`reporting result ${s.path}`),e.hooks.result.callAsync(s,r,o=>{if(o)return i(o);typeof r.yield=="function"?(r.yield(s),i(null,null)):i(null,s)})})}}});var as=_((ed,cs)=>{"use strict";var uu=Z(),Kt=class{constructor(e,n,r){this.roots=[...n],this.source=e,this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("RootsPlugin",(r,i,s)=>{let o=r.request;if(!o||!o.startsWith("/"))return s();uu(this.roots,(c,a)=>{let f=e.join(c,o.slice(1)),u={...r,path:f,relativePath:r.relativePath&&f};e.doResolve(n,u,`root path ${c}`,i,a)},s)})}};cs.exports=Kt});var fs=_((nd,ls)=>{"use strict";var us=le(),lu=47,Yt=Symbol("NoSelfRef");ls.exports=class{constructor(e,n,r){this.source=e,this.target=r,this.fieldName=n,this._nameCache=new WeakMap}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("SelfReferencePlugin",(r,i,s)=>{if(!r.descriptionFileData)return s();let o=r.request;if(!o)return s();let{descriptionFileData:c}=r,a=this._nameCache.get(c);if(a===void 0){if(!us.getField(c,this.fieldName))return this._nameCache.set(c,Yt),s();let u=us.getField(c,"name");if(typeof u!="string")return this._nameCache.set(c,Yt),s();a=u,this._nameCache.set(c,a)}else if(a===Yt)return s();if(o.startsWith(a)&&(o.length===a.length||o.charCodeAt(a.length)===lu)){let f=`.${o.slice(a.length)}`,u={...r,request:f,path:r.descriptionFileRoot,relativePath:"."};e.doResolve(n,u,"self reference",i,s)}else return s()})}}});var ps=_((id,hs)=>{"use strict";var fu=Z(),{getPathsCached:du}=At(),{PathType:ds,getType:hu}=J();hs.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target),r=e.fileSystem;e.getHook(this.source).tapAsync("SymlinkPlugin",(i,s,o)=>{if(i.ignoreSymlinks)return o();let c=du(r,i.path),{paths:a,segments:f}=c,u=null,l=!1,d=-1;fu(a,(h,p)=>{d++,s.fileDependencies&&s.fileDependencies.add(h),r.readlink(h,(g,y)=>{if(!g&&y){u===null&&(u=[...f]),u[d]=y,l=!0;let w=hu(y.toString());if(w===ds.AbsoluteWin||w===ds.AbsolutePosix)return p(null,d)}p()})},(h,p)=>{if(!l)return o();let g=u,w=(typeof p=="number"?g.slice(0,p+1):g).reduceRight((P,E)=>e.join(P,E)),A={...i,path:w};e.doResolve(n,A,`resolved symlink to ${w}`,s,(P,E)=>P?o(P):E?o(null,E):o(null,null))})})}}});var ys=_((sd,gs)=>{"use strict";function pu(t){this.fs=t,this.lstat=void 0,this.lstatSync=void 0;let{lstatSync:e}=t;e&&(this.lstat=((i,s,o)=>{let c;try{c=o?e.call(t,i,s):e.call(t,i)}catch(a){return(o||s)(a)}(o||s)(null,c)}),this.lstatSync=((i,s)=>e.call(t,i,s))),this.stat=((i,s,o)=>{let c;try{c=o?t.statSync(i,s):t.statSync(i)}catch(a){return(o||s)(a)}(o||s)(null,c)}),this.statSync=((i,s)=>t.statSync(i,s)),this.readdir=((i,s,o)=>{let c;try{c=o?t.readdirSync(i,s):t.readdirSync(i)}catch(a){return(o||s)(a,[])}(o||s)(null,c)}),this.readdirSync=((i,s)=>t.readdirSync(i,s)),this.readFile=((i,s,o)=>{let c;try{c=o?t.readFileSync(i,s):t.readFileSync(i)}catch(a){return(o||s)(a)}(o||s)(null,c)}),this.readFileSync=((i,s)=>t.readFileSync(i,s)),this.readlink=((i,s,o)=>{let c;try{c=o?t.readlinkSync(i,s):t.readlinkSync(i)}catch(a){return(o||s)(a)}(o||s)(null,c)}),this.readlinkSync=((i,s)=>t.readlinkSync(i,s)),this.readJson=void 0,this.readJsonSync=void 0;let{readJsonSync:n}=t;n&&(this.readJson=((i,s)=>{let o;try{o=n.call(t,i)}catch(c){return s(c)}s(null,o)}),this.readJsonSync=(i=>n.call(t,i))),this.realpath=void 0,this.realpathSync=void 0;let{realpathSync:r}=t;r&&(this.realpath=((i,s,o)=>{let c;try{c=o?r.call(t,i,s):r.call(t,i)}catch(a){return(o||s)(a)}(o||s)(null,c)}),this.realpathSync=((i,s)=>r.call(t,i,s)))}gs.exports=pu});var _s=_((cd,ms)=>{"use strict";ms.exports=class{constructor(e,n,r){this.source=e,this.message=n,this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("TryNextPlugin",(r,i,s)=>{e.doResolve(n,r,this.message,i,s)})}}});var Zt=_((ld,$s)=>{"use strict";var{aliasResolveHandler:gu,compileAliasOptions:yu}=yt(),{modulesResolveHandler:mu}=St(),{readJson:_u}=qe(),{PathType:ad,isSubPath:wu,normalize:Au}=J(),ws=Symbol("NULL_CONTEXT"),As=new WeakMap,De="tsconfig.json",Su={stripComments:!0},Ss=/[/\\]\*$/;function Ps(t){let e=t.indexOf("*");return e===-1?t.length:e}function Pu(t){return[...t].sort((e,n)=>Ps(n)-Ps(e))}function Qt(t,e){return t=t||{},e=e||{},{...t,...e,compilerOptions:{...t.compilerOptions,...e.compilerOptions}}}function Xt(t,e){return t.includes("${configDir}")?t.replace(/\$\{configDir\}/g,e):t}function Rs(t,e,n,r){let i=r?n.join(t,r):t,s=Pu(Object.keys(e)),o=[],c=[];for(let a of s){let u=e[a].map(l=>{let d=Xt(l,t);return n.join(i,d)});if(u.length>0)if(a==="*")for(let l=0;l({path:r})):e.references==="auto"?this.references="auto":this.references=[],this.baseUrl=e.baseUrl}else this.isAutoConfigFile=e===!0,this.configFile=this.isAutoConfigFile?De:e,this.references=[],this.baseUrl=void 0}apply(e){let n=e.ensureHook("internal-resolve"),r=e.ensureHook("module");e.getHook("raw-resolve").tapAsync("TsconfigPathsPlugin",(i,s,o)=>{this._getTsconfigPathsMap(e,i,s,(c,a)=>{if(c)return o(c);if(!a)return o();let f=this._selectPathsDataForContext(i.path,a);if(!f)return o();gu(e,f.alias,n,i,s,(u,l)=>u?o(u):l?o(null,l):o())})}),e.getHook("raw-module").tapAsync("TsconfigPathsPlugin",(i,s,o)=>{this._getTsconfigPathsMap(e,i,s,(c,a)=>{if(c)return o(c);if(!a)return o();let f=this._selectPathsDataForContext(i.path,a);if(!f)return o();mu(e,f.modules,r,i,s,o)})})}_getTsconfigPathsMap(e,n,r,i){if(typeof n.tsconfigPathsMap<"u"){let o=n.tsconfigPathsMap;if(!o)return i(null,null);if(r.fileDependencies)for(let c of o.fileDependencies)r.fileDependencies.add(c);return i(null,o)}if(this.isAutoConfigFile){this._findTsconfigUpward(e,n.path||process.cwd(),(o,c)=>{if(o)return n.tsconfigPathsMap=null,i(o);if(!c)return n.tsconfigPathsMap=null,i(null,null);let a=c;if(n.tsconfigPathsMap=a,r.fileDependencies)for(let f of a.fileDependencies)r.fileDependencies.add(f);i(null,a)});return}let s=e.join(n.path||process.cwd(),this.configFile);this._loadTsconfigPathsMap(e,s,(o,c)=>{if(o)return n.tsconfigPathsMap=null,i(o);let a=c;if(n.tsconfigPathsMap=a,r.fileDependencies)for(let f of a.fileDependencies)r.fileDependencies.add(f);i(null,a)})}_findTsconfigUpward(e,n,r){let{fileSystem:i}=e,s=this.configFile,o=c=>{let a=e.join(c,s);i.stat(a,f=>{if(!f){this._loadTsconfigPathsMap(e,a,(l,d)=>{if(l)return r(null,null);r(null,d)});return}let u=e.dirname(c);if(u===c)return r(null,null);o(u)})};o(n)}_loadTsconfigPathsMap(e,n,r){let i=new Set;this._loadTsconfig(e,n,i,void 0,(s,o)=>{if(s)return r(s);let c=o,a=c.compilerOptions||{},f=e.dirname(n),u=this.baseUrl!==void 0?this.baseUrl:a.baseUrl,l=Rs(f,a.paths||{},e,u),d={},h=null;if(this.references==="auto"?h=c.references:Array.isArray(this.references)&&(h=this.references),!Array.isArray(h))return r(null,Es(l,f,d,i));this._loadTsconfigReferences(e,f,h,i,d,p=>{if(p)return r(p);r(null,Es(l,f,d,i))})})}_selectPathsDataForContext(e,n){let{main:r,allContexts:i,contextList:s}=n;if(!e)return r;let o;if(s.length>=2)if(o=As.get(n),o!==void 0){let u=o.get(e);if(u!==void 0)return u===ws?null:u}else o=new Map,As.set(n,o);let c=null,a=0;for(let u=0;ua&&wu(l,e)&&(c=l,a=l.length)}let f=c===null?null:i[c];return o!==void 0&&o.set(e,f===null?ws:f),f}_loadTsconfigFromExtends(e,n,r,i,s,o){let{fileSystem:c}=e,a=e.dirname(n);r=Xt(r,a);let f=r;typeof r=="string"&&!r.includes(".json")&&(r+=".json");let u=e.join(a,r),l=d=>{this._loadTsconfig(e,d,i,s,(h,p)=>{if(h)return o(h);let g=p,y=g.compilerOptions||{baseUrl:void 0};if(y.baseUrl){let w=e.dirname(d);y.baseUrl=Ru(w,e,y.baseUrl)}delete g.references,o(null,g)})};c.stat(u,d=>{if(!d)return l(u);let h=null;if(typeof f=="string"&&f.startsWith("@")&&f.split("/").length===2?h=`${f}/${De}`:r.includes("/")&&!f.startsWith(".")&&!f.startsWith("/")?h=r:!f.startsWith(".")&&!f.startsWith("/")&&(h=`${f}/${De}`),h===null)return l(u);let p=Au(`node_modules/${h}`);this._findExtendsInNodeModules(e,a,p,g=>{l(g||e.join(a,p))})})}_findExtendsInNodeModules(e,n,r,i){let{fileSystem:s}=e,o=c=>{let a=e.join(c,r);s.stat(a,f=>{if(!f)return i(a);let u=e.dirname(c);if(u===c)return i(null);o(u)})};o(n)}_loadTsconfigReferences(e,n,r,i,s,o,c){if(r.length===0)return o(null);let a=c||new Set,f=r.length,u=()=>{--f===0&&o(null)};for(let l of r){let d=Xt(l.path,n),h=e.join(e.join(n,d),De);if(a.has(h)){u();continue}a.add(h),this._loadTsconfig(e,h,i,void 0,(p,g)=>{if(p)return u();let y=g;if(y.compilerOptions&&y.compilerOptions.paths){let w=e.dirname(h);s[w]=Rs(w,y.compilerOptions.paths||{},e,y.compilerOptions.baseUrl)}this.references==="auto"&&Array.isArray(y.references)?this._loadTsconfigReferences(e,e.dirname(h),y.references,i,s,u,a):u()})}}_loadTsconfig(e,n,r,i,s){let o=i||new Set;if(o.has(n))return s(null,{});o.add(n),_u(e.fileSystem,n,Su,(c,a)=>{if(c)return s(c);let f=a;r.add(n);let u=f.extends;if(!u)return s(null,f);if(!Array.isArray(u)){this._loadTsconfigFromExtends(e,n,u,r,o,(p,g)=>{if(p)return s(p);s(null,Qt(g,f))});return}let l={},d=0,h=()=>{if(d>=u.length)return s(null,Qt(l,f));this._loadTsconfigFromExtends(e,n,u[d++],r,o,(p,g)=>{if(p)return s(p);l=Qt(l,g),h()})};h()})}}});var ks=_((dd,Fs)=>{"use strict";var{isRelativeRequest:vs}=J();function Eu(t,e,n){let r=n.join(t,e);return vs(r)?r:`./${r}`}function $u(t){return t.descriptionFileRoot&&!t.module?t.descriptionFileRoot:t.path}function vu(t,e){let n=t.request;return!n||!t.relativePath||!vs(n)?n:Eu(t.relativePath,n,e)}function Fu(t,e,n,r){return JSON.stringify({type:t,context:n?e.context:"",path:$u(e),query:e.query,fragment:e.fragment,request:vu(e,r)})}Fs.exports=class{constructor(e,n,r,i,s){this.source=e,this.filterPredicate=n,this.withContext=i,this.cache=r,this.target=s}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("UnsafeCachePlugin",(r,i,s)=>{if(!this.filterPredicate(r))return e.doResolve(n,r,null,i,s);let o=typeof i.yield=="function",c=Fu(o?"yield":"default",r,this.withContext,e),a=this.cache[c];if(a){if(o){let d=i.yield;if(Array.isArray(a))for(let h of a)d(h);else d(a);return s(null,null)}return s(null,a)}let f,u,l=[];o&&(f=i.yield,u=d=>{l.push(d)}),e.doResolve(n,r,null,u?{...i,yield:u}:i,(d,h)=>{if(d)return s(d);if(o){h&&l.push(h);for(let p of l)f(p);return this.cache[c]=l,s(null,null)}if(h)return s(null,this.cache[c]=h);s()})})}}});var Ms=_((pd,Os)=>{"use strict";Os.exports=class{constructor(e,n,r){this.source=e,this.filename=n,this.target=r}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("UseFilePlugin",(r,i,s)=>{let o=e.join(r.path,this.filename),c={...r,path:o,relativePath:r.relativePath&&e.join(r.relativePath,this.filename)};e.doResolve(n,c,`using path: ${o}`,i,s)})}}});var Us=_((gd,Is)=>{"use strict";var{cwd:xs,versions:ku}=b("process"),Ds=bn(),Vt=Kn(),Ou=Qn(),we=Zn(),Ce=tr(),Cs=rr(),Mu=Pr(),en=Er(),xu=vr(),Du=Or(),Cu=xr(),Qe=Cr(),Lu=jr(),tn=qr(),Tu=Jr(),G=zr(),Nu=ri(),ju=si(),Hu=ci(),Iu=ns(),Uu=is(),Wu=os(),Bu=as(),qu=fs(),bu=ps(),Ju=ys(),Gu=_s(),zu=Zt(),Ku=ks(),Ls=Ms(),{PathType:Xe,getType:Hs,join:Yu,toPath:Y}=J();function Qu(t){if(t===void 0&&ku.pnp){let e=b("module").findPnpApi;if(e)return{resolveToUnqualified(n,r,i){let s=e(r);return s?s.resolveToUnqualified(n,r,i):null}}}return t||null}function Ts(t){return t===!1?!1:Array.isArray(t)?t.map(Y):Y(t)}function Ns(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null?Object.keys(t).map(e=>{let n={name:e,onlyModule:!1,alias:Ts(t[e])};return/\$$/.test(e)&&(n.onlyModule=!0,n.name=e.slice(0,-1)),n}):t?t.map(e=>({...e,alias:Ts(e.alias)})):[]}function js(t){let e=Y(t),n=Hs(e);if(n===Xe.AbsolutePosix||n===Xe.AbsoluteWin)return e;if(typeof xs!="function")throw new Error("The 'packageMap' option needs an absolute 'configFile' in an environment without a working directory");return Yu(xs(),e)}function Xu(t){if(t===void 0)return null;if(typeof t=="string"||t instanceof URL)return{configFile:js(t),packages:null};let{configFile:e,packages:n}=t;if(n!==void 0&&e===void 0)throw new Error("The 'packageMap' option needs a 'configFile' next to 'packages' to resolve the package urls against");if(e===void 0)throw new Error("The 'packageMap' option needs either a 'configFile' or 'packages'");return{configFile:js(e),packages:n===void 0?null:n}}function Zu(t){if(t===void 0)return!1;if(typeof t=="boolean")return t;if(typeof t=="string"||t instanceof URL)return Y(t);let e={};return t.configFile!==void 0&&(e.configFile=Y(t.configFile)),t.baseUrl!==void 0&&(e.baseUrl=Y(t.baseUrl)),t.references!==void 0&&(e.references=Array.isArray(t.references)?t.references.map(Y):t.references),e}function Vu(t,e){let n=[],r=new Set(t);for(let i of r)if(e(i)){let s=n.length>0?n[n.length-1]:void 0;Array.isArray(s)?s.push(i):n.push([i])}else n.push(i);return n}function el(t){let e=new Set(t.mainFields||["main"]),n=[];for(let r of e)typeof r=="string"?n.push({name:[r],forceRelative:!0}):Array.isArray(r)?n.push({name:r,forceRelative:!0}):n.push({name:Array.isArray(r.name)?r.name:[r.name],forceRelative:r.forceRelative});return{alias:Ns(t.alias),fallback:Ns(t.fallback),aliasFields:new Set(t.aliasFields),cachePredicate:t.cachePredicate||function(){return!0},cacheWithContext:typeof t.cacheWithContext<"u"?t.cacheWithContext:!0,exportsFields:new Set(t.exportsFields||["exports"]),importsFields:new Set(t.importsFields||["imports"]),conditionNames:new Set(t.conditionNames),descriptionFiles:[...new Set(t.descriptionFiles||["package.json"])],enforceExtension:t.enforceExtension===void 0?!!(t.extensions&&t.extensions.includes("")):t.enforceExtension,extensions:new Set(t.extensions||[".js",".json",".node"]),extensionAlias:t.extensionAlias?Object.keys(t.extensionAlias).map(r=>({extension:r,alias:t.extensionAlias[r]})):[],extensionAliasForExports:t.extensionAliasForExports||!1,fileSystem:t.useSyncFileSystemCalls?new Ju(t.fileSystem):t.fileSystem,unsafeCache:t.unsafeCache&&typeof t.unsafeCache!="object"?{}:t.unsafeCache||!1,symlinks:typeof t.symlinks<"u"?t.symlinks:!0,resolver:t.resolver,modules:Vu(Array.isArray(t.modules)?t.modules.map(Y):t.modules?[Y(t.modules)]:["node_modules"],r=>{let i=Hs(r);return i===Xe.Normal||i===Xe.Relative}),mainFields:n,mainFiles:new Set(t.mainFiles||["index"]),plugins:t.plugins||[],packageMap:Xu(t.packageMap),pnpApi:Qu(t.pnpApi),roots:new Set(t.roots?t.roots.map(Y):void 0),fullySpecified:t.fullySpecified||!1,resolveToContext:t.resolveToContext||!1,preferRelative:t.preferRelative||!1,preferAbsolute:t.preferAbsolute||!1,restrictions:new Set(t.restrictions&&t.restrictions.map(r=>r instanceof RegExp?r:Y(r))),tsconfig:Zu(t.tsconfig)}}Is.exports.createResolver=function(e){let n=el(e),{alias:r,fallback:i,aliasFields:s,extensionAliasForExports:o,cachePredicate:c,cacheWithContext:a,conditionNames:f,descriptionFiles:u,enforceExtension:l,exportsFields:d,extensionAlias:h,importsFields:p,extensions:g,fileSystem:y,fullySpecified:w,mainFields:A,mainFiles:P,modules:E,packageMap:k,plugins:N,pnpApi:oe,resolveToContext:Q,preferRelative:R,preferAbsolute:O,symlinks:F,unsafeCache:j,resolver:H,restrictions:T,roots:x,tsconfig:D}=n,m=[...N],S=H||new Iu(y,n);S.ensureHook("resolve"),S.ensureHook("internalResolve"),S.ensureHook("newInternalResolve"),S.ensureHook("importsResolve"),S.ensureHook("parsedResolve"),S.ensureHook("describedResolve"),S.ensureHook("rawResolve"),S.ensureHook("normalResolve"),S.ensureHook("internal"),S.ensureHook("rawModule"),S.ensureHook("alternateRawModule"),S.ensureHook("module"),S.ensureHook("resolveAsModule"),S.ensureHook("undescribedResolveInPackage"),S.ensureHook("resolveInPackage"),S.ensureHook("resolveInExistingDirectory"),S.ensureHook("importsFieldRelative"),o&&S.ensureHook("exportsFieldRelative"),S.ensureHook("relative"),S.ensureHook("describedRelative"),S.ensureHook("directory"),S.ensureHook("undescribedExistingDirectory"),S.ensureHook("existingDirectory"),S.ensureHook("undescribedRawFile"),S.ensureHook("rawFile"),S.ensureHook("file"),S.ensureHook("finalFile"),S.ensureHook("existingFile"),S.ensureHook("resolved"),S.hooks.newInteralResolve=S.hooks.newInternalResolve;for(let{source:$,resolveOptions:et}of[{source:"resolve",resolveOptions:{fullySpecified:w}},{source:"internal-resolve",resolveOptions:{fullySpecified:!1}},{source:"imports-resolve",resolveOptions:{fullySpecified:!1,internal:!1}}])m.push(new ju($,et,"parsed-resolve"));m.push(new Ce("parsed-resolve",u,!1,"described-resolve")),m.push(new G("after-parsed-resolve","described-resolve")),j?m.push(new Ku("described-resolve",c,j,a,"raw-resolve")):m.push(new G("described-resolve","raw-resolve")),i.length>0&&m.push(new Vt("described-resolve",i,"internal-resolve")),r.length>0&&m.push(new Vt("raw-resolve",r,"internal-resolve")),D&&m.push(new zu(D));for(let $ of s)m.push(new Ds("raw-resolve",$,"internal-resolve"));for(let $ of h)m.push(new en("raw-resolve",$,"normal-resolve"));m.push(new G("raw-resolve","normal-resolve")),R&&m.push(new Qe("after-normal-resolve","relative")),m.push(new we("after-normal-resolve",{module:!0},"resolve as module",!1,"raw-module")),m.push(new we("after-normal-resolve",{internal:!0},"resolve as internal import",!1,"internal")),O&&m.push(new Qe("after-normal-resolve","relative")),x.size>0&&m.push(new Bu("after-normal-resolve",x,"relative")),!R&&!O&&m.push(new Qe("after-normal-resolve","relative"));for(let $ of p)m.push(new Du("internal",f,$,"imports-field-relative","imports-resolve"));for(let $ of h)m.push(new en("imports-field-relative",$,"relative"));m.push(new G("imports-field-relative","relative")),k&&m.push(new Nu("raw-module",k,F,"undescribed-resolve-in-package"));for(let $ of d)m.push(new qu("raw-module",$,"resolve-as-module"));for(let $ of E)Array.isArray($)?$.includes("node_modules")&&oe?(m.push(new tn("raw-module",$.filter(et=>et!=="node_modules"),"module")),m.push(new Hu("raw-module",oe,"undescribed-resolve-in-package","alternate-raw-module")),m.push(new tn("alternate-raw-module",["node_modules"],"module"))):m.push(new tn("raw-module",$,"module")):m.push(new Tu("raw-module",$,"module"));m.push(new Cu("module","resolve-as-module")),Q||m.push(new we("resolve-as-module",{directory:!1,request:"."},"single file module",!0,"undescribed-raw-file")),m.push(new Cs("resolve-as-module","undescribed-resolve-in-package")),m.push(new Ce("undescribed-resolve-in-package",u,!1,"resolve-in-package")),m.push(new G("after-undescribed-resolve-in-package","resolve-in-package"));let M=o?"exports-field-relative":"relative";for(let $ of d)m.push(new Mu("resolve-in-package",f,$,M,T.size>0));if(m.push(new G("resolve-in-package","resolve-in-existing-directory")),o){for(let $ of h)m.push(new en("exports-field-relative",$,"relative"));m.push(new G("exports-field-relative","relative"))}if(m.push(new Qe("resolve-in-existing-directory","relative")),m.push(new Ce("relative",u,!0,"described-relative")),m.push(new G("after-relative","described-relative")),Q?m.push(new G("described-relative","directory")):(m.push(new we("described-relative",{directory:!1},null,!0,"raw-file")),m.push(new we("described-relative",{fullySpecified:!1},"as directory",!0,"directory"))),m.push(new Cs("directory","undescribed-existing-directory")),Q)m.push(new G("undescribed-existing-directory","resolved"));else{m.push(new Ce("undescribed-existing-directory",u,!1,"existing-directory"));for(let $ of P)m.push(new Ls("undescribed-existing-directory",$,"undescribed-raw-file"));for(let $ of A)m.push(new Lu("existing-directory",$,"resolve-in-existing-directory"));for(let $ of P)m.push(new Ls("existing-directory",$,"undescribed-raw-file"));m.push(new Ce("undescribed-raw-file",u,!0,"raw-file")),m.push(new G("after-undescribed-raw-file","raw-file")),m.push(new we("raw-file",{fullySpecified:!0},null,!1,"file")),l||m.push(new Gu("raw-file","no extension","file"));for(let $ of g)m.push(new Ou("raw-file",$,"file"));r.length>0&&m.push(new Vt("file",r,"internal-resolve"));for(let $ of s)m.push(new Ds("file",$,"internal-resolve"));m.push(new G("file","final-file")),m.push(new xu("final-file","existing-file")),F&&m.push(new bu("existing-file","existing-file")),m.push(new G("existing-file","resolved"))}let{resolved:Ve}=S.hooks;T.size>0&&m.push(new Uu(Ve,T)),m.push(new Wu(Ve));for(let $ of m)typeof $=="function"?$.call(S,S):$&&$.apply(S);return S}});var Bs=_((md,Ws)=>{"use strict";Ws.exports=class{constructor(e,n){this.source=e,this.target=n}apply(e){let n=e.ensureHook(this.target);e.getHook(this.source).tapAsync("CloneBasenamePlugin",(r,i,s)=>{let o=r.path,c=e.basename(o),a=e.join(o,c),f={...r,path:a,relativePath:r.relativePath&&e.join(r.relativePath,c)};e.doResolve(n,f,`using path: ${a}`,i,s)})}}});var bs=_((wd,qs)=>{"use strict";qs.exports=class{constructor(e){this.source=e}apply(e){let{source:n}=this;e.getHook(this.source).tapAsync("LogInfoPlugin",(r,i,s)=>{if(!i.log)return s();let{log:o}=i,c=`[${n}] `;r.path&&o(`${c}Resolving in directory: ${r.path}`),r.request&&o(`${c}Resolving request: ${r.request}`),r.module&&o(`${c}Request is an module request.`),r.directory&&o(`${c}Request is a directory request.`),r.query&&o(`${c}Resolving request query: ${r.query}`),r.fragment&&o(`${c}Resolving request fragment: ${r.fragment}`),r.descriptionFilePath&&o(`${c}Has description data from ${r.descriptionFilePath}`),r.relativePath&&o(`${c}Relative path from description file is: ${r.relativePath}`),s()})}}});var Ys=_((Ad,Ks)=>{"use strict";var Ae=tt(),Gs=Ae(()=>pn()),Le=Ae(()=>{let t=$n(),e=Gs();return new e(t,4e3)}),Se=Ae(()=>({environments:["node+es3+es5+process+native"]})),Pe=Ae(()=>Us()),zs=Ae(()=>Pe().createResolver({conditionNames:["node"],extensions:[".js",".json",".node"],fileSystem:Le()})),tl=(t,e,n,r,i)=>{(typeof t=="string"||t instanceof URL)&&(i=r,r=n,n=e,e=t,t=Se()),typeof i!="function"&&(i=r),zs().resolve(t,e,n,r,i)},nl=Ae(()=>Pe().createResolver({conditionNames:["node"],extensions:[".js",".json",".node"],useSyncFileSystemCalls:!0,fileSystem:Le()})),rl=(t,e,n,r)=>((typeof t=="string"||t instanceof URL)&&(r=n,n=e,e=t,t=Se()),nl().resolveSync(t,e,n,r)),il=(t,e,n,r)=>((typeof t=="string"||t instanceof URL)&&(r=n,n=e,e=t,t=Se()),zs().resolvePromise(t,e,n,r));function sl(t){let e=Pe().createResolver({...t,fileSystem:t.fileSystem||Le()});return function(r,i,s,o,c){(typeof r=="string"||r instanceof URL)&&(c=o,o=s,s=i,i=r,r=Se()),typeof c!="function"&&(c=o),e.resolve(r,i,s,o,c)}}function ol(t){let e=Pe().createResolver({useSyncFileSystemCalls:!0,...t,fileSystem:t.fileSystem||Le()});return function(r,i,s,o){return(typeof r=="string"||r instanceof URL)&&(o=s,s=i,i=r,r=Se()),e.resolveSync(r,i,s,o)}}function cl(t){let e=Pe().createResolver({...t,fileSystem:t.fileSystem||Le()});return function(r,i,s,o){return(typeof r=="string"||r instanceof URL)&&(o=s,s=i,i=r,r=Se()),e.resolvePromise(r,i,s,o)}}var Js=(t,e)=>{let n=Object.getOwnPropertyDescriptors(e);return Object.defineProperties(t,n),Object.freeze(t)};Ks.exports=Js(tl,{get sync(){return rl},get promise(){return il},create:Js(sl,{get sync(){return ol},get promise(){return cl}}),get ResolverFactory(){return Pe()},get CachedInputFileSystem(){return Gs()},get CloneBasenamePlugin(){return Bs()},get LogInfoPlugin(){return bs()},get TsconfigPathsPlugin(){return Zt()},get forEachBail(){return Z()}})});import{URL as $l}from"node:url";import _l,{isBuiltin as to}from"node:module";import ne from"node:path";import wl from"node:process";import{fileURLToPath as Re,pathToFileURL as ro,URL as io}from"node:url";var Vs=ho(Ys(),1);import Ne from"node:path";import{Buffer as al}from"node:buffer";import{createHash as Xs}from"node:crypto";import Ze from"node:fs";import W from"node:path";import{fileURLToPath as ul}from"node:url";function L(t,e){return Object.assign(new Error(e),{code:t})}function Zs(t){let e=ul(t),n=W.dirname(e),r=JSON.parse(Ze.readFileSync(e,"utf8"));if(!Te(r)||r.version!==1||typeof r.storeDir!="string")throw L("ERR_PNPM_LOADER_MANIFEST",`Invalid store manifest: ${e}`);let i=W.join(n,".pnpm-loader"),s=W.resolve(n,r.storeDir),o=fl(r.packages,n,i),c=new Map,a=new Set([i]);for(let g of o.values())g.stored&&a.add(g.root);let f=ll(o);function u(g){return g?.stored&&!g.indexed&&hl(g,c,a,s),g}function l(g){return u(f(g))}function d(g){return l(g),c.get(g)}function h(g){return l(g),a.has(g)}let p=yl({file:d,isDirectory:h,virtualRoot:i});return{packages:o,index:u,owner:l,filesystem:p,file:d,isDirectory:h,virtualRoot:i}}function ll(t){let e=new Map([...t.values()].map(r=>[r.root,r])),n=new Map;return function(i){if(n.has(i))return n.get(i);let s=i;for(;!e.has(s)&&W.dirname(s)!==s;)s=W.dirname(s);let o=e.get(s);return n.set(i,o),o}}function fl(t,e,n){if(!Te(t))throw L("ERR_PNPM_LOADER_MANIFEST","The store manifest needs a packages object");let r=new Map,i=new Map;for(let[s,o]of Object.entries(t)){dl(s,o);let c=Object.hasOwn(o,"files");if(c===Object.hasOwn(o,"root"))throw L("ERR_PNPM_LOADER_MANIFEST",`${s} must have either files or root`);let a=c?W.join(n,Xs("sha256").update(s).digest("hex")):W.resolve(e,o.root),f=i.get(a);if(!c&&B(n,a)||f&&(f.resolution!=="node"||o.resolution!=="node"))throw L("ERR_PNPM_LOADER_MANIFEST",`Conflicting package root: ${a}`);i.set(a,o),r.set(s,{...o,id:s,root:a,stored:c,dependencies:new Map(Object.entries(o.dependencies??{}))})}for(let s of r.values())for(let[o,c]of s.dependencies)if(!r.has(c))throw L("ERR_PNPM_LOADER_MANIFEST",`Unknown dependency ${o} -> ${c} in ${s.id}`);return r}function dl(t,e){if(!Te(e)||!Te(e.dependencies??{})||Object.hasOwn(e,"files")&&!Te(e.files)||Object.hasOwn(e,"root")&&typeof e.root!="string"||e.resolution!==void 0&&(e.resolution!=="node"||typeof e.root!="string"))throw L("ERR_PNPM_LOADER_MANIFEST",`Invalid package entry: ${t}`)}function Te(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function hl(t,e,n,r){if(t.indexError)throw t.indexError;try{let i=pl(t,r);for(let[s,o]of i.files)e.set(s,o);for(let s of i.directories)n.add(s);t.hasNodeModules=i.hasNodeModules,t.indexed=!0}catch(i){throw t.indexError=i,i}}function pl(t,e){let n=new Map,r=new Set,i=!1;Object.hasOwn(t.files,"package.json")||n.set(W.join(t.root,"package.json"),{source:al.from("{}")});for(let[s,o]of Object.entries(t.files)){let c=s.split("/");if(!gl(s,c)||typeof o!="string"||!/^[a-f0-9]{128}(?:-exec)?$/.test(o))throw L("ERR_PNPM_LOADER_MANIFEST",`Invalid store file ${t.id}/${s}`);c.includes("node_modules")&&(i=!0);let a=W.join(t.root,s);n.set(a,{blob:W.join(e,"files",o.slice(0,2),o.slice(2)),hash:o.slice(0,128)});for(let f=W.dirname(a);B(t.root,f);f=W.dirname(f))r.add(f)}for(let s of n.keys())if(r.has(s))throw L("ERR_PNPM_LOADER_MANIFEST",`File is also a directory: ${s}`);return{files:n,directories:r,hasNodeModules:i}}function gl(t,e){return t.length>0&&!t.includes("\\")&&!t.includes("\0")&&!t.includes(":")&&e.every(n=>n!==""&&n!=="."&&n!=="..")}function B(t,e){return e===t||e.startsWith(`${t}${W.sep}`)}function yl({file:t,isDirectory:e,virtualRoot:n}){let r=new Map;function i(c){let a=W.resolve(c);if(!B(n,a))return Ze.statSync(c);let f=t(a)!==void 0,u=e(a);if(!f&&!u)throw Qs(c);return{isFile:()=>f,isDirectory:()=>u,isSymbolicLink:()=>!1}}function s(c,a){let f=W.resolve(c);if(!B(n,f))return Ze.readFileSync(c,a);let u=t(f);if(!u)throw Qs(c);if(u.source)return a?u.source.toString(a):u.source;let l=Ze.readFileSync(u.blob);if(Xs("sha512").update(l).digest("hex")!==u.hash)throw L("ERR_PNPM_LOADER_INTEGRITY",`Store file failed integrity verification: ${u.blob}`);return a?l.toString(a):l}function o(c){let a=W.resolve(c);if(r.has(a))return r.get(a);let f=s(c,"utf8"),u=JSON.parse(f.charCodeAt(0)===65279?f.slice(1):f);return B(n,a)&&r.set(a,u),u}return{statSync:i,readFileSync:s,readJsonSync:o}}function Qs(t){return L("ENOENT",`No file in store manifest: ${t}`)}function eo(t){let e=new Map,n,r={resolveToUnqualified(i,s){let o=t.owner(Ne.resolve(s));if(o?.hasNodeModules&&ml(t,o,{issuer:Ne.resolve(s),name:i}))return null;let c=o?.dependencies.get(i);if(c===void 0)throw L("ERR_PNPM_LOADER_UNDECLARED_DEPENDENCY",`Package ${o?.id??s} does not declare ${i}`);return n=t.index(t.packages.get(c)),n.root}};return function(s,o,{conditions:c,filename:a}){let f=JSON.stringify(c),u=e.get(f);u||(u=Vs.default.ResolverFactory.createResolver({fileSystem:t.filesystem,useSyncFileSystemCalls:!0,conditionNames:c,extensions:[".js",".json",".node"],mainFields:["main"],mainFiles:["index"],fullySpecified:!c.includes("require"),symlinks:!1,pnpApi:r}),e.set(f,u)),n=t.owner(a??o);let l,d;if(u.resolve({},Ne.dirname(o),s,{},(h,p,g)=>{d=h,l=g}),d)throw d;if(!l?.path)throw L("ERR_MODULE_NOT_FOUND",`Cannot resolve ${s} from ${o}`);if(n?.stored&&!B(n.root,l.path))throw L("ERR_PNPM_LOADER_PATH_ESCAPE",`Resolved ${s} escapes package ${n.id}`);return l}}function ml(t,e,{issuer:n,name:r}){for(let i=n;B(e.root,i);i=Ne.dirname(i))if(t.isDirectory(Ne.join(i,"node_modules",r)))return!0;return!1}function so(t){return Al(wl.versions.node),_l.registerHooks(Sl(t))}function Al(t){let[e,n]=t.split("-",2),[r,i,s]=e.split(".").map(Number),o=c=>i>c||i===c&&(s>0||n===void 0);if(!(r===24&&o(18)||r===26&&o(2)||r>26))throw L("ERR_PNPM_LOADER_UNSUPPORTED_NODE",`The pnpm store loader requires Node.js ^24.18.0 or >=26.2.0, but this is Node.js ${t}. Use a supported Node.js version, or install with a different nodeLinker.`)}function Sl(t){let e=Zs(t),n=eo(e),r=new Map;return{resolve(i,s,o){if(!s.parentURL&&!to(i)){let d=El(i,e,r);if(d)return d}if(to(i)||!s.parentURL?.startsWith("file:"))return o(i,s);let c=Re(s.parentURL),a=e.owner(c);if(!a)return o(i,s);let f=Pl(i,s);if(f===null||a.resolution==="node"&&(!f.filename||!B(e.virtualRoot,f.filename))||f.filename&&(!a.stored||!f.relative)&&!B(e.virtualRoot,f.filename))return o(i,s);if(a.stored&&f.relative&&!B(a.root,f.filename))throw L("ERR_PNPM_LOADER_PATH_ESCAPE",`Import ${i} escapes package ${a.id}`);let u=n(f.specifier,c,{conditions:s.conditions,filename:f.filename}),l=ro(u.path);return l.search=f.search||u.query||"",l.hash=f.hash||u.fragment||"",B(e.virtualRoot,u.path)&&nn(u.path,e,r),{url:l.href,shortCircuit:!0}},load(i,s,o){if(!i.startsWith("file:"))return o(i,s);let c=Re(i);if(!B(e.virtualRoot,c))return o(i,s);let a=nn(c,e,r);if(a==="json"&&!s.conditions.includes("require")&&s.importAttributes?.type!=="json")throw L("ERR_IMPORT_ATTRIBUTE_MISSING",`Module ${i} needs an import attribute of type json`);return Rl(a,s.importAttributes,i),{format:a,source:e.filesystem.readFileSync(c),shortCircuit:!0}}}}function Pl(t,e){let r=e.conditions.includes("require")&&(t==="."||t==="..")||t.startsWith("./")||t.startsWith("../");if(ne.isAbsolute(t)&&!t.startsWith("/")||e.conditions.includes("require")&&(r||ne.isAbsolute(t))){let s=ne.resolve(ne.dirname(Re(e.parentURL)),t);return{filename:s,relative:r,specifier:no(s)}}if(t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")){let s=new io(t,e.parentURL),o=Re(s);return{filename:o,relative:r,specifier:no(o),search:s.search,hash:s.hash}}if(t.includes(":"))return null;if(!t.startsWith("#")&&(t.includes("\\")||t.split("/").includes("..")))throw L("ERR_PNPM_LOADER_PATH_ESCAPE",`Invalid package subpath: ${t}`);return{specifier:t}}function no(t){return t.replaceAll("#","\0#").replaceAll("?","\0?")}function nn(t,e,n){let r=ne.extname(t);if(r===".mjs")return"module";if(r===".cjs")return"commonjs";if(r===".json")return"json";if(r!==".js"&&r!=="")throw L("ERR_PNPM_LOADER_UNSUPPORTED_FORMAT",`Cannot load ${r||"extensionless"} store file: ${t}`);let i=e.owner(t);if(!i)throw L("ENOENT",`No package in store manifest: ${t}`);for(let s=ne.dirname(t);B(i.root,s);s=ne.dirname(s)){let o=ne.join(s,"package.json");if(e.file(o))return n.has(o)||n.set(o,e.filesystem.readJsonSync(o)),n.get(o).type==="module"?"module":"commonjs"}return"commonjs"}function Rl(t,e={},n){for(let[r,i]of Object.entries(e))if(r!=="type"||i!=="json")throw L("ERR_IMPORT_ATTRIBUTE_UNSUPPORTED",`Unsupported import attribute ${r}=${i} for ${n}`);if(t!=="json"&&e.type==="json")throw L("ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE",`Module ${n} is not JSON`)}function El(t,e,n){let r=t.startsWith("file:")?new io(t):ne.isAbsolute(t)?ro(t):null;return!r||!e.file(Re(r))?null:{url:r.href,format:nn(Re(r),e,n),shortCircuit:!0}}so(new $l("./.store-manifest.json",import.meta.url)); diff --git a/pnpm/crates/store-dir/src/store_index.rs b/pnpm/crates/store-dir/src/store_index.rs index 312bf46179..84d0c9a12c 100644 --- a/pnpm/crates/store-dir/src/store_index.rs +++ b/pnpm/crates/store-dir/src/store_index.rs @@ -74,26 +74,7 @@ impl StoreIndex { let conn = Connection::open(&db_path) .map_err(|source| StoreIndexError::Open { path: db_path.clone(), source })?; - // Busy-timeout FIRST so the internal busy handler is active during the - // rest of the setup — on Windows file locking is mandatory and - // concurrent pacquet / pnpm invocations can contend. - conn.execute_batch( - " - PRAGMA busy_timeout=5000; - PRAGMA journal_mode=WAL; - PRAGMA synchronous=NORMAL; - PRAGMA mmap_size=536870912; - PRAGMA cache_size=-32000; - PRAGMA temp_store=MEMORY; - PRAGMA wal_autocheckpoint=10000; - CREATE TABLE IF NOT EXISTS package_index ( - key TEXT PRIMARY KEY, - data BLOB NOT NULL - ) WITHOUT ROWID; - ", - ) - .and_then(|()| conn.execute_batch(aliases::CREATE_ALIAS_TABLE)) - .map_err(|source| StoreIndexError::InitSchema { source })?; + schema::initialize(&conn).map_err(|source| StoreIndexError::InitSchema { source })?; Ok(StoreIndex::sqlite( conn, @@ -524,6 +505,8 @@ mod writer; mod queries; +mod schema; + mod aliases; mod error; diff --git a/pnpm/crates/store-dir/src/store_index/schema.rs b/pnpm/crates/store-dir/src/store_index/schema.rs new file mode 100644 index 0000000000..623d9a89b3 --- /dev/null +++ b/pnpm/crates/store-dir/src/store_index/schema.rs @@ -0,0 +1,39 @@ +//! Initialize a shared index even when another installer is switching it to WAL. +use rusqlite::{Connection, ErrorCode}; +use std::time::Duration; + +/// `SQLite` can return `SQLITE_BUSY` from a journal-mode transition without +/// invoking its busy handler. Retry the idempotent setup within the same +/// pnpm v11 retry policy: up to 100 retries, 50 milliseconds apart. +pub(super) fn initialize(connection: &Connection) -> rusqlite::Result<()> { + connection.busy_timeout(Duration::from_secs(5))?; + let mut retries = 0; + loop { + let result = connection + .execute_batch( + "PRAGMA journal_mode=WAL; + PRAGMA synchronous=NORMAL; + PRAGMA mmap_size=536870912; + PRAGMA cache_size=-32000; + PRAGMA temp_store=MEMORY; + PRAGMA wal_autocheckpoint=10000; + CREATE TABLE IF NOT EXISTS package_index ( + key TEXT PRIMARY KEY, + data BLOB NOT NULL + ) WITHOUT ROWID;", + ) + .and_then(|()| connection.execute_batch(super::aliases::CREATE_ALIAS_TABLE)); + match result { + Err(error) + if error.sqlite_error_code() == Some(ErrorCode::DatabaseBusy) && retries < 100 => + { + retries += 1; + std::thread::sleep(Duration::from_millis(50)); + } + result => return result, + } + } +} + +#[cfg(test)] +mod tests; diff --git a/pnpm/crates/store-dir/src/store_index/schema/tests.rs b/pnpm/crates/store-dir/src/store_index/schema/tests.rs new file mode 100644 index 0000000000..e557096a4d --- /dev/null +++ b/pnpm/crates/store-dir/src/store_index/schema/tests.rs @@ -0,0 +1,41 @@ +use crate::{StoreIndex, store_index::tests::sample_index}; +use std::{path::Path, sync::Barrier}; + +#[test] +fn concurrent_first_open_persists_every_writer_row() { + for _ in 0..16 { + let store = tempfile::tempdir().unwrap(); + open_concurrently(store.path()); + } +} + +fn open_concurrently(store: &Path) { + let start = Barrier::new(8); + std::thread::scope(|scope| { + let writers = (0..8) + .map(|worker| { + let start = &start; + scope.spawn(move || { + start.wait(); + let index = + StoreIndex::open(store).expect("initialize a concurrent store writer"); + index + .set(&format!("fixture-{worker}"), &sample_index()) + .unwrap(); + }) + }) + .collect::>(); + for writer in writers { + writer.join().unwrap(); + } + }); + let index = StoreIndex::open_readonly(store).unwrap(); + for worker in 0..8 { + assert_eq!( + index + .get(&format!("fixture-{worker}")) + .unwrap(), + Some(sample_index()), + ); + } +} diff --git a/pnpm/esm-loader/package.json b/pnpm/esm-loader/package.json index dbf8c56de0..eec1f5354e 100644 --- a/pnpm/esm-loader/package.json +++ b/pnpm/esm-loader/package.json @@ -15,7 +15,8 @@ "node": "^24.18.0 || >=26.2.0" }, "scripts": { - "prepare": "node scripts/bundle-runtime.mjs", + "prepare": "node scripts/bundle-runtime.mjs --check", + "build:runtime": "node scripts/bundle-runtime.mjs", "test": "node --test test/*.test.mjs", ".test": "node --test test/*.test.mjs" }, diff --git a/pnpm/esm-loader/scripts/bundle-runtime.mjs b/pnpm/esm-loader/scripts/bundle-runtime.mjs index aa0770d928..35e349ad76 100644 --- a/pnpm/esm-loader/scripts/bundle-runtime.mjs +++ b/pnpm/esm-loader/scripts/bundle-runtime.mjs @@ -16,6 +16,12 @@ const result = await esbuild.build({ }) const output = result.outputFiles[0] -const tempPath = `${output.path}.${process.pid}.tmp` -fs.writeFileSync(tempPath, output.contents) -fs.renameSync(tempPath, output.path) +if (process.argv.includes('--check')) { + if (!fs.readFileSync(output.path).equals(output.contents)) { + throw new Error('The embedded loader is stale. Run pnpm --filter @pnpm/esm-loader build:runtime and commit the generated file.') + } +} else { + const tempPath = `${output.path}.${process.pid}.tmp` + fs.writeFileSync(tempPath, output.contents) + fs.renameSync(tempPath, output.path) +} diff --git a/pnpm/esm-loader/test/bundle-runtime.test.mjs b/pnpm/esm-loader/test/bundle-runtime.test.mjs new file mode 100644 index 0000000000..149f835ea3 --- /dev/null +++ b/pnpm/esm-loader/test/bundle-runtime.test.mjs @@ -0,0 +1,37 @@ +import assert from 'node:assert/strict' +import { execFileSync, spawnSync } from 'node:child_process' +import fs from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import process from 'node:process' +import { test } from 'node:test' +import { fileURLToPath } from 'node:url' + +const loader = fileURLToPath(new URL('../', import.meta.url)) + +test('the committed loader matches the runtime sources', () => { + execFileSync(process.execPath, [path.join(loader, 'scripts/bundle-runtime.mjs'), '--check'], { stdio: 'inherit' }) +}) + +test('check rejects a stale bundle without rewriting it', () => { + const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'pnpm-loader-check-')) + try { + const isolatedLoader = path.join(directory, 'esm-loader') + fs.cpSync(loader, isolatedLoader, { + recursive: true, + filter: source => !['node_modules', 'test'].includes(path.basename(source)), + }) + fs.symlinkSync(fs.realpathSync(path.join(loader, 'node_modules')), path.join(isolatedLoader, 'node_modules'), 'junction') + const output = path.join(directory, 'crates/deps-restorer/src/cas-loader.mjs.inc') + fs.mkdirSync(path.dirname(output), { recursive: true }) + const stale = '// deliberately stale runtime\n' + fs.writeFileSync(output, stale) + const result = spawnSync(process.execPath, [path.join(isolatedLoader, 'scripts/bundle-runtime.mjs'), '--check'], { encoding: 'utf8' }) + assert.ifError(result.error) + assert.equal(result.status, 1, result.stderr) + assert.match(result.stderr, /The embedded loader is stale/) + assert.equal(fs.readFileSync(output, 'utf8'), stale) + } finally { + fs.rmSync(directory, { recursive: true, force: true }) + } +})