easy-web-worker 1.1.5 → 1.1.7
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/lib/EasyWebWorker.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
1
2
|
import { CancelablePromise } from 'cancelable-promise-jq';
|
|
2
3
|
/**
|
|
3
4
|
* EasyWorker Config
|
|
@@ -16,30 +17,63 @@ export interface IWorkerConfig {
|
|
|
16
17
|
* */
|
|
17
18
|
onWorkerError: (error: ErrorEvent) => void;
|
|
18
19
|
}
|
|
20
|
+
export interface IWorkerData<IPayload> {
|
|
21
|
+
/**
|
|
22
|
+
* This is the message id
|
|
23
|
+
* */
|
|
24
|
+
messageId: string;
|
|
25
|
+
execution?: {
|
|
26
|
+
payload?: IPayload;
|
|
27
|
+
};
|
|
28
|
+
cancelation?: {
|
|
29
|
+
reason?: unknown;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
19
32
|
/**
|
|
20
33
|
* This is the structure that the messages of the worker will have
|
|
21
34
|
*/
|
|
22
35
|
export interface IMessageData<IPayload = null> {
|
|
23
36
|
/**
|
|
24
|
-
* This
|
|
37
|
+
* This is the message id
|
|
38
|
+
* */
|
|
39
|
+
messageId: string;
|
|
40
|
+
/**
|
|
41
|
+
* When present, this means that the message was resolved
|
|
25
42
|
*/
|
|
26
|
-
|
|
43
|
+
resolved?: {
|
|
44
|
+
payload: [IPayload?];
|
|
45
|
+
};
|
|
27
46
|
/**
|
|
28
|
-
*
|
|
47
|
+
* When present, this means that the message was rejected
|
|
29
48
|
* */
|
|
30
|
-
|
|
49
|
+
rejected?: {
|
|
50
|
+
reason: unknown;
|
|
51
|
+
};
|
|
31
52
|
/**
|
|
32
|
-
*
|
|
53
|
+
* When present, this means that the message was canceled
|
|
33
54
|
* */
|
|
34
|
-
|
|
55
|
+
canceled?: {
|
|
56
|
+
reason: unknown;
|
|
57
|
+
};
|
|
35
58
|
/**
|
|
36
|
-
*
|
|
59
|
+
* When present, this means that the message was canceled from inside the worker
|
|
37
60
|
* */
|
|
38
|
-
|
|
61
|
+
worker_canceled?: {
|
|
62
|
+
reason: unknown;
|
|
63
|
+
};
|
|
39
64
|
/**
|
|
40
|
-
*
|
|
65
|
+
* When present, this means that the should report the progress
|
|
41
66
|
* */
|
|
42
|
-
|
|
67
|
+
progress?: {
|
|
68
|
+
/**
|
|
69
|
+
* This is the progress percentage
|
|
70
|
+
* */
|
|
71
|
+
percentage: number;
|
|
72
|
+
/**
|
|
73
|
+
* This extra data can be included in the progress
|
|
74
|
+
* */
|
|
75
|
+
payload: unknown;
|
|
76
|
+
};
|
|
43
77
|
}
|
|
44
78
|
export interface IEasyWorkerInstance<IPayload = null, IResult = void> {
|
|
45
79
|
/**
|
|
@@ -54,6 +88,27 @@ export interface IEasyWorkerInstance<IPayload = null, IResult = void> {
|
|
|
54
88
|
* @param {MessageEvent} callback.event - This is the event that was received
|
|
55
89
|
* */
|
|
56
90
|
onMessage(callback: (message: IEasyWebWorkerMessage<IPayload, IResult>, event: MessageEvent<IMessageData<IPayload>>) => void): void;
|
|
91
|
+
/**
|
|
92
|
+
* Use this method to defined which will be the functionality of your worker when a message is send to it
|
|
93
|
+
* @param {string} method - Create a callback for an specific method
|
|
94
|
+
* @param {function} callback - This is the callback that will be executed when a message is received
|
|
95
|
+
* @param {IEasyWebWorkerMessage} callback.message - This is the message that was received
|
|
96
|
+
* @param {IEasyWebWorkerMessage} callback.message.messageId - This is the message id
|
|
97
|
+
* @param {IEasyWebWorkerMessage} callback.message.payload - This are the parameters included in the message
|
|
98
|
+
* @param {IEasyWebWorkerMessage} callback.message.reject - This method is used to reject the message from inside the worker
|
|
99
|
+
* @param {IEasyWebWorkerMessage} callback.message.reportProgress - This method is used to report the progress of the message from inside the worker
|
|
100
|
+
* @param {IEasyWebWorkerMessage} callback.message.resolve - This method is used to resolve the message from inside the worker
|
|
101
|
+
* @param {MessageEvent} callback.event - This is the event that was received
|
|
102
|
+
* */
|
|
103
|
+
onMessage(method: string, callback: (message: IEasyWebWorkerMessage<IPayload, IResult>, event: MessageEvent<IMessageData<IPayload>>) => void): void;
|
|
104
|
+
/**
|
|
105
|
+
* Import scripts to the worker
|
|
106
|
+
*/
|
|
107
|
+
importScripts(...scripts: string[]): void;
|
|
108
|
+
/**
|
|
109
|
+
* This method reject all the messages that are currently in the queue of the worker and close the worker
|
|
110
|
+
* */
|
|
111
|
+
close(): void;
|
|
57
112
|
}
|
|
58
113
|
/**
|
|
59
114
|
* This type defined the structure that a WorkerBody should have.
|
|
@@ -69,7 +124,7 @@ easyWorker: IEasyWorkerInstance<IPayload, IResult>,
|
|
|
69
124
|
/**
|
|
70
125
|
* This is the context of the worker, you can use it to access to the global scope of the worker
|
|
71
126
|
* */
|
|
72
|
-
context:
|
|
127
|
+
context: DedicatedWorkerGlobalScope & Record<string, unknown>) => void;
|
|
73
128
|
export interface IEasyWebWorkerMessage<TPayload = null, TResult = void> {
|
|
74
129
|
/**
|
|
75
130
|
* This is the message id
|
|
@@ -86,7 +141,7 @@ export interface IEasyWebWorkerMessage<TPayload = null, TResult = void> {
|
|
|
86
141
|
/**
|
|
87
142
|
* This method is used to report the progress of the message from inside the worker
|
|
88
143
|
* */
|
|
89
|
-
reportProgress(progressPercentage: number): void;
|
|
144
|
+
reportProgress(progressPercentage: number, payload?: unknown): void;
|
|
90
145
|
/**
|
|
91
146
|
* This method is used to resolve the message from inside the worker
|
|
92
147
|
* */
|
|
@@ -96,13 +151,12 @@ export interface IEasyWebWorkerMessage<TPayload = null, TResult = void> {
|
|
|
96
151
|
* */
|
|
97
152
|
cancel: (reason?: unknown) => void;
|
|
98
153
|
}
|
|
99
|
-
export declare const
|
|
100
|
-
export declare const createBlobWorker: <IPayload = null, IResult = void>(source: EasyWebWorkerBody<IPayload, IResult> | EasyWebWorkerBody<IPayload, IResult>[], imports?: string[]) => string;
|
|
154
|
+
export declare const createBlobWorker: <IPayload = null, IResult = void>(source: EasyWebWorkerBody<IPayload, IResult> | EasyWebWorkerBody<IPayload, IResult>[], imports?: string[], origin?: string) => string;
|
|
101
155
|
/**
|
|
102
156
|
* This is a class to create global-store objects
|
|
103
|
-
* @template
|
|
104
|
-
* @template
|
|
105
|
-
* @param {EasyWebWorkerBody<
|
|
157
|
+
* @template TPayload - Indicates if your WORKERS messages requires a parameter to be provided, NULL indicates they doesn't
|
|
158
|
+
* @template TResult - Indicates if your WORKERS messages has a result... NULL indicates all you messages are Promise<void>
|
|
159
|
+
* @param {EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[]} workerBody -
|
|
106
160
|
* this parameter should be a function or set of functions that will become the body of your Web-Worker
|
|
107
161
|
* 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.
|
|
108
162
|
* the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
|
|
@@ -110,14 +164,14 @@ export declare const createBlobWorker: <IPayload = null, IResult = void>(source:
|
|
|
110
164
|
* @param {Partial<IWorkerConfig>} WorkerConfig - You could add extra configuration to your worker,
|
|
111
165
|
* consult IWorkerConfig description to have more information
|
|
112
166
|
* */
|
|
113
|
-
export declare class EasyWebWorker<
|
|
167
|
+
export declare class EasyWebWorker<TPayload = null, TResult = void> {
|
|
114
168
|
/**
|
|
115
169
|
* this parameter should be a function or set of functions that will become the body of your Web-Worker
|
|
116
170
|
* 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.
|
|
117
171
|
* the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
|
|
118
172
|
* you could easily identify what is on the context of your Worker.
|
|
119
173
|
*/
|
|
120
|
-
protected workerBody: EasyWebWorkerBody<
|
|
174
|
+
protected workerBody: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string;
|
|
121
175
|
name: string;
|
|
122
176
|
/**
|
|
123
177
|
* @deprecated Directly modifying the worker may lead to unexpected behavior. Use it only if you know what you are doing.
|
|
@@ -147,7 +201,7 @@ export declare class EasyWebWorker<IPayload = null, IResult = void> {
|
|
|
147
201
|
* the above the reason of why we are injecting all worker context into the MessageBody Callbacks, so,
|
|
148
202
|
* you could easily identify what is on the context of your Worker.
|
|
149
203
|
*/
|
|
150
|
-
workerBody: EasyWebWorkerBody<
|
|
204
|
+
workerBody: EasyWebWorkerBody<TPayload, TResult> | EasyWebWorkerBody<TPayload, TResult>[] | string,
|
|
151
205
|
/**
|
|
152
206
|
* You could import scripts into your worker, this is useful if you want to use external libraries
|
|
153
207
|
*/
|
|
@@ -158,36 +212,34 @@ export declare class EasyWebWorker<IPayload = null, IResult = void> {
|
|
|
158
212
|
*/
|
|
159
213
|
private executeMessageCallback;
|
|
160
214
|
protected getWorkerUrl(): string;
|
|
161
|
-
protected
|
|
215
|
+
protected initializeWorker(): Worker;
|
|
162
216
|
/**
|
|
163
|
-
* Terminates the worker and remove all messages from the queue
|
|
164
217
|
* Execute the cancel callback of each message in the queue if provided
|
|
165
|
-
* @param {unknown} reason - reason
|
|
218
|
+
* @param {unknown} reason - reason messages where canceled
|
|
166
219
|
*/
|
|
167
|
-
cancelAll(reason?: unknown):
|
|
220
|
+
cancelAll(reason?: unknown): Promise<any[]>;
|
|
168
221
|
/**
|
|
169
222
|
* Send a message to the worker queue
|
|
170
|
-
* @param {
|
|
171
|
-
* @returns {IMessagePromise<
|
|
223
|
+
* @param {TPayload} payload - whatever json data you want to send to the worker
|
|
224
|
+
* @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
|
|
172
225
|
*/
|
|
173
|
-
send:
|
|
226
|
+
send: TPayload extends null ? () => CancelablePromise<TResult> : (payload: TPayload) => CancelablePromise<TResult>;
|
|
174
227
|
/**
|
|
175
228
|
* This method terminate all current messages and send a new one to the worker queue
|
|
176
|
-
* @param {
|
|
229
|
+
* @param {TPayload} payload - whatever json data you want to send to the worker, should be serializable
|
|
177
230
|
* @param {unknown} reason - reason why the worker was terminated
|
|
178
|
-
* @returns {IMessagePromise<
|
|
231
|
+
* @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
|
|
179
232
|
*/
|
|
180
|
-
override:
|
|
233
|
+
override: TPayload extends null ? (reason?: unknown) => CancelablePromise<TResult> : (payload: TPayload, reason?: unknown) => CancelablePromise<TResult>;
|
|
181
234
|
/**
|
|
182
235
|
* 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
|
|
183
|
-
* @param {
|
|
236
|
+
* @param {TPayload} payload - whatever json data you want to send to the worker should be serializable
|
|
184
237
|
* @param {unknown} reason - reason why the worker was terminated
|
|
185
|
-
* @returns {IMessagePromise<
|
|
238
|
+
* @returns {IMessagePromise<TResult>} generated defer that will be resolved when the message completed
|
|
186
239
|
*/
|
|
187
|
-
overrideAfterCurrent:
|
|
240
|
+
overrideAfterCurrent: TPayload extends null ? (reason?: unknown) => CancelablePromise<TResult> : (payload: TPayload, reason?: unknown) => CancelablePromise<TResult>;
|
|
188
241
|
/**
|
|
189
242
|
* This method will remove the WebWorker and the BlobUrl
|
|
190
243
|
*/
|
|
191
|
-
dispose(): void
|
|
244
|
+
dispose(): Promise<void>;
|
|
192
245
|
}
|
|
193
|
-
export default EasyWebWorker;
|
|
@@ -2,4 +2,5 @@ export declare const generatedId: () => string;
|
|
|
2
2
|
/**
|
|
3
3
|
* This is the template of the worker, should be and string to avoid compilation issues
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const getWorkerTemplate: () => string;
|
|
6
|
+
export declare const minifyJS: (code: string) => string;
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
import { TDecoupledCancelablePromise
|
|
1
|
+
import { TDecoupledCancelablePromise } from 'cancelable-promise-jq';
|
|
2
2
|
/**
|
|
3
3
|
* This class represents a message that will be send to a worker
|
|
4
4
|
*/
|
|
5
5
|
export declare class EasyWebWorkerMessage<TPayload = null, TResult = void> {
|
|
6
|
-
payload: TPayload;
|
|
7
6
|
/**
|
|
8
7
|
* This is the message id, it's generated automatically
|
|
9
8
|
*/
|
|
10
9
|
messageId: string;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* When present, this means that the message was resolved
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
resolved?: {
|
|
14
|
+
payload: [TPayload?];
|
|
15
|
+
};
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
* When present, this means that the message was rejected
|
|
18
|
+
* */
|
|
19
|
+
rejected?: {
|
|
20
|
+
reason: unknown;
|
|
21
|
+
};
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
+
* When present, this means that the message was canceled
|
|
24
|
+
* */
|
|
25
|
+
canceled?: {
|
|
26
|
+
reason: unknown;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* When present, this means that the message was canceled
|
|
30
|
+
* */
|
|
31
|
+
worker_canceled?: {
|
|
32
|
+
reason: unknown;
|
|
33
|
+
};
|
|
23
34
|
/**
|
|
24
35
|
* Decoupled promise that will be resolved when the message is completed
|
|
25
36
|
* The decoupled promise is a promise that can be resolved, rejected or canceled from outside
|
|
26
37
|
*/
|
|
27
38
|
decoupledPromise: TDecoupledCancelablePromise<TResult>;
|
|
28
|
-
|
|
29
|
-
* This method will resolve the decoupled promise
|
|
30
|
-
*/
|
|
31
|
-
resolve: (...args: TResult extends void ? [null?] : [TResult]) => void;
|
|
32
|
-
/**
|
|
33
|
-
* This method will reject the decoupled promise
|
|
34
|
-
*/
|
|
35
|
-
reject: (reason: unknown) => void;
|
|
36
|
-
/**
|
|
37
|
-
* This method will cancel the decoupled promise
|
|
38
|
-
*/
|
|
39
|
-
cancel: (reason: unknown) => void;
|
|
40
|
-
/**
|
|
41
|
-
* This method will report the progress of the message
|
|
42
|
-
* @param {number} progressPercentage - This is the progress percentage
|
|
43
|
-
*/
|
|
44
|
-
reportProgress: TOnProgressCallback;
|
|
45
|
-
/**
|
|
46
|
-
* This is the constructor of the class
|
|
47
|
-
* @param {TPayload} payload - This are the parameters included in the message
|
|
48
|
-
*/
|
|
49
|
-
constructor(payload: TPayload);
|
|
39
|
+
constructor();
|
|
50
40
|
}
|
|
@@ -1,64 +1,12 @@
|
|
|
1
1
|
import { IEasyWebWorkerMessage, IEasyWorkerInstance, IMessageData } from './EasyWebWorker';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {TPayload} payload - This are the parameters included in the message
|
|
11
|
-
* @param {string} messageId - This is the message id
|
|
12
|
-
* @param {string} messageTargetOrigin - This is the target origin of the message
|
|
13
|
-
*/
|
|
14
|
-
constructor(payload: TPayload, messageId: string, messageTargetOrigin?: string);
|
|
15
|
-
/**
|
|
16
|
-
* This method is used to resolve the message from inside the worker
|
|
17
|
-
*/
|
|
18
|
-
resolve: TResult extends void ? () => void : (payload: TResult) => void;
|
|
19
|
-
/**
|
|
20
|
-
* This method is used to reject the message from inside the worker
|
|
21
|
-
* */
|
|
22
|
-
reject(reason: unknown): void;
|
|
23
|
-
/**
|
|
24
|
-
* This method is used to cancel the message from inside the worker
|
|
25
|
-
*/
|
|
26
|
-
cancel(reason?: unknown): void;
|
|
27
|
-
/**
|
|
28
|
-
* This method is used to report the progress of the message from inside the worker
|
|
29
|
-
* */
|
|
30
|
-
reportProgress(progressPercentage: number): void;
|
|
31
|
-
}
|
|
3
|
+
* Constructor for the StaticEasyWebWorker
|
|
4
|
+
* @param onMessageCallback - callback to be called when a message is received
|
|
5
|
+
* @param targetOrigin - the target origin to be used when sending messages
|
|
6
|
+
* @returns an instance of the StaticEasyWebWorker
|
|
7
|
+
* */
|
|
8
|
+
export declare const StaticEasyWebWorker: new <TPayload = null, TResult = null>(onMessageCallback?: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void, targetOrigin?: string) => IEasyWorkerInstance<TPayload, TResult>;
|
|
32
9
|
/**
|
|
33
|
-
* This
|
|
34
|
-
* @param {function} onMessageCallback - This is the callback that will be executed when a message is received
|
|
35
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message - This is the message that was received
|
|
36
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message.messageId - This is the message id
|
|
37
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message.payload - This are the parameters included in the message
|
|
38
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message.reject - This method is used to reject the message from inside the worker
|
|
39
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message.reportProgress - This method is used to report the progress of the message from inside the worker
|
|
40
|
-
* @param {IEasyWebWorkerMessage} onMessageCallback.message.resolve - This method is used to resolve the message from inside the worker
|
|
41
|
-
* @param {MessageEvent} onMessageCallback.event - This is the event that was received
|
|
42
|
-
* @param {string} messageTargetOrigin - This is the target origin of the message
|
|
10
|
+
* This method is used to create a new instance of the easy static web worker
|
|
43
11
|
*/
|
|
44
|
-
export declare
|
|
45
|
-
onMessageCallback: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void;
|
|
46
|
-
constructor(onMessageCallback: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void, messageTargetOrigin?: string);
|
|
47
|
-
/**
|
|
48
|
-
* This method is used to define the onMessage callback
|
|
49
|
-
* @param {string} messageTargetOrigin - This is the target origin of the message
|
|
50
|
-
* */
|
|
51
|
-
defineOnMessage(messageTargetOrigin: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* This method is used to define the onMessage callback
|
|
54
|
-
* @param {function} callback - This is the callback that will be executed when a message is received
|
|
55
|
-
* @param {IEasyWebWorkerMessage} callback.message - This is the message that was received
|
|
56
|
-
* @param {IEasyWebWorkerMessage} callback.message.messageId - This is the message id
|
|
57
|
-
* @param {IEasyWebWorkerMessage} callback.message.payload - This are the parameters included in the message
|
|
58
|
-
* @param {IEasyWebWorkerMessage} callback.message.reject - This method is used to reject the message from inside the worker
|
|
59
|
-
* @param {IEasyWebWorkerMessage} callback.message.reportProgress - This method is used to report the progress of the message from inside the worker
|
|
60
|
-
* @param {IEasyWebWorkerMessage} callback.message.resolve - This method is used to resolve the message from inside the worker
|
|
61
|
-
* @param {MessageEvent} callback.event - This is the event that was received
|
|
62
|
-
*/
|
|
63
|
-
onMessage(callback: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void): void;
|
|
64
|
-
}
|
|
12
|
+
export declare const createStaticEasyWebWorker: <TPayload = null, TResult = void>(onMessageCallback?: (message: IEasyWebWorkerMessage<TPayload, TResult>, event: MessageEvent<IMessageData<TPayload>>) => void, targetOrigin?: string) => IEasyWorkerInstance<TPayload, TResult>;
|
package/lib/bundle.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["easy-web-worker"]=r():e["easy-web-worker"]=r()}(this,(()=>{return e={30:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(s.push(n.value),s.length!==r);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,r)||a(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function s(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorker=r.createBlobWorker=r.createBlobFromString=void 0;var c=t(213),l=t(726),u=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.length?'self.importScripts(["'.concat(e.join('","'),'"]);'):""};r.createBlobFromString=function(e){var r="".concat(u(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]),"\n ").concat(e);return(window.URL||window.webkitURL).createObjectURL(new Blob([r],{type:"application/javascript"}))},r.createBlobWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=(0,l.WorkerTemplate)(),n=Array.isArray(e)?e:[e];return(window.URL||window.webkitURL).createObjectURL(new Blob(["".concat(u(r),"\n \n ").concat(t,"\n \n ").concat(n.map((function(e,r){return"// content #".concat(r,"\n(").concat(e.toString(),")(easyWorker, self);")})).join("\n\n"))],{type:"application/javascript"}))};var f=function(){function e(r){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.scripts,i=void 0===a?[]:a,s=n.name,u=n.onWorkerError,f=void 0===u?null:u;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.workerBody=r,this.messagesQueue=new Map,this.scripts=[],this.send=function(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var a=n[0],i=new c.EasyWebWorkerMessage(a),s=i.messageId;return t.messagesQueue.set(i.messageId,i),null===(e=t.worker)||void 0===e||e.postMessage({messageId:s,payload:a}),i.decoupledPromise.promise},this.override=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r[0],a=r[1];return t.cancelAll(a),t.send.apply(t,[o])},this.overrideAfterCurrent=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=r[0],i=r[1];if(t.messagesQueue.size){var s=o(t.messagesQueue,1),c=o(s[0],2)[1];t.messagesQueue.delete(c.messageId),t.cancelAll(i),t.messagesQueue.set(c.messageId,c)}return t.send.apply(t,[a])},this.name=s||(0,l.generatedId)(),this.scripts=i,this.worker=this.createWorker(),this.onWorkerError=f}var t,n;return t=e,(n=[{key:"isExternalWorkerFile",get:function(){return"string"==typeof this.workerBody}},{key:"RemoveMessageFromQueue",value:function(e){this.messagesQueue.delete(e)}},{key:"executeMessageCallback",value:function(e){var r,t,n=null!==(r=this.messagesQueue.get(e.data.messageId))&&void 0!==r?r:null;if(n){var o=e.data,s=o.payload,c=o.reason,l=o.wasCanceled,u=o.progressPercentage;this.worker?void 0===u?(this.RemoveMessageFromQueue(n.messageId),n.wasCompleted=!1,l?n.cancel(c):c?n.reject(c):(n.wasCompleted=!0,n.resolve.apply(n,function(e){if(Array.isArray(e))return i(e)}(t=null!=s?s:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))):n.reportProgress(u):this.RemoveMessageFromQueue(n.messageId)}}},{key:"getWorkerUrl",value:function(){return this.isExternalWorkerFile?this.workerBody:(0,r.createBlobWorker)(this.workerBody,this.scripts)}},{key:"createWorker",value:function(){var e=this;this.workerUrl=this.getWorkerUrl();var r=new Worker(this.workerUrl,{name:this.name});return r.onmessage=function(r){e.executeMessageCallback(r)},r.onerror=function(r){if(!e.onWorkerError)throw r;e.onWorkerError(r)},r}},{key:"cancelAll",value:function(e){var r;null===(r=this.worker)||void 0===r||r.terminate(),Array.from(this.messagesQueue.values()).forEach((function(r){return r.cancel(e)})),this.messagesQueue=new Map}},{key:"dispose",value:function(){this.cancelAll(),URL.revokeObjectURL(this.workerUrl),this.worker=null}}])&&s(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.EasyWebWorker=f,r.default=f},726:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WorkerTemplate=r.generatedId=void 0,r.generatedId=function(){return"".concat((new Date).getTime()).concat(Math.random().toString(36).substr(2,9))},r.WorkerTemplate=function(){return'\n //this-code-was auto-generated\n const easyWorker = new (class {\n onMessageCallback = () => {\n throw "you didn\'t defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage";\n };\n\n onMessage = (callback) => {\n this.onMessageCallback = callback;\n };\n })();\n\n self.onmessage = (event) => {\n const { messageId, payload } = event.data;\n\n // each message should have his own resolution methods\n const message = new (class {\n payload = payload;\n\n messageId = messageId;\n\n resolve = (...result) => self.postMessage({ messageId, payload: result });\n\n reject = (reason) => self.postMessage({ messageId, reason });\n\n cancel = (reason) => self.postMessage({ messageId, reason, wasCanceled: true });\n\n reportProgress = (progressPercentage) => self.postMessage({ messageId, progressPercentage });\n })();\n\n easyWorker.onMessageCallback(message, event);\n };\n'}},213:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}function a(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorkerMessage=void 0;var i=t(367),s=t(726),c=a((function e(r){var t=this;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.payload=r,this.wasCompleted=!1,this.wasCanceled=!1,this.reportProgress=function(){throw new Error("Message should receive a progress-callback in order to be able to report... send(..).onProgressCallback")},this.messageId=(0,s.generatedId)(),this.decoupledPromise=(0,i.createDecoupledPromise)(),this.resolve=this.decoupledPromise.resolve,this.reject=this.decoupledPromise.reject,this.cancel=this.decoupledPromise.cancel,this.reportProgress=this.decoupledPromise.promise.reportProgress,this.decoupledPromise.onCancel((function(){t.wasCanceled=!0}))}));r.EasyWebWorkerMessage=c},973:(e,r)=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function o(e,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===t(a)?a:String(a)),o)}var a}function a(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(r,"__esModule",{value:!0}),r.StaticEasyWebWorker=r.WorkerMessage=void 0;var i=function(){function e(r,t){var o=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"*";n(this,e),this.payload=r,this.messageId=t,this.messageTargetOrigin=a,this.resolve=function(){for(var e=o.messageId,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];self.postMessage({messageId:e,payload:t},o.messageTargetOrigin)}}return a(e,[{key:"reject",value:function(e){self.postMessage({reason:e},this.messageTargetOrigin)}},{key:"cancel",value:function(e){self.postMessage({wasCanceled:!0,reason:e},this.messageTargetOrigin)}},{key:"reportProgress",value:function(e){var r=this.messageId;self.postMessage({messageId:r,progressPercentage:e},this.messageTargetOrigin)}}]),e}();r.WorkerMessage=i;var s=function(){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";n(this,e),this.onMessageCallback=r,this.defineOnMessage(t)}return a(e,[{key:"defineOnMessage",value:function(e){var r=this;self.onmessage=function(t){var n=t.data,o=n.messageId,a=n.payload,s=new i(a,o,e);r.onMessageCallback.call(r,s,t)}}},{key:"onMessage",value:function(e){this.onMessageCallback=e}}]),e}();r.StaticEasyWebWorker=s},991:(e,r,t)=>{"use strict";var n=Object.create?function(e,r,t,n){void 0===n&&(n=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,o)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]},o=function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||n(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=t(30);Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a.EasyWebWorker}}),o(t(30),r),o(t(973),r)},367:function(e){var r;r=()=>(()=>{"use strict";var e={399:(e,r)=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var n=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=l(e)););return e}(e,r);if(n){var o=Object.getOwnPropertyDescriptor(n,r);return o.get?o.get.call(arguments.length<3?e:t):o.value}},o.apply(this,arguments)}function a(e){var r="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},a(e)}function i(e,r,t){return i=s()?Reflect.construct.bind():function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&c(o,t.prototype),o},i.apply(null,arguments)}function s(){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 c(e,r){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},c(e,r)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CancelablePromise=void 0;var u=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&c(e,r)}(f,e);var r,a,i,u=(a=f,i=s(),function(){var e,r=l(a);if(i){var o=l(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}(this,e)});function f(e){var r,t,a,i,s;return function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,f),(a=u.call(this,(function(e,r){i=e,s=r}))).status="pending",a.data={},a.cancelCallbacks=[],a.ownCancelCallbacks=[],a.onProgressCallbacks=[],a.subscribeToOwnCancelEvent=function(e){a.ownCancelCallbacks.push(e)},a.cancel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if("pending"===a.status)return a.status="canceled",a.ownCancelCallbacks.forEach((function(r){return r(e)})),a.cancelCallbacks.forEach((function(r){return r(e)})),a.reject(e),a.cancelCallbacks=[],a.ownCancelCallbacks=[],n(a)},a.onCancel=function(e){return a.cancelCallbacks.push(e),n(a)},a.onProgress=function(e){return a.onProgressCallbacks.push(e),n(a)},a.reportProgress=function(e){return a.onProgressCallbacks.forEach((function(r){return r(e)})),n(a)},a.createChildPromise=function(){var e,r,t=new f((function(t,n,o){e=t,r=n}));return t.onProgressCallbacks=a.onProgressCallbacks,t.onCancel((function(e){a.cancel(e)})),{promise:t,resolve:e,reject:r}},a.resolve=i,a.reject=s,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){a.reportProgress(e)}}),a.then=function(e,t){var i=a.createChildPromise(),s=i.promise,c=i.resolve,u=i.reject;return o((r=n(a),l(f.prototype)),"then",r).call(r,e,t).then(c,u),s},a.catch=function(e){var r=a.createChildPromise(),i=r.promise,s=r.resolve,c=r.reject;return o((t=n(a),l(f.prototype)),"catch",t).call(t,e).then(s,c),i},a}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(a(Promise));r.CancelablePromise=u,u.prototype.constructor=Promise},716:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toCancelablePromise=r.isPromise=r.groupAsCancelablePromise=r.createDecoupledPromise=void 0;var n=t(399);function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}r.createDecoupledPromise=function(){var e,r,t,o=new n.CancelablePromise((function(n,o,a){e=n,r=o,t=a}));return Object.assign(Object.assign({resolve:e,reject:r},t),{promise:o})};var a=function e(r){if(r instanceof n.CancelablePromise)return r;if("function"==typeof r)return e(r());if(!i(r))return new n.CancelablePromise((function(e){return e(r)}));var t,o,a=new n.CancelablePromise((function(e,n,a){t=e,o=n,r.then(t,o)}));return a.onCancel((function(e){o(e)})),a};r.toCancelablePromise=a,r.groupAsCancelablePromise=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var t,i=r.maxConcurrent,s=void 0===i?8:i,c=r.executeInOrder,l=void 0!==c&&c,u=r.beforeEachCallback,f=void 0===u?null:u,p=r.afterEachCallback,y=void 0===p?null:p,d=r.onQueueEmptyCallback,b=void 0===d?null:d,m=function(e){if(Array.isArray(e))return o(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=[];return new n.CancelablePromise((function(e,r,t){return function e(){if(m.length){var r=m.splice(0,s).map((function(e){var r="function"==typeof e?e():e;null==f||f();var n=a(r);return t.onCancel((function(){n.cancel()})),n.then((function(e){v.push(e),null==y||y(e)})),l?n.then((function(e){return e})):n}));return Promise.all(r).then((function(){return e()}))}}().then((function(){null==b||b(v),e(v)}))}))};var i=function(e){return Promise.resolve(e)===e};r.isPromise=i},522:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"CancelablePromise",{enumerable:!0,get:function(){return n.CancelablePromise}}),Object.defineProperty(r,"createDecoupledPromise",{enumerable:!0,get:function(){return o.createDecoupledPromise}}),Object.defineProperty(r,"groupAsCancelablePromise",{enumerable:!0,get:function(){return o.groupAsCancelablePromise}}),Object.defineProperty(r,"isPromise",{enumerable:!0,get:function(){return o.isPromise}}),Object.defineProperty(r,"toCancelablePromise",{enumerable:!0,get:function(){return o.toCancelablePromise}});var n=t(399),o=t(716)},335:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(969)},969:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(948)},948:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tryCatchPromise=r.tryCatch=void 0;var n=t(522);r.tryCatch=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.defaultResult,n=void 0===t?null:t,o=r.exceptionHandlingType,a=void 0===o?"error":o;try{return{error:null,result:e()}}catch(e){return"ignore"!==a&&console[a](e),{error:e,result:n}}},r.tryCatchPromise=function(e,r){var t=r||{},o=t.defaultResult,a=void 0===o?null:o,i=t.exceptionHandlingType,s=void 0===i?"error":i,c=t.ignoreCancel,l=void 0===c||c,u=null,f=null,p=function(e){f=e,"ignore"!=s&&("canceled"===u.status&&l||console[s](f))};try{if(e instanceof n.CancelablePromise)return u=e,new Promise((function(e){u.then((function(e){return{error:null,result:e,promise:u}})).catch((function(e){return p(e),{error:e,result:a,promise:u}}))}));var y=e(),d=y instanceof n.CancelablePromise;return u=d?y:(0,n.toCancelablePromise)(y),new Promise((function(e){u.then((function(r){e({error:null,result:r,promise:u})})).catch((function(r){p(r),e({error:r,result:a,promise:u})}))}))}catch(e){return p(e),Promise.resolve({error:f,result:a,promise:u})}}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"CancelablePromise",{enumerable:!0,get:function(){return r.CancelablePromise}}),Object.defineProperty(e,"createDecoupledPromise",{enumerable:!0,get:function(){return r.createDecoupledPromise}}),Object.defineProperty(e,"groupAsCancelablePromise",{enumerable:!0,get:function(){return r.groupAsCancelablePromise}}),Object.defineProperty(e,"isPromise",{enumerable:!0,get:function(){return r.isPromise}}),Object.defineProperty(e,"toCancelablePromise",{enumerable:!0,get:function(){return r.toCancelablePromise}}),Object.defineProperty(e,"tryCatch",{enumerable:!0,get:function(){return o.tryCatch}}),Object.defineProperty(e,"tryCatchPromise",{enumerable:!0,get:function(){return o.tryCatchPromise}});var r=t(522),o=t(335)})(),n})(),e.exports=r()}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n].call(a.exports,a,a.exports,t),a.exports}(991);var e,r}));
|
|
1
|
+
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["easy-web-worker"]=r():e["easy-web-worker"]=r()}(this,(()=>{return e={30:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,c=[],s=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=a.call(t)).done)&&(c.push(n.value),c.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,r)||a(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(){c=function(){return e};var e={},r=Object.prototype,t=r.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function u(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{u({},"")}catch(e){u=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var a=r&&r.prototype instanceof y?r:y,i=Object.create(a.prototype),c=new x(n||[]);return o(i,"_invoke",{value:j(e,t,c)}),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var d={};function y(){}function h(){}function v(){}var m={};u(m,i,(function(){return this}));var b=Object.getPrototypeOf,g=b&&b(b(S([])));g&&g!==r&&t.call(g,i)&&(m=g);var w=v.prototype=y.prototype=Object.create(m);function P(e){["next","throw","return"].forEach((function(r){u(e,r,(function(e){return this._invoke(r,e)}))}))}function k(e,r){function a(o,i,c,s){var l=p(e[o],e,i);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==n(f)&&t.call(f,"__await")?r.resolve(f.__await).then((function(e){a("next",e,c,s)}),(function(e){a("throw",e,c,s)})):r.resolve(f).then((function(e){u.value=e,c(u)}),(function(e){return a("throw",e,c,s)}))}s(l.arg)}var i;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return i=i?i.then(n,n):n()}})}function j(e,r,t){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(t.method=o,t.arg=a;;){var i=t.delegate;if(i){var c=C(i,t);if(c){if(c===d)continue;return c}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var s=p(e,r,t);if("normal"===s.type){if(n=t.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:t.done}}"throw"===s.type&&(n="completed",t.method="throw",t.arg=s.arg)}}}function C(e,r){var t=r.method,n=e.iterator[t];if(void 0===n)return r.delegate=null,"throw"===t&&e.iterator.return&&(r.method="return",r.arg=void 0,C(e,r),"throw"===r.method)||"return"!==t&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+t+"' method")),d;var o=p(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function O(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function E(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function S(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function r(){for(;++n<e.length;)if(t.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:M}}function M(){return{value:void 0,done:!0}}return h.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=u(v,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},P(k.prototype),u(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(r,t,n,o,a){void 0===a&&(a=Promise);var i=new k(f(r,t,n,o),a);return e.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},P(w),u(w,l,"Generator"),u(w,i,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var r in this)"t"===r.charAt(0)&&t.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=t.call(a,"catchLoc"),s=t.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),E(t),d}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;E(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:S(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},e}function s(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}var l=function(e,r,t,n){return new(t||(t=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,c)}s((n=n.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorker=r.createBlobWorker=void 0;var u=t(213),f=t(726),p=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.length?'self.importScripts(["'.concat(e.join('","'),'"]);'):""};r.createBlobWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=(0,f.getWorkerTemplate)(),o=Array.isArray(e)?e:[e];return(window.URL||window.webkitURL).createObjectURL(new Blob(["".concat(p(r),"\n ").concat(n,"\n ").concat(o.map((function(e){return'\n \n var easyWorker = createEasyWebWorker("'.concat(t,'");\n \n (').concat(e,")(easyWorker, self);")})).join("\n\n"))],{type:"application/javascript"}))};var d=function(){function e(r){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.scripts,i=void 0===a?[]:a,s=n.name,p=n.onWorkerError,d=void 0===p?null:p;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.workerBody=r,this.messagesQueue=new Map,this.scripts=[],this.send=function(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var a=n[0],i=new u.EasyWebWorkerMessage,c=i.messageId,s=i.decoupledPromise,l=s.cancel;s.promise.cancel=function(e){var r;s.cancel=l;var n={messageId:c,cancelation:{reason:e}};return null===(r=t.worker)||void 0===r||r.postMessage(n),s.promise},t.messagesQueue.set(i.messageId,i);var f={messageId:c,execution:{payload:a}};return null===(e=t.worker)||void 0===e||e.postMessage(f),s.promise},this.override=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=r[0],a=r[1];return l(t,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll(a);case 2:return e.abrupt("return",this.send.apply(this,[o]));case 3:case"end":return e.stop()}}),e,this)})))},this.overrideAfterCurrent=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=r[0],i=r[1];return l(t,void 0,void 0,c().mark((function e(){var r,t,n,s;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesQueue.size){e.next=7;break}return r=o(this.messagesQueue,1),t=r[0],n=o(t,2),s=n[1],this.messagesQueue.delete(s.messageId),e.next=6,this.cancelAll(i);case 6:this.messagesQueue.set(s.messageId,s);case 7:return e.abrupt("return",this.send.apply(this,[a]));case 8:case"end":return e.stop()}}),e,this)})))},this.name=s||(0,f.generatedId)(),this.scripts=i,this.worker=this.initializeWorker(),this.onWorkerError=d}var t,n;return t=e,(n=[{key:"isExternalWorkerFile",get:function(){return"string"==typeof this.workerBody}},{key:"RemoveMessageFromQueue",value:function(e){this.messagesQueue.delete(e)}},{key:"executeMessageCallback",value:function(e){var r,t,n=null!==(r=this.messagesQueue.get(e.data.messageId))&&void 0!==r?r:null;if(n){var o=e.data.progress;if(this.worker){var c=n.decoupledPromise;if(o){var s=o.percentage,l=o.payload;c.reportProgress(s,l)}else{this.RemoveMessageFromQueue(n.messageId);var u=e.data.worker_canceled;if(u){var f=u.reason;c.reject(f)}else{var p=e.data.rejected;if(p){var d=p.reason;c.reject(d)}else{var y=e.data.resolved.payload;c.resolve.apply(c,function(e){if(Array.isArray(e))return i(e)}(t=null!=y?y:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}}}else this.RemoveMessageFromQueue(n.messageId)}}},{key:"getWorkerUrl",value:function(){return this.isExternalWorkerFile?this.workerBody:(0,r.createBlobWorker)(this.workerBody,this.scripts)}},{key:"initializeWorker",value:function(){var e,r=this;this.workerUrl=null!==(e=this.workerUrl)&&void 0!==e?e:this.getWorkerUrl();var t=new Worker(this.workerUrl,{name:this.name});return t.onmessage=function(e){r.executeMessageCallback(e)},t.onerror=function(e){if(!r.onWorkerError)throw e;r.onWorkerError(e)},t}},{key:"cancelAll",value:function(e){var r=Array.from(this.messagesQueue.values()),t=100/r.length,n=r.map((function(r){var n=r.decoupledPromise.promise;return n.cancel(e).catch((function(e){return n.reportProgress(t,e),e}))}));return Promise.all(n)}},{key:"dispose",value:function(){return l(this,void 0,void 0,c().mark((function e(){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancelAll();case 2:URL.revokeObjectURL(this.workerUrl),this.worker=null;case 4:case"end":return e.stop()}}),e,this)})))}}])&&s(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.EasyWebWorker=d},726:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.minifyJS=r.getWorkerTemplate=r.generatedId=void 0,r.generatedId=function(){return"".concat((new Date).getTime()).concat(Math.random().toString(36).substr(2,9))},r.getWorkerTemplate=function(){return"/*this-code-was auto-generated*/\nconst createEasyWebWorker = (targetOrigin) => {\n /* Keep track of the messages sent allowing us to cancel them */\n const workerMessages = new Map();\n\n /* This structure allows us to have multiple callbacks for the same worker */\n const workerCallbacks = new Map([\n [\n '',\n () => {\n throw \"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage\";\n },\n ],\n ]);\n\n const createMessage = ({ messageId, payload, origin }) => {\n const cancelCallbacks = new Set();\n\n const postMessage = (data) => {\n const { progress } = data;\n\n if (!progress) {\n /* If it's not a progress message means that the message is resolved | rejected | canceled */\n workerMessages.delete(messageId);\n }\n\n self.postMessage({ messageId, ...data }, origin);\n };\n\n const resolve = (...result) => {\n postMessage({ resolved: { payload: result } });\n };\n\n const reject = (reason) => {\n postMessage({ rejected: { reason } });\n };\n\n const cancel = (reason) => {\n const callbacks = [...cancelCallbacks];\n\n callbacks.forEach((callback) => callback(reason));\n\n postMessage({ worker_canceled: { reason } });\n };\n\n const reportProgress = (percentage, payload) => {\n postMessage({ progress: { percentage, payload } });\n };\n\n /* Returns a function that can be used to unsubscribe from the cancelation */\n const onCancel = (callback) => {\n cancelCallbacks.add(callback);\n\n return () => cancelCallbacks.delete(callback);\n };\n\n return {\n payload,\n resolve,\n reject,\n cancel,\n onCancel,\n reportProgress,\n };\n };\n\n const importScripts = (...scripts) => {\n self.importScripts(...scripts);\n };\n\n const onMessage = (...args) => {\n const [param1, param2] = args;\n const hasCustomCallbackKey = typeof param1 === 'string';\n\n if (hasCustomCallbackKey) {\n const callbackKey = param1;\n const callback = param2;\n\n workerCallbacks.set(callbackKey, callback);\n\n return;\n }\n\n const callback = param1;\n workerCallbacks.set('', callback);\n };\n\n const close = () => {\n /* should cancel all the promises of the main thread */\n const messages = [...workerMessages.values()];\n\n messages.forEach((message) => message.reject(new Error('worker closed')));\n\n self.close();\n };\n\n self.onmessage = (event) => {\n const { data, origin } = event;\n const { messageId, cancelation } = data;\n\n if (cancelation) {\n const { reason } = cancelation;\n\n const message = workerMessages.get(messageId);\n\n message.cancel(reason);\n\n return;\n }\n\n const { method, execution } = data;\n const { payload } = execution;\n\n const message = createMessage({\n messageId,\n payload,\n origin: targetOrigin || origin || '*',\n });\n\n workerMessages.set(messageId, message);\n\n const callback = workerCallbacks.get(method || '');\n\n callback(message, event);\n };\n\n return {\n importScripts,\n onMessage,\n close,\n };\n};"},r.minifyJS=function(e){var r=e.replace(/\/\/.*|\/\*[\s\S]*?\*\//g,"");r=r.replace(/\s+/g," ");for(var t="",n=!1,o="",a=0;a<r.length;a++){var i=r[a],c=r[a+1];'"'!==i||"\\"===r[a-1]?/\s/.test(i)||(";"!==i||"}"!==c?/[\+\-\*\/%=<>!&|^?:]/.test(i)?(t+=o.trimRight()+i,o=""):(o+=i,n||(t+=o,o="")):a++):(n=!n,o+=i)}return t+o.trimRight()}},213:(e,r,t)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(void 0,a=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o.key),"symbol"===n(a)?a:String(a)),o)}var a}function a(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(r,"__esModule",{value:!0}),r.EasyWebWorkerMessage=void 0;var i=t(367),c=t(726),s=a((function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.messageId=(0,c.generatedId)(),this.decoupledPromise=(0,i.createDecoupledPromise)()}));r.EasyWebWorkerMessage=s},973:(e,r)=>{"use strict";function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return n(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,r):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}Object.defineProperty(r,"__esModule",{value:!0}),r.createStaticEasyWebWorker=r.StaticEasyWebWorker=void 0,r.StaticEasyWebWorker=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=new Map,o=new Map([["",function(){throw"you didn't defined a message-callback, please assign a callback by calling IEasyWorkerInstance.onMessage"}]]),a=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=r[0],a=r[1];if("string"==typeof n){var i=n,c=a;o.set(i,c)}else{var s=n;o.set("",s)}};self.onmessage=function(e){var a=e.data,i=e.origin,c=a.messageId,s=a.cancelation;if(s){var l=s.reason;n.get(c).cancel(l)}else{var u=e.data,f=u.method,p=function(e){var r=e.messageId,n=e.payload,o=e.origin,a=new Set,i=function(e){self.postMessage(Object.assign({messageId:r},e),o)};return{payload:n,resolve:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i({resolved:{payload:r}})},reject:function(e){i({rejected:{reason:e}})},cancel:function(e){t(a).forEach((function(r){return r(e)})),i({canceled:{reason:e}})},onCancel:function(e){return a.add(e),function(){return a.delete(e)}},reportProgress:function(e,r){i({progress:{percentage:e,payload:r}})}}}({messageId:c,payload:u.execution.payload,origin:r||i||"*"});o.get(f||"")(p,e)}},e&&a(e),this.importScripts=function(){var e;(e=self).importScripts.apply(e,arguments)},this.close=function(){t(n.values()).forEach((function(e){return e.reject(new Error("worker closed"))})),self.close()},this.onMessage=a},r.createStaticEasyWebWorker=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return new r.StaticEasyWebWorker(e,t)}},991:(e,r,t)=>{"use strict";var n=Object.create?function(e,r,t,n){void 0===n&&(n=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,o)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]},o=function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||n(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=t(30);Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a.EasyWebWorker}}),o(t(30),r),o(t(973),r)},367:function(e){var r;r=()=>(()=>{"use strict";var e={399:(e,r)=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var n=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=l(e)););return e}(e,r);if(n){var o=Object.getOwnPropertyDescriptor(n,r);return o.get?o.get.call(arguments.length<3?e:t):o.value}},o.apply(this,arguments)}function a(e){var r="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},a(e)}function i(e,r,t){return i=c()?Reflect.construct.bind():function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&s(o,t.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function s(e,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},s(e,r)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CancelablePromise=void 0;var u=function(e){!function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&s(e,r)}(f,e);var r,a,i,u=(a=f,i=c(),function(){var e,r=l(a);if(i){var o=l(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}(this,e)});function f(e){var r,t,a,i,c;return function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,f),(a=u.call(this,(function(e,r){i=e,c=r}))).status="pending",a.data={},a.cancelCallbacks=[],a.ownCancelCallbacks=[],a.onProgressCallbacks=[],a.subscribeToOwnCancelEvent=function(e){a.ownCancelCallbacks.push(e)},a.cancel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if("pending"===a.status)return a.status="canceled",a.ownCancelCallbacks.forEach((function(r){return r(e)})),a.cancelCallbacks.forEach((function(r){return r(e)})),a.reject(e),a.cancelCallbacks=[],a.ownCancelCallbacks=[],n(a)},a.onCancel=function(e){return a.cancelCallbacks.push(e),n(a)},a.onProgress=function(e){return a.onProgressCallbacks.push(e),n(a)},a.reportProgress=function(e){return a.onProgressCallbacks.forEach((function(r){return r(e)})),n(a)},a.createChildPromise=function(){var e,r,t=new f((function(t,n,o){e=t,r=n}));return t.onProgressCallbacks=a.onProgressCallbacks,t.onCancel((function(e){a.cancel(e)})),{promise:t,resolve:e,reject:r}},a.resolve=i,a.reject=c,e((function(e){a.status="resolved",a.resolve(e)}),(function(e){a.status="rejected",a.reject(e)}),{cancel:function(e){return a.cancel(e)},onCancel:function(e){return a.subscribeToOwnCancelEvent(e),n(a)},onProgress:function(e){return a.onProgress(e)},reportProgress:function(e){a.reportProgress(e)}}),a.then=function(e,t){var i=a.createChildPromise(),c=i.promise,s=i.resolve,u=i.reject;return o((r=n(a),l(f.prototype)),"then",r).call(r,e,t).then(s,u),c},a.catch=function(e){var r=a.createChildPromise(),i=r.promise,c=r.resolve,s=r.reject;return o((t=n(a),l(f.prototype)),"catch",t).call(t,e).then(c,s),i},a}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(a(Promise));r.CancelablePromise=u,u.prototype.constructor=Promise},716:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.toCancelablePromise=r.isPromise=r.groupAsCancelablePromise=r.createDecoupledPromise=void 0;var n=t(399);function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}r.createDecoupledPromise=function(){var e,r,t,o=new n.CancelablePromise((function(n,o,a){e=n,r=o,t=a}));return Object.assign(Object.assign({resolve:e,reject:r},t),{promise:o})};var a=function e(r){if(r instanceof n.CancelablePromise)return r;if("function"==typeof r)return e(r());if(!i(r))return new n.CancelablePromise((function(e){return e(r)}));var t,o,a=new n.CancelablePromise((function(e,n,a){t=e,o=n,r.then(t,o)}));return a.onCancel((function(e){o(e)})),a};r.toCancelablePromise=a,r.groupAsCancelablePromise=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.length)return null;var t,i=r.maxConcurrent,c=void 0===i?8:i,s=r.executeInOrder,l=void 0!==s&&s,u=r.beforeEachCallback,f=void 0===u?null:u,p=r.afterEachCallback,d=void 0===p?null:p,y=r.onQueueEmptyCallback,h=void 0===y?null:y,v=function(e){if(Array.isArray(e))return o(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),m=[];return new n.CancelablePromise((function(e,r,t){return function e(){if(v.length){var r=v.splice(0,c).map((function(e){var r="function"==typeof e?e():e;null==f||f();var n=a(r);return t.onCancel((function(){n.cancel()})),n.then((function(e){m.push(e),null==d||d(e)})),l?n.then((function(e){return e})):n}));return Promise.all(r).then((function(){return e()}))}}().then((function(){null==h||h(m),e(m)}))}))};var i=function(e){return Promise.resolve(e)===e};r.isPromise=i},522:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"CancelablePromise",{enumerable:!0,get:function(){return n.CancelablePromise}}),Object.defineProperty(r,"createDecoupledPromise",{enumerable:!0,get:function(){return o.createDecoupledPromise}}),Object.defineProperty(r,"groupAsCancelablePromise",{enumerable:!0,get:function(){return o.groupAsCancelablePromise}}),Object.defineProperty(r,"isPromise",{enumerable:!0,get:function(){return o.isPromise}}),Object.defineProperty(r,"toCancelablePromise",{enumerable:!0,get:function(){return o.toCancelablePromise}});var n=t(399),o=t(716)},335:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(969)},969:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"tryCatch",{enumerable:!0,get:function(){return n.tryCatch}}),Object.defineProperty(r,"tryCatchPromise",{enumerable:!0,get:function(){return n.tryCatchPromise}});var n=t(948)},948:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.tryCatchPromise=r.tryCatch=void 0;var n=t(522);r.tryCatch=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.defaultResult,n=void 0===t?null:t,o=r.exceptionHandlingType,a=void 0===o?"error":o;try{return{error:null,result:e()}}catch(e){return"ignore"!==a&&console[a](e),{error:e,result:n}}},r.tryCatchPromise=function(e,r){var t=r||{},o=t.defaultResult,a=void 0===o?null:o,i=t.exceptionHandlingType,c=void 0===i?"error":i,s=t.ignoreCancel,l=void 0===s||s,u=null,f=null,p=function(e){f=e,"ignore"!=c&&("canceled"===u.status&&l||console[c](f))};try{if(e instanceof n.CancelablePromise)return u=e,new Promise((function(e){u.then((function(e){return{error:null,result:e,promise:u}})).catch((function(e){return p(e),{error:e,result:a,promise:u}}))}));var d=e(),y=d instanceof n.CancelablePromise;return u=y?d:(0,n.toCancelablePromise)(d),new Promise((function(e){u.then((function(r){e({error:null,result:r,promise:u})})).catch((function(r){p(r),e({error:r,result:a,promise:u})}))}))}catch(e){return p(e),Promise.resolve({error:f,result:a,promise:u})}}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"CancelablePromise",{enumerable:!0,get:function(){return r.CancelablePromise}}),Object.defineProperty(e,"createDecoupledPromise",{enumerable:!0,get:function(){return r.createDecoupledPromise}}),Object.defineProperty(e,"groupAsCancelablePromise",{enumerable:!0,get:function(){return r.groupAsCancelablePromise}}),Object.defineProperty(e,"isPromise",{enumerable:!0,get:function(){return r.isPromise}}),Object.defineProperty(e,"toCancelablePromise",{enumerable:!0,get:function(){return r.toCancelablePromise}}),Object.defineProperty(e,"tryCatch",{enumerable:!0,get:function(){return o.tryCatch}}),Object.defineProperty(e,"tryCatchPromise",{enumerable:!0,get:function(){return o.tryCatchPromise}});var r=t(522),o=t(335)})(),n})(),e.exports=r()}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n].call(a.exports,a,a.exports,t),a.exports}(991);var e,r}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-web-worker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
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",
|