Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mortice

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mortice - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Mortice = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Mortice=(()=>{var Ae=Object.create;var N=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Ke=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),qe=(r,e)=>{for(var t in e)N(r,t,{get:e[t],enumerable:!0})},me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Me(e))!Ne.call(r,i)&&i!==t&&N(r,i,{get:()=>e[i],enumerable:!(n=We(e,i))||n.enumerable});return r};var ze=(r,e,t)=>(t=r!=null?Ae(Se(r)):{},me(e||!r||!r.__esModule?N(t,"default",{value:r,enumerable:!0}):t,r)),De=r=>me(N({},"__esModule",{value:!0}),r);var pe=Ke((He,B)=>{"use strict";var Fe=Object.prototype.hasOwnProperty,p="~";function Q(){}Object.create&&(Q.prototype=Object.create(null),new Q().__proto__||(p=!1));function $e(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function _e(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var u=new $e(t,n||r,i),o=p?p+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],u]:r._events[o].push(u):(r._events[o]=u,r._eventsCount++),r}function K(r,e){--r._eventsCount===0?r._events=new Q:delete r._events[e]}function _(){this._events=new Q,this._eventsCount=0}_.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Fe.call(t,n)&&e.push(p?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};_.prototype.listeners=function(e){var t=p?p+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,u=n.length,o=new Array(u);i<u;i++)o[i]=n[i].fn;return o};_.prototype.listenerCount=function(e){var t=p?p+e:e,n=this._events[t];return n?n.fn?1:n.length:0};_.prototype.emit=function(e,t,n,i,u,o){var l=p?p+e:e;if(!this._events[l])return!1;var s=this._events[l],d=arguments.length,f,c;if(s.fn){switch(s.once&&this.removeListener(e,s.fn,void 0,!0),d){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,t),!0;case 3:return s.fn.call(s.context,t,n),!0;case 4:return s.fn.call(s.context,t,n,i),!0;case 5:return s.fn.call(s.context,t,n,i,u),!0;case 6:return s.fn.call(s.context,t,n,i,u,o),!0}for(c=1,f=new Array(d-1);c<d;c++)f[c-1]=arguments[c];s.fn.apply(s.context,f)}else{var y=s.length,O;for(c=0;c<y;c++)switch(s[c].once&&this.removeListener(e,s[c].fn,void 0,!0),d){case 1:s[c].fn.call(s[c].context);break;case 2:s[c].fn.call(s[c].context,t);break;case 3:s[c].fn.call(s[c].context,t,n);break;case 4:s[c].fn.call(s[c].context,t,n,i);break;default:if(!f)for(O=1,f=new Array(d-1);O<d;O++)f[O-1]=arguments[O];s[c].fn.apply(s[c].context,f)}}return!0};_.prototype.on=function(e,t,n){return _e(this,e,t,n,!1)};_.prototype.once=function(e,t,n){return _e(this,e,t,n,!0)};_.prototype.removeListener=function(e,t,n,i){var u=p?p+e:e;if(!this._events[u])return this;if(!t)return K(this,u),this;var o=this._events[u];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&K(this,u);else{for(var l=0,s=[],d=o.length;l<d;l++)(o[l].fn!==t||i&&!o[l].once||n&&o[l].context!==n)&&s.push(o[l]);s.length?this._events[u]=s.length===1?s[0]:s:K(this,u)}return this};_.prototype.removeAllListeners=function(e){var t;return e?(t=p?p+e:e,this._events[t]&&K(this,t)):(this._events=new Q,this._eventsCount=0),this};_.prototype.off=_.prototype.removeListener;_.prototype.addListener=_.prototype.on;_.prefixed=p;_.EventEmitter=_;typeof B<"u"&&(B.exports=_)});var Be={};qe(Be,{default:()=>ke});var U=ze(pe(),1);var C=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},H=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},ve=r=>globalThis.DOMException===void 0?new H(r):new DOMException(r),Ee=r=>{let e=r.reason===void 0?ve("This operation was aborted."):r.reason;return e instanceof Error?e:ve(e)};function J(r,e,t,n){let i,u=new Promise((o,l)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:s}=n;s.aborted&&l(Ee(s)),s.addEventListener("abort",()=>{l(Ee(s))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){l(f)}return}let s=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,d=t instanceof Error?t:new C(s);typeof r.cancel=="function"&&r.cancel(),l(d)},e),(async()=>{try{o(await r)}catch(s){l(s)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return u.clear=()=>{clearTimeout(i),i=void 0},u}function X(r,e,t){let n=0,i=r.length;for(;i>0;){let u=Math.trunc(i/2),o=n+u;t(r[o],e)<=0?(n=++o,i-=u+1):i=u}return n}var L=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},g,Z=class{constructor(){g.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&L(this,g,"f")[this.size-1].priority>=t.priority){L(this,g,"f").push(n);return}let i=X(L(this,g,"f"),n,(u,o)=>o.priority-u.priority);L(this,g,"f").splice(i,0,n)}dequeue(){let e=L(this,g,"f").shift();return e?.run}filter(e){return L(this,g,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return L(this,g,"f").length}};g=new WeakMap;var we=Z;var h=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},a=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},m,A,W,T,G,M,q,w,k,v,z,E,S,P,D,ye,ge,be,Pe,Te,F,j,ee,V,xe,$,Y=class extends Error{},te=class extends U.default{constructor(e){var t,n,i,u;if(super(),m.add(this),A.set(this,void 0),W.set(this,void 0),T.set(this,0),G.set(this,void 0),M.set(this,void 0),q.set(this,0),w.set(this,void 0),k.set(this,void 0),v.set(this,void 0),z.set(this,void 0),E.set(this,0),S.set(this,void 0),P.set(this,void 0),D.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:we,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(u=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&u!==void 0?u:""}\` (${typeof e.interval})`);h(this,A,e.carryoverConcurrencyCount,"f"),h(this,W,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),h(this,G,e.intervalCap,"f"),h(this,M,e.interval,"f"),h(this,v,new e.queueClass,"f"),h(this,z,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,h(this,D,e.throwOnTimeout===!0,"f"),h(this,P,e.autoStart===!1,"f")}get concurrency(){return a(this,S,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);h(this,S,e,"f"),a(this,m,"m",V).call(this)}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:a(this,D,"f"),...t},new Promise((n,i)=>{a(this,v,"f").enqueue(async()=>{var u,o,l;h(this,E,(o=a(this,E,"f"),o++,o),"f"),h(this,T,(l=a(this,T,"f"),l++,l),"f");try{if(!((u=t.signal)===null||u===void 0)&&u.aborted)throw new Y("The task was aborted.");let s=e({signal:t.signal});t.timeout&&(s=J(Promise.resolve(s),t.timeout)),t.signal&&(s=Promise.race([s,a(this,m,"m",xe).call(this,t.signal)]));let d=await s;n(d),this.emit("completed",d)}catch(s){if(s instanceof C&&!t.throwOnTimeout){n();return}i(s),this.emit("error",s)}finally{a(this,m,"m",be).call(this)}},t),this.emit("add"),a(this,m,"m",F).call(this)})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return a(this,P,"f")?(h(this,P,!1,"f"),a(this,m,"m",V).call(this),this):this}pause(){h(this,P,!0,"f")}clear(){h(this,v,new(a(this,z,"f")),"f")}async onEmpty(){a(this,v,"f").size!==0&&await a(this,m,"m",$).call(this,"empty")}async onSizeLessThan(e){a(this,v,"f").size<e||await a(this,m,"m",$).call(this,"next",()=>a(this,v,"f").size<e)}async onIdle(){a(this,E,"f")===0&&a(this,v,"f").size===0||await a(this,m,"m",$).call(this,"idle")}get size(){return a(this,v,"f").size}sizeBy(e){return a(this,v,"f").filter(e).length}get pending(){return a(this,E,"f")}get isPaused(){return a(this,P,"f")}};A=new WeakMap,W=new WeakMap,T=new WeakMap,G=new WeakMap,M=new WeakMap,q=new WeakMap,w=new WeakMap,k=new WeakMap,v=new WeakMap,z=new WeakMap,E=new WeakMap,S=new WeakMap,P=new WeakMap,D=new WeakMap,m=new WeakSet,ye=function(){return a(this,W,"f")||a(this,T,"f")<a(this,G,"f")},ge=function(){return a(this,E,"f")<a(this,S,"f")},be=function(){var e;h(this,E,(e=a(this,E,"f"),e--,e),"f"),a(this,m,"m",F).call(this),this.emit("next")},Pe=function(){a(this,m,"m",ee).call(this),a(this,m,"m",j).call(this),h(this,k,void 0,"f")},Te=function(){let e=Date.now();if(a(this,w,"f")===void 0){let t=a(this,q,"f")-e;if(t<0)h(this,T,a(this,A,"f")?a(this,E,"f"):0,"f");else return a(this,k,"f")===void 0&&h(this,k,setTimeout(()=>{a(this,m,"m",Pe).call(this)},t),"f"),!0}return!1},F=function(){if(a(this,v,"f").size===0)return a(this,w,"f")&&clearInterval(a(this,w,"f")),h(this,w,void 0,"f"),this.emit("empty"),a(this,E,"f")===0&&this.emit("idle"),!1;if(!a(this,P,"f")){let e=!a(this,m,"a",Te);if(a(this,m,"a",ye)&&a(this,m,"a",ge)){let t=a(this,v,"f").dequeue();return t?(this.emit("active"),t(),e&&a(this,m,"m",j).call(this),!0):!1}}return!1},j=function(){a(this,W,"f")||a(this,w,"f")!==void 0||(h(this,w,setInterval(()=>{a(this,m,"m",ee).call(this)},a(this,M,"f")),"f"),h(this,q,Date.now()+a(this,M,"f"),"f"))},ee=function(){a(this,T,"f")===0&&a(this,E,"f")===0&&a(this,w,"f")&&(clearInterval(a(this,w,"f")),h(this,w,void 0,"f")),h(this,T,a(this,A,"f")?a(this,E,"f"):0,"f"),a(this,m,"m",V).call(this)},V=function(){for(;a(this,m,"m",F).call(this););},xe=async function(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(new Y("The task was aborted."))},{once:!0})})},$=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var re=te;var ne=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ie=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Le=r=>globalThis.DOMException===void 0?new ie(r):new DOMException(r),Ie=r=>{let e=r.reason===void 0?Le("This operation was aborted."):r.reason;return e instanceof Error?e:Le(e)};function se(r,e){let{milliseconds:t,fallback:n,message:i,customTimers:u={setTimeout,clearTimeout}}=e,o,s=new Promise((d,f)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:y}=e;y.aborted&&f(Ie(y)),y.addEventListener("abort",()=>{f(Ie(y))})}if(t===Number.POSITIVE_INFINITY){r.then(d,f);return}let c=new ne;o=u.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(y){f(y)}return}typeof r.cancel=="function"&&r.cancel(),i===!1?d():i instanceof Error?f(i):(c.message=i??`Promise timed out after ${t} milliseconds`,f(c))},t),(async()=>{try{d(await r)}catch(y){f(y)}})()}).finally(()=>{s.clear()});return s.clear=()=>{u.clearTimeout.call(void 0,o),o=void 0},s}var b={},R=r=>{r.addEventListener("message",e=>{R.dispatchEvent("message",r,e)}),r.port!=null&&r.port.addEventListener("message",e=>{R.dispatchEvent("message",r,e)})};R.addEventListener=(r,e)=>{b[r]==null&&(b[r]=[]),b[r].push(e)};R.removeEventListener=(r,e)=>{b[r]!=null&&(b[r]=b[r].filter(t=>t===e))};R.dispatchEvent=function(r,e,t){b[r]!=null&&b[r].forEach(n=>n(e,t))};var ae=R;var oe="lock:worker:request-read",ue="lock:worker:release-read",le="lock:master:grant-read",ce="lock:worker:request-write",fe="lock:worker:release-write",he="lock:master:grant-write";var Re=(r=21)=>Math.random().toString().substring(2);var Oe=(r,e,t,n,i)=>(u,o)=>{if(o.data.type!==t)return;let l={type:o.data.type,name:o.data.name,identifier:o.data.identifier};r.dispatchEvent(new MessageEvent(e,{data:{name:l.name,handler:async()=>{u.postMessage({type:i,name:l.name,identifier:l.identifier}),await new Promise(s=>{let d=f=>{if(f==null||f.data==null)return;let c={type:f.data.type,name:f.data.name,identifier:f.data.identifier};c.type===n&&c.identifier===l.identifier&&(u.removeEventListener("message",d),s())};u.addEventListener("message",d)})}}}))},Qe=(r,e,t,n)=>async()=>{let i=Re();return globalThis.postMessage({type:e,identifier:i,name:r}),new Promise(u=>{let o=l=>{if(l==null||l.data==null)return;let s={type:l.data.type,identifier:l.data.identifier};s.type===t&&s.identifier===i&&(globalThis.removeEventListener("message",o),u(()=>{globalThis.postMessage({type:n,identifier:i,name:r})}))};globalThis.addEventListener("message",o)})},Ge={singleProcess:!1},Ce=r=>{if(r=Object.assign({},Ge,r),!!globalThis.document||r.singleProcess){let t=new EventTarget;return ae.addEventListener("message",Oe(t,"requestReadLock",oe,ue,le)),ae.addEventListener("message",Oe(t,"requestWriteLock",ce,fe,he)),t}return{isWorker:!0,readLock:t=>Qe(t,oe,le,ue),writeLock:t=>Qe(t,ce,he,fe)}};var I={},x;async function de(r,e){let t,n=new Promise(i=>{t=i});return r.add(async()=>se((async()=>{await new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})),n}var Ve=(r,e)=>{if(x.isWorker===!0)return{readLock:x.readLock(r,e),writeLock:x.writeLock(r,e)};let t=new re({concurrency:1}),n;return{async readLock(){if(n!=null)return de(n,e);n=new re({concurrency:e.concurrency,autoStart:!1});let i=n,u=de(n,e);return t.add(async()=>{i.start(),await i.onIdle().then(()=>{n===i&&(n=null)})}),u},async writeLock(){return n=null,de(t,e)}}},Ye={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function ke(r){let e=Object.assign({},Ye,r);return x==null&&(x=Ce(e),x.isWorker!==!0&&(x.addEventListener("requestReadLock",t=>{I[t.data.name]!=null&&I[t.data.name].readLock().then(async n=>t.data.handler().finally(()=>{n()}))}),x.addEventListener("requestWriteLock",async t=>{I[t.data.name]!=null&&I[t.data.name].writeLock().then(async n=>t.data.handler().finally(()=>{n()}))}))),I[e.name]==null&&(I[e.name]=Ve(e.name,e)),I[e.name]}return De(Be);})();
"use strict";var Mortice=(()=>{var H=Object.create;var b=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var ee=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),te=(r,e)=>{for(var t in e)b(r,t,{get:e[t],enumerable:!0})},M=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of X(e))!j.call(r,i)&&i!==t&&b(r,i,{get:()=>e[i],enumerable:!(n=J(e,i))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?H(Z(r)):{},M(e||!r||!r.__esModule?b(t,"default",{value:r,enumerable:!0}):t,r)),ne=r=>M(b({},"__esModule",{value:!0}),r);var Q=ee((fe,I)=>{"use strict";var ie=Object.prototype.hasOwnProperty,d="~";function w(){}Object.create&&(w.prototype=Object.create(null),new w().__proto__||(d=!1));function se(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function D(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var a=new se(t,n||r,i),o=d?d+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],a]:r._events[o].push(a):(r._events[o]=a,r._eventsCount++),r}function x(r,e){--r._eventsCount===0?r._events=new w:delete r._events[e]}function h(){this._events=new w,this._eventsCount=0}h.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)ie.call(t,n)&&e.push(d?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};h.prototype.listeners=function(e){var t=d?d+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=new Array(a);i<a;i++)o[i]=n[i].fn;return o};h.prototype.listenerCount=function(e){var t=d?d+e:e,n=this._events[t];return n?n.fn?1:n.length:0};h.prototype.emit=function(e,t,n,i,a,o){var c=d?d+e:e;if(!this._events[c])return!1;var s=this._events[c],f=arguments.length,l,u;if(s.fn){switch(s.once&&this.removeListener(e,s.fn,void 0,!0),f){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,t),!0;case 3:return s.fn.call(s.context,t,n),!0;case 4:return s.fn.call(s.context,t,n,i),!0;case 5:return s.fn.call(s.context,t,n,i,a),!0;case 6:return s.fn.call(s.context,t,n,i,a,o),!0}for(u=1,l=new Array(f-1);u<f;u++)l[u-1]=arguments[u];s.fn.apply(s.context,l)}else{var m=s.length,_;for(u=0;u<m;u++)switch(s[u].once&&this.removeListener(e,s[u].fn,void 0,!0),f){case 1:s[u].fn.call(s[u].context);break;case 2:s[u].fn.call(s[u].context,t);break;case 3:s[u].fn.call(s[u].context,t,n);break;case 4:s[u].fn.call(s[u].context,t,n,i);break;default:if(!l)for(_=1,l=new Array(f-1);_<f;_++)l[_-1]=arguments[_];s[u].fn.apply(s[u].context,l)}}return!0};h.prototype.on=function(e,t,n){return D(this,e,t,n,!1)};h.prototype.once=function(e,t,n){return D(this,e,t,n,!0)};h.prototype.removeListener=function(e,t,n,i){var a=d?d+e:e;if(!this._events[a])return this;if(!t)return x(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&x(this,a);else{for(var c=0,s=[],f=o.length;c<f;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&s.push(o[c]);s.length?this._events[a]=s.length===1?s[0]:s:x(this,a)}return this};h.prototype.removeAllListeners=function(e){var t;return e?(t=d?d+e:e,this._events[t]&&x(this,t)):(this._events=new w,this._eventsCount=0),this};h.prototype.off=h.prototype.removeListener;h.prototype.addListener=h.prototype.on;h.prefixed=d;h.EventEmitter=h;typeof I<"u"&&(I.exports=h)});var le={};te(le,{default:()=>Y});var O=re(Q(),1);var L=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},C=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},$=r=>globalThis.DOMException===void 0?new C(r):new DOMException(r),F=r=>{let e=r.reason===void 0?$("This operation was aborted."):r.reason;return e instanceof Error?e:$(e)};function T(r,e){let{milliseconds:t,fallback:n,message:i,customTimers:a={setTimeout,clearTimeout}}=e,o,s=new Promise((f,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:m}=e;m.aborted&&l(F(m)),m.addEventListener("abort",()=>{l(F(m))})}if(t===Number.POSITIVE_INFINITY){r.then(f,l);return}let u=new L;o=a.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(m){l(m)}return}typeof r.cancel=="function"&&r.cancel(),i===!1?f():i instanceof Error?l(i):(u.message=i??`Promise timed out after ${t} milliseconds`,l(u))},t),(async()=>{try{f(await r)}catch(m){l(m)}})()}).finally(()=>{s.clear()});return s.clear=()=>{a.clearTimeout.call(void 0,o),o=void 0},s}function k(r,e,t){let n=0,i=r.length;for(;i>0;){let a=Math.trunc(i/2),o=n+a;t(r[o],e)<=0?(n=++o,i-=a+1):i=a}return n}var R=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let i=k(this.#e,n,(a,o)=>o.priority-a.priority);this.#e.splice(i,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var v=class extends O.default{#e;#a;#s=0;#d;#o;#m=0;#r;#u;#t;#p;#n=0;#l;#i;#E;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:R,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#a=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#o=e.interval,this.#t=new e.queueClass,this.#p=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#E=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#g(){return this.#a||this.#s<this.#d}get#_(){return this.#n<this.#l}#w(){this.#n--,this.#c(),this.emit("next")}#L(){this.#v(),this.#y(),this.#u=void 0}get#T(){let e=Date.now();if(this.#r===void 0){let t=this.#m-e;if(t<0)this.#s=this.#e?this.#n:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#L()},t)),!0}return!1}#c(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#T;if(this.#g&&this.#_){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#a||this.#r!==void 0||(this.#r=setInterval(()=>{this.#v()},this.#o),this.#m=Date.now()+this.#o)}#v(){this.#s===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#s=this.#e?this.#n:0,this.#f()}#f(){for(;this.#c(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#f()}async#R(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#E,...t},new Promise((n,i)=>{this.#t.enqueue(async()=>{this.#n++,this.#s++;try{t.signal?.throwIfAborted();let a=e({signal:t.signal});t.timeout&&(a=T(Promise.resolve(a),{milliseconds:t.timeout})),t.signal&&(a=Promise.race([a,this.#R(t.signal)]));let o=await a;n(o),this.emit("completed",o)}catch(a){if(a instanceof L&&!t.throwOnTimeout){n();return}i(a),this.emit("error",a)}finally{this.#w()}},t),this.emit("add"),this.#c()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#i?(this.#i=!1,this.#f(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#p}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#h("next",()=>this.#t.size<e)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#h("idle")}async#h(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#i}};var p={},g=r=>{r.addEventListener("message",e=>{g.dispatchEvent("message",r,e)}),r.port!=null&&r.port.addEventListener("message",e=>{g.dispatchEvent("message",r,e)})};g.addEventListener=(r,e)=>{p[r]==null&&(p[r]=[]),p[r].push(e)};g.removeEventListener=(r,e)=>{p[r]!=null&&(p[r]=p[r].filter(t=>t===e))};g.dispatchEvent=function(r,e,t){p[r]!=null&&p[r].forEach(n=>n(e,t))};var A=g;var P="lock:worker:request-read",S="lock:worker:release-read",W="lock:master:grant-read",K="lock:worker:request-write",N="lock:worker:release-write",q="lock:master:grant-write";var B=(r=21)=>Math.random().toString().substring(2);var G=(r,e,t,n,i)=>(a,o)=>{if(o.data.type!==t)return;let c={type:o.data.type,name:o.data.name,identifier:o.data.identifier};r.dispatchEvent(new MessageEvent(e,{data:{name:c.name,handler:async()=>{a.postMessage({type:i,name:c.name,identifier:c.identifier}),await new Promise(s=>{let f=l=>{if(l==null||l.data==null)return;let u={type:l.data.type,name:l.data.name,identifier:l.data.identifier};u.type===n&&u.identifier===c.identifier&&(a.removeEventListener("message",f),s())};a.addEventListener("message",f)})}}}))},U=(r,e,t,n)=>async()=>{let i=B();return globalThis.postMessage({type:e,identifier:i,name:r}),new Promise(a=>{let o=c=>{if(c==null||c.data==null)return;let s={type:c.data.type,identifier:c.data.identifier};s.type===t&&s.identifier===i&&(globalThis.removeEventListener("message",o),a(()=>{globalThis.postMessage({type:n,identifier:i,name:r})}))};globalThis.addEventListener("message",o)})},ae={singleProcess:!1},V=r=>{if(r=Object.assign({},ae,r),!!globalThis.document||r.singleProcess){let t=new EventTarget;return A.addEventListener("message",G(t,"requestReadLock",P,S,W)),A.addEventListener("message",G(t,"requestWriteLock",K,N,q)),t}return{isWorker:!0,readLock:t=>U(t,P,W,S),writeLock:t=>U(t,K,q,N)}};var y={},E;async function z(r,e){let t,n=new Promise(i=>{t=i});return r.add(async()=>T((async()=>{await new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})),n}var oe=(r,e)=>{if(E.isWorker===!0)return{readLock:E.readLock(r,e),writeLock:E.writeLock(r,e)};let t=new v({concurrency:1}),n;return{async readLock(){if(n!=null)return z(n,e);n=new v({concurrency:e.concurrency,autoStart:!1});let i=n,a=z(n,e);return t.add(async()=>{i.start(),await i.onIdle().then(()=>{n===i&&(n=null)})}),a},async writeLock(){return n=null,z(t,e)}}},ue={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function Y(r){let e=Object.assign({},ue,r);return E==null&&(E=V(e),E.isWorker!==!0&&(E.addEventListener("requestReadLock",t=>{y[t.data.name]!=null&&y[t.data.name].readLock().then(async n=>t.data.handler().finally(()=>{n()}))}),E.addEventListener("requestWriteLock",async t=>{y[t.data.name]!=null&&y[t.data.name].writeLock().then(async n=>t.data.handler().finally(()=>{n()}))}))),y[e.name]==null&&(y[e.name]=oe(e.name,e)),y[e.name]}return ne(le);})();
return Mortice}));

