easy-web-worker 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,9 +13,20 @@ const backgroundWorker = new EasyWebWorker<string, string>((easyWorker) => {
13
13
 
14
14
  message.resolve(`this is a message from the worker: ${payload}`);
15
15
  });
16
+
17
+ // you could also define and send specific methods which allow you to create a better structured API
18
+ easyWorker.onMessage<number, number>('doSomething', (message) => {
19
+ const { payload } = message;
20
+
21
+ message.resolve(payload + 2);
22
+ });
16
23
  });
17
24
 
25
+ // outside your worker
18
26
  const messageResult = await backgroundWorker.send('hello!');
27
+
28
+ // for specific methods us the sendToMethod function
29
+ const messageResult2 = await backgroundWorker.sendToMethod('doSomething', 2);
19
30
  ```
20
31
 
21
32
  ### Important notes:
@@ -23,6 +23,7 @@ export interface IWorkerData<IPayload> {
23
23
  * This is the message id
24
24
  * */
25
25
  messageId: string;
26
+ method?: string;
26
27
  execution?: {
27
28
  payload?: IPayload;
28
29
  };
@@ -76,7 +77,7 @@ export interface IMessageData<IPayload = null> {
76
77
  payload: unknown;
77
78
  };
78
79
  }
79
- export interface IEasyWorkerInstance<IPayload = null, IResult = void> {
80
+ export interface IEasyWorkerInstance<TPayload = null, TResult = void> {
80
81
  /**
81
82
  * Use this method to defined which will be the functionality of your worker when a message is send to it
82
83
  * @param {function} callback - This is the callback that will be executed when a message is received
@@ -88,7 +89,7 @@ export interface IEasyWorkerInstance<IPayload = null, IResult = void> {
88
89
  * @param {IEasyWebWorkerMessage} callback.message.resolve - This method is used to resolve the message from inside the worker
89
90
  * @param {MessageEvent} callback.event - This is the event that was received
90
91
  * */
91
- onMessage(callback: (message: IEasyWebWorkerMessage<IPayload, IResult>, event: MessageEvent<IMessageData<IPayload>>) => void): void;
92
+ onMessage(callback: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void): void;
92
93
  /**
93
94
  * Use this method to defined which will be the functionality of your worker when a message is send to it
94
95
  * @param {string} method - Create a callback for an specific method
@@ -101,7 +102,7 @@ export interface IEasyWorkerInstance<IPayload = null, IResult = void> {
101
102
  * @param {IEasyWebWorkerMessage} callback.message.resolve - This method is used to resolve the message from inside the worker
102
103
  * @param {MessageEvent} callback.event - This is the event that was received
103
104
  * */
104
- onMessage(method: string, callback: (message: IEasyWebWorkerMessage<IPayload, IResult>, event: MessageEvent<IMessageData<IPayload>>) => void): void;
105
+ onMessage<TPayload_ = null, TResult_ = void>(method: string, callback: (message: IEasyWebWorkerMessage<TPayload_, TResult_>, event: MessageEvent<IMessageData<TPayload_>>) => void): void;
105
106
  /**
106
107
  * Import scripts to the worker
107
108
  */
@@ -233,13 +234,23 @@ export declare class EasyWebWorker<TPayload = null, TResult = void> {
233
234
  cancelAll(reason?: unknown, { force }?: {
234
235
  force?: boolean;
235
236
  }): any;
236
- protected addMessageToQueue(message: EasyWebWorkerMessage<TPayload, TResult>): void;
237
+ protected addMessageToQueue(message: EasyWebWorkerMessage<unknown, unknown>): void;
238
+ /**
239
+ * Send a message to the worker queue to an specific method
240
+ * @template TResult_ - result type of the message (if any)
241
+ * @template TPayload_ - payload type of the message (if any)
242
+ * @param {string} method - method name
243
+ * @param {TPayload} payload - whatever json data you want to send to the worker
244
+ * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
245
+ */
246
+ sendToMethod<TResult_ = void, TPayload_ = null>(method: string, payload?: TPayload_): CancelablePromise<TResult_>;
237
247
  /**
238
248
  * Send a message to the worker queue
239
249
  * @param {TPayload} payload - whatever json data you want to send to the worker
240
250
  * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
241
251
  */
242
252
  send: TPayload extends null ? () => CancelablePromise<TResult> : (payload: TPayload) => CancelablePromise<TResult>;
253
+ private sendToWorker;
243
254
  /**
244
255
  * This method terminate all current messages and send a new one to the worker queue
245
256
  * @param {TPayload} payload - whatever json data you want to send to the worker, should be serializable
package/lib/bundle.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["easy-web-worker"]=r():e["easy-web-worker"]=r()}(this,(()=>{return e={30:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,c=[],s=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=a.call(t)).done)&&(c.push(n.value),c.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,r)||a(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(){c=function(){return e};var e={},r=Object.prototype,t=r.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var a=r&&r.prototype instanceof y?r:y,i=Object.create(a.prototype),c=new x(n||[]);return o(i,"_invoke",{value:j(e,t,c)}),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var d={};function y(){}function h(){}function v(){}var m={};u(m,i,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(S([])));g&&g!==r&&t.call(g,i)&&(m=g);var w=v.prototype=y.prototype=Object.create(m);function k(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function a(o,i,c,s){var l=p(e[o],e,i);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==n(f)&&t.call(f,"__await")?r.resolve(f.__await).then((function(e){a("next",e,c,s)}),(function(e){a("throw",e,c,s)})):r.resolve(f).then((function(e){u.value=e,c(u)}),(function(e){return a("throw",e,c,s)}))}s(l.arg)}var i;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return i=i?i.then(n,n):n()}})}function j(e,r,t){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(t.method=o,t.arg=a;;){var i=t.delegate;if(i){var c=C(i,t);if(c){if(c===d)continue;return c}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var s=p(e,r,t);if("normal"===s.type){if(n=t.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:t.done}}"throw"===s.type&&(n="completed",t.method="throw",t.arg=s.arg)}}}function C(e,r){var t=r.method,n=e.iterator[t];if(void 0===n)return r.delegate=null,"throw"===t&&e.iterator.return&&(r.method="return",r.arg=void 0,C(e,r),"throw"===r.method)||"return"!==t&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+t+"' method")),d;var o=p(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function O(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function E(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function r(){for(;++n<e.length;)if(t.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:M}}function M(){return{value:void 0,done:!0}}return h.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=u(v,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},k(P.prototype),u(P.prototype,s,(function(){return this})),e.AsyncIterator=P,e.async=function(r,t,n,o,a){void 0===a&&(a=Promise);var i=new P(f(r,t,n,o),a);return e.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(w),u(w,l,"Generator"),u(w,i,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&t.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=t.call(a,"catchLoc"),s=t.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),E(t),d}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;E(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:S(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},e}function s(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}var l=function(e,r,t,n){return new(t||(t=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,c)}s((n=n.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorker=r.createBlobWorker=void 0;var u=t(213),f=t(726),p=t(367);r.createBlobWorker=function(e){var r,t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a="true"==(null===(t=null===(r=window.process)||void 0===r?void 0:r.env)||void 0===t?void 0:t.DEV_MODE),i=(0,f.getWorkerTemplate)(),c=Array.isArray(e)?e:[e],s="".concat(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.length?'self.importScripts(["'.concat(e.join('","'),'"]);'):""}(n),"\n ").concat(i,"\n ").concat(c.map((function(e){return'\n \n var easyWorker = createEasyWebWorker("'.concat(o,'");\n \n (').concat(e,")(easyWorker, self);")})).join("\n\n"));return s=a?s:(0,f.simpleMinifier)(s),(window.URL||window.webkitURL).createObjectURL(new Blob([s],{type:"application/javascript"}))};var d=function(){function e(r){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.scripts,i=void 0===a?[]:a,s=n.name,d=n.onWorkerError,y=void 0===d?null:d;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.workerBody=r,this.messagesQueue=new Map,this.scripts=[],this.send=function(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var a=n[0],i=new u.EasyWebWorkerMessage,c=i.messageId,s=i.decoupledPromise,l=s.cancel;s.promise.cancel=function(e){var r;s.cancel=l;var n={messageId:c,cancelation:{reason:e}};return t.worker?(null===(r=t.worker)||void 0===r||r.postMessage(n),s.promise):(l(e),(0,p.toCancelablePromise)(Promise.reject(e)))},t.addMessageToQueue(i);var f={messageId:c,execution:{payload:a}};return null===(e=t.worker)||void 0===e||e.postMessage(f),s.promise},this.override=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r[0],a=r[1],i=r[2];return l(t,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll(a,i);case 2:return e.abrupt("return",this.send.apply(this,[o]));case 3:case"end":return e.stop()}}),e,this)})))},this.overrideAfterCurrent=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=r[0],i=r[1],s=r[2];return l(t,void 0,void 0,c().mark((function e(){var r,t,n,l;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesQueue.size){e.next=7;break}return r=o(this.messagesQueue,1),t=r[0],n=o(t,2),l=n[1],this.RemoveMessageFromQueue(l.messageId),e.next=6,this.cancelAll(i,s);case 6:this.addMessageToQueue(l);case 7:return e.abrupt("return",this.send.apply(this,[a]));case 8:case"end":return e.stop()}}),e,this)})))},this.name=s||(0,f.generatedId)(),this.scripts=i,this.worker=this.initializeWorker(),this.onWorkerError=y}var t,n;return t=e,n=[{key:"isExternalWorkerFile",get:function(){return"string"==typeof this.workerBody}},{key:"RemoveMessageFromQueue",value:function(e){this.messagesQueue.delete(e)}},{key:"executeMessageCallback",value:function(e){var r,t,n=null!==(r=this.messagesQueue.get(e.data.messageId))&&void 0!==r?r:null;if(n){var o=e.data.progress;if(this.worker){var c=n.decoupledPromise;if(o){var s=o.percentage,l=o.payload;c.reportProgress(s,l)}else{this.RemoveMessageFromQueue(n.messageId);var u=e.data.worker_canceled;if(u){var f=u.reason;c.reject(f)}else{var p=e.data.rejected;if(p){var d=p.reason;c.reject(d)}else{var y=e.data.resolved.payload;c.resolve.apply(c,function(e){if(Array.isArray(e))return i(e)}(t=null!=y?y:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}}}else this.RemoveMessageFromQueue(n.messageId)}}},{key:"getWorkerUrl",value:function(){return this.isExternalWorkerFile?this.workerBody:(0,r.createBlobWorker)(this.workerBody,this.scripts)}},{key:"initializeWorker",value:function(){var e,r=this;this.workerUrl=null!==(e=this.workerUrl)&&void 0!==e?e:this.getWorkerUrl();var t=new Worker(this.workerUrl,{name:this.name});return t.onmessage=function(e){r.executeMessageCallback(e)},t.onerror=function(e){if(!r.onWorkerError)throw e;r.onWorkerError(e)},t}},{key:"cancelAll",value:function(e){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).force,t=void 0!==r&&r,n=Array.from(this.messagesQueue.values()),o=100/n.length;if(t)return this.reboot(e);var a=n.map((function(r){var t=r.decoupledPromise.promise;return t.cancel(e).catch((function(e){return t.reportProgress(o,e),e}))}));return Promise.all(a)}},{key:"addMessageToQueue",value:function(e){this.messagesQueue.set(e.messageId,e)}},{key:"reboot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Worker was rebooted";this.worker.terminate(),this.worker=null;var r=this.cancelAll(e);return this.worker=this.initializeWorker(),r}},{key:"dispose",value:function(){return l(this,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll(null);case 2:URL.revokeObjectURL(this.workerUrl),this.worker.terminate(),this.worker=null;case 5:case"end":return e.stop()}}),e,this)})))}}],n&&s(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.EasyWebWorker=d},726:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.simpleMinifier=r.getWorkerTemplate=r.generatedId=void 0,r.generatedId=function(){return"".concat((new Date).getTime()).concat(Math.random().toString(36).substr(2,9))},r.getWorkerTemplate=function(){return"/*this-code-was auto-generated*/\n const createEasyWebWorker = (targetOrigin) => {\n /* Keep track of the messages sent allowing us to cancel them */\n const workerMessages = new Map();\n \n /* This structure allows us to have multiple callbacks for the same worker */\n const workerCallbacks = new Map([\n [\n '',\n () => {\n throw \"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\";\n },\n ],\n ]);\n \n const createMessage = ({ messageId, payload, origin }) => {\n const cancelCallbacks = new Set();\n \n const postMessage = (data) => {\n const { progress } = data;\n \n if (!progress) {\n /* If it's not a progress message means that the message is resolved | rejected | canceled */\n workerMessages.delete(messageId);\n }\n \n self.postMessage({ messageId, ...data }, origin);\n };\n \n const resolve = (...result) => {\n postMessage({ resolved: { payload: result } });\n };\n \n const reject = (reason) => {\n postMessage({ rejected: { reason } });\n };\n \n const cancel = (reason) => {\n const callbacks = [...cancelCallbacks];\n \n callbacks.forEach((callback) => callback(reason));\n \n postMessage({ worker_canceled: { reason } });\n };\n \n const reportProgress = (percentage, payload) => {\n postMessage({ progress: { percentage, payload } });\n };\n \n /* Returns a function that can be used to unsubscribe from the cancelation */\n const onCancel = (callback) => {\n cancelCallbacks.add(callback);\n \n return () => cancelCallbacks.delete(callback);\n };\n \n return {\n payload,\n resolve,\n reject,\n cancel,\n onCancel,\n reportProgress,\n };\n };\n \n const importScripts = (...scripts) => {\n self.importScripts(...scripts);\n };\n \n const onMessage = (...args) => {\n const [param1, param2] = args;\n const hasCustomCallbackKey = typeof param1 === 'string';\n \n if (hasCustomCallbackKey) {\n const callbackKey = param1;\n const callback = param2;\n \n workerCallbacks.set(callbackKey, callback);\n \n return;\n }\n \n const callback = param1;\n workerCallbacks.set('', callback);\n };\n \n const close = () => {\n /* should cancel all the promises of the main thread */\n const messages = [...workerMessages.values()];\n \n messages.forEach((message) => message.reject(new Error('worker closed')));\n \n self.close();\n };\n \n self.onmessage = (event) => {\n const { data, origin } = event;\n const { messageId, cancelation } = data;\n \n if (cancelation) {\n const { reason } = cancelation;\n \n const message = workerMessages.get(messageId);\n \n message.cancel(reason);\n \n return;\n }\n \n const { method, execution } = data;\n const { payload } = execution;\n \n const message = createMessage({\n messageId,\n payload,\n origin: targetOrigin || origin || undefined,\n });\n \n workerMessages.set(messageId, message);\n \n const callback = workerCallbacks.get(method || '');\n \n callback(message, event);\n };\n \n return {\n importScripts,\n onMessage,\n close,\n };\n };"},r.simpleMinifier=function(e){for(var r="",t=!1,n=!1,o=0;o<e.length;o++){var a=e.charAt(o);t?"*"===a&&"/"===e.charAt(o+1)&&(t=!1,o++):n?(r+=a,'"'===a&&"\\"!==e.charAt(o-1)&&(n=!1)):"/"!==a||"*"!==e.charAt(o+1)?'"'!==a?"\n"!==a&&"\r"!==a&&(r+=a):(n=!0,r+=a):(t=!0,o++)}return r.replace(/\s+/g," ").trim()}},213:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}function a(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorkerMessage=void 0;var i=t(367),c=t(726),s=a((function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.messageId=(0,c.generatedId)(),this.decoupledPromise=(0,i.createDecoupledPromise)()}));r.EasyWebWorkerMessage=s},973:(e,r)=>{"use strict";function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return n(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,r):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}Object.defineProperty(r,"__esModule",{value:!0}),r.createStaticEasyWebWorker=r.StaticEasyWebWorker=void 0,r.StaticEasyWebWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=new Map,o=new Map([["",function(){throw"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage"}]]),a=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=r[0],a=r[1];if("string"==typeof n){var i=n,c=a;o.set(i,c)}else{var s=n;o.set("",s)}};self.onmessage=function(e){var a=e.data,i=e.origin,c=a.messageId,s=a.cancelation;if(s){var l=s.reason;n.get(c).cancel(l)}else{var u=e.data,f=u.method,p=function(e){var r=e.messageId,n=e.payload,o=e.origin,a=new Set,i=function(e){self.postMessage(Object.assign({messageId:r},e),o)};return{payload:n,resolve:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i({resolved:{payload:r}})},reject:function(e){i({rejected:{reason:e}})},cancel:function(e){t(a).forEach((function(r){return r(e)})),i({canceled:{reason:e}})},onCancel:function(e){return a.add(e),function(){return a.delete(e)}},reportProgress:function(e,r){i({progress:{percentage:e,payload:r}})}}}({messageId:c,payload:u.execution.payload,origin:r||i||"*"});o.get(f||"")(p,e)}},e&&a(e),this.importScripts=function(){var e;(e=self).importScripts.apply(e,arguments)},this.close=function(){t(n.values()).forEach((function(e){return e.reject(new Error("worker closed"))})),self.close()},this.onMessage=a},r.createStaticEasyWebWorker=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return new r.StaticEasyWebWorker(e,t)}},991:(e,r,t)=>{"use strict";var n=Object.create?function(e,r,t,n){void 0===n&&(n=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,o)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]},o=function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||n(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=t(30);Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a.EasyWebWorker}}),o(t(30),r),o(t(973),r)},367:function(e){var r;r=()=>(()=>{"use strict";var e={399:(e,r)=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var n=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=l(e)););return e}(e,r);if(n){var o=Object.getOwnPropertyDescriptor(n,r);return o.get?o.get.call(arguments.length<3?e:t):o.value}},o.apply(this,arguments)}function a(e){var r="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},a(e)}function i(e,r,t){return i=c()?Reflect.construct.bind():function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&s(o,t.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function s(e,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},s(e,r)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CancelablePromise=void 0;var u=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&s(e,r)}(f,e);var r,a,i,u=(a=f,i=c(),function(){var e,r=l(a);if(i){var o=l(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}(this,e)});function f(e){var r,t,a,i,c;return function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,f),(a=u.call(this,(function(e,r){i=e,c=r}))).status="pending",a.data={},a.cancelCallbacks=[],a.ownCancelCallbacks=[],a.onProgressCallbacks=[],a.subscribeToOwnCancelEvent=function(e){a.ownCancelCallbacks.push(e)},a.cancel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if("pending"===a.status)return a.status="canceled",a.ownCancelCallbacks.forEach((function(r){return r(e)})),a.cancelCallbacks.forEach((function(r){return r(e)})),a.reject(e),a.cancelCallbacks=[],a.ownCancelCallbacks=[],n(a)},a.onCancel=function(e){return a.cancelCallbacks.push(e),n(a)},a.onProgress=function(e){return a.onProgressCallbacks.push(e),n(a)},a.reportProgress=function(e,r){return a.onProgressCallbacks.forEach((function(t){return t(e,r)})),n(a)},a.createChildPromise=function(){var e,r,t=new f((function(t,n,o){e=t,r=n}));return t.onProgressCallbacks=a.onProgressCallbacks,t.onCancel((function(e){a.cancel(e)})),{promise:t,resolve:e,reject:r}},a.resolve=i,a.reject=c,e((function(e){a.status="resolved",a.resolve(e)}),(function(e){a.status="rejected",a.reject(e)}),{cancel:function(e){return a.cancel(e)},onCancel:function(e){return a.subscribeToOwnCancelEvent(e),n(a)},onProgress:function(e){return a.onProgress(e)},reportProgress:function(e,r){a.reportProgress(e,r)}}),a.then=function(e,t){var i=a.createChildPromise(),c=i.promise,s=i.resolve,u=i.reject;return o((r=n(a),l(f.prototype)),"then",r).call(r,e,t).then(s,u),c},a.catch=function(e){var r=a.createChildPromise(),i=r.promise,c=r.resolve,s=r.reject;return o((t=n(a),l(f.prototype)),"catch",t).call(t,e).then(c,s),i},a}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(a(Promise));r.CancelablePromise=u,u.prototype.constructor=Promise},716:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toCancelablePromise=r.isPromise=r.groupAsCancelablePromise=r.createDecoupledPromise=void 0;var n=t(399);function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}r.createDecoupledPromise=function(){var e,r,t,o=new n.CancelablePromise((function(n,o,a){e=n,r=o,t=a}));return Object.assign(Object.assign({resolve:e,reject:r},t),{promise:o})};var a=function e(r){if(r instanceof n.CancelablePromise)return r;if("function"==typeof r)return e(r());if(!i(r))return new n.CancelablePromise((function(e){return e(r)}));var t,o,a=new n.CancelablePromise((function(e,n,a){t=e,o=n,r.then(t,o)}));return a.onCancel((function(e){o(e)})),a};r.toCancelablePromise=a,r.groupAsCancelablePromise=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var t,i=r.maxConcurrent,c=void 0===i?8:i,s=r.executeInOrder,l=void 0!==s&&s,u=r.beforeEachCallback,f=void 0===u?null:u,p=r.afterEachCallback,d=void 0===p?null:p,y=r.onQueueEmptyCallback,h=void 0===y?null:y,v=function(e){if(Array.isArray(e))return o(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),m=[];return new n.CancelablePromise((function(e,r,t){return function e(){if(v.length){var r=v.splice(0,c).map((function(e){var r="function"==typeof e?e():e;null==f||f();var n=a(r);return t.onCancel((function(){n.cancel()})),n.then((function(e){m.push(e),null==d||d(e)})),l?n.then((function(e){return e})):n}));return Promise.all(r).then((function(){return e()}))}}().then((function(){null==h||h(m),e(m)}))}))};var i=function(e){return Promise.resolve(e)===e};r.isPromise=i},522:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"CancelablePromise",{enumerable:!0,get:function(){return n.CancelablePromise}}),Object.defineProperty(r,"createDecoupledPromise",{enumerable:!0,get:function(){return o.createDecoupledPromise}}),Object.defineProperty(r,"groupAsCancelablePromise",{enumerable:!0,get:function(){return o.groupAsCancelablePromise}}),Object.defineProperty(r,"isPromise",{enumerable:!0,get:function(){return o.isPromise}}),Object.defineProperty(r,"toCancelablePromise",{enumerable:!0,get:function(){return o.toCancelablePromise}});var n=t(399),o=t(716)},335:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(969)},969:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(948)},948:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tryCatchPromise=r.tryCatch=void 0;var n=t(522);r.tryCatch=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.defaultResult,n=void 0===t?null:t,o=r.exceptionHandlingType,a=void 0===o?"error":o;try{return{error:null,result:e()}}catch(e){return"ignore"!==a&&console[a](e),{error:e,result:n}}},r.tryCatchPromise=function(e,r){var t=r||{},o=t.defaultResult,a=void 0===o?null:o,i=t.exceptionHandlingType,c=void 0===i?"error":i,s=t.ignoreCancel,l=void 0===s||s,u=null,f=null,p=function(e){f=e,"ignore"!=c&&("canceled"===u.status&&l||console[c](f))};try{if(e instanceof n.CancelablePromise)return u=e,new Promise((function(e){u.then((function(e){return{error:null,result:e,promise:u}})).catch((function(e){return p(e),{error:e,result:a,promise:u}}))}));var d=e(),y=d instanceof n.CancelablePromise;return u=y?d:(0,n.toCancelablePromise)(d),new Promise((function(e){u.then((function(r){e({error:null,result:r,promise:u})})).catch((function(r){p(r),e({error:r,result:a,promise:u})}))}))}catch(e){return p(e),Promise.resolve({error:f,result:a,promise:u})}}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"CancelablePromise",{enumerable:!0,get:function(){return r.CancelablePromise}}),Object.defineProperty(e,"createDecoupledPromise",{enumerable:!0,get:function(){return r.createDecoupledPromise}}),Object.defineProperty(e,"groupAsCancelablePromise",{enumerable:!0,get:function(){return r.groupAsCancelablePromise}}),Object.defineProperty(e,"isPromise",{enumerable:!0,get:function(){return r.isPromise}}),Object.defineProperty(e,"toCancelablePromise",{enumerable:!0,get:function(){return r.toCancelablePromise}}),Object.defineProperty(e,"tryCatch",{enumerable:!0,get:function(){return o.tryCatch}}),Object.defineProperty(e,"tryCatchPromise",{enumerable:!0,get:function(){return o.tryCatchPromise}});var r=t(522),o=t(335)})(),n})(),e.exports=r()}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n].call(a.exports,a,a.exports,t),a.exports}(991);var e,r}));
2
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["easy-web-worker"]=r():e["easy-web-worker"]=r()}(this,(()=>{return e={30:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,c=[],s=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=a.call(t)).done)&&(c.push(n.value),c.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,r)||a(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(){c=function(){return e};var e={},r=Object.prototype,t=r.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var a=r&&r.prototype instanceof y?r:y,i=Object.create(a.prototype),c=new x(n||[]);return o(i,"_invoke",{value:j(e,t,c)}),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var d={};function y(){}function h(){}function v(){}var m={};u(m,i,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(S([])));g&&g!==r&&t.call(g,i)&&(m=g);var w=v.prototype=y.prototype=Object.create(m);function k(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function P(e,r){function a(o,i,c,s){var l=p(e[o],e,i);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==n(f)&&t.call(f,"__await")?r.resolve(f.__await).then((function(e){a("next",e,c,s)}),(function(e){a("throw",e,c,s)})):r.resolve(f).then((function(e){u.value=e,c(u)}),(function(e){return a("throw",e,c,s)}))}s(l.arg)}var i;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return i=i?i.then(n,n):n()}})}function j(e,r,t){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(t.method=o,t.arg=a;;){var i=t.delegate;if(i){var c=C(i,t);if(c){if(c===d)continue;return c}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var s=p(e,r,t);if("normal"===s.type){if(n=t.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:t.done}}"throw"===s.type&&(n="completed",t.method="throw",t.arg=s.arg)}}}function C(e,r){var t=r.method,n=e.iterator[t];if(void 0===n)return r.delegate=null,"throw"===t&&e.iterator.return&&(r.method="return",r.arg=void 0,C(e,r),"throw"===r.method)||"return"!==t&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+t+"' method")),d;var o=p(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function O(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function E(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function r(){for(;++n<e.length;)if(t.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:M}}function M(){return{value:void 0,done:!0}}return h.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=u(v,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},k(P.prototype),u(P.prototype,s,(function(){return this})),e.AsyncIterator=P,e.async=function(r,t,n,o,a){void 0===a&&(a=Promise);var i=new P(f(r,t,n,o),a);return e.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(w),u(w,l,"Generator"),u(w,i,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&t.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=t.call(a,"catchLoc"),s=t.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),E(t),d}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;E(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:S(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},e}function s(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}var l=function(e,r,t,n){return new(t||(t=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,c)}s((n=n.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorker=r.createBlobWorker=void 0;var u=t(213),f=t(726),p=t(367);r.createBlobWorker=function(e){var r,t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a="true"==(null===(t=null===(r=window.process)||void 0===r?void 0:r.env)||void 0===t?void 0:t.DEV_MODE),i=(0,f.getWorkerTemplate)(),c=Array.isArray(e)?e:[e],s="".concat(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.length?'self.importScripts(["'.concat(e.join('","'),'"]);'):""}(n),"\n ").concat(i,"\n ").concat(c.map((function(e){return'\n \n var easyWorker = createEasyWebWorker("'.concat(o,'");\n \n (').concat(e,")(easyWorker, self);")})).join("\n\n"));return s=a?s:(0,f.simpleMinifier)(s),(window.URL||window.webkitURL).createObjectURL(new Blob([s],{type:"application/javascript"}))};var d=function(){function e(r){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.scripts,i=void 0===a?[]:a,s=n.name,d=n.onWorkerError,y=void 0===d?null:d;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.workerBody=r,this.messagesQueue=new Map,this.scripts=[],this.send=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r[0];return t.sendToWorker({payload:o})},this.sendToWorker=function(e){var r,n=e.payload,o=e.method,a=new u.EasyWebWorkerMessage,i=a.messageId,c=a.decoupledPromise,s=c.cancel;c.promise.cancel=function(e){var r;c.cancel=s;var n={messageId:i,method:o,cancelation:{reason:e}};return t.worker?(null===(r=t.worker)||void 0===r||r.postMessage(n),c.promise):(s(e),(0,p.toCancelablePromise)(Promise.reject(e)))},t.addMessageToQueue(a);var l={messageId:i,method:o,execution:{payload:n}};return null===(r=t.worker)||void 0===r||r.postMessage(l),c.promise},this.override=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r[0],a=r[1],i=r[2];return l(t,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll(a,i);case 2:return e.abrupt("return",this.send.apply(this,[o]));case 3:case"end":return e.stop()}}),e,this)})))},this.overrideAfterCurrent=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=r[0],i=r[1],s=r[2];return l(t,void 0,void 0,c().mark((function e(){var r,t,n,l;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesQueue.size){e.next=7;break}return r=o(this.messagesQueue,1),t=r[0],n=o(t,2),l=n[1],this.RemoveMessageFromQueue(l.messageId),e.next=6,this.cancelAll(i,s);case 6:this.addMessageToQueue(l);case 7:return e.abrupt("return",this.send.apply(this,[a]));case 8:case"end":return e.stop()}}),e,this)})))},this.name=s||(0,f.generatedId)(),this.scripts=i,this.worker=this.initializeWorker(),this.onWorkerError=y}var t,n;return t=e,n=[{key:"isExternalWorkerFile",get:function(){return"string"==typeof this.workerBody}},{key:"RemoveMessageFromQueue",value:function(e){this.messagesQueue.delete(e)}},{key:"executeMessageCallback",value:function(e){var r,t,n=null!==(r=this.messagesQueue.get(e.data.messageId))&&void 0!==r?r:null;if(n){var o=e.data.progress;if(this.worker){var c=n.decoupledPromise;if(o){var s=o.percentage,l=o.payload;c.reportProgress(s,l)}else{this.RemoveMessageFromQueue(n.messageId);var u=e.data.worker_canceled;if(u){var f=u.reason;c.reject(f)}else{var p=e.data.rejected;if(p){var d=p.reason;c.reject(d)}else{var y=e.data.resolved.payload;c.resolve.apply(c,function(e){if(Array.isArray(e))return i(e)}(t=null!=y?y:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}}}else this.RemoveMessageFromQueue(n.messageId)}}},{key:"getWorkerUrl",value:function(){return this.isExternalWorkerFile?this.workerBody:(0,r.createBlobWorker)(this.workerBody,this.scripts)}},{key:"initializeWorker",value:function(){var e,r=this;this.workerUrl=null!==(e=this.workerUrl)&&void 0!==e?e:this.getWorkerUrl();var t=new Worker(this.workerUrl,{name:this.name});return t.onmessage=function(e){r.executeMessageCallback(e)},t.onerror=function(e){if(!r.onWorkerError)throw e;r.onWorkerError(e)},t}},{key:"cancelAll",value:function(e){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).force,t=void 0!==r&&r,n=Array.from(this.messagesQueue.values()),o=100/n.length;if(t)return this.reboot(e);var a=n.map((function(r){var t=r.decoupledPromise.promise;return t.cancel(e).catch((function(e){return t.reportProgress(o,e),e}))}));return Promise.all(a)}},{key:"addMessageToQueue",value:function(e){this.messagesQueue.set(e.messageId,e)}},{key:"sendToMethod",value:function(e,r){return this.sendToWorker({method:e,payload:r})}},{key:"reboot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Worker was rebooted";this.worker.terminate(),this.worker=null;var r=this.cancelAll(e);return this.worker=this.initializeWorker(),r}},{key:"dispose",value:function(){return l(this,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll(null);case 2:URL.revokeObjectURL(this.workerUrl),this.worker.terminate(),this.worker=null;case 5:case"end":return e.stop()}}),e,this)})))}}],n&&s(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.EasyWebWorker=d},726:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.simpleMinifier=r.getWorkerTemplate=r.generatedId=void 0,r.generatedId=function(){return"".concat((new Date).getTime()).concat(Math.random().toString(36).substr(2,9))},r.getWorkerTemplate=function(){return"/*this-code-was auto-generated*/\n const createEasyWebWorker = (targetOrigin) => {\n /* Keep track of the messages sent allowing us to cancel them */\n const workerMessages = new Map();\n \n /* This structure allows us to have multiple callbacks for the same worker */\n const workerCallbacks = new Map([\n [\n '',\n () => {\n throw \"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\";\n },\n ],\n ]);\n \n const createMessage = ({ messageId, payload, origin }) => {\n const cancelCallbacks = new Set();\n \n const postMessage = (data) => {\n const { progress } = data;\n \n if (!progress) {\n /* If it's not a progress message means that the message is resolved | rejected | canceled */\n workerMessages.delete(messageId);\n }\n \n self.postMessage({ messageId, ...data }, origin);\n };\n \n const resolve = (...result) => {\n postMessage({ resolved: { payload: result } });\n };\n \n const reject = (reason) => {\n postMessage({ rejected: { reason } });\n };\n \n const cancel = (reason) => {\n const callbacks = [...cancelCallbacks];\n \n callbacks.forEach((callback) => callback(reason));\n \n postMessage({ worker_canceled: { reason } });\n };\n \n const reportProgress = (percentage, payload) => {\n postMessage({ progress: { percentage, payload } });\n };\n \n /* Returns a function that can be used to unsubscribe from the cancelation */\n const onCancel = (callback) => {\n cancelCallbacks.add(callback);\n \n return () => cancelCallbacks.delete(callback);\n };\n \n return {\n payload,\n resolve,\n reject,\n cancel,\n onCancel,\n reportProgress,\n };\n };\n \n const importScripts = (...scripts) => {\n self.importScripts(...scripts);\n };\n \n const onMessage = (...args) => {\n const [param1, param2] = args;\n const hasCustomCallbackKey = typeof param1 === 'string';\n \n if (hasCustomCallbackKey) {\n const callbackKey = param1;\n const callback = param2;\n \n workerCallbacks.set(callbackKey, callback);\n \n return;\n }\n \n const callback = param1;\n workerCallbacks.set('', callback);\n };\n \n const close = () => {\n /* should cancel all the promises of the main thread */\n const messages = [...workerMessages.values()];\n \n messages.forEach((message) => message.reject(new Error('worker closed')));\n \n self.close();\n };\n \n self.onmessage = (event) => {\n const { data, origin } = event;\n const { messageId, cancelation } = data;\n \n if (cancelation) {\n const { reason } = cancelation;\n \n const message = workerMessages.get(messageId);\n \n message.cancel(reason);\n \n return;\n }\n \n const { method, execution } = data;\n const { payload } = execution;\n \n const message = createMessage({\n messageId,\n payload,\n origin: targetOrigin || origin || undefined,\n });\n \n workerMessages.set(messageId, message);\n \n const callback = workerCallbacks.get(method || '');\n \n callback(message, event);\n };\n \n return {\n importScripts,\n onMessage,\n close,\n };\n };"},r.simpleMinifier=function(e){for(var r="",t=!1,n=!1,o=0;o<e.length;o++){var a=e.charAt(o);t?"*"===a&&"/"===e.charAt(o+1)&&(t=!1,o++):n?(r+=a,'"'===a&&"\\"!==e.charAt(o-1)&&(n=!1)):"/"!==a||"*"!==e.charAt(o+1)?'"'!==a?"\n"!==a&&"\r"!==a&&(r+=a):(n=!0,r+=a):(t=!0,o++)}return r.replace(/\s+/g," ").trim()}},213:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}function a(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorkerMessage=void 0;var i=t(367),c=t(726),s=a((function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.messageId=(0,c.generatedId)(),this.decoupledPromise=(0,i.createDecoupledPromise)()}));r.EasyWebWorkerMessage=s},973:(e,r)=>{"use strict";function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return n(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,r):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}Object.defineProperty(r,"__esModule",{value:!0}),r.createStaticEasyWebWorker=r.StaticEasyWebWorker=void 0,r.StaticEasyWebWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=new Map,o=new Map([["",function(){throw"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage"}]]),a=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=r[0],a=r[1];if("string"==typeof n){var i=n,c=a;o.set(i,c)}else{var s=n;o.set("",s)}};self.onmessage=function(e){var a=e.data,i=e.origin,c=a.messageId,s=a.cancelation;if(s){var l=s.reason;n.get(c).cancel(l)}else{var u=e.data,f=u.method,p=function(e){var r=e.messageId,n=e.payload,o=e.origin,a=new Set,i=function(e){self.postMessage(Object.assign({messageId:r},e),o)};return{payload:n,resolve:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i({resolved:{payload:r}})},reject:function(e){i({rejected:{reason:e}})},cancel:function(e){t(a).forEach((function(r){return r(e)})),i({canceled:{reason:e}})},onCancel:function(e){return a.add(e),function(){return a.delete(e)}},reportProgress:function(e,r){i({progress:{percentage:e,payload:r}})}}}({messageId:c,payload:u.execution.payload,origin:r||i||"*"});o.get(f||"")(p,e)}},e&&a(e),this.importScripts=function(){var e;(e=self).importScripts.apply(e,arguments)},this.close=function(){t(n.values()).forEach((function(e){return e.reject(new Error("worker closed"))})),self.close()},this.onMessage=a},r.createStaticEasyWebWorker=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return new r.StaticEasyWebWorker(e,t)}},991:(e,r,t)=>{"use strict";var n=Object.create?function(e,r,t,n){void 0===n&&(n=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,o)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]},o=function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||n(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=t(30);Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a.EasyWebWorker}}),o(t(30),r),o(t(973),r)},367:function(e){var r;r=()=>(()=>{"use strict";var e={399:(e,r)=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var n=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=l(e)););return e}(e,r);if(n){var o=Object.getOwnPropertyDescriptor(n,r);return o.get?o.get.call(arguments.length<3?e:t):o.value}},o.apply(this,arguments)}function a(e){var r="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},a(e)}function i(e,r,t){return i=c()?Reflect.construct.bind():function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&s(o,t.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function s(e,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},s(e,r)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CancelablePromise=void 0;var u=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&s(e,r)}(f,e);var r,a,i,u=(a=f,i=c(),function(){var e,r=l(a);if(i){var o=l(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}(this,e)});function f(e){var r,t,a,i,c;return function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,f),(a=u.call(this,(function(e,r){i=e,c=r}))).status="pending",a.data={},a.cancelCallbacks=[],a.ownCancelCallbacks=[],a.onProgressCallbacks=[],a.subscribeToOwnCancelEvent=function(e){a.ownCancelCallbacks.push(e)},a.cancel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if("pending"===a.status)return a.status="canceled",a.ownCancelCallbacks.forEach((function(r){return r(e)})),a.cancelCallbacks.forEach((function(r){return r(e)})),a.reject(e),a.cancelCallbacks=[],a.ownCancelCallbacks=[],n(a)},a.onCancel=function(e){return a.cancelCallbacks.push(e),n(a)},a.onProgress=function(e){return a.onProgressCallbacks.push(e),n(a)},a.reportProgress=function(e,r){return a.onProgressCallbacks.forEach((function(t){return t(e,r)})),n(a)},a.createChildPromise=function(){var e,r,t=new f((function(t,n,o){e=t,r=n}));return t.onProgressCallbacks=a.onProgressCallbacks,t.onCancel((function(e){a.cancel(e)})),{promise:t,resolve:e,reject:r}},a.resolve=i,a.reject=c,e((function(e){a.status="resolved",a.resolve(e)}),(function(e){a.status="rejected",a.reject(e)}),{cancel:function(e){return a.cancel(e)},onCancel:function(e){return a.subscribeToOwnCancelEvent(e),n(a)},onProgress:function(e){return a.onProgress(e)},reportProgress:function(e,r){a.reportProgress(e,r)}}),a.then=function(e,t){var i=a.createChildPromise(),c=i.promise,s=i.resolve,u=i.reject;return o((r=n(a),l(f.prototype)),"then",r).call(r,e,t).then(s,u),c},a.catch=function(e){var r=a.createChildPromise(),i=r.promise,c=r.resolve,s=r.reject;return o((t=n(a),l(f.prototype)),"catch",t).call(t,e).then(c,s),i},a}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(a(Promise));r.CancelablePromise=u,u.prototype.constructor=Promise},716:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toCancelablePromise=r.isPromise=r.groupAsCancelablePromise=r.createDecoupledPromise=void 0;var n=t(399);function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}r.createDecoupledPromise=function(){var e,r,t,o=new n.CancelablePromise((function(n,o,a){e=n,r=o,t=a}));return Object.assign(Object.assign({resolve:e,reject:r},t),{promise:o})};var a=function e(r){if(r instanceof n.CancelablePromise)return r;if("function"==typeof r)return e(r());if(!i(r))return new n.CancelablePromise((function(e){return e(r)}));var t,o,a=new n.CancelablePromise((function(e,n,a){t=e,o=n,r.then(t,o)}));return a.onCancel((function(e){o(e)})),a};r.toCancelablePromise=a,r.groupAsCancelablePromise=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var t,i=r.maxConcurrent,c=void 0===i?8:i,s=r.executeInOrder,l=void 0!==s&&s,u=r.beforeEachCallback,f=void 0===u?null:u,p=r.afterEachCallback,d=void 0===p?null:p,y=r.onQueueEmptyCallback,h=void 0===y?null:y,v=function(e){if(Array.isArray(e))return o(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),m=[];return new n.CancelablePromise((function(e,r,t){return function e(){if(v.length){var r=v.splice(0,c).map((function(e){var r="function"==typeof e?e():e;null==f||f();var n=a(r);return t.onCancel((function(){n.cancel()})),n.then((function(e){m.push(e),null==d||d(e)})),l?n.then((function(e){return e})):n}));return Promise.all(r).then((function(){return e()}))}}().then((function(){null==h||h(m),e(m)}))}))};var i=function(e){return Promise.resolve(e)===e};r.isPromise=i},522:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"CancelablePromise",{enumerable:!0,get:function(){return n.CancelablePromise}}),Object.defineProperty(r,"createDecoupledPromise",{enumerable:!0,get:function(){return o.createDecoupledPromise}}),Object.defineProperty(r,"groupAsCancelablePromise",{enumerable:!0,get:function(){return o.groupAsCancelablePromise}}),Object.defineProperty(r,"isPromise",{enumerable:!0,get:function(){return o.isPromise}}),Object.defineProperty(r,"toCancelablePromise",{enumerable:!0,get:function(){return o.toCancelablePromise}});var n=t(399),o=t(716)},335:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(969)},969:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(948)},948:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tryCatchPromise=r.tryCatch=void 0;var n=t(522);r.tryCatch=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.defaultResult,n=void 0===t?null:t,o=r.exceptionHandlingType,a=void 0===o?"error":o;try{return{error:null,result:e()}}catch(e){return"ignore"!==a&&console[a](e),{error:e,result:n}}},r.tryCatchPromise=function(e,r){var t=r||{},o=t.defaultResult,a=void 0===o?null:o,i=t.exceptionHandlingType,c=void 0===i?"error":i,s=t.ignoreCancel,l=void 0===s||s,u=null,f=null,p=function(e){f=e,"ignore"!=c&&("canceled"===u.status&&l||console[c](f))};try{if(e instanceof n.CancelablePromise)return u=e,new Promise((function(e){u.then((function(e){return{error:null,result:e,promise:u}})).catch((function(e){return p(e),{error:e,result:a,promise:u}}))}));var d=e(),y=d instanceof n.CancelablePromise;return u=y?d:(0,n.toCancelablePromise)(d),new Promise((function(e){u.then((function(r){e({error:null,result:r,promise:u})})).catch((function(r){p(r),e({error:r,result:a,promise:u})}))}))}catch(e){return p(e),Promise.resolve({error:f,result:a,promise:u})}}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"CancelablePromise",{enumerable:!0,get:function(){return r.CancelablePromise}}),Object.defineProperty(e,"createDecoupledPromise",{enumerable:!0,get:function(){return r.createDecoupledPromise}}),Object.defineProperty(e,"groupAsCancelablePromise",{enumerable:!0,get:function(){return r.groupAsCancelablePromise}}),Object.defineProperty(e,"isPromise",{enumerable:!0,get:function(){return r.isPromise}}),Object.defineProperty(e,"toCancelablePromise",{enumerable:!0,get:function(){return r.toCancelablePromise}}),Object.defineProperty(e,"tryCatch",{enumerable:!0,get:function(){return o.tryCatch}}),Object.defineProperty(e,"tryCatchPromise",{enumerable:!0,get:function(){return o.tryCatchPromise}});var r=t(522),o=t(335)})(),n})(),e.exports=r()}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n].call(a.exports,a,a.exports,t),a.exports}(991);var e,r}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-web-worker",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "This is a library to easily handle and create web-workers, if you are a web developer and never tried this... do not wait any longer! Workers are an amazing option to improve user experience and make your webpages even greater",
5
5
  "main": "lib/bundle.js",
6
6
  "types": "lib/index.d.ts",