3 lines
7.9 KiB
JavaScript
3 lines
7.9 KiB
JavaScript
import{I as C}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";var b={exports:{}},x;function P(){return x||(x=1,function(f){var t=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function h(i,n,r){this.fn=i,this.context=n,this.once=r||!1}function a(i,n,r,c,y){if(typeof r!="function")throw new TypeError("The listener must be a function");var p=new h(r,c||i,y),m=e?e+n:n;return i._events[m]?i._events[m].fn?i._events[m]=[i._events[m],p]:i._events[m].push(p):(i._events[m]=p,i._eventsCount++),i}function v(i,n){--i._eventsCount===0?i._events=new o:delete i._events[n]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var i=[],n,r;if(this._eventsCount===0)return i;for(r in n=this._events)t.call(n,r)&&i.push(e?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(n)):i},u.prototype.listeners=function(i){var n=e?e+i:i,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var c=0,y=r.length,p=new Array(y);c<y;c++)p[c]=r[c].fn;return p},u.prototype.listenerCount=function(i){var n=e?e+i:i,r=this._events[n];return r?r.fn?1:r.length:0},u.prototype.emit=function(i,n,r,c,y,p){var m=e?e+i:i;if(!this._events[m])return!1;var s=this._events[m],d=arguments.length,w,l;if(s.fn){switch(s.once&&this.removeListener(i,s.fn,void 0,!0),d){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,n),!0;case 3:return s.fn.call(s.context,n,r),!0;case 4:return s.fn.call(s.context,n,r,c),!0;case 5:return s.fn.call(s.context,n,r,c,y),!0;case 6:return s.fn.call(s.context,n,r,c,y,p),!0}for(l=1,w=new Array(d-1);l<d;l++)w[l-1]=arguments[l];s.fn.apply(s.context,w)}else{var E=s.length,g;for(l=0;l<E;l++)switch(s[l].once&&this.removeListener(i,s[l].fn,void 0,!0),d){case 1:s[l].fn.call(s[l].context);break;case 2:s[l].fn.call(s[l].context,n);break;case 3:s[l].fn.call(s[l].context,n,r);break;case 4:s[l].fn.call(s[l].context,n,r,c);break;default:if(!w)for(g=1,w=new Array(d-1);g<d;g++)w[g-1]=arguments[g];s[l].fn.apply(s[l].context,w)}}return!0},u.prototype.on=function(i,n,r){return a(this,i,n,r,!1)},u.prototype.once=function(i,n,r){return a(this,i,n,r,!0)},u.prototype.removeListener=function(i,n,r,c){var y=e?e+i:i;if(!this._events[y])return this;if(!n)return v(this,y),this;var p=this._events[y];if(p.fn)p.fn===n&&(!c||p.once)&&(!r||p.context===r)&&v(this,y);else{for(var m=0,s=[],d=p.length;m<d;m++)(p[m].fn!==n||c&&!p[m].once||r&&p[m].context!==r)&&s.push(p[m]);s.length?this._events[y]=s.length===1?s[0]:s:v(this,y)}return this},u.prototype.removeAllListeners=function(i){var n;return i?(n=e?e+i:i,this._events[n]&&v(this,n)):(this._events=new o,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=e,u.EventEmitter=u,f.exports=u}(b)),b.exports}var O=P();const N=C(O);class T extends Error{constructor(t){super(t),this.name="TimeoutError"}}class z extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const _=f=>globalThis.DOMException===void 0?new z(f):new DOMException(f),I=f=>{const t=f.reason===void 0?_("This operation was aborted."):f.reason;return t instanceof Error?t:_(t)};function S(f,t){const{milliseconds:e,fallback:o,message:h,customTimers:a={setTimeout,clearTimeout}}=t;let v;const u=new Promise((i,n)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){const{signal:c}=t;c.aborted&&n(I(c)),c.addEventListener("abort",()=>{n(I(c))})}if(e===Number.POSITIVE_INFINITY){f.then(i,n);return}const r=new T;v=a.setTimeout.call(void 0,()=>{if(o){try{i(o())}catch(c){n(c)}return}typeof f.cancel=="function"&&f.cancel(),h===!1?i():h instanceof Error?n(h):(r.message=h??`Promise timed out after ${e} milliseconds`,n(r))},e),(async()=>{try{i(await f)}catch(c){n(c)}})()}).finally(()=>{u.clear()});return u.clear=()=>{a.clearTimeout.call(void 0,v),v=void 0},u}function q(f,t,e){let o=0,h=f.length;for(;h>0;){const a=Math.trunc(h/2);let v=o+a;e(f[v],t)<=0?(o=++v,h-=a+1):h=a}return o}class L{#t=[];enqueue(t,e){e={priority:0,...e};const o={priority:e.priority,id:e.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=e.priority){this.#t.push(o);return}const h=q(this.#t,o,(a,v)=>v.priority-a.priority);this.#t.splice(h,0,o)}setPriority(t,e){const o=this.#t.findIndex(a=>a.id===t);if(o===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);const[h]=this.#t.splice(o,1);this.enqueue(h.run,{priority:e,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return this.#t.length}}class A extends N{#t;#o;#s=0;#p;#a;#v=0;#i;#c;#e;#m;#n=0;#h;#r;#y;#g=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:L,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#o=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#p=t.intervalCap,this.#a=t.interval,this.#e=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#r=t.autoStart===!1}get#b(){return this.#o||this.#s<this.#p}get#x(){return this.#n<this.#h}#_(){this.#n--,this.#u(),this.emit("next")}#I(){this.#w(),this.#d(),this.#c=void 0}get#T(){const t=Date.now();if(this.#i===void 0){const e=this.#v-t;if(e<0)this.#s=this.#t?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#I()},e)),!0}return!1}#u(){if(this.#e.size===0)return this.#i&&clearInterval(this.#i),this.#i=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#r){const t=!this.#T;if(this.#b&&this.#x){const e=this.#e.dequeue();return e?(this.emit("active"),e(),t&&this.#d(),!0):!1}}return!1}#d(){this.#o||this.#i!==void 0||(this.#i=setInterval(()=>{this.#w()},this.#a),this.#v=Date.now()+this.#a)}#w(){this.#s===0&&this.#n===0&&this.#i&&(clearInterval(this.#i),this.#i=void 0),this.#s=this.#t?this.#n:0,this.#l()}#l(){for(;this.#u(););}get concurrency(){return this.#h}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#h=t,this.#l()}async#E(t){return new Promise((e,o)=>{t.addEventListener("abort",()=>{o(t.reason)},{once:!0})})}setPriority(t,e){this.#e.setPriority(t,e)}async add(t,e={}){return e.id??=(this.#g++).toString(),e={timeout:this.timeout,throwOnTimeout:this.#y,...e},new Promise((o,h)=>{this.#e.enqueue(async()=>{this.#n++,this.#s++;try{e.signal?.throwIfAborted();let a=t({signal:e.signal});e.timeout&&(a=S(Promise.resolve(a),{milliseconds:e.timeout})),e.signal&&(a=Promise.race([a,this.#E(e.signal)]));const v=await a;o(v),this.emit("completed",v)}catch(a){if(a instanceof T&&!e.throwOnTimeout){o();return}h(a),this.emit("error",a)}finally{this.#_()}},e),this.emit("add"),this.#u()})}async addAll(t,e){return Promise.all(t.map(async o=>this.add(o,e)))}start(){return this.#r?(this.#r=!1,this.#l(),this):this}pause(){this.#r=!0}clear(){this.#e=new this.#m}async onEmpty(){this.#e.size!==0&&await this.#f("empty")}async onSizeLessThan(t){this.#e.size<t||await this.#f("next",()=>this.#e.size<t)}async onIdle(){this.#n===0&&this.#e.size===0||await this.#f("idle")}async#f(t,e){return new Promise(o=>{const h=()=>{e&&!e()||(this.off(t,h),o())};this.on(t,h)})}get size(){return this.#e.size}sizeBy(t){return this.#e.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#r}}export{A as P};
|
|
//# sourceMappingURL=index-_ghYQSTa.chunk.mjs.map
|