@@ -214,3 +214,3 @@ "use strict";

// node_modules/p-queue/node_modules/p-timeout/index.js
// node_modules/p-timeout/index.js
var TimeoutError = class extends Error {

@@ -234,16 +234,14 @@ constructor(message) {

};
function pTimeout(promise, milliseconds, fallback, options) {
function pTimeout(promise, options) {
const {
milliseconds,
fallback,
message,
customTimers = { setTimeout, clearTimeout }
} = options;
let timer;
const cancelablePromise = new Promise((resolve, reject) => {
const wrappedPromise = new Promise((resolve, reject) => {
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
}
if (milliseconds === Number.POSITIVE_INFINITY) {
resolve(promise);
return;
}
options = {
customTimers: { setTimeout, clearTimeout },
...options
};
if (options.signal) {

@@ -258,4 +256,9 @@ const { signal } = options;

}
timer = options.customTimers.setTimeout.call(void 0, () => {
if (typeof fallback === "function") {
if (milliseconds === Number.POSITIVE_INFINITY) {
promise.then(resolve, reject);
return;
}
const timeoutError = new TimeoutError();
timer = customTimers.setTimeout.call(void 0, () => {
if (fallback) {
try {

@@ -268,8 +271,13 @@ resolve(fallback());

}
const message = typeof fallback === "string" ? fallback : `Promise timed out after ${milliseconds} milliseconds`;
const timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);
if (typeof promise.cancel === "function") {
promise.cancel();
}
reject(timeoutError);
if (message === false) {
resolve();
} else if (message instanceof Error) {
reject(message);
} else {
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
reject(timeoutError);
}
}, milliseconds);

@@ -281,9 +289,10 @@ (async () => {

reject(error);
} finally {
options.customTimers.clearTimeout.call(void 0, timer);
}
})();
});
const cancelablePromise = wrappedPromise.finally(() => {
cancelablePromise.clear();
});
cancelablePromise.clear = () => {
clearTimeout(timer);
customTimers.clearTimeout.call(void 0, timer);
timer = void 0;

@@ -312,14 +321,4 @@ };

// node_modules/p-queue/dist/priority-queue.js
var __classPrivateFieldGet = function(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PriorityQueue_queue;
var PriorityQueue = class {
constructor() {
_PriorityQueue_queue.set(this, []);
}
#queue = [];
enqueue(run2, options) {

@@ -334,94 +333,47 @@ options = {

};
if (this.size && __classPrivateFieldGet(this, _PriorityQueue_queue, "f")[this.size - 1].priority >= options.priority) {
__classPrivateFieldGet(this, _PriorityQueue_queue, "f").push(element);
if (this.size && this.#queue[this.size - 1].priority >= options.priority) {
this.#queue.push(element);
return;
}
const index = lowerBound(__classPrivateFieldGet(this, _PriorityQueue_queue, "f"), element, (a, b) => b.priority - a.priority);
__classPrivateFieldGet(this, _PriorityQueue_queue, "f").splice(index, 0, element);
const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);
this.#queue.splice(index, 0, element);
}
dequeue() {
const item = __classPrivateFieldGet(this, _PriorityQueue_queue, "f").shift();
return item === null || item === void 0 ? void 0 : item.run;
const item = this.#queue.shift();
return item?.run;
}
filter(options) {
return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").filter((element) => element.priority === options.priority).map((element) => element.run);
return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
}
get size() {
return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").length;
return this.#queue.length;
}
};
_PriorityQueue_queue = /* @__PURE__ */ new WeakMap();
var priority_queue_default = PriorityQueue;
// node_modules/p-queue/dist/index.js
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
var __classPrivateFieldGet2 = function(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PQueue_instances;
var _PQueue_carryoverConcurrencyCount;
var _PQueue_isIntervalIgnored;
var _PQueue_intervalCount;
var _PQueue_intervalCap;
var _PQueue_interval;
var _PQueue_intervalEnd;
var _PQueue_intervalId;
var _PQueue_timeoutId;
var _PQueue_queue;
var _PQueue_queueClass;
var _PQueue_pending;
var _PQueue_concurrency;
var _PQueue_isPaused;
var _PQueue_throwOnTimeout;
var _PQueue_doesIntervalAllowAnother_get;
var _PQueue_doesConcurrentAllowAnother_get;
var _PQueue_next;
var _PQueue_onResumeInterval;
var _PQueue_isIntervalPaused_get;
var _PQueue_tryToStartAnother;
var _PQueue_initializeIntervalIfNeeded;
var _PQueue_onInterval;
var _PQueue_processQueue;
var _PQueue_throwOnAbort;
var _PQueue_onEvent;
var AbortError2 = class extends Error {
};
var PQueue = class extends import_index.default {
#carryoverConcurrencyCount;
#isIntervalIgnored;
#intervalCount = 0;
#intervalCap;
#interval;
#intervalEnd = 0;
#intervalId;
#timeoutId;
#queue;
#queueClass;
#pending = 0;
// The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
#concurrency;
#isPaused;
#throwOnTimeout;
/**
Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
Applies to each future operation.
*/
timeout;
// TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
constructor(options) {
var _a, _b, _c, _d;
super();
_PQueue_instances.add(this);
_PQueue_carryoverConcurrencyCount.set(this, void 0);
_PQueue_isIntervalIgnored.set(this, void 0);
_PQueue_intervalCount.set(this, 0);
_PQueue_intervalCap.set(this, void 0);
_PQueue_interval.set(this, void 0);
_PQueue_intervalEnd.set(this, 0);
_PQueue_intervalId.set(this, void 0);
_PQueue_timeoutId.set(this, void 0);
_PQueue_queue.set(this, void 0);
_PQueue_queueClass.set(this, void 0);
_PQueue_pending.set(this, 0);
_PQueue_concurrency.set(this, void 0);
_PQueue_isPaused.set(this, void 0);
_PQueue_throwOnTimeout.set(this, void 0);
Object.defineProperty(this, "timeout", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
options = {

@@ -433,24 +385,110 @@ carryoverConcurrencyCount: false,

autoStart: true,
queueClass: priority_queue_default,
queueClass: PriorityQueue,
...options
};
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(_b = (_a = options.intervalCap) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ""}\` (${typeof options.intervalCap})`);
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
}
if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(_d = (_c = options.interval) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""}\` (${typeof options.interval})`);
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
}
__classPrivateFieldSet(this, _PQueue_carryoverConcurrencyCount, options.carryoverConcurrencyCount, "f");
__classPrivateFieldSet(this, _PQueue_isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0, "f");
__classPrivateFieldSet(this, _PQueue_intervalCap, options.intervalCap, "f");
__classPrivateFieldSet(this, _PQueue_interval, options.interval, "f");
__classPrivateFieldSet(this, _PQueue_queue, new options.queueClass(), "f");
__classPrivateFieldSet(this, _PQueue_queueClass, options.queueClass, "f");
this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;
this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
this.#intervalCap = options.intervalCap;
this.#interval = options.interval;
this.#queue = new options.queueClass();
this.#queueClass = options.queueClass;
this.concurrency = options.concurrency;
this.timeout = options.timeout;
__classPrivateFieldSet(this, _PQueue_throwOnTimeout, options.throwOnTimeout === true, "f");
__classPrivateFieldSet(this, _PQueue_isPaused, options.autoStart === false, "f");
this.#throwOnTimeout = options.throwOnTimeout === true;
this.#isPaused = options.autoStart === false;
}
get #doesIntervalAllowAnother() {
return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;
}
get #doesConcurrentAllowAnother() {
return this.#pending < this.#concurrency;
}
#next() {
this.#pending--;
this.#tryToStartAnother();
this.emit("next");
}
#onResumeInterval() {
this.#onInterval();
this.#initializeIntervalIfNeeded();
this.#timeoutId = void 0;
}
get #isIntervalPaused() {
const now = Date.now();
if (this.#intervalId === void 0) {
const delay2 = this.#intervalEnd - now;
if (delay2 < 0) {
this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
} else {
if (this.#timeoutId === void 0) {
this.#timeoutId = setTimeout(() => {
this.#onResumeInterval();
}, delay2);
}
return true;
}
}
return false;
}
#tryToStartAnother() {
if (this.#queue.size === 0) {
if (this.#intervalId) {
clearInterval(this.#intervalId);
}
this.#intervalId = void 0;
this.emit("empty");
if (this.#pending === 0) {
this.emit("idle");
}
return false;
}
if (!this.#isPaused) {
const canInitializeInterval = !this.#isIntervalPaused;
if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
const job = this.#queue.dequeue();
if (!job) {
return false;
}
this.emit("active");
job();
if (canInitializeInterval) {
this.#initializeIntervalIfNeeded();
}
return true;
}
}
return false;
}
#initializeIntervalIfNeeded() {
if (this.#isIntervalIgnored || this.#intervalId !== void 0) {
return;
}
this.#intervalId = setInterval(() => {
this.#onInterval();
}, this.#interval);
this.#intervalEnd = Date.now() + this.#interval;
}
#onInterval() {
if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
clearInterval(this.#intervalId);
this.#intervalId = void 0;
}
this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
this.#processQueue();
}
/**
Executes all queued functions until it reaches the limit.
*/
#processQueue() {
while (this.#tryToStartAnother()) {
}
}
get concurrency() {
return __classPrivateFieldGet2(this, _PQueue_concurrency, "f");
return this.#concurrency;
}

