easy-web-worker 3.0.0 → 4.0.0

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
@@ -14,7 +14,7 @@ Check out the running example with **React** and **TypeScript** at [CODEPEN](htt
14
14
  /**
15
15
  * The callback parameter will be the body of the worker
16
16
  */
17
- const worker = new EasyWebWorker((easyWorker) => {
17
+ const worker = createEasyWebWorker((easyWorker) => {
18
18
  /**
19
19
  * Inside the worker we have to define an action when onMessage
20
20
  */
@@ -41,12 +41,13 @@ await worker.send('Hello Worker!');
41
41
 
42
42
  And that's it! You now have a worker running heavy computation in a real separate thread, with real asynchronous programming in JavaScript.
43
43
 
44
- You can also create an easy web worker from a static file, or from a native worker instance.
44
+ You can also create an easy web worker from a static file, or from a native worker instance:
45
45
 
46
46
  ```ts
47
- // static file
48
- const worker = new EasyWebWorker('./worker.js');
47
+ const worker = createEasyWebWorker('./worker.js');
48
+ const worker = createEasyWebWorker(new Worker('./worker.js')); // ƒ Worker() { [native code] }
49
49
 
50
+ const worker = new EasyWebWorker('./worker.js');
50
51
  const worker = new EasyWebWorker(new Worker('./worker.js')); // ƒ Worker() { [native code] }
51
52
  ```
52
53
 
@@ -3,7 +3,7 @@ import { CancelablePromise } from 'cancelable-promise-jq';
3
3
  /**
4
4
  * EasyWorker Config
5
5
  * */
6
- export interface IWorkerConfig {
6
+ export interface IWorkerConfig<TPrimitiveParameters extends any[] = unknown[]> {
7
7
  /**
8
8
  ** External scripts that you want to include in your worker
9
9
  */
@@ -20,17 +20,43 @@ export interface IWorkerConfig {
20
20
  * Url of the worker file, this is reserver for EasyWebWorker created from a Worker Instance
21
21
  */
22
22
  url?: string;
23
+ /**
24
+ * Maximum quantity of workers that will be created, default is 4
25
+ */
26
+ maxWorkers?: number;
27
+ /**
28
+ * Indicates if the worker should be kept alive after the message is completed
29
+ * otherwise, the workers will be terminated after a configured delay has passed and there is no messages in the queue
30
+ */
31
+ keepAlive?: boolean;
32
+ /**
33
+ * Quantity of milliseconds to wait before terminating the worker if there is no messages in the queue
34
+ */
35
+ terminationDelay?: number;
36
+ /**
37
+ * Indicates whenever the maximum quantity of workers should be created at the initialization of the easy web worker,
38
+ * If warmUp is true keepAlive will be set to true
39
+ */
40
+ warmUpWorkers?: boolean;
41
+ /**
42
+ * Allows to pass static primitive parameters to the worker
43
+ */
44
+ primitiveParameters?: TPrimitiveParameters;
45
+ /**
46
+ * Allows to override the worker file origin
47
+ */
48
+ origin?: string;
23
49
  }
24
50
  export interface IWorkerData<IPayload> {
25
51
  /**
26
52
  * This is the message id
27
53
  * */
28
- messageId: string;
29
- method?: string;
30
- execution?: {
54
+ readonly messageId: string;
55
+ readonly method?: string;
56
+ readonly execution?: {
31
57
  payload?: IPayload;
32
58
  };
33
- cancelation?: {
59
+ readonly cancelation?: {
34
60
  reason?: unknown;
35
61
  };
36
62
  }
@@ -41,35 +67,35 @@ export interface IMessageData<IPayload = null> {
41
67
  /**
42
68
  * This is the message id
43
69
  * */
44
- messageId: string;
70
+ readonly messageId: string;
45
71
  /**
46
72
  * When present, this means that the message was resolved
47
73
  */
48
- resolved?: {
74
+ readonly resolved?: {
49
75
  payload: [IPayload?];
50
76
  };
51
77
  /**
52
78
  * When present, this means that the message was rejected
53
79
  * */
54
- rejected?: {
80
+ readonly rejected?: {
55
81
  reason: unknown;
56
82
  };
57
83
  /**
58
84
  * When present, this means that the message was canceled
59
85
  * */
60
- canceled?: {
86
+ readonly canceled?: {
61
87
  reason: unknown;
62
88
  };
63
89
  /**
64
90
  * When present, this means that the message was canceled from inside the worker
65
91
  * */
66
- worker_canceled?: {
92
+ readonly worker_canceled?: {
67
93
  reason: unknown;
68
94
  };
69
95
  /**
70
96
  * When present, this means that the should report the progress
71
97
  * */
72
- progress?: {
98
+ readonly progress?: {
73
99
  /**
74
100
  * This is the progress percentage
75
101
  * */
@@ -115,7 +141,7 @@ export interface IEasyWorkerInstance<TPayload = null, TResult = void> {
115
141
  * */
116
142
  close(): void;
117
143
  }
118
- type TOverrideConfig = {
144
+ export type TOverrideConfig = {
119
145
  /**
120
146
  * If true, the worker reboots and cancel instantly all the messages that are currently in the queue
121
147
  */
@@ -127,7 +153,7 @@ type TOverrideConfig = {
127
153
  * @template IResult - Indicates if your WORKERS messages has a result... NULL indicates all you messages are Promise<void>
128
154
  * @param {IEasyWorkerInstance<IPayload, IResult>} easyWorker - ,
129
155
  */
130
- export type EasyWebWorkerBody<IPayload = null, IResult = void> = (
156
+ export type EasyWebWorkerBody<IPayload = null, IResult = void, TPrimitiveParameters extends any[] = unknown[]> = (
131
157
  /**
132
158
  * This is the instance of the worker that you can use to communicate with the main thread
133
159
  */
@@ -135,40 +161,44 @@ easyWorker: IEasyWorkerInstance<IPayload, IResult>,
135
161
  /**
136
162
  * This is the context of the worker, you can use it to access to the global scope of the worker
137
163
  * */
138
- context: DedicatedWorkerGlobalScope & Record<string, unknown>) => void;
164
+ context: DedicatedWorkerGlobalScope & {
165
+ primitiveParameters: TPrimitiveParameters;
166
+ } & Record<string, unknown>) => void;
139
167
  export interface IEasyWebWorkerMessage<TPayload = null, TResult = void> {
140
168
  /**
141
169
  * This is the message id
142
170
  */
143
- messageId: string;
171
+ readonly messageId: string;
144
172
  /**
145
173
  * This are the parameters included in the message
146
174
  * */
147
- payload: TPayload;
175
+ readonly payload: TPayload;
148
176
  /**
149
177
  * This method is used to reject the message from inside the worker
150
178
  * */
151
- reject: (reason?: unknown) => void;
179
+ readonly reject: (reason?: unknown) => void;
152
180
  /**
153
181
  * This method is used to report the progress of the message from inside the worker
154
182
  * */
155
- reportProgress(percentage: number, payload?: unknown): void;
183
+ readonly reportProgress: (percentage: number, payload?: unknown) => void;
156
184
  /**
157
185
  * This method is used to resolve the message from inside the worker
158
186
  * */
159
- resolve: TResult extends void ? () => void : (payload: TResult) => void;
187
+ readonly resolve: TResult extends void ? () => void : (payload: TResult) => void;
160
188
  /**
161
189
  * This method is used to cancel the message from inside the worker
162
190
  * */
163
- cancel: (reason?: unknown) => void;
191
+ readonly cancel: (reason?: unknown) => void;
164
192
  /**
165
193
  * Thus method is used to subscribe to the cancel event from the main thread
166
194
  */
167
- onCancel: (callback: (reason?: unknown) => void) => void;
195
+ readonly onCancel: (callback: (reason?: unknown) => void) => void;
168
196
  }
169
- export declare const createBlobWorker: <IPayload = null, IResult = void>(source: EasyWebWorkerBody<IPayload, IResult> | EasyWebWorkerBody<IPayload, IResult>[], imports?: string[], origin?: string) => string;
197
+ export declare const createBlobWorker: <IPayload = null, IResult = void, TPrimitiveParameters extends any[] = unknown[]>(source: EasyWebWorkerBody<IPayload, IResult, unknown[]> | EasyWebWorkerBody<IPayload, IResult, unknown[]>[], imports?: string[], origin?: string, { primitiveParameters, }?: {
198
+ primitiveParameters?: TPrimitiveParameters;
199
+ }) => string;
170
200
  /**
171
- * This is a class to create global-store objects
201
+ * This is a class to create an EasyWebWorker
172
202
  * @template TPayload - Indicates if your WORKERS messages requires a parameter to be provided, NULL indicates they doesn't
173
203
  * @template TResult - Indicates if your WORKERS messages has a result... NULL indicates all you messages are Promise<void>
174
204
  * @param {EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[]} workerBody -
@@ -179,19 +209,26 @@ export declare const createBlobWorker: <IPayload = null, IResult = void>(source:
179
209
  * @param {Partial<IWorkerConfig>} WorkerConfig - You could add extra configuration to your worker,
180
210
  * consult IWorkerConfig description to have more information
181
211
  * */
182
- export declare class EasyWebWorker<TPayload = null, TResult = void> {
212
+ export declare class EasyWebWorker<TPayload = null, TResult = void, TPrimitiveParameters extends any[] = unknown[]> {
183
213
  /**
184
214
  * this parameter should be a function or set of functions that will become the body of your Web-Worker
185
215
  * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.
186
216
  * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
187
217
  * you could easily identify what is on the context of your Worker.
188
218
  */
189
- protected source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker;
219
+ protected source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker | Worker[];
190
220
  name: string;
191
221
  /**
192
222
  * @deprecated Directly modifying the worker may lead to unexpected behavior. Use it only if you know what you are doing.
193
223
  */
194
- worker: Worker;
224
+ get worker(): Worker;
225
+ maxWorkers: number;
226
+ private workers;
227
+ keepAlive: boolean;
228
+ warmUpWorkers: boolean;
229
+ terminationDelay: number;
230
+ origin: string;
231
+ primitiveParameters: TPrimitiveParameters;
195
232
  /**
196
233
  * These where send to the worker but not yet resolved
197
234
  */
@@ -216,18 +253,22 @@ export declare class EasyWebWorker<TPayload = null, TResult = void> {
216
253
  * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
217
254
  * you could easily identify what is on the context of your Worker.
218
255
  */
219
- source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker,
256
+ source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker | Worker[],
220
257
  /**
221
258
  * You could import scripts into your worker, this is useful if you want to use external libraries
222
259
  */
223
- { scripts, name, onWorkerError, url, }?: Partial<IWorkerConfig>);
260
+ { scripts, name, onWorkerError, url, maxWorkers, keepAlive: _keepAlive, terminationDelay, warmUpWorkers: _warmUpWorkers, primitiveParameters, origin, }?: Partial<IWorkerConfig<TPrimitiveParameters>>);
261
+ private warmUp;
262
+ private fillWorkerMethods;
263
+ private createNewWorker;
264
+ private getWorkerFromPool;
265
+ protected computeWorkerBaseSource: () => void;
224
266
  private RemoveMessageFromQueue;
225
267
  /**
226
268
  * Categorizes the worker response and executes the corresponding callback
227
269
  */
228
270
  private executeMessageCallback;
229
271
  protected getWorkerUrl(): string;
230
- protected initializeWorker(): Worker;
231
272
  /**
232
273
  * Execute the cancel callback of each message in the queue if provided
233
274
  * @param {unknown} reason - reason messages where canceled
@@ -278,4 +319,3 @@ export declare class EasyWebWorker<TPayload = null, TResult = void> {
278
319
  */
279
320
  dispose(): Promise<void>;
280
321
  }
281
- export {};
@@ -0,0 +1,2 @@
1
+ import { EasyWebWorker, EasyWebWorkerBody, IWorkerConfig } from './EasyWebWorker';
2
+ export declare const createEasyWebWorker: <TPayload = null, TResult = void>(source: string | Worker | Worker[] | EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[], parameters?: Partial<IWorkerConfig>) => EasyWebWorker<TPayload, TResult, unknown[]>;
@@ -0,0 +1,137 @@
1
+ import { EasyWebWorkerMessage } from './EasyWebWorkerMessage';
2
+ import { CancelablePromise } from 'cancelable-promise-jq';
3
+ import { EasyWebWorkerBody, IWorkerConfig, TOverrideConfig } from './EasyWebWorker';
4
+ export type IWorkerConfigParallel = IWorkerConfig & {
5
+ /**
6
+ * Maximum quantity of workers that will be created, default is 4
7
+ */
8
+ maxWorkers?: number;
9
+ /**
10
+ * Indicates if the worker should be kept alive after the message is completed
11
+ * otherwise, the workers will be terminated after a configured delay has passed and there is no messages in the queue
12
+ */
13
+ keepAlive?: boolean;
14
+ /**
15
+ * Quantity of milliseconds to wait before terminating the worker if there is no messages in the queue
16
+ */
17
+ terminationDelay?: number;
18
+ /**
19
+ * Indicates whenever the maximum quantity of workers should be created at the initialization of the easy web worker,
20
+ * If warmUp is true keepAlive will be set to true,
21
+ * When maxWorkers is null or 1 we'll always create a worker
22
+ */
23
+ warmUp?: boolean;
24
+ };
25
+ /**
26
+ * This is a class to create a new instance of the easy concurrent web worker
27
+ * @template TPayload - Indicates if your WORKERS messages requires a parameter to be provided, NULL indicates they doesn't
28
+ * @template TResult - Indicates if your WORKERS messages has a result... NULL indicates all you messages are Promise<void>
29
+ * @param {EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[]} workerBody -
30
+ * this parameter should be a function or set of functions that will become the body of your Web-Worker
31
+ * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.
32
+ * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
33
+ * you could easily identify what is on the context of your Worker.
34
+ * @param {Partial<IWorkerConfig>} WorkerConfig - You could add extra configuration to your worker,
35
+ * consult IWorkerConfig description to have more information
36
+ * */
37
+ export declare class EasyWebWorkerParallel<TPayload = null, TResult = void> {
38
+ /**
39
+ * this parameter should be a function or set of functions that will become the body of your Web-Worker
40
+ * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.
41
+ * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
42
+ * you could easily identify what is on the context of your Worker.
43
+ */
44
+ protected source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker[];
45
+ name: string;
46
+ /**
47
+ * This is the URL of the worker file
48
+ */
49
+ workerUrl: string;
50
+ /**
51
+ * This is the list of scripts that will be imported into the worker
52
+ */
53
+ scripts: string[];
54
+ maxWorkers: number;
55
+ /**
56
+ * This is the callback that will be executed when the worker throws an error
57
+ */
58
+ onWorkerError: (error: ErrorEvent) => void;
59
+ private workers;
60
+ keepAlive: boolean;
61
+ terminationDelay: number;
62
+ /**
63
+ * These where send to the worker but not yet resolved
64
+ */
65
+ private messagesQueue;
66
+ protected get isExternalWorkerFile(): boolean;
67
+ constructor(
68
+ /**
69
+ * this parameter should be a function or set of functions that will become the body of your Web-Worker
70
+ * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.
71
+ * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
72
+ * you could easily identify what is on the context of your Worker.
73
+ */
74
+ source: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string | Worker[],
75
+ /**
76
+ * You could import scripts into your worker, this is useful if you want to use external libraries
77
+ */
78
+ { scripts, name, onWorkerError, url, maxWorkers, keepAlive, terminationDelay, warmUpWorkers: warmUp, }?: Partial<IWorkerConfigParallel>);
79
+ private warmUp;
80
+ private RemoveMessageFromQueue;
81
+ /**
82
+ * Categorizes the worker response and executes the corresponding callback
83
+ */
84
+ private executeMessageCallback;
85
+ protected getWorkerUrl(): string;
86
+ protected initializeWorkerBaseSource(): {
87
+ workerUrl: string;
88
+ isArrayOfWebWorkers: boolean;
89
+ isArraySource?: boolean;
90
+ };
91
+ /**
92
+ * Execute the cancel callback of each message in the queue if provided
93
+ * @param {unknown} reason - reason messages where canceled
94
+ * @param {boolean} force - if true, the messages will be cancelled immediately without waiting for the worker to respond
95
+ * This action will reboot the worker
96
+ */
97
+ cancelAll(reason?: unknown, { force }?: {
98
+ force?: boolean;
99
+ }): void;
100
+ protected addMessageToQueue(message: EasyWebWorkerMessage<unknown, unknown>): void;
101
+ /**
102
+ * Send a message to the worker queue to an specific method
103
+ * @template TResult_ - result type of the message (if any)
104
+ * @template TPayload_ - payload type of the message (if any)
105
+ * @param {string} method - method name
106
+ * @param {TPayload} payload - whatever json data you want to send to the worker
107
+ * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
108
+ */
109
+ sendToMethod<TResult_ = void, TPayload_ = null>(method: string, payload?: TPayload_): CancelablePromise<TResult_>;
110
+ /**
111
+ * Send a message to the worker queue
112
+ * @param {TPayload} payload - whatever json data you want to send to the worker
113
+ * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
114
+ */
115
+ send: TPayload extends null ? () => CancelablePromise<TResult> : (payload: TPayload) => CancelablePromise<TResult>;
116
+ private createNewWorkerInstance;
117
+ private getWorkerFromPool;
118
+ private sendToWorker;
119
+ /**
120
+ * This method terminate all current messages and send a new one to the worker queue
121
+ * @param {TPayload} payload - whatever json data you want to send to the worker, should be serializable
122
+ * @param {unknown} reason - reason why the worker was terminated
123
+ * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
124
+ */
125
+ override: TPayload extends null ? (reason?: unknown, config?: TOverrideConfig) => CancelablePromise<TResult> : (payload: TPayload, reason?: unknown, config?: TOverrideConfig) => CancelablePromise<TResult>;
126
+ /**
127
+ * This method will alow the current message to be completed and send a new one to the worker queue after it, all the messages after the current one will be canceled
128
+ * @param {TPayload} payload - whatever json data you want to send to the worker should be serializable
129
+ * @param {unknown} reason - reason why the worker was terminated
130
+ * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
131
+ */
132
+ overrideAfterCurrent: TPayload extends null ? (reason?: unknown, TOverrideConfig?: any) => CancelablePromise<TResult> : (payload: TPayload, reason?: unknown, config?: TOverrideConfig) => CancelablePromise<TResult>;
133
+ /**
134
+ * This method will remove the WebWorker and the BlobUrl
135
+ */
136
+ dispose(): Promise<void>;
137
+ }
package/lib/bundle.js CHANGED
@@ -1,2 +1,134 @@
1
- /*! For license information please see bundle.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["easy-web-worker"]=t():e["easy-web-worker"]=t()}(this,(()=>{return e={30:(e,t,r)=>{"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,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||i(e,t)||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 i(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(){c=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),c=new _(n||[]);return o(a,"_invoke",{value:P(e,r,c)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var h={};function d(){}function y(){}function v(){}var m={};l(m,a,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(S([])));b&&b!==t&&r.call(b,a)&&(m=b);var w=v.prototype=d.prototype=Object.create(m);function j(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(o,a,c,u){var s=p(e[o],e,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){i("next",e,c,u)}),(function(e){i("throw",e,c,u)})):t.resolve(f).then((function(e){l.value=e,c(l)}),(function(e){return i("throw",e,c,u)}))}u(s.arg)}var a;o(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function P(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=O(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function O(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function S(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:y,configurable:!0}),y.displayName=l(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},j(k.prototype),l(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},j(w),l(w,s,"Generator"),l(w,a,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,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(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=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 t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){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&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function u(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,i=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.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(i)?i:String(i)),o)}var i}var s=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EasyWebWorker=t.createBlobWorker=void 0;var l=r(213),f=r(726),p=r(367);t.createBlobWorker=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=Array.isArray(e)?e:[e],o="".concat(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.length?'self.importScripts(["'.concat(e.join('","'),'"]);'):""}(t)).concat((0,f.getWorkerTemplate)()).concat(n.map((function(e){return'self.ew$=self.cw$("'.concat(r,'");(').concat(e,")(self.ew$, self);")})).join(""));return(window.URL||window.webkitURL).createObjectURL(new Blob([o],{type:"application/javascript"}))};var h=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.scripts,a=void 0===i?[]:i,u=n.name,h=n.onWorkerError,d=void 0===h?null:h,y=n.url,v=void 0===y?null:y;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.source=t,this.messagesQueue=new Map,this.workerUrl=null,this.scripts=[],this.send=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=t[0];return r.sendToWorker({payload:o})},this.sendToWorker=function(e){var t,n=e.payload,o=e.method,i=new l.EasyWebWorkerMessage,a=i.messageId,c=i.decoupledPromise,u=c.cancel;c.promise.cancel=function(e){var t;c.cancel=u;var n={messageId:a,method:o,cancelation:{reason:e}};return r.worker?(null===(t=r.worker)||void 0===t||t.postMessage(n),c.promise):(u(e),(0,p.toCancelablePromise)(Promise.reject(e)))},r.addMessageToQueue(i);var s={messageId:a,method:o,execution:{payload:n}};return null===(t=r.worker)||void 0===t||t.postMessage(s),c.promise},this.override=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=t[0],i=t[1],a=t[2];return s(r,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(i,a);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,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t[0],a=t[1],u=t[2];return s(r,void 0,void 0,c().mark((function e(){var t,r,n,s;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesQueue.size){e.next=7;break}return t=o(this.messagesQueue,1),r=t[0],n=o(r,2),s=n[1],this.RemoveMessageFromQueue(s.messageId),e.next=6,this.cancelAll(a,u);case 6:this.addMessageToQueue(s);case 7:return e.abrupt("return",this.send.apply(this,[i]));case 8:case"end":return e.stop()}}),e,this)})))},this.name=u||(0,f.generatedId)(),this.scripts=a,this.worker=this.initializeWorker(),this.onWorkerError=d,v&&(this.workerUrl=v)}var r,n;return r=e,n=[{key:"isExternalWorkerFile",get:function(){return"string"==typeof this.source}},{key:"RemoveMessageFromQueue",value:function(e){this.messagesQueue.delete(e)}},{key:"executeMessageCallback",value:function(e){var t,r,n=null!==(t=this.messagesQueue.get(e.data.messageId))&&void 0!==t?t:null;if(n){var o=e.data.progress;if(this.worker){var c=n.decoupledPromise;if(o){var u=o.percentage,s=o.payload;c.reportProgress(u,s)}else{this.RemoveMessageFromQueue(n.messageId);var l=e.data.worker_canceled;if(l){var f=l.reason;c.reject(f)}else{var p=e.data.rejected;if(p){var h=p.reason;c.reject(h)}else{var d=e.data.resolved.payload;c.resolve.apply(c,function(e){if(Array.isArray(e))return a(e)}(r=null!=d?d:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||i(r)||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.source:(0,t.createBlobWorker)(this.source,this.scripts)}},{key:"initializeWorker",value:function(){var e,t=this,r=this.source instanceof Worker;r||(this.workerUrl=null!==(e=this.workerUrl)&&void 0!==e?e:this.getWorkerUrl());var n=r?this.source:new Worker(this.workerUrl,{name:this.name});return n.onmessage=function(e){t.executeMessageCallback(e)},n.onerror=function(e){if(!t.onWorkerError)throw e;t.onWorkerError(e)},n}},{key:"cancelAll",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).force,r=void 0!==t&&t,n=Array.from(this.messagesQueue.values()),o=100/n.length;if(r)return this.reboot(e);var i=n.map((function(t){var r=t.decoupledPromise.promise;return r.cancel(e).catch((function(e){return r.reportProgress(o,e),e}))}));return Promise.all(i)}},{key:"addMessageToQueue",value:function(e){this.messagesQueue.set(e.messageId,e)}},{key:"sendToMethod",value:function(e,t){return this.sendToWorker({method:e,payload:t})}},{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 t=this.cancelAll(e);return this.worker=this.initializeWorker(),t}},{key:"dispose",value:function(){return s(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&&u(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),e}();t.EasyWebWorker=h},726:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWorkerTemplate=t.generatedId=void 0,t.generatedId=function(){return"".concat((new Date).getTime()).concat(Math.random().toString(36).substr(2,9))},t.getWorkerTemplate=function(){return"self.cw$=a=>{const b=new Map(),c=new Map([['',()=>{throw\"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\"}]]),d=({messageId:e,payload:f,origin:g})=>{const h=new Set(),i=j=>{const{progress:k}=j;k||b.delete(e),self.postMessage({messageId:e,...j},g)},l=(...m)=>{i({resolved:{payload:m}})},n=o=>{i({rejected:{reason:o}})},p=q=>{[...h].forEach(r=>r(q)),i({worker_canceled:{reason:q}})},s=(t,u)=>{i({progress:{percentage:t,payload:u}})},v=w=>(h.add(w),()=>h.delete(w));return{payload:f,resolve:l,reject:n,cancel:p,onCancel:v,reportProgress:s}},x=(...y)=>{self.importScripts(...y)},z=(...A)=>{const[B,C]=A,D=typeof B==='string';if(D){const E=B,F=C;c.set(E,F);return;}const G=B;c.set('',G)},H=()=>{[...b.values()].forEach(I=>I.reject(new Error('worker closed')));self.close();};self.onmessage=J=>{const{data:K,origin:L}=J,{messageId:M,cancelation:N}=K;if(N){const{reason:O}=N,P=b.get(M);P.cancel(O);return;}const{method:Q,execution:R}=K,{payload:S}=R,T=d({messageId:M,payload:S,origin:a||L||undefined});b.set(M,T);const U=c.get(Q||'');U(T,J)};return{importScripts:x,onMessage:z,close:H}};"}},213:(e,t,r)=>{"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,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,i=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.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(i)?i:String(i)),o)}var i}function i(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(t,"__esModule",{value:!0}),t.EasyWebWorkerMessage=void 0;var a=r(367),c=r(726),u=i((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.messageId=(0,c.generatedId)(),this.decoupledPromise=(0,a.createDecoupledPromise)()}));t.EasyWebWorkerMessage=u},973:(e,t)=>{"use strict";function r(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,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):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,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.createStaticEasyWebWorker=t.StaticEasyWebWorker=void 0,t.StaticEasyWebWorker=function(e){var t=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"}]]),i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t[0],i=t[1];if("string"==typeof n){var a=n,c=i;o.set(a,c)}else{var u=n;o.set("",u)}};self.onmessage=function(e){var i=e.data,a=e.origin,c=i.messageId,u=i.cancelation;if(u){var s=u.reason;n.get(c).cancel(s)}else{var l=e.data,f=l.method,p=function(e){var t=e.messageId,o=e.payload,i=e.origin,a=new Set,c=function(e){e.progress||n.delete(t),self.postMessage(Object.assign({messageId:t},e),i)};return{payload:o,resolve:function(){var e=Array.from(arguments);c({resolved:{payload:e}})},reject:function(e){c({rejected:{reason:e}})},cancel:function(e){r(a).forEach((function(t){return t(e)})),c({canceled:{reason:e}})},onCancel:function(e){return a.add(e),function(){return a.delete(e)}},reportProgress:function(e,t){c({progress:{percentage:e,payload:t}})}}}({messageId:c,payload:l.execution.payload,origin:t||a||void 0});o.get(f||"")(p,e)}},e&&i(e),this.importScripts=function(){var e;(e=self).importScripts.apply(e,arguments)},this.close=function(){r(n.values()).forEach((function(e){return e.reject(new Error("worker closed"))})),self.close()},this.onMessage=i},t.createStaticEasyWebWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return new t.StaticEasyWebWorker(e,r)}},991:(e,t,r)=>{"use strict";var n=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=r(30);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.EasyWebWorker}}),o(r(30),t),o(r(973),t)},367:function(e){var t;t=()=>(()=>{"use strict";var e={399:(e,t)=>{function r(e){return r="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},r(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,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},o.apply(this,arguments)}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},i(e)}function a(e,t,r){return a=c()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&u(o,r.prototype),o},a.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 u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.CancelablePromise=void 0;var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(f,e);var t,i,a,l=(i=f,a=c(),function(){var e,t=s(i);if(a){var o=s(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}(this,e)});function f(e){var t,r,i,a,c,u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,f),(a=l.call(this,(function(e,t){c=e,u=t}))).status="pending",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(t){return t(e)})),a.cancelCallbacks.forEach((function(t){return t(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,t){return a.onProgressCallbacks.forEach((function(r){return r(e,t)})),n(a)},a.createChildPromise=function(){var e,t,r=new f((function(r,n,o){e=r,t=n}));return r.onProgressCallbacks=a.onProgressCallbacks,r.onCancel((function(e){a.cancel(e)})),{promise:r,resolve:e,reject:t}},a.resolve=c,a.reject=u,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,t){a.reportProgress(e,t)}}),a.then=function(e,r){var i=a.createChildPromise(),c=i.promise,u=i.resolve,l=i.reject;return o((t=n(a),s(f.prototype)),"then",t).call(t,e,r).then(u,l),c},a.catch=function(e){var t=a.createChildPromise(),i=t.promise,c=t.resolve,u=t.reject;return o((r=n(a),s(f.prototype)),"catch",r).call(r,e).then(c,u),i},a.finally=function(e){var t=a.createChildPromise(),r=t.promise,c=t.resolve,u=t.reject;return o((i=n(a),s(f.prototype)),"finally",i).call(i,e).then(c,u),r},a}return t=f,Object.defineProperty(t,"prototype",{writable:!1}),t}(i(Promise));t.CancelablePromise=l,l.prototype.constructor=Promise},716:(e,t,r)=>{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)}Object.defineProperty(t,"__esModule",{value:!0}),t.toCancelablePromise=t.isPromise=t.groupAsCancelablePromise=t.createDecoupledPromise=t.allSettledCancelable=void 0;var o=r(335),i=r(399);function a(){a=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),c=new _(n||[]);return o(a,"_invoke",{value:P(e,r,c)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var h={};function d(){}function y(){}function v(){}var m={};l(m,c,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(S([])));b&&b!==t&&r.call(b,c)&&(m=b);var w=v.prototype=d.prototype=Object.create(m);function j(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(o,a,c,u){var s=p(e[o],e,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){i("next",e,c,u)}),(function(e){i("throw",e,c,u)})):t.resolve(f).then((function(e){l.value=e,c(l)}),(function(e){return i("throw",e,c,u)}))}u(s.arg)}var a;o(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function P(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=O(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function O(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function S(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:y,configurable:!0}),y.displayName=l(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},j(k.prototype),l(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},j(w),l(w,s,"Generator"),l(w,c,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,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(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=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 t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){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&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}t.createDecoupledPromise=function(){var e,t,r,n=new i.CancelablePromise((function(n,o,i){e=n,t=o,r=i}));return Object.assign(Object.assign({resolve:e,reject:t},r),{promise:n})};var u=function e(t){if(t instanceof i.CancelablePromise)return t;if("function"==typeof t)return e(t());if(!l(t))return new i.CancelablePromise((function(e){return e(t)}));var r,n,o=new i.CancelablePromise((function(e,o,i){r=e,n=o,t.then(r,n)}));return o.onCancel((function(e){n(e)})),o};t.toCancelablePromise=u;var s=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var r,n=t.maxConcurrent,o=void 0===n?8:n,a=t.executeInOrder,s=void 0!==a&&a,l=t.beforeEachCallback,f=void 0===l?null:l,p=t.afterEachCallback,h=void 0===p?null:p,d=t.onQueueEmptyCallback,y=void 0===d?null:d,v=function(e){if(Array.isArray(e))return c(e)}(r=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(r)||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 i.CancelablePromise((function(e,t,r){return function e(){if(v.length){var t=v.splice(0,o).map((function(e){var t="function"==typeof e?e():e;null==f||f();var n=u(t);return r.onCancel((function(){n.cancel()})),n.then((function(e){m.push(e),null==h||h(e)})),s?n.then((function(e){return e})):n}));return Promise.all(t).then((function(){return e()}))}}().then((function(){null==y||y(m),e(m)}))}))};t.groupAsCancelablePromise=s;var l=function(e){return Promise.resolve(e)===e};t.isPromise=l,t.allSettledCancelable=function(e){var t=[],r=e.map((function(e){var r=u(e);return t.push(r),(0,o.tryCatchPromise)((function(){return r})).then((function(e){return{error:e.error,result:e.result,promise:r}}))})),n=s(t);return new i.CancelablePromise((function(e,t,o){return i=void 0,c=a().mark((function t(){var i;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.onCancel(n.cancel),t.next=3,Promise.all(r);case 3:i=t.sent,e(i);case 5:case"end":return t.stop()}}),t)})),new(i||(i=Promise))((function(e,t){function r(e){try{o(c.next(e))}catch(e){t(e)}}function n(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof i?o:new i((function(e){e(o)}))).then(r,n)}o((c=c.apply(void 0,[])).next())}));var i,c}))}},522:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(399);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(716);Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},991:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(522);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(335);Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},335:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(969);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}))},969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r(948);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(667);Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},948:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchPromise=t.tryCatch=void 0;var n=r(522);t.tryCatch=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.defaultResult,n=void 0===r?null:r,o=t.exceptionHandlingType,i=void 0===o?"error":o;try{return{error:null,result:e()}}catch(e){return"ignore"!==i&&console[i](e),{error:e,result:n}}},t.tryCatchPromise=function(e,t){var r=t||{},o=r.defaultResult,i=void 0===o?null:o,a=r.exceptionHandlingType,c=void 0===a?"error":a,u=r.ignoreCancel,s=void 0===u||u,l=null,f=null,p=function(e){f=e,"ignore"!=c&&("canceled"===l.status&&s||console[c](f))};try{if(e instanceof n.CancelablePromise)return l=e,new Promise((function(e){l.then((function(e){return{error:null,result:e,promise:l}})).catch((function(e){return p(e),{error:e,result:i,promise:l}}))}));var h=e(),d=h instanceof n.CancelablePromise;return l=d?h:(0,n.toCancelablePromise)(h),new Promise((function(e){l.then((function(t){e({error:null,result:t,promise:l})})).catch((function(t){p(t),e({error:t,result:i,promise:l})}))}))}catch(e){return p(e),Promise.resolve({error:f,result:i,promise:l})}}},667:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})}},t={};return function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}(991)})(),e.exports=t()}},t={},function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(991);var e,t}));
1
+ /*
2
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
+ * This devtool is neither made for production nor for readable output files.
4
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
+ * or disable the default devtool with "devtool: false".
7
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory();
12
+ else if(typeof define === 'function' && define.amd)
13
+ define([], factory);
14
+ else if(typeof exports === 'object')
15
+ exports["easy-web-worker"] = factory();
16
+ else
17
+ root["easy-web-worker"] = factory();
18
+ })(this, () => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ var __webpack_modules__ = ({
21
+
22
+ /***/ "./src/EasyWebWorker.functions.ts":
23
+ /*!****************************************!*\
24
+ !*** ./src/EasyWebWorker.functions.ts ***!
25
+ \****************************************/
26
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
27
+
28
+ "use strict";
29
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.createEasyWebWorker = void 0;\nvar EasyWebWorker_1 = __webpack_require__(/*! ./EasyWebWorker */ \"./src/EasyWebWorker.ts\");\nvar createEasyWebWorker = function createEasyWebWorker(source) {\n var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return new EasyWebWorker_1.EasyWebWorker(source, parameters);\n};\nexports.createEasyWebWorker = createEasyWebWorker;\n\n//# sourceURL=webpack://easy-web-worker/./src/EasyWebWorker.functions.ts?");
30
+
31
+ /***/ }),
32
+
33
+ /***/ "./src/EasyWebWorker.ts":
34
+ /*!******************************!*\
35
+ !*** ./src/EasyWebWorker.ts ***!
36
+ \******************************/
37
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
38
+
39
+ "use strict";
40
+ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i[\"return\"] && (_r = _i[\"return\"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, \"throw\" === methodName && delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method) || \"return\" !== methodName && (context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a '\" + methodName + \"' method\")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.EasyWebWorker = exports.createBlobWorker = void 0;\nvar EasyWebWorkerMessage_1 = __webpack_require__(/*! ./EasyWebWorkerMessage */ \"./src/EasyWebWorkerMessage.ts\");\nvar EasyWebWorkerFixtures_1 = __webpack_require__(/*! ./EasyWebWorkerFixtures */ \"./src/EasyWebWorkerFixtures.ts\");\nvar cancelable_promise_jq_1 = __webpack_require__(/*! cancelable-promise-jq */ \"./node_modules/cancelable-promise-jq/lib/bundle.js\");\nvar getImportScriptsTemplate = function getImportScriptsTemplate() {\n var scripts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n if (!scripts.length) return '';\n return \"self.importScripts([\\\"\".concat(scripts.join('\",\"'), \"\\\"]);\");\n};\nvar createBlobWorker = function createBlobWorker(source) {\n var imports = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},\n _ref$primitiveParamet = _ref.primitiveParameters,\n primitiveParameters = _ref$primitiveParamet === void 0 ? [] : _ref$primitiveParamet;\n var contentCollection = Array.isArray(source) ? source : [source];\n var worker_content = \"self.primitiveParameters=JSON.parse(`\".concat(JSON.stringify(primitiveParameters !== null && primitiveParameters !== void 0 ? primitiveParameters : []), \"`);\").concat(getImportScriptsTemplate(imports)).concat((0, EasyWebWorkerFixtures_1.getWorkerTemplate)()).concat(contentCollection.map(function (content) {\n return \"self.ew$=self.cw$(\\\"\".concat(origin, \"\\\");(\").concat(content, \")(self.ew$, self);\");\n }).join(''));\n return (window.URL || window.webkitURL).createObjectURL(new Blob([worker_content], {\n type: 'application/javascript'\n }));\n};\nexports.createBlobWorker = createBlobWorker;\n/**\n * This is a class to create an EasyWebWorker\n * @template TPayload - Indicates if your WORKERS messages requires a parameter to be provided, NULL indicates they doesn't\n * @template TResult - Indicates if your WORKERS messages has a result... NULL indicates all you messages are Promise<void>\n * @param {EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[]} workerBody -\n * this parameter should be a function or set of functions that will become the body of your Web-Worker\n * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.\n * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,\n * you could easily identify what is on the context of your Worker.\n * @param {Partial<IWorkerConfig>} WorkerConfig - You could add extra configuration to your worker,\n * consult IWorkerConfig description to have more information\n * */\nvar EasyWebWorker = /*#__PURE__*/function () {\n function EasyWebWorker(\n /**\n * this parameter should be a function or set of functions that will become the body of your Web-Worker\n * IMPORTANT!! all WORKERS content is gonna be transpiled on run time, so you can not use any variable, method of resource that weren't included into the WORKER.\n * the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,\n * you could easily identify what is on the context of your Worker.\n */\n source) {\n var _this = this;\n var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref2$scripts = _ref2.scripts,\n scripts = _ref2$scripts === void 0 ? [] : _ref2$scripts,\n name = _ref2.name,\n _ref2$onWorkerError = _ref2.onWorkerError,\n onWorkerError = _ref2$onWorkerError === void 0 ? null : _ref2$onWorkerError,\n _ref2$url = _ref2.url,\n url = _ref2$url === void 0 ? null : _ref2$url,\n _ref2$maxWorkers = _ref2.maxWorkers,\n maxWorkers = _ref2$maxWorkers === void 0 ? 1 : _ref2$maxWorkers,\n _ref2$keepAlive = _ref2.keepAlive,\n _keepAlive = _ref2$keepAlive === void 0 ? null : _ref2$keepAlive,\n _ref2$terminationDela = _ref2.terminationDelay,\n terminationDelay = _ref2$terminationDela === void 0 ? 1000 : _ref2$terminationDela,\n _ref2$warmUpWorkers = _ref2.warmUpWorkers,\n _warmUpWorkers = _ref2$warmUpWorkers === void 0 ? null : _ref2$warmUpWorkers,\n primitiveParameters = _ref2.primitiveParameters,\n _ref2$origin = _ref2.origin,\n origin = _ref2$origin === void 0 ? '' : _ref2$origin;\n _classCallCheck(this, EasyWebWorker);\n this.source = source;\n this.maxWorkers = 1;\n this.workers = [];\n this.keepAlive = true;\n this.warmUpWorkers = false;\n this.terminationDelay = 1000;\n this.origin = '';\n this.primitiveParameters = [];\n /**\n * These where send to the worker but not yet resolved\n */\n this.messagesQueue = new Map();\n /**\n * This is the URL of the worker file\n */\n this.workerUrl = null;\n /**\n * This is the list of scripts that will be imported into the worker\n */\n this.scripts = [];\n this.warmUp = function () {\n if (!_this.warmUpWorkers) return;\n var maxWorkers = _this.maxWorkers;\n new Array(maxWorkers).fill(null).forEach(function () {\n return _this.getWorkerFromPool();\n });\n };\n this.fillWorkerMethods = function (worker) {\n worker.onmessage = function (event) {\n _this.executeMessageCallback(event);\n };\n /**\n * If not handled, the error will be thrown to the global scope\n */\n worker.onerror = function (reason) {\n if (!_this.onWorkerError) throw reason;\n _this.onWorkerError(reason);\n };\n return worker;\n };\n this.createNewWorker = function () {\n var worker = new Worker(_this.workerUrl, {\n name: function () {\n var length = _this.workers.length;\n if (length === 0) return _this.name;\n return \"\".concat(_this.name, \"-\").concat(length);\n }()\n });\n return _this.fillWorkerMethods(worker);\n };\n this.getWorkerFromPool = function () {\n var maxWorkers = _this.maxWorkers,\n messagesQueue = _this.messagesQueue;\n var messagesQueueSize = messagesQueue.size;\n // there are less workers than the maximum allowed, and there is messages in the queue\n if (!_this.workers.length || _this.workers.length < maxWorkers && messagesQueueSize) {\n var _worker = _this.createNewWorker();\n _this.workers.push(_worker);\n return _worker;\n }\n // rotate the worker\n var worker = _this.workers.shift();\n _this.workers.push(worker);\n return worker;\n };\n this.computeWorkerBaseSource = function () {\n var _ref3 = function () {\n var _a, _b;\n var isWorkerInstance = _this.source instanceof Worker;\n if (isWorkerInstance) {\n // static simgle workers instance\n _this.workers = [_this.fillWorkerMethods(_this.source)];\n return {\n isArrayOfWebWorkers: false,\n workerUrl: null\n };\n }\n var isUrlBase = typeof _this.source === 'string';\n var isFunctionTemplate = typeof _this.source === 'function';\n if (isUrlBase || isFunctionTemplate) {\n var _workerUrl = (_a = _this.workerUrl) !== null && _a !== void 0 ? _a : _this.getWorkerUrl();\n return {\n isArrayOfWebWorkers: false,\n workerUrl: _workerUrl\n };\n }\n var isArraySource = Array.isArray(_this.source);\n var isArrayOfFunctionsTemplates = isArraySource && typeof _this.source[0] === 'function';\n if (isArrayOfFunctionsTemplates) {\n var _workerUrl2 = (_b = _this.workerUrl) !== null && _b !== void 0 ? _b : _this.getWorkerUrl();\n return {\n isArrayOfWebWorkers: false,\n workerUrl: _workerUrl2\n };\n }\n var isArrayOfWebWorkers = isArraySource && _this.source[0] instanceof Worker;\n if (isArrayOfWebWorkers) {\n // static workers collection\n _this.workers = _this.source.map(_this.fillWorkerMethods);\n return {\n isArrayOfWebWorkers: isArrayOfWebWorkers,\n workerUrl: null\n };\n }\n return {\n isArrayOfWebWorkers: false,\n workerUrl: null\n };\n }(),\n workerUrl = _ref3.workerUrl,\n isArrayOfWebWorkers = _ref3.isArrayOfWebWorkers;\n _this.workerUrl = workerUrl;\n _this.maxWorkers = isArrayOfWebWorkers ? _this.workers.length : _this.maxWorkers;\n // if the source is an array of web workers we need to keep them alive\n _this.keepAlive = isArrayOfWebWorkers ? true : _this.keepAlive;\n };\n /**\n * Send a message to the worker queue\n * @param {TPayload} payload - whatever json data you want to send to the worker\n * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed\n */\n this.send = function () {\n for (var _len = arguments.length, payload = new Array(_len), _key = 0; _key < _len; _key++) {\n payload[_key] = arguments[_key];\n }\n var $payload = payload[0];\n return _this.sendToWorker({\n payload: $payload\n });\n };\n this.sendToWorker = function (_ref4) {\n var payload = _ref4.payload,\n method = _ref4.method;\n var _a, _b;\n var message = new EasyWebWorkerMessage_1.EasyWebWorkerMessage();\n var messageId = message.messageId,\n decoupledPromise = message.decoupledPromise;\n var cancel = decoupledPromise.cancel;\n var worker = _this.getWorkerFromPool();\n decoupledPromise.promise.cancel = function (reason) {\n // restore the original cancel method so we can cancel the message when the worker response\n decoupledPromise.cancel = cancel;\n // if the message is canceled, we need to send a cancelation message to the worker,\n // once the worker response, the message will be removed from the queue nad the promise will be canceled in the main thread\n var data = {\n messageId: messageId,\n method: method,\n cancelation: {\n reason: reason\n }\n };\n // if the worker was disposed, we need to automatically reject the promise\n if (!_this.workers.length) {\n cancel(reason);\n return (0, cancelable_promise_jq_1.toCancelablePromise)(Promise.reject(reason));\n }\n worker.postMessage(data);\n return decoupledPromise.promise;\n };\n if (!_this.keepAlive) {\n (_b = (_a = decoupledPromise.promise) === null || _a === void 0 ? void 0 : _a[\"finally\"]) === null || _b === void 0 ? void 0 : _b.call(_a, function () {\n setTimeout(function () {\n var messagesQueue = _this.messagesQueue;\n if (messagesQueue.size) return;\n _this.workers.forEach(function (worker) {\n return worker.terminate();\n });\n _this.workers = [];\n }, _this.terminationDelay);\n });\n }\n _this.addMessageToQueue(message);\n var data = {\n messageId: messageId,\n method: method,\n execution: {\n payload: payload\n }\n };\n worker.postMessage(data);\n return decoupledPromise.promise;\n };\n /**\n * This method terminate all current messages and send a new one to the worker queue\n * @param {TPayload} payload - whatever json data you want to send to the worker, should be serializable\n * @param {unknown} reason - reason why the worker was terminated\n * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed\n */\n this.override = function () {\n for (var _len2 = arguments.length, _ref5 = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n _ref5[_key2] = arguments[_key2];\n }\n var payload = _ref5[0],\n reason = _ref5[1],\n config = _ref5[2];\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return this.cancelAll(reason, config);\n case 2:\n return _context.abrupt(\"return\", this.send.apply(this, [payload]));\n case 3:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this);\n }));\n };\n /**\n * This method will alow the current message to be completed and send a new one to the worker queue after it, all the messages after the current one will be canceled\n * @param {TPayload} payload - whatever json data you want to send to the worker should be serializable\n * @param {unknown} reason - reason why the worker was terminated\n * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed\n */\n this.overrideAfterCurrent = function () {\n for (var _len3 = arguments.length, _ref6 = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n _ref6[_key3] = arguments[_key3];\n }\n var payload = _ref6[0],\n reason = _ref6[1],\n config = _ref6[2];\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this$messagesQueue, firstItem, _firstItem, currentMessage;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!this.messagesQueue.size) {\n _context2.next = 7;\n break;\n }\n _this$messagesQueue = _slicedToArray(this.messagesQueue, 1), firstItem = _this$messagesQueue[0];\n _firstItem = _slicedToArray(firstItem, 2), currentMessage = _firstItem[1];\n this.RemoveMessageFromQueue(currentMessage.messageId);\n _context2.next = 6;\n return this.cancelAll(reason, config);\n case 6:\n this.addMessageToQueue(currentMessage);\n case 7:\n return _context2.abrupt(\"return\", this.send.apply(this, [payload]));\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n };\n var warmUpWorkers = !maxWorkers || maxWorkers === 1 ? true : _warmUpWorkers;\n var keepAlive = warmUpWorkers || (_keepAlive !== null && _keepAlive !== void 0 ? _keepAlive : false);\n this.name = name || (0, EasyWebWorkerFixtures_1.generatedId)();\n this.scripts = scripts;\n this.onWorkerError = onWorkerError;\n this.workerUrl = url !== null && url !== void 0 ? url : null;\n this.maxWorkers = maxWorkers;\n this.keepAlive = keepAlive;\n this.terminationDelay = terminationDelay;\n this.warmUpWorkers = warmUpWorkers;\n this.primitiveParameters = primitiveParameters !== null && primitiveParameters !== void 0 ? primitiveParameters : [];\n this.origin = origin;\n this.computeWorkerBaseSource();\n this.warmUp();\n }\n _createClass(EasyWebWorker, [{\n key: \"worker\",\n get:\n /**\n * @deprecated Directly modifying the worker may lead to unexpected behavior. Use it only if you know what you are doing.\n */\n function get() {\n return this.workers.length > 1 ? null : this.workers[0];\n }\n }, {\n key: \"isExternalWorkerFile\",\n get: function get() {\n return typeof this.source === 'string';\n }\n }, {\n key: \"RemoveMessageFromQueue\",\n value: function RemoveMessageFromQueue(messageId) {\n this.messagesQueue[\"delete\"](messageId);\n }\n /**\n * Categorizes the worker response and executes the corresponding callback\n */\n }, {\n key: \"executeMessageCallback\",\n value: function executeMessageCallback(event) {\n var _a;\n var message = (_a = this.messagesQueue.get(event.data.messageId)) !== null && _a !== void 0 ? _a : null;\n if (!message) return;\n var progress = event.data.progress;\n // workers were disposed before the message was resolved\n if (!this.workers.length) {\n this.RemoveMessageFromQueue(message.messageId);\n return;\n }\n var decoupledPromise = message.decoupledPromise;\n // execute progress callback\n if (progress) {\n var percentage = progress.percentage,\n _payload = progress.payload;\n decoupledPromise.reportProgress(percentage, _payload);\n return;\n }\n // remove message from queue\n this.RemoveMessageFromQueue(message.messageId);\n var worker_canceled = event.data.worker_canceled;\n if (worker_canceled) {\n var reason = worker_canceled.reason;\n decoupledPromise.reject(reason);\n return;\n }\n var rejected = event.data.rejected;\n if (rejected) {\n var _reason = rejected.reason;\n decoupledPromise.reject(_reason);\n return;\n }\n var resolved = event.data.resolved;\n var payload = resolved.payload;\n // resolve message with the serialized payload\n decoupledPromise.resolve.apply(decoupledPromise, _toConsumableArray(payload !== null && payload !== void 0 ? payload : []));\n }\n }, {\n key: \"getWorkerUrl\",\n value: function getWorkerUrl() {\n var _a;\n if (this.isExternalWorkerFile) {\n return this.source;\n }\n return (0, exports.createBlobWorker)(this.source, this.scripts, (_a = this.origin) !== null && _a !== void 0 ? _a : '', {\n primitiveParameters: this.primitiveParameters\n });\n }\n /**\n * Execute the cancel callback of each message in the queue if provided\n * @param {unknown} reason - reason messages where canceled\n * @param {boolean} force - if true, the messages will be cancelled immediately without waiting for the worker to respond\n * This action will reboot the worker\n */\n }, {\n key: \"cancelAll\",\n value: function cancelAll(reason) {\n var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref7$force = _ref7.force,\n force = _ref7$force === void 0 ? false : _ref7$force;\n var messages = Array.from(this.messagesQueue.values());\n var total = messages.length;\n var percentage = 100 / total;\n if (force) {\n return this.reboot(reason);\n }\n var rejectedPromises = messages.map(function (message) {\n var decoupledPromise = message.decoupledPromise;\n var promise = decoupledPromise.promise;\n // promises are gonna be rejected so we need to wait until they are settled\n return promise.cancel(reason)[\"catch\"](function (error) {\n promise.reportProgress(percentage, error);\n return error;\n });\n });\n return Promise.all(rejectedPromises);\n }\n }, {\n key: \"addMessageToQueue\",\n value: function addMessageToQueue(message) {\n this.messagesQueue.set(message.messageId, message);\n }\n /**\n * Send a message to the worker queue to an specific method\n * @template TResult_ - result type of the message (if any)\n * @template TPayload_ - payload type of the message (if any)\n * @param {string} method - method name\n * @param {TPayload} payload - whatever json data you want to send to the worker\n * @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed\n */\n }, {\n key: \"sendToMethod\",\n value: function sendToMethod(method, payload) {\n return this.sendToWorker({\n method: method,\n payload: payload\n });\n }\n /**\n * This method will reboot the worker and cancel all the messages in the queue\n * @param {unknown} reason - reason why the worker will be restarted\n */\n }, {\n key: \"reboot\",\n value: function reboot() {\n var reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Worker was rebooted';\n if (!this.workerUrl) {\n throw new Error('You can not reboot a worker that was created from a Worker Instance');\n }\n this.workers.forEach(function (worker) {\n return worker.terminate();\n });\n this.workers = [];\n // the messages need to be canceled before the worker is restarted to force an immediate rejection\n var resolutionPromises = this.cancelAll(reason);\n this.warmUp();\n return resolutionPromises;\n }\n /**\n * This method will remove the WebWorker and the BlobUrl\n */\n }, {\n key: \"dispose\",\n value: function dispose() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.cancelAll(null);\n case 2:\n if (this.workerUrl) URL.revokeObjectURL(this.workerUrl);\n this.workers.forEach(function (worker) {\n return worker.terminate();\n });\n this.workers = [];\n case 5:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }]);\n return EasyWebWorker;\n}();\nexports.EasyWebWorker = EasyWebWorker;\n\n//# sourceURL=webpack://easy-web-worker/./src/EasyWebWorker.ts?");
41
+
42
+ /***/ }),
43
+
44
+ /***/ "./src/EasyWebWorkerFixtures.ts":
45
+ /*!**************************************!*\
46
+ !*** ./src/EasyWebWorkerFixtures.ts ***!
47
+ \**************************************/
48
+ /***/ ((__unused_webpack_module, exports) => {
49
+
50
+ "use strict";
51
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.getWorkerTemplate = exports.generatedId = void 0;\nvar generatedId = function generatedId() {\n return \"\".concat(new Date().getTime()).concat(Math.random().toString(36).substr(2, 9));\n};\nexports.generatedId = generatedId;\nvar getWorkerTemplate = function getWorkerTemplate() {\n var template = \"self.cw$=a=>{const b=new Map(),c=new Map([['',()=>{throw\\\"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\\\"}]]),d=({messageId:e,payload:f,origin:g})=>{const h=new Set(),i=j=>{const{progress:k}=j;k||b.delete(e),self.postMessage({messageId:e,...j},g)},l=(...m)=>{i({resolved:{payload:m}})},n=o=>{i({rejected:{reason:o}})},p=q=>{[...h].forEach(r=>r(q)),i({worker_canceled:{reason:q}})},s=(t,u)=>{i({progress:{percentage:t,payload:u}})},v=w=>(h.add(w),()=>h.delete(w));return{payload:f,resolve:l,reject:n,cancel:p,onCancel:v,reportProgress:s}},x=(...y)=>{self.importScripts(...y)},z=(...A)=>{const[B,C]=A,D=typeof B==='string';if(D){const E=B,F=C;c.set(E,F);return;}const G=B;c.set('',G)},H=()=>{[...b.values()].forEach(I=>I.reject(new Error('worker closed')));self.close();};self.onmessage=J=>{const{data:K,origin:L}=J,{messageId:M,cancelation:N}=K;if(N){const{reason:O}=N,P=b.get(M);P.cancel(O);return;}const{method:Q,execution:R}=K,{payload:S}=R,T=d({messageId:M,payload:S,origin:a||L||undefined});b.set(M,T);const U=c.get(Q||'');U(T,J)};return{importScripts:x,onMessage:z,close:H}};\";\n return template;\n};\nexports.getWorkerTemplate = getWorkerTemplate;\n\n//# sourceURL=webpack://easy-web-worker/./src/EasyWebWorkerFixtures.ts?");
52
+
53
+ /***/ }),
54
+
55
+ /***/ "./src/EasyWebWorkerMessage.ts":
56
+ /*!*************************************!*\
57
+ !*** ./src/EasyWebWorkerMessage.ts ***!
58
+ \*************************************/
59
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
60
+
61
+ "use strict";
62
+ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.EasyWebWorkerMessage = void 0;\nvar cancelable_promise_jq_1 = __webpack_require__(/*! cancelable-promise-jq */ \"./node_modules/cancelable-promise-jq/lib/bundle.js\");\nvar EasyWebWorkerFixtures_1 = __webpack_require__(/*! ./EasyWebWorkerFixtures */ \"./src/EasyWebWorkerFixtures.ts\");\n/**\n * This class represents a message that will be send to a worker\n */\nvar EasyWebWorkerMessage = /*#__PURE__*/_createClass(function EasyWebWorkerMessage() {\n _classCallCheck(this, EasyWebWorkerMessage);\n this.messageId = (0, EasyWebWorkerFixtures_1.generatedId)();\n this.decoupledPromise = (0, cancelable_promise_jq_1.createDecoupledPromise)();\n});\nexports.EasyWebWorkerMessage = EasyWebWorkerMessage;\n\n//# sourceURL=webpack://easy-web-worker/./src/EasyWebWorkerMessage.ts?");
63
+
64
+ /***/ }),
65
+
66
+ /***/ "./src/StaticEasyWebWorker.ts":
67
+ /*!************************************!*\
68
+ !*** ./src/StaticEasyWebWorker.ts ***!
69
+ \************************************/
70
+ /***/ ((__unused_webpack_module, exports) => {
71
+
72
+ "use strict";
73
+ eval("\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.createStaticEasyWebWorker = exports.StaticEasyWebWorker = void 0;\n/**\n * Constructor for the StaticEasyWebWorker\n * @param onMessageCallback - callback to be called when a message is received\n * @param targetOrigin - the target origin to be used when sending messages\n * @returns an instance of the StaticEasyWebWorker\n * */\nexports.StaticEasyWebWorker = function (onMessageCallback) {\n var targetOrigin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var createMessage = function createMessage(_ref) {\n var messageId = _ref.messageId,\n payload = _ref.payload,\n origin = _ref.origin;\n var cancelCallbacks = new Set();\n var postMessage = function postMessage(data) {\n var progress = data.progress;\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 self.postMessage(Object.assign({\n messageId: messageId\n }, data), origin);\n };\n var resolve = function resolve() {\n var result = Array.from(arguments);\n postMessage({\n resolved: {\n payload: result\n }\n });\n };\n var reject = function reject(reason) {\n postMessage({\n rejected: {\n reason: reason\n }\n });\n };\n var cancel = function cancel(reason) {\n var callbacks = _toConsumableArray(cancelCallbacks);\n callbacks.forEach(function (callback) {\n return callback(reason);\n });\n postMessage({\n canceled: {\n reason: reason\n }\n });\n };\n /* Returns a function that can be used to unsubscribe from the cancelation */\n var onCancel = function onCancel(callback) {\n cancelCallbacks.add(callback);\n return function () {\n return cancelCallbacks[\"delete\"](callback);\n };\n };\n var reportProgress = function reportProgress(percentage, payload) {\n postMessage({\n progress: {\n percentage: percentage,\n payload: payload\n }\n });\n };\n return {\n payload: payload,\n resolve: resolve,\n reject: reject,\n cancel: cancel,\n onCancel: onCancel,\n reportProgress: reportProgress\n };\n };\n /**\n * This is the map that contains all the messages that are being processed by the worker\n */\n var workerMessages = new Map();\n /**\n * This is the map that contains all the callbacks that are being processed by the worker\n * */\n var workerCallbacks = new Map([['', function () {\n throw \"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\";\n }]]);\n var importScripts = function importScripts() {\n var _self;\n // @ts-ignore\n (_self = self).importScripts.apply(_self, arguments);\n };\n var close = function close() {\n /* should cancel all the promises of the main thread before closing the worker */\n var messages = _toConsumableArray(workerMessages.values());\n messages.forEach(function (message) {\n return message.reject(new Error('worker closed'));\n });\n self.close();\n };\n /**\n * This method is used to define the onMessage callback\n * @param {string} callbackKey - This is the key of the callback\n * @param {function} callback - This is the callback that will be executed when a message is received\n * @param {IEasyWebWorkerMessage} callback.message - This is the message that was received\n * @param {IEasyWebWorkerMessage} callback.message.messageId - This is the message id\n * @param {IEasyWebWorkerMessage} callback.message.payload - This are the parameters included in the message\n * @param {IEasyWebWorkerMessage} callback.message.reject - This method is used to reject the message from inside the worker\n * @param {IEasyWebWorkerMessage} callback.message.reportProgress - This method is used to report the progress of the message from inside the worker\n * @param {IEasyWebWorkerMessage} callback.message.resolve - This method is used to resolve the message from inside the worker\n * @param {MessageEvent} callback.event - This is the event that was received\n */\n var onMessage = function onMessage() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var param1 = args[0],\n param2 = args[1];\n var hasCustomCallbackKey = typeof param1 === 'string';\n if (hasCustomCallbackKey) {\n var callbackKey = param1;\n var _callback = param2;\n workerCallbacks.set(callbackKey, _callback);\n return;\n }\n var callback = param1;\n workerCallbacks.set('', callback);\n };\n /**\n * This is the onMessage callback that will be executed when a message is received\n */\n self.onmessage = function (event) {\n var data = event.data,\n origin = event.origin;\n var messageId = data.messageId,\n cancelation = data.cancelation;\n if (cancelation) {\n var reason = cancelation.reason;\n var _message = workerMessages.get(messageId);\n _message.cancel(reason);\n return;\n }\n var _event$data = event.data,\n method = _event$data.method,\n execution = _event$data.execution;\n var payload = execution.payload;\n var message = createMessage({\n messageId: messageId,\n payload: payload,\n origin: targetOrigin || origin || undefined\n });\n var callback = workerCallbacks.get(method || '');\n callback(message, event);\n };\n if (onMessageCallback) {\n onMessage(onMessageCallback);\n }\n this.importScripts = importScripts;\n // @ts-ignore\n this.close = close;\n // @ts-ignore\n this.onMessage = onMessage;\n};\n/**\n * This method is used to create a new instance of the easy static web worker\n */\nvar createStaticEasyWebWorker = function createStaticEasyWebWorker(onMessageCallback) {\n var targetOrigin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var worker = new exports.StaticEasyWebWorker(onMessageCallback, targetOrigin);\n return worker;\n};\nexports.createStaticEasyWebWorker = createStaticEasyWebWorker;\n\n//# sourceURL=webpack://easy-web-worker/./src/StaticEasyWebWorker.ts?");
74
+
75
+ /***/ }),
76
+
77
+ /***/ "./src/index.ts":
78
+ /*!**********************!*\
79
+ !*** ./src/index.ts ***!
80
+ \**********************/
81
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
82
+
83
+ "use strict";
84
+ eval("\n\nvar __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = {\n enumerable: true,\n get: function get() {\n return m[k];\n }\n };\n }\n Object.defineProperty(o, k2, desc);\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\nvar __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar EasyWebWorker_1 = __webpack_require__(/*! ./EasyWebWorker */ \"./src/EasyWebWorker.ts\");\nObject.defineProperty(exports, \"default\", ({\n enumerable: true,\n get: function get() {\n return EasyWebWorker_1.EasyWebWorker;\n }\n}));\n__exportStar(__webpack_require__(/*! ./EasyWebWorker */ \"./src/EasyWebWorker.ts\"), exports);\n__exportStar(__webpack_require__(/*! ./StaticEasyWebWorker */ \"./src/StaticEasyWebWorker.ts\"), exports);\n__exportStar(__webpack_require__(/*! ./EasyWebWorker.functions */ \"./src/EasyWebWorker.functions.ts\"), exports);\n\n//# sourceURL=webpack://easy-web-worker/./src/index.ts?");
85
+
86
+ /***/ }),
87
+
88
+ /***/ "./node_modules/cancelable-promise-jq/lib/bundle.js":
89
+ /*!**********************************************************!*\
90
+ !*** ./node_modules/cancelable-promise-jq/lib/bundle.js ***!
91
+ \**********************************************************/
92
+ /***/ (function(module) {
93
+
94
+ eval("/*! For license information please see bundle.js.LICENSE.txt */\n!function(e,t){ true?module.exports=t():0}(this,(()=>(()=>{\"use strict\";var e={399:(e,t)=>{function r(e){return r=\"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},r(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,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},o.apply(this,arguments)}function i(e){var t=\"function\"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf(\"[native code]\")))return e;var r;if(\"function\"!=typeof e)throw new TypeError(\"Super expression must either be null or a function\");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},i(e)}function c(e,t,r){return c=a()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&u(o,r.prototype),o},c.apply(null,arguments)}function a(){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 u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.CancelablePromise=void 0;var f=function(e){!function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,\"prototype\",{writable:!1}),t&&u(e,t)}(s,e);var t,i,c,f=(i=s,c=a(),function(){var e,t=l(i);if(c){var o=l(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&(\"object\"===r(t)||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return n(e)}(this,e)});function s(e){var t,r,i,c,a,u;return function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,s),(c=f.call(this,(function(e,t){a=e,u=t}))).status=\"pending\",c.cancelCallbacks=[],c.ownCancelCallbacks=[],c.onProgressCallbacks=[],c.subscribeToOwnCancelEvent=function(e){c.ownCancelCallbacks.push(e)},c.cancel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(\"pending\"===c.status)return c.status=\"canceled\",c.ownCancelCallbacks.forEach((function(t){return t(e)})),c.cancelCallbacks.forEach((function(t){return t(e)})),c.reject(e),c.cancelCallbacks=[],c.ownCancelCallbacks=[],n(c)},c.onCancel=function(e){return c.cancelCallbacks.push(e),n(c)},c.onProgress=function(e){return c.onProgressCallbacks.push(e),n(c)},c.reportProgress=function(e,t){return c.onProgressCallbacks.forEach((function(r){return r(e,t)})),n(c)},c.createChildPromise=function(){var e,t,r=new s((function(r,n,o){e=r,t=n}));return r.onProgressCallbacks=c.onProgressCallbacks,r.onCancel((function(e){c.cancel(e)})),{promise:r,resolve:e,reject:t}},c.resolve=a,c.reject=u,e((function(e){c.status=\"resolved\",c.resolve(e)}),(function(e){c.status=\"rejected\",c.reject(e)}),{cancel:function(e){return c.cancel(e)},onCancel:function(e){return c.subscribeToOwnCancelEvent(e),n(c)},onProgress:function(e){return c.onProgress(e)},reportProgress:function(e,t){c.reportProgress(e,t)}}),c.then=function(e,r){var i=c.createChildPromise(),a=i.promise,u=i.resolve,f=i.reject;return o((t=n(c),l(s.prototype)),\"then\",t).call(t,e,r).then(u,f),a},c.catch=function(e){var t=c.createChildPromise(),i=t.promise,a=t.resolve,u=t.reject;return o((r=n(c),l(s.prototype)),\"catch\",r).call(r,e).then(a,u),i},c.finally=function(e){var t=c.createChildPromise(),r=t.promise,a=t.resolve,u=t.reject;return o((i=n(c),l(s.prototype)),\"finally\",i).call(i,e).then(a,u),r},c}return t=s,Object.defineProperty(t,\"prototype\",{writable:!1}),t}(i(Promise));t.CancelablePromise=f,f.prototype.constructor=Promise},716:(e,t,r)=>{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)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.toCancelablePromise=t.isPromise=t.groupAsCancelablePromise=t.createDecoupledPromise=t.allSettledCancelable=void 0;var o=r(335),i=r(399);function c(){c=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i=\"function\"==typeof Symbol?Symbol:{},a=i.iterator||\"@@iterator\",u=i.asyncIterator||\"@@asyncIterator\",l=i.toStringTag||\"@@toStringTag\";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},\"\")}catch(e){f=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,c=Object.create(i.prototype),a=new E(n||[]);return o(c,\"_invoke\",{value:O(e,r,a)}),c}function p(e,t,r){try{return{type:\"normal\",arg:e.call(t,r)}}catch(e){return{type:\"throw\",arg:e}}}e.wrap=s;var h={};function y(){}function d(){}function v(){}var b={};f(b,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(k([])));g&&g!==t&&r.call(g,a)&&(b=g);var w=v.prototype=y.prototype=Object.create(b);function P(e){[\"next\",\"throw\",\"return\"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function j(e,t){function i(o,c,a,u){var l=p(e[o],e,c);if(\"throw\"!==l.type){var f=l.arg,s=f.value;return s&&\"object\"==n(s)&&r.call(s,\"__await\")?t.resolve(s.__await).then((function(e){i(\"next\",e,a,u)}),(function(e){i(\"throw\",e,a,u)})):t.resolve(s).then((function(e){f.value=e,a(f)}),(function(e){return i(\"throw\",e,a,u)}))}u(l.arg)}var c;o(this,\"_invoke\",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return c=c?c.then(n,n):n()}})}function O(e,t,r){var n=\"suspendedStart\";return function(o,i){if(\"executing\"===n)throw new Error(\"Generator is already running\");if(\"completed\"===n){if(\"throw\"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var a=C(c,r);if(a){if(a===h)continue;return a}}if(\"next\"===r.method)r.sent=r._sent=r.arg;else if(\"throw\"===r.method){if(\"suspendedStart\"===n)throw n=\"completed\",r.arg;r.dispatchException(r.arg)}else\"return\"===r.method&&r.abrupt(\"return\",r.arg);n=\"executing\";var u=p(e,t,r);if(\"normal\"===u.type){if(n=r.done?\"completed\":\"suspendedYield\",u.arg===h)continue;return{value:u.arg,done:r.done}}\"throw\"===u.type&&(n=\"completed\",r.method=\"throw\",r.arg=u.arg)}}}function C(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,\"throw\"===r&&e.iterator.return&&(t.method=\"return\",t.arg=void 0,C(e,t),\"throw\"===t.method)||\"return\"!==r&&(t.method=\"throw\",t.arg=new TypeError(\"The iterator does not provide a '\"+r+\"' method\")),h;var o=p(n,e.iterator,t.arg);if(\"throw\"===o.type)return t.method=\"throw\",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,\"return\"!==t.method&&(t.method=\"next\",t.arg=void 0),t.delegate=null,h):i:(t.method=\"throw\",t.arg=new TypeError(\"iterator result is not an object\"),t.delegate=null,h)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type=\"normal\",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:\"root\"}],e.forEach(_,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if(\"function\"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=v,o(w,\"constructor\",{value:v,configurable:!0}),o(v,\"constructor\",{value:d,configurable:!0}),d.displayName=f(v,l,\"GeneratorFunction\"),e.isGeneratorFunction=function(e){var t=\"function\"==typeof e&&e.constructor;return!!t&&(t===d||\"GeneratorFunction\"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,f(e,l,\"GeneratorFunction\")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},P(j.prototype),f(j.prototype,u,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var c=new j(s(t,r,n,o),i);return e.isGeneratorFunction(r)?c:c.next().then((function(e){return e.done?e.value:c.next()}))},P(w),f(w,l,\"Generator\"),f(w,a,(function(){return this})),f(w,\"toString\",(function(){return\"[object Generator]\"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=k,E.prototype={constructor:E,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(x),!e)for(var t in this)\"t\"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=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 t=this;function n(r,n){return c.type=\"throw\",c.arg=e,t.next=r,n&&(t.method=\"next\",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if(\"root\"===i.tryLoc)return n(\"end\");if(i.tryLoc<=this.prev){var a=r.call(i,\"catchLoc\"),u=r.call(i,\"finallyLoc\");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error(\"try statement without catch or finally\");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,\"finallyLoc\")&&this.prev<o.finallyLoc){var i=o;break}}i&&(\"break\"===e||\"continue\"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=e,c.arg=t,i?(this.method=\"next\",this.next=i.finallyLoc,h):this.complete(c)},complete:function(e,t){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&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if(\"throw\"===n.type){var o=n.arg;x(r)}return o}}throw new Error(\"illegal catch attempt\")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},\"next\"===this.method&&(this.arg=void 0),h}},e}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}t.createDecoupledPromise=function(){var e,t,r,n=new i.CancelablePromise((function(n,o,i){e=n,t=o,r=i}));return Object.assign(Object.assign({resolve:e,reject:t},r),{promise:n})};var u=function e(t){if(t instanceof i.CancelablePromise)return t;if(\"function\"==typeof t)return e(t());if(!f(t))return new i.CancelablePromise((function(e){return e(t)}));var r,n,o=new i.CancelablePromise((function(e,o,i){r=e,n=o,t.then(r,n)}));return o.onCancel((function(e){n(e)})),o};t.toCancelablePromise=u;var l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var r,n=t.maxConcurrent,o=void 0===n?8:n,c=t.executeInOrder,l=void 0!==c&&c,f=t.beforeEachCallback,s=void 0===f?null:f,p=t.afterEachCallback,h=void 0===p?null:p,y=t.onQueueEmptyCallback,d=void 0===y?null:y,v=function(e){if(Array.isArray(e))return a(e)}(r=e)||function(e){if(\"undefined\"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e[\"@@iterator\"])return Array.from(e)}(r)||function(e,t){if(e){if(\"string\"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===r&&e.constructor&&(r=e.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(e):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(r)||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.\")}(),b=[];return new i.CancelablePromise((function(e,t,r){return function e(){if(v.length){var t=v.splice(0,o).map((function(e){var t=\"function\"==typeof e?e():e;null==s||s();var n=u(t);return r.onCancel((function(){n.cancel()})),n.then((function(e){b.push(e),null==h||h(e)})),l?n.then((function(e){return e})):n}));return Promise.all(t).then((function(){return e()}))}}().then((function(){null==d||d(b),e(b)}))}))};t.groupAsCancelablePromise=l;var f=function(e){return Promise.resolve(e)===e};t.isPromise=f,t.allSettledCancelable=function(e){var t=[],r=e.map((function(e){var r=u(e);return t.push(r),(0,o.tryCatchPromise)((function(){return r})).then((function(e){return{error:e.error,result:e.result,promise:r}}))})),n=l(t);return new i.CancelablePromise((function(e,t,o){return i=void 0,a=void 0,u=void 0,l=c().mark((function t(){var i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.onCancel(n.cancel),t.next=3,Promise.all(r);case 3:i=t.sent,e(i);case 5:case\"end\":return t.stop()}}),t)})),new(u||(u=Promise))((function(e,t){function r(e){try{o(l.next(e))}catch(e){t(e)}}function n(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof u?o:new u((function(e){e(o)}))).then(r,n)}o((l=l.apply(i,a||[])).next())}));var i,a,u,l}))}},522:(e,t,r)=>{Object.defineProperty(t,\"__esModule\",{value:!0});var n=r(399);Object.keys(n).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(716);Object.keys(o).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},991:(e,t,r)=>{Object.defineProperty(t,\"__esModule\",{value:!0});var n=r(522);Object.keys(n).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(335);Object.keys(o).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},335:(e,t,r)=>{Object.defineProperty(t,\"__esModule\",{value:!0});var n=r(969);Object.keys(n).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}))},969:(e,t,r)=>{Object.defineProperty(t,\"__esModule\",{value:!0});var n=r(948);Object.keys(n).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var o=r(667);Object.keys(o).forEach((function(e){\"default\"!==e&&\"__esModule\"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}))},948:(e,t,r)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.tryCatchPromise=t.tryCatch=void 0;var n=r(522);t.tryCatch=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.defaultResult,n=void 0===r?null:r,o=t.exceptionHandlingType,i=void 0===o?\"error\":o;try{return{error:null,result:e()}}catch(e){return\"ignore\"!==i&&console[i](e),{error:e,result:n}}},t.tryCatchPromise=function(e,t){var r=t||{},o=r.defaultResult,i=void 0===o?null:o,c=r.exceptionHandlingType,a=void 0===c?\"error\":c,u=r.ignoreCancel,l=void 0===u||u,f=null,s=null,p=function(e){s=e,\"ignore\"!=a&&(\"canceled\"===f.status&&l||console[a](s))};try{if(e instanceof n.CancelablePromise)return f=e,new Promise((function(e){f.then((function(e){return{error:null,result:e,promise:f}})).catch((function(e){return p(e),{error:e,result:i,promise:f}}))}));var h=e(),y=h instanceof n.CancelablePromise;return f=y?h:(0,n.toCancelablePromise)(h),new Promise((function(e){f.then((function(t){e({error:null,result:t,promise:f})})).catch((function(t){p(t),e({error:t,result:i,promise:f})}))}))}catch(e){return p(e),Promise.resolve({error:s,result:i,promise:f})}}},667:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0})}},t={};return function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}(991)})()));\n\n//# sourceURL=webpack://easy-web-worker/./node_modules/cancelable-promise-jq/lib/bundle.js?");
95
+
96
+ /***/ })
97
+
98
+ /******/ });
99
+ /************************************************************************/
100
+ /******/ // The module cache
101
+ /******/ var __webpack_module_cache__ = {};
102
+ /******/
103
+ /******/ // The require function
104
+ /******/ function __webpack_require__(moduleId) {
105
+ /******/ // Check if module is in cache
106
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
107
+ /******/ if (cachedModule !== undefined) {
108
+ /******/ return cachedModule.exports;
109
+ /******/ }
110
+ /******/ // Create a new module (and put it into the cache)
111
+ /******/ var module = __webpack_module_cache__[moduleId] = {
112
+ /******/ // no module.id needed
113
+ /******/ // no module.loaded needed
114
+ /******/ exports: {}
115
+ /******/ };
116
+ /******/
117
+ /******/ // Execute the module function
118
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
119
+ /******/
120
+ /******/ // Return the exports of the module
121
+ /******/ return module.exports;
122
+ /******/ }
123
+ /******/
124
+ /************************************************************************/
125
+ /******/
126
+ /******/ // startup
127
+ /******/ // Load entry module and return exports
128
+ /******/ // This entry module is referenced by other modules so it can't be inlined
129
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
130
+ /******/
131
+ /******/ return __webpack_exports__;
132
+ /******/ })()
133
+ ;
134
+ });
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { EasyWebWorker as default } from './EasyWebWorker';
2
2
  export * from './EasyWebWorker';
3
3
  export * from './StaticEasyWebWorker';
4
+ export * from './EasyWebWorker.functions';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-web-worker",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
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",
@@ -47,10 +47,10 @@
47
47
  "cancelable-promise-jq": "^1.1.3",
48
48
  "jest": "^29.3.1",
49
49
  "jsdom": "^16.4.0",
50
- "ts-jest": "^29.0.3",
50
+ "ts-jest": "^29.1.1",
51
51
  "ts-loader": "^9.4.2",
52
52
  "tslib": "^2.4.1",
53
- "typescript": "^4.9.4",
53
+ "typescript": "^5.3.3",
54
54
  "webpack": "^5.76.3",
55
55
  "webpack-cli": "^5.0.1"
56
56
  },