2 lines
7.1 KiB
JavaScript
2 lines
7.1 KiB
JavaScript
var M=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var K=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of x(t))!j.call(e,i)&&i!==n&&E(e,i,{get:()=>t[i],enumerable:!(r=F(t,i))||r.enumerable});return e};var k=(e,t,n)=>(n=e!=null?M(N(e)):{},K(t||!e||!e.__esModule?E(n,"default",{value:e,enumerable:!0}):n,e));var C=W((Z,v)=>{"use strict";var a=typeof Reflect=="object"?Reflect:null,h=a&&typeof a.apply=="function"?a.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},l;a&&typeof a.ownKeys=="function"?l=a.ownKeys:Object.getOwnPropertySymbols?l=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:l=function(t){return Object.getOwnPropertyNames(t)};function H(e){console&&console.warn&&console.warn(e)}var _=Number.isNaN||function(t){return t!==t};function s(){s.init.call(this)}v.exports=s;v.exports.once=B;s.EventEmitter=s;s.prototype._events=void 0;s.prototype._eventsCount=0;s.prototype._maxListeners=void 0;var O=10;function p(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return O},set:function(e){if(typeof e!="number"||e<0||_(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");O=e}});s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};s.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||_(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function m(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return m(this)};s.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="error",f=this._events;if(f!==void 0)i=i&&f.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var c=f[t];if(c===void 0)return!1;if(typeof c=="function")h(c,this,n);else for(var d=c.length,P=I(c,d),r=0;r<d;++r)h(P[r],this,n);return!0};function D(e,t,n,r){var i,f,o;if(p(n),f=e._events,f===void 0?(f=e._events=Object.create(null),e._eventsCount=0):(f.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),f=e._events),o=f[t]),o===void 0)o=f[t]=n,++e._eventsCount;else if(typeof o=="function"?o=f[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),i=m(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,H(u)}return e}s.prototype.addListener=function(t,n){return D(this,t,n,!1)};s.prototype.on=s.prototype.addListener;s.prototype.prependListener=function(t,n){return D(this,t,n,!0)};function U(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function y(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=U.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(t,n){return p(n),this.on(t,y(this,t,n)),this};s.prototype.prependOnceListener=function(t,n){return p(n),this.prependListener(t,y(this,t,n)),this};s.prototype.removeListener=function(t,n){var r,i,f,o,u;if(p(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(f=-1,o=r.length-1;o>=0;o--)if(r[o]===n||r[o].listener===n){u=r[o].listener,f=o;break}if(f<0)return this;f===0?r.shift():T(r,f),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,u||n)}return this};s.prototype.off=s.prototype.removeListener;s.prototype.removeAllListeners=function(t){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var f=Object.keys(r),o;for(i=0;i<f.length;++i)o=f[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function A(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?S(i):I(i,i.length)}s.prototype.listeners=function(t){return A(this,t,!0)};s.prototype.rawListeners=function(t){return A(this,t,!1)};s.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):g.call(e,t)};s.prototype.listenerCount=g;function g(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function I(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function T(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function S(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function B(e,t){return new Promise(function(n,r){function i(o){e.removeListener(t,f),r(o)}function f(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}R(e,t,f,{once:!0}),t!=="error"&&J(e,i,{once:!0})})}function J(e,t,n){typeof e.on=="function"&&R(e,"error",t,n)}function R(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(f){r.once&&e.removeEventListener(t,i),n(f)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var b=k(C());var L=(r=>(r[r.PAUSE=0]="PAUSE",r[r.PROVIDE_FILE=1]="PROVIDE_FILE",r[r.RESUME=2]="RESUME",r))(L||{});var w=new b.default,G=(e,t)=>(Object.assign(e,t),typeof WorkerGlobalScope<"u"&&self.postMessage({event:"FILE_UPDATED",lufiFile:e}),e),ne=(e,t)=>{G(e,{uploadStatus:2}),self.postMessage({event:"OPERATION_FAILED",error:t})},re=()=>{w.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),w.once("OPERATION_FAILED",e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})},ie=e=>typeof e=="object"&&e!==null&&"action"in e&&Object.values(L).includes(e.action);export{w as events,re as init,ie as isWorkerActionMessage,ne as sendFileError,G as updateFile};
|