@@ -461,27 +499,30 @@ set concurrency(newConcurrency) {

}
__classPrivateFieldSet(this, _PQueue_concurrency, newConcurrency, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
this.#concurrency = newConcurrency;
this.#processQueue();
}
async #throwOnAbort(signal) {
return new Promise((_resolve, reject) => {
signal.addEventListener("abort", () => {
reject(signal.reason);
}, { once: true });
});
}
async add(function_, options = {}) {
options = {
timeout: this.timeout,
throwOnTimeout: __classPrivateFieldGet2(this, _PQueue_throwOnTimeout, "f"),
throwOnTimeout: this.#throwOnTimeout,
...options
};
return new Promise((resolve, reject) => {
__classPrivateFieldGet2(this, _PQueue_queue, "f").enqueue(async () => {
var _a;
var _b, _c;
__classPrivateFieldSet(this, _PQueue_pending, (_b = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _b++, _b), "f");
__classPrivateFieldSet(this, _PQueue_intervalCount, (_c = __classPrivateFieldGet2(this, _PQueue_intervalCount, "f"), _c++, _c), "f");
this.#queue.enqueue(async () => {
this.#pending++;
this.#intervalCount++;
try {
if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
throw new AbortError2("The task was aborted.");
}
options.signal?.throwIfAborted();
let operation = function_({ signal: options.signal });
if (options.timeout) {
operation = pTimeout(Promise.resolve(operation), options.timeout);
operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
}
if (options.signal) {
operation = Promise.race([operation, __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_throwOnAbort).call(this, options.signal)]);
operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);
}

@@ -499,7 +540,7 @@ const result = await operation;

} finally {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_next).call(this);
this.#next();
}
}, options);
this.emit("add");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this);
this.#tryToStartAnother();
});

@@ -514,7 +555,7 @@ }

start() {
if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) {
if (!this.#isPaused) {
return this;
}
__classPrivateFieldSet(this, _PQueue_isPaused, false, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
this.#isPaused = false;
this.#processQueue();
return this;

@@ -526,3 +567,3 @@ }

pause() {
__classPrivateFieldSet(this, _PQueue_isPaused, true, "f");
this.#isPaused = true;
}

@@ -533,3 +574,3 @@ /**

clear() {
__classPrivateFieldSet(this, _PQueue_queue, new (__classPrivateFieldGet2(this, _PQueue_queueClass, "f"))(), "f");
this.#queue = new this.#queueClass();
}

@@ -542,6 +583,6 @@ /**

async onEmpty() {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (this.#queue.size === 0) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "empty");
await this.#onEvent("empty");
}

@@ -556,6 +597,6 @@ /**

async onSizeLessThan(limit) {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit) {
if (this.#queue.size < limit) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "next", () => __classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit);
await this.#onEvent("next", () => this.#queue.size < limit);
}

@@ -568,7 +609,19 @@ /**

async onIdle() {
if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (this.#pending === 0 && this.#queue.size === 0) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "idle");
await this.#onEvent("idle");
}
async #onEvent(event, filter) {
return new Promise((resolve) => {
const listener = () => {
if (filter && !filter()) {
return;
}
this.off(event, listener);
resolve();
};
this.on(event, listener);
});
}
/**

@@ -578,3 +631,3 @@ Size of the queue, the number of queued items waiting to run.

get size() {
return __classPrivateFieldGet2(this, _PQueue_queue, "f").size;
return this.#queue.size;
}

@@ -587,3 +640,3 @@ /**

sizeBy(options) {
return __classPrivateFieldGet2(this, _PQueue_queue, "f").filter(options).length;
return this.#queue.filter(options).length;
}

@@ -594,3 +647,3 @@ /**

get pending() {
return __classPrivateFieldGet2(this, _PQueue_pending, "f");
return this.#pending;
}

@@ -601,184 +654,6 @@ /**

get isPaused() {
return __classPrivateFieldGet2(this, _PQueue_isPaused, "f");
return this.#isPaused;
}
};
_PQueue_carryoverConcurrencyCount = /* @__PURE__ */ new WeakMap(), _PQueue_isIntervalIgnored = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCount = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCap = /* @__PURE__ */ new WeakMap(), _PQueue_interval = /* @__PURE__ */ new WeakMap(), _PQueue_intervalEnd = /* @__PURE__ */ new WeakMap(), _PQueue_intervalId = /* @__PURE__ */ new WeakMap(), _PQueue_timeoutId = /* @__PURE__ */ new WeakMap(), _PQueue_queue = /* @__PURE__ */ new WeakMap(), _PQueue_queueClass = /* @__PURE__ */ new WeakMap(), _PQueue_pending = /* @__PURE__ */ new WeakMap(), _PQueue_concurrency = /* @__PURE__ */ new WeakMap(), _PQueue_isPaused = /* @__PURE__ */ new WeakMap(), _PQueue_throwOnTimeout = /* @__PURE__ */ new WeakMap(), _PQueue_instances = /* @__PURE__ */ new WeakSet(), _PQueue_doesIntervalAllowAnother_get = function _PQueue_doesIntervalAllowAnother_get2() {
return __classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalCount, "f") < __classPrivateFieldGet2(this, _PQueue_intervalCap, "f");
}, _PQueue_doesConcurrentAllowAnother_get = function _PQueue_doesConcurrentAllowAnother_get2() {
return __classPrivateFieldGet2(this, _PQueue_pending, "f") < __classPrivateFieldGet2(this, _PQueue_concurrency, "f");
}, _PQueue_next = function _PQueue_next2() {
var _a;
__classPrivateFieldSet(this, _PQueue_pending, (_a = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _a--, _a), "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this);
this.emit("next");
}, _PQueue_onResumeInterval = function _PQueue_onResumeInterval2() {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this);
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this);
__classPrivateFieldSet(this, _PQueue_timeoutId, void 0, "f");
}, _PQueue_isIntervalPaused_get = function _PQueue_isIntervalPaused_get2() {
const now = Date.now();
if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f") === void 0) {
const delay2 = __classPrivateFieldGet2(this, _PQueue_intervalEnd, "f") - now;
if (delay2 < 0) {
__classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f");
} else {
if (__classPrivateFieldGet2(this, _PQueue_timeoutId, "f") === void 0) {
__classPrivateFieldSet(this, _PQueue_timeoutId, setTimeout(() => {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onResumeInterval).call(this);
}, delay2), "f");
}
return true;
}
}
return false;
}, _PQueue_tryToStartAnother = function _PQueue_tryToStartAnother2() {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f")) {
clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f"));
}
__classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f");
this.emit("empty");
if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0) {
this.emit("idle");
}
return false;
}
if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) {
const canInitializeInterval = !__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_isIntervalPaused_get);
if (__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesIntervalAllowAnother_get) && __classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesConcurrentAllowAnother_get)) {
const job = __classPrivateFieldGet2(this, _PQueue_queue, "f").dequeue();
if (!job) {
return false;
}
this.emit("active");
job();
if (canInitializeInterval) {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this);
}
return true;
}
}
return false;
}, _PQueue_initializeIntervalIfNeeded = function _PQueue_initializeIntervalIfNeeded2() {
if (__classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalId, "f") !== void 0) {
return;
}
__classPrivateFieldSet(this, _PQueue_intervalId, setInterval(() => {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this);
}, __classPrivateFieldGet2(this, _PQueue_interval, "f")), "f");
__classPrivateFieldSet(this, _PQueue_intervalEnd, Date.now() + __classPrivateFieldGet2(this, _PQueue_interval, "f"), "f");
}, _PQueue_onInterval = function _PQueue_onInterval2() {
if (__classPrivateFieldGet2(this, _PQueue_intervalCount, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_intervalId, "f")) {
clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f"));
__classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f");
}
__classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
}, _PQueue_processQueue = function _PQueue_processQueue2() {
while (__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this)) {
}
}, _PQueue_throwOnAbort = async function _PQueue_throwOnAbort2(signal) {
return new Promise((_resolve, reject) => {
signal.addEventListener("abort", () => {
reject(new AbortError2("The task was aborted."));
}, { once: true });
});
}, _PQueue_onEvent = async function _PQueue_onEvent2(event, filter) {
return new Promise((resolve) => {
const listener = () => {
if (filter && !filter()) {
return;
}
this.off(event, listener);
resolve();
};
this.on(event, listener);
});
};
var dist_default = PQueue;
// node_modules/p-timeout/index.js
var TimeoutError2 = class extends Error {
constructor(message) {
super(message);
this.name = "TimeoutError";
}
};
var AbortError3 = class extends Error {
constructor(message) {
super();
this.name = "AbortError";
this.message = message;
}
};
var getDOMException2 = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError3(errorMessage) : new DOMException(errorMessage);
var getAbortedReason2 = (signal) => {
const reason = signal.reason === void 0 ? getDOMException2("This operation was aborted.") : signal.reason;
return reason instanceof Error ? reason : getDOMException2(reason);
};
function pTimeout2(promise, options) {
const {
milliseconds,
fallback,
message,
customTimers = { setTimeout, clearTimeout }
} = options;
let timer;
const wrappedPromise = new Promise((resolve, reject) => {
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
}
if (options.signal) {
const { signal } = options;
if (signal.aborted) {
reject(getAbortedReason2(signal));
}
signal.addEventListener("abort", () => {
reject(getAbortedReason2(signal));
});
}
if (milliseconds === Number.POSITIVE_INFINITY) {
promise.then(resolve, reject);
return;
}
const timeoutError = new TimeoutError2();
timer = customTimers.setTimeout.call(void 0, () => {
if (fallback) {
try {
resolve(fallback());
} catch (error) {
reject(error);
}
return;
}
if (typeof promise.cancel === "function") {
promise.cancel();
}
if (message === false) {
resolve();
} else if (message instanceof Error) {
reject(message);
} else {
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
reject(timeoutError);
}
}, milliseconds);
(async () => {
try {
resolve(await promise);
} catch (error) {
reject(error);
}
})();
});
const cancelablePromise = wrappedPromise.finally(() => {
cancelablePromise.clear();
});
cancelablePromise.clear = () => {
customTimers.clearTimeout.call(void 0, timer);
timer = void 0;
};
return cancelablePromise;
}
// node_modules/observable-webworkers/dist/src/index.js

@@ -930,3 +805,3 @@ var events = {};

});
void queue.add(async () => pTimeout2((async () => {
void queue.add(async () => pTimeout((async () => {
await new Promise((resolve) => {

@@ -949,3 +824,3 @@ res(() => {

}
const masterQueue = new dist_default({ concurrency: 1 });
const masterQueue = new PQueue({ concurrency: 1 });
let readQueue;

@@ -957,3 +832,3 @@ return {

}
readQueue = new dist_default({
readQueue = new PQueue({
concurrency: options.concurrency,

@@ -960,0 +835,0 @@ autoStart: false

@@ -214,3 +214,3 @@ "use strict";

// node_modules/p-queue/node_modules/p-timeout/index.js
// node_modules/p-timeout/index.js
var TimeoutError = class extends Error {

@@ -234,16 +234,14 @@ constructor(message) {

};
function pTimeout(promise, milliseconds, fallback, options) {
function pTimeout(promise, options) {
const {
milliseconds,
fallback,
message,
customTimers = { setTimeout, clearTimeout }
} = options;
let timer;
const cancelablePromise = new Promise((resolve, reject) => {
const wrappedPromise = new Promise((resolve, reject) => {
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
}
if (milliseconds === Number.POSITIVE_INFINITY) {
resolve(promise);
return;
}
options = {
customTimers: { setTimeout, clearTimeout },
...options
};
if (options.signal) {

@@ -258,4 +256,9 @@ const { signal } = options;

}
timer = options.customTimers.setTimeout.call(void 0, () => {
if (typeof fallback === "function") {
if (milliseconds === Number.POSITIVE_INFINITY) {
promise.then(resolve, reject);
return;
}
const timeoutError = new TimeoutError();
timer = customTimers.setTimeout.call(void 0, () => {
if (fallback) {
try {

@@ -268,8 +271,13 @@ resolve(fallback());

}
const message = typeof fallback === "string" ? fallback : `Promise timed out after ${milliseconds} milliseconds`;
const timeoutError = fallback instanceof Error ? fallback : new TimeoutError(message);
if (typeof promise.cancel === "function") {
promise.cancel();
}
reject(timeoutError);
if (message === false) {
resolve();
} else if (message instanceof Error) {
reject(message);
} else {
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
reject(timeoutError);
}
}, milliseconds);

@@ -281,9 +289,10 @@ (async () => {

reject(error);
} finally {
options.customTimers.clearTimeout.call(void 0, timer);
}
})();
});
const cancelablePromise = wrappedPromise.finally(() => {
cancelablePromise.clear();
});
cancelablePromise.clear = () => {
clearTimeout(timer);
customTimers.clearTimeout.call(void 0, timer);
timer = void 0;

@@ -312,14 +321,4 @@ };

// node_modules/p-queue/dist/priority-queue.js
var __classPrivateFieldGet = function(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PriorityQueue_queue;
var PriorityQueue = class {
constructor() {
_PriorityQueue_queue.set(this, []);
}
#queue = [];
enqueue(run2, options) {

@@ -334,94 +333,47 @@ options = {

};
if (this.size && __classPrivateFieldGet(this, _PriorityQueue_queue, "f")[this.size - 1].priority >= options.priority) {
__classPrivateFieldGet(this, _PriorityQueue_queue, "f").push(element);
if (this.size && this.#queue[this.size - 1].priority >= options.priority) {
this.#queue.push(element);
return;
}
const index = lowerBound(__classPrivateFieldGet(this, _PriorityQueue_queue, "f"), element, (a, b) => b.priority - a.priority);
__classPrivateFieldGet(this, _PriorityQueue_queue, "f").splice(index, 0, element);
const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);
this.#queue.splice(index, 0, element);
}
dequeue() {
const item = __classPrivateFieldGet(this, _PriorityQueue_queue, "f").shift();
return item === null || item === void 0 ? void 0 : item.run;
const item = this.#queue.shift();
return item?.run;
}
filter(options) {
return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").filter((element) => element.priority === options.priority).map((element) => element.run);
return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
}
get size() {
return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").length;
return this.#queue.length;
}
};
_PriorityQueue_queue = /* @__PURE__ */ new WeakMap();
var priority_queue_default = PriorityQueue;
// node_modules/p-queue/dist/index.js
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
var __classPrivateFieldGet2 = function(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _PQueue_instances;
var _PQueue_carryoverConcurrencyCount;
var _PQueue_isIntervalIgnored;
var _PQueue_intervalCount;
var _PQueue_intervalCap;
var _PQueue_interval;
var _PQueue_intervalEnd;
var _PQueue_intervalId;
var _PQueue_timeoutId;
var _PQueue_queue;
var _PQueue_queueClass;
var _PQueue_pending;
var _PQueue_concurrency;
var _PQueue_isPaused;
var _PQueue_throwOnTimeout;
var _PQueue_doesIntervalAllowAnother_get;
var _PQueue_doesConcurrentAllowAnother_get;
var _PQueue_next;
var _PQueue_onResumeInterval;
var _PQueue_isIntervalPaused_get;
var _PQueue_tryToStartAnother;
var _PQueue_initializeIntervalIfNeeded;
var _PQueue_onInterval;
var _PQueue_processQueue;
var _PQueue_throwOnAbort;
var _PQueue_onEvent;
var AbortError2 = class extends Error {
};
var PQueue = class extends import_index.default {
#carryoverConcurrencyCount;
#isIntervalIgnored;
#intervalCount = 0;
#intervalCap;
#interval;
#intervalEnd = 0;
#intervalId;
#timeoutId;
#queue;
#queueClass;
#pending = 0;
// The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
#concurrency;
#isPaused;
#throwOnTimeout;
/**
Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
Applies to each future operation.
*/
timeout;
// TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
constructor(options) {
var _a, _b, _c, _d;
super();
_PQueue_instances.add(this);
_PQueue_carryoverConcurrencyCount.set(this, void 0);
_PQueue_isIntervalIgnored.set(this, void 0);
_PQueue_intervalCount.set(this, 0);
_PQueue_intervalCap.set(this, void 0);
_PQueue_interval.set(this, void 0);
_PQueue_intervalEnd.set(this, 0);
_PQueue_intervalId.set(this, void 0);
_PQueue_timeoutId.set(this, void 0);
_PQueue_queue.set(this, void 0);
_PQueue_queueClass.set(this, void 0);
_PQueue_pending.set(this, 0);
_PQueue_concurrency.set(this, void 0);
_PQueue_isPaused.set(this, void 0);
_PQueue_throwOnTimeout.set(this, void 0);
Object.defineProperty(this, "timeout", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
options = {

@@ -433,24 +385,110 @@ carryoverConcurrencyCount: false,

autoStart: true,
queueClass: priority_queue_default,
queueClass: PriorityQueue,
...options
};
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(_b = (_a = options.intervalCap) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ""}\` (${typeof options.intervalCap})`);
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
}
if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(_d = (_c = options.interval) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""}\` (${typeof options.interval})`);
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
}
__classPrivateFieldSet(this, _PQueue_carryoverConcurrencyCount, options.carryoverConcurrencyCount, "f");
__classPrivateFieldSet(this, _PQueue_isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0, "f");
__classPrivateFieldSet(this, _PQueue_intervalCap, options.intervalCap, "f");
__classPrivateFieldSet(this, _PQueue_interval, options.interval, "f");
__classPrivateFieldSet(this, _PQueue_queue, new options.queueClass(), "f");
__classPrivateFieldSet(this, _PQueue_queueClass, options.queueClass, "f");
this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;
this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
this.#intervalCap = options.intervalCap;
this.#interval = options.interval;
this.#queue = new options.queueClass();
this.#queueClass = options.queueClass;
this.concurrency = options.concurrency;
this.timeout = options.timeout;
__classPrivateFieldSet(this, _PQueue_throwOnTimeout, options.throwOnTimeout === true, "f");
__classPrivateFieldSet(this, _PQueue_isPaused, options.autoStart === false, "f");
this.#throwOnTimeout = options.throwOnTimeout === true;
this.#isPaused = options.autoStart === false;
}
get #doesIntervalAllowAnother() {
return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;
}
get #doesConcurrentAllowAnother() {
return this.#pending < this.#concurrency;
}
#next() {
this.#pending--;
this.#tryToStartAnother();
this.emit("next");
}
#onResumeInterval() {
this.#onInterval();
this.#initializeIntervalIfNeeded();
this.#timeoutId = void 0;
}
get #isIntervalPaused() {
const now = Date.now();
if (this.#intervalId === void 0) {
const delay2 = this.#intervalEnd - now;
if (delay2 < 0) {
this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
} else {
if (this.#timeoutId === void 0) {
this.#timeoutId = setTimeout(() => {
this.#onResumeInterval();
}, delay2);
}
return true;
}
}
return false;
}
#tryToStartAnother() {
if (this.#queue.size === 0) {
if (this.#intervalId) {
clearInterval(this.#intervalId);
}
this.#intervalId = void 0;
this.emit("empty");
if (this.#pending === 0) {
this.emit("idle");
}
return false;
}
if (!this.#isPaused) {
const canInitializeInterval = !this.#isIntervalPaused;
if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
const job = this.#queue.dequeue();
if (!job) {
return false;
}
this.emit("active");
job();
if (canInitializeInterval) {
this.#initializeIntervalIfNeeded();
}
return true;
}
}
return false;
}
#initializeIntervalIfNeeded() {
if (this.#isIntervalIgnored || this.#intervalId !== void 0) {
return;
}
this.#intervalId = setInterval(() => {
this.#onInterval();
}, this.#interval);
this.#intervalEnd = Date.now() + this.#interval;
}
#onInterval() {
if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
clearInterval(this.#intervalId);
this.#intervalId = void 0;
}
this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;
this.#processQueue();
}
/**
Executes all queued functions until it reaches the limit.
*/
#processQueue() {
while (this.#tryToStartAnother()) {
}
}
get concurrency() {
return __classPrivateFieldGet2(this, _PQueue_concurrency, "f");
return this.#concurrency;
}

@@ -461,27 +499,30 @@ set concurrency(newConcurrency) {

}
__classPrivateFieldSet(this, _PQueue_concurrency, newConcurrency, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
this.#concurrency = newConcurrency;
this.#processQueue();
}
async #throwOnAbort(signal) {
return new Promise((_resolve, reject) => {
signal.addEventListener("abort", () => {
reject(signal.reason);
}, { once: true });
});
}
async add(function_, options = {}) {
options = {
timeout: this.timeout,
throwOnTimeout: __classPrivateFieldGet2(this, _PQueue_throwOnTimeout, "f"),
throwOnTimeout: this.#throwOnTimeout,
...options
};
return new Promise((resolve, reject) => {
__classPrivateFieldGet2(this, _PQueue_queue, "f").enqueue(async () => {
var _a;
var _b, _c;
__classPrivateFieldSet(this, _PQueue_pending, (_b = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _b++, _b), "f");
__classPrivateFieldSet(this, _PQueue_intervalCount, (_c = __classPrivateFieldGet2(this, _PQueue_intervalCount, "f"), _c++, _c), "f");
this.#queue.enqueue(async () => {
this.#pending++;
this.#intervalCount++;
try {
if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
throw new AbortError2("The task was aborted.");
}
options.signal?.throwIfAborted();
let operation = function_({ signal: options.signal });
if (options.timeout) {
operation = pTimeout(Promise.resolve(operation), options.timeout);
operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
}
if (options.signal) {
operation = Promise.race([operation, __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_throwOnAbort).call(this, options.signal)]);
operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);
}

@@ -499,7 +540,7 @@ const result = await operation;

} finally {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_next).call(this);
this.#next();
}
}, options);
this.emit("add");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this);
this.#tryToStartAnother();
});

@@ -514,7 +555,7 @@ }

start() {
if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) {
if (!this.#isPaused) {
return this;
}
__classPrivateFieldSet(this, _PQueue_isPaused, false, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
this.#isPaused = false;
this.#processQueue();
return this;

@@ -526,3 +567,3 @@ }

pause() {
__classPrivateFieldSet(this, _PQueue_isPaused, true, "f");
this.#isPaused = true;
}

@@ -533,3 +574,3 @@ /**

clear() {
__classPrivateFieldSet(this, _PQueue_queue, new (__classPrivateFieldGet2(this, _PQueue_queueClass, "f"))(), "f");
this.#queue = new this.#queueClass();
}

@@ -542,6 +583,6 @@ /**

async onEmpty() {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (this.#queue.size === 0) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "empty");
await this.#onEvent("empty");
}

@@ -556,6 +597,6 @@ /**

async onSizeLessThan(limit) {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit) {
if (this.#queue.size < limit) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "next", () => __classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit);
await this.#onEvent("next", () => this.#queue.size < limit);
}

@@ -568,7 +609,19 @@ /**

async onIdle() {
if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (this.#pending === 0 && this.#queue.size === 0) {
return;
}
await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "idle");
await this.#onEvent("idle");
}
async #onEvent(event, filter) {
return new Promise((resolve) => {
const listener = () => {
if (filter && !filter()) {
return;
}
this.off(event, listener);
resolve();
};
this.on(event, listener);
});
}
/**

@@ -578,3 +631,3 @@ Size of the queue, the number of queued items waiting to run.

get size() {
return __classPrivateFieldGet2(this, _PQueue_queue, "f").size;
return this.#queue.size;
}

@@ -587,3 +640,3 @@ /**

sizeBy(options) {
return __classPrivateFieldGet2(this, _PQueue_queue, "f").filter(options).length;
return this.#queue.filter(options).length;
}

@@ -594,3 +647,3 @@ /**

get pending() {
return __classPrivateFieldGet2(this, _PQueue_pending, "f");
return this.#pending;
}

@@ -601,184 +654,6 @@ /**

get isPaused() {
return __classPrivateFieldGet2(this, _PQueue_isPaused, "f");
return this.#isPaused;
}
};
_PQueue_carryoverConcurrencyCount = /* @__PURE__ */ new WeakMap(), _PQueue_isIntervalIgnored = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCount = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCap = /* @__PURE__ */ new WeakMap(), _PQueue_interval = /* @__PURE__ */ new WeakMap(), _PQueue_intervalEnd = /* @__PURE__ */ new WeakMap(), _PQueue_intervalId = /* @__PURE__ */ new WeakMap(), _PQueue_timeoutId = /* @__PURE__ */ new WeakMap(), _PQueue_queue = /* @__PURE__ */ new WeakMap(), _PQueue_queueClass = /* @__PURE__ */ new WeakMap(), _PQueue_pending = /* @__PURE__ */ new WeakMap(), _PQueue_concurrency = /* @__PURE__ */ new WeakMap(), _PQueue_isPaused = /* @__PURE__ */ new WeakMap(), _PQueue_throwOnTimeout = /* @__PURE__ */ new WeakMap(), _PQueue_instances = /* @__PURE__ */ new WeakSet(), _PQueue_doesIntervalAllowAnother_get = function _PQueue_doesIntervalAllowAnother_get2() {
return __classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalCount, "f") < __classPrivateFieldGet2(this, _PQueue_intervalCap, "f");
}, _PQueue_doesConcurrentAllowAnother_get = function _PQueue_doesConcurrentAllowAnother_get2() {
return __classPrivateFieldGet2(this, _PQueue_pending, "f") < __classPrivateFieldGet2(this, _PQueue_concurrency, "f");
}, _PQueue_next = function _PQueue_next2() {
var _a;
__classPrivateFieldSet(this, _PQueue_pending, (_a = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _a--, _a), "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this);
this.emit("next");
}, _PQueue_onResumeInterval = function _PQueue_onResumeInterval2() {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this);
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this);
__classPrivateFieldSet(this, _PQueue_timeoutId, void 0, "f");
}, _PQueue_isIntervalPaused_get = function _PQueue_isIntervalPaused_get2() {
const now = Date.now();
if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f") === void 0) {
const delay2 = __classPrivateFieldGet2(this, _PQueue_intervalEnd, "f") - now;
if (delay2 < 0) {
__classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f");
} else {
if (__classPrivateFieldGet2(this, _PQueue_timeoutId, "f") === void 0) {
__classPrivateFieldSet(this, _PQueue_timeoutId, setTimeout(() => {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onResumeInterval).call(this);
}, delay2), "f");
}
return true;
}
}
return false;
}, _PQueue_tryToStartAnother = function _PQueue_tryToStartAnother2() {
if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) {
if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f")) {
clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f"));
}
__classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f");
this.emit("empty");
if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0) {
this.emit("idle");
}
return false;
}
if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) {
const canInitializeInterval = !__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_isIntervalPaused_get);
if (__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesIntervalAllowAnother_get) && __classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesConcurrentAllowAnother_get)) {
const job = __classPrivateFieldGet2(this, _PQueue_queue, "f").dequeue();
if (!job) {
return false;
}
this.emit("active");
job();
if (canInitializeInterval) {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this);
}
return true;
}
}
return false;
}, _PQueue_initializeIntervalIfNeeded = function _PQueue_initializeIntervalIfNeeded2() {
if (__classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalId, "f") !== void 0) {
return;
}
__classPrivateFieldSet(this, _PQueue_intervalId, setInterval(() => {
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this);
}, __classPrivateFieldGet2(this, _PQueue_interval, "f")), "f");
__classPrivateFieldSet(this, _PQueue_intervalEnd, Date.now() + __classPrivateFieldGet2(this, _PQueue_interval, "f"), "f");
}, _PQueue_onInterval = function _PQueue_onInterval2() {
if (__classPrivateFieldGet2(this, _PQueue_intervalCount, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_intervalId, "f")) {
clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f"));
__classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f");
}
__classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f");
__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this);
}, _PQueue_processQueue = function _PQueue_processQueue2() {
while (__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this)) {
}
}, _PQueue_throwOnAbort = async function _PQueue_throwOnAbort2(signal) {
return new Promise((_resolve, reject) => {
signal.addEventListener("abort", () => {
reject(new AbortError2("The task was aborted."));
}, { once: true });
});
}, _PQueue_onEvent = async function _PQueue_onEvent2(event, filter) {
return new Promise((resolve) => {
const listener = () => {
if (filter && !filter()) {
return;
}
this.off(event, listener);
resolve();
};
this.on(event, listener);
});
};
var dist_default = PQueue;
// node_modules/p-timeout/index.js
var TimeoutError2 = class extends Error {
constructor(message) {
super(message);
this.name = "TimeoutError";
}
};
var AbortError3 = class extends Error {
constructor(message) {
super();
this.name = "AbortError";
this.message = message;
}
};
var getDOMException2 = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError3(errorMessage) : new DOMException(errorMessage);
var getAbortedReason2 = (signal) => {
const reason = signal.reason === void 0 ? getDOMException2("This operation was aborted.") : signal.reason;
return reason instanceof Error ? reason : getDOMException2(reason);
};
function pTimeout2(promise, options) {
const {
milliseconds,
fallback,
message,
customTimers = { setTimeout, clearTimeout }
} = options;
let timer;
const wrappedPromise = new Promise((resolve, reject) => {
if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
}
if (options.signal) {
const { signal } = options;
if (signal.aborted) {
reject(getAbortedReason2(signal));
}
signal.addEventListener("abort", () => {
reject(getAbortedReason2(signal));
});
}
if (milliseconds === Number.POSITIVE_INFINITY) {
promise.then(resolve, reject);
return;
}
const timeoutError = new TimeoutError2();
timer = customTimers.setTimeout.call(void 0, () => {
if (fallback) {
try {
resolve(fallback());
} catch (error) {
reject(error);
}
return;
}
if (typeof promise.cancel === "function") {
promise.cancel();
}
if (message === false) {
resolve();
} else if (message instanceof Error) {
reject(message);
} else {
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
reject(timeoutError);
}
}, milliseconds);
(async () => {
try {
resolve(await promise);
} catch (error) {
reject(error);
}
})();
});
const cancelablePromise = wrappedPromise.finally(() => {
cancelablePromise.clear();
});
cancelablePromise.clear = () => {
customTimers.clearTimeout.call(void 0, timer);
timer = void 0;
};
return cancelablePromise;
}
// node_modules/observable-webworkers/dist/src/index.js

@@ -930,3 +805,3 @@ var events = {};

});
void queue.add(async () => pTimeout2((async () => {
void queue.add(async () => pTimeout((async () => {
await new Promise((resolve) => {

@@ -949,3 +824,3 @@ res(() => {

}
const masterQueue = new dist_default({ concurrency: 1 });
const masterQueue = new PQueue({ concurrency: 1 });
let readQueue;

@@ -957,3 +832,3 @@ return {

}
readQueue = new dist_default({
readQueue = new PQueue({
concurrency: options.concurrency,

@@ -960,0 +835,0 @@ autoStart: false

{
"name": "mortice",
"version": "3.0.3",
"version": "3.0.4",
"description": "Isomorphic read/write lock that works in single processes, node clusters and web workers",

@@ -147,3 +147,3 @@ "author": "Alex Potsides <alex@achingbrain.net>",

"observable-webworkers": "^2.0.1",
"p-queue": "^7.2.0",
"p-queue": "^8.0.1",
"p-timeout": "^6.0.0"

@@ -150,0 +150,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc