scandit-datacapture-frameworks-core 7.6.2 → 8.0.0-beta.2

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.
Files changed (32) hide show
  1. package/__mocks__/Defaults.ts +64 -0
  2. package/__mocks__/ScanditDataCaptureCore.ts +148 -0
  3. package/dist/dts/camera/Camera.d.ts +32 -5
  4. package/dist/dts/camera/CameraController.d.ts +2 -2
  5. package/dist/dts/camera/VideoResolution.d.ts +1 -0
  6. package/dist/dts/camerahelpers/CameraOwner.d.ts +3 -0
  7. package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +42 -0
  8. package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +24 -0
  9. package/dist/dts/camerahelpers/index.d.ts +3 -0
  10. package/dist/dts/common/Payload.d.ts +2 -0
  11. package/dist/dts/context/DataCaptureContext.d.ts +6 -10
  12. package/dist/dts/frame/FrameSource.d.ts +1 -0
  13. package/dist/dts/view/DataCaptureView.d.ts +2 -2
  14. package/dist/dts/view/index.d.ts +1 -1
  15. package/dist/index.js +647 -222
  16. package/dist/index.js.map +1 -1
  17. package/jest.config.js +39 -0
  18. package/node_modules/eventemitter3/LICENSE +21 -0
  19. package/node_modules/eventemitter3/README.md +94 -0
  20. package/node_modules/eventemitter3/dist/eventemitter3.esm.js +347 -0
  21. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +1 -0
  22. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +1 -0
  23. package/node_modules/eventemitter3/dist/eventemitter3.umd.js +355 -0
  24. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +1 -0
  25. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +1 -0
  26. package/node_modules/eventemitter3/index.d.ts +135 -0
  27. package/node_modules/eventemitter3/index.js +336 -0
  28. package/node_modules/eventemitter3/index.mjs +4 -0
  29. package/node_modules/eventemitter3/package.json +67 -0
  30. package/package.json +4 -4
  31. package/test/Camera.test.ts +294 -0
  32. package/dist/dts/view/ScreenStateManager.d.ts +0 -8
package/jest.config.js ADDED
@@ -0,0 +1,39 @@
1
+ const { defaults: tsjPreset } = require('ts-jest/presets')
2
+
3
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
4
+ module.exports = {
5
+ ...tsjPreset,
6
+ preset: 'ts-jest',
7
+ testEnvironment: 'jsdom',
8
+ extensionsToTreatAsEsm: ['.ts'],
9
+ transform: {
10
+ '^.+\\.tsx?$': [
11
+ 'ts-jest',
12
+ {
13
+ tsconfig: 'tsconfig.json',
14
+ useESM: true,
15
+ },
16
+ ],
17
+ },
18
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
19
+ testMatch: ['**/__tests__/**/*.(ts|tsx|js)', '**/*.(test|spec).(ts|tsx|js)'],
20
+ collectCoverageFrom: [
21
+ 'src/**/*.{ts,tsx}',
22
+ '!src/**/*.d.ts',
23
+ '!src/**/index.ts',
24
+ ],
25
+ moduleNameMapper: {
26
+ '^@/(.*)$': '<rootDir>/src/$1',
27
+ '^scandit-datacapture-frameworks-core$': '<rootDir>/src/index.ts',
28
+ },
29
+ setupFiles: [
30
+ './__mocks__/Defaults.ts',
31
+ './__mocks__/ScanditDataCaptureCore.ts',
32
+ ],
33
+ transformIgnorePatterns: [
34
+ 'node_modules/(?!(scandit-datacapture-frameworks-core))',
35
+ ],
36
+ silent: false,
37
+ verbose: false,
38
+ }
39
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Arnout Kazemier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ # EventEmitter3
2
+
3
+ [![Version npm](https://img.shields.io/npm/v/eventemitter3.svg?style=flat-square)](https://www.npmjs.com/package/eventemitter3)[![CI](https://img.shields.io/github/actions/workflow/status/primus/eventemitter3/ci.yml?branch=master&label=CI&style=flat-square)](https://github.com/primus/eventemitter3/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/primus/eventemitter3/master.svg?style=flat-square)](https://coveralls.io/r/primus/eventemitter3?branch=master)
4
+
5
+ [![Sauce Test Status](https://saucelabs.com/browser-matrix/eventemitter3.svg)](https://saucelabs.com/u/eventemitter3)
6
+
7
+ EventEmitter3 is a high performance EventEmitter. It has been micro-optimized
8
+ for various of code paths making this, one of, if not the fastest EventEmitter
9
+ available for Node.js and browsers. The module is API compatible with the
10
+ EventEmitter that ships by default with Node.js but there are some slight
11
+ differences:
12
+
13
+ - Domain support has been removed.
14
+ - We do not `throw` an error when you emit an `error` event and nobody is
15
+ listening.
16
+ - The `newListener` and `removeListener` events have been removed as they
17
+ are useful only in some uncommon use-cases.
18
+ - The `setMaxListeners`, `getMaxListeners`, `prependListener` and
19
+ `prependOnceListener` methods are not available.
20
+ - Support for custom context for events so there is no need to use `fn.bind`.
21
+ - The `removeListener` method removes all matching listeners, not only the
22
+ first.
23
+
24
+ It's a drop in replacement for existing EventEmitters, but just faster. Free
25
+ performance, who wouldn't want that? The EventEmitter is written in EcmaScript 3
26
+ so it will work in the oldest browsers and node versions that you need to
27
+ support.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ $ npm install --save eventemitter3
33
+ ```
34
+
35
+ ## CDN
36
+
37
+ Recommended CDN:
38
+
39
+ ```text
40
+ https://unpkg.com/eventemitter3@latest/dist/eventemitter3.umd.min.js
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ After installation the only thing you need to do is require the module:
46
+
47
+ ```js
48
+ var EventEmitter = require('eventemitter3');
49
+ ```
50
+
51
+ And you're ready to create your own EventEmitter instances. For the API
52
+ documentation, please follow the official Node.js documentation:
53
+
54
+ http://nodejs.org/api/events.html
55
+
56
+ ### Contextual emits
57
+
58
+ We've upgraded the API of the `EventEmitter.on`, `EventEmitter.once` and
59
+ `EventEmitter.removeListener` to accept an extra argument which is the `context`
60
+ or `this` value that should be set for the emitted events. This means you no
61
+ longer have the overhead of an event that required `fn.bind` in order to get a
62
+ custom `this` value.
63
+
64
+ ```js
65
+ var EE = new EventEmitter()
66
+ , context = { foo: 'bar' };
67
+
68
+ function emitted() {
69
+ console.log(this === context); // true
70
+ }
71
+
72
+ EE.once('event-name', emitted, context);
73
+ EE.on('another-event', emitted, context);
74
+ EE.removeListener('another-event', emitted, context);
75
+ ```
76
+
77
+ ### Tests and benchmarks
78
+
79
+ This module is well tested. You can run:
80
+
81
+ - `npm test` to run the tests under Node.js.
82
+ - `npm run test-browser` to run the tests in real browsers via Sauce Labs.
83
+
84
+ We also have a set of benchmarks to compare EventEmitter3 with some available
85
+ alternatives. To run the benchmarks run `npm run benchmark`.
86
+
87
+ Tests and benchmarks are not included in the npm package. If you want to play
88
+ with them you have to clone the GitHub repository.
89
+ Note that you will have to run an additional `npm i` in the benchmarks folder
90
+ before `npm run benchmark`.
91
+
92
+ ## License
93
+
94
+ [MIT](LICENSE)
@@ -0,0 +1,347 @@
1
+ var eventemitter3Exports = {};
2
+ var eventemitter3 = {
3
+ get exports(){ return eventemitter3Exports; },
4
+ set exports(v){ eventemitter3Exports = v; },
5
+ };
6
+
7
+ (function (module) {
8
+
9
+ var has = Object.prototype.hasOwnProperty
10
+ , prefix = '~';
11
+
12
+ /**
13
+ * Constructor to create a storage for our `EE` objects.
14
+ * An `Events` instance is a plain object whose properties are event names.
15
+ *
16
+ * @constructor
17
+ * @private
18
+ */
19
+ function Events() {}
20
+
21
+ //
22
+ // We try to not inherit from `Object.prototype`. In some engines creating an
23
+ // instance in this way is faster than calling `Object.create(null)` directly.
24
+ // If `Object.create(null)` is not supported we prefix the event names with a
25
+ // character to make sure that the built-in object properties are not
26
+ // overridden or used as an attack vector.
27
+ //
28
+ if (Object.create) {
29
+ Events.prototype = Object.create(null);
30
+
31
+ //
32
+ // This hack is needed because the `__proto__` property is still inherited in
33
+ // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
34
+ //
35
+ if (!new Events().__proto__) prefix = false;
36
+ }
37
+
38
+ /**
39
+ * Representation of a single event listener.
40
+ *
41
+ * @param {Function} fn The listener function.
42
+ * @param {*} context The context to invoke the listener with.
43
+ * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
44
+ * @constructor
45
+ * @private
46
+ */
47
+ function EE(fn, context, once) {
48
+ this.fn = fn;
49
+ this.context = context;
50
+ this.once = once || false;
51
+ }
52
+
53
+ /**
54
+ * Add a listener for a given event.
55
+ *
56
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
57
+ * @param {(String|Symbol)} event The event name.
58
+ * @param {Function} fn The listener function.
59
+ * @param {*} context The context to invoke the listener with.
60
+ * @param {Boolean} once Specify if the listener is a one-time listener.
61
+ * @returns {EventEmitter}
62
+ * @private
63
+ */
64
+ function addListener(emitter, event, fn, context, once) {
65
+ if (typeof fn !== 'function') {
66
+ throw new TypeError('The listener must be a function');
67
+ }
68
+
69
+ var listener = new EE(fn, context || emitter, once)
70
+ , evt = prefix ? prefix + event : event;
71
+
72
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
73
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
74
+ else emitter._events[evt] = [emitter._events[evt], listener];
75
+
76
+ return emitter;
77
+ }
78
+
79
+ /**
80
+ * Clear event by name.
81
+ *
82
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
83
+ * @param {(String|Symbol)} evt The Event name.
84
+ * @private
85
+ */
86
+ function clearEvent(emitter, evt) {
87
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
88
+ else delete emitter._events[evt];
89
+ }
90
+
91
+ /**
92
+ * Minimal `EventEmitter` interface that is molded against the Node.js
93
+ * `EventEmitter` interface.
94
+ *
95
+ * @constructor
96
+ * @public
97
+ */
98
+ function EventEmitter() {
99
+ this._events = new Events();
100
+ this._eventsCount = 0;
101
+ }
102
+
103
+ /**
104
+ * Return an array listing the events for which the emitter has registered
105
+ * listeners.
106
+ *
107
+ * @returns {Array}
108
+ * @public
109
+ */
110
+ EventEmitter.prototype.eventNames = function eventNames() {
111
+ var names = []
112
+ , events
113
+ , name;
114
+
115
+ if (this._eventsCount === 0) return names;
116
+
117
+ for (name in (events = this._events)) {
118
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
119
+ }
120
+
121
+ if (Object.getOwnPropertySymbols) {
122
+ return names.concat(Object.getOwnPropertySymbols(events));
123
+ }
124
+
125
+ return names;
126
+ };
127
+
128
+ /**
129
+ * Return the listeners registered for a given event.
130
+ *
131
+ * @param {(String|Symbol)} event The event name.
132
+ * @returns {Array} The registered listeners.
133
+ * @public
134
+ */
135
+ EventEmitter.prototype.listeners = function listeners(event) {
136
+ var evt = prefix ? prefix + event : event
137
+ , handlers = this._events[evt];
138
+
139
+ if (!handlers) return [];
140
+ if (handlers.fn) return [handlers.fn];
141
+
142
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
143
+ ee[i] = handlers[i].fn;
144
+ }
145
+
146
+ return ee;
147
+ };
148
+
149
+ /**
150
+ * Return the number of listeners listening to a given event.
151
+ *
152
+ * @param {(String|Symbol)} event The event name.
153
+ * @returns {Number} The number of listeners.
154
+ * @public
155
+ */
156
+ EventEmitter.prototype.listenerCount = function listenerCount(event) {
157
+ var evt = prefix ? prefix + event : event
158
+ , listeners = this._events[evt];
159
+
160
+ if (!listeners) return 0;
161
+ if (listeners.fn) return 1;
162
+ return listeners.length;
163
+ };
164
+
165
+ /**
166
+ * Calls each of the listeners registered for a given event.
167
+ *
168
+ * @param {(String|Symbol)} event The event name.
169
+ * @returns {Boolean} `true` if the event had listeners, else `false`.
170
+ * @public
171
+ */
172
+ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
173
+ var evt = prefix ? prefix + event : event;
174
+
175
+ if (!this._events[evt]) return false;
176
+
177
+ var listeners = this._events[evt]
178
+ , len = arguments.length
179
+ , args
180
+ , i;
181
+
182
+ if (listeners.fn) {
183
+ if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
184
+
185
+ switch (len) {
186
+ case 1: return listeners.fn.call(listeners.context), true;
187
+ case 2: return listeners.fn.call(listeners.context, a1), true;
188
+ case 3: return listeners.fn.call(listeners.context, a1, a2), true;
189
+ case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
190
+ case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
191
+ case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
192
+ }
193
+
194
+ for (i = 1, args = new Array(len -1); i < len; i++) {
195
+ args[i - 1] = arguments[i];
196
+ }
197
+
198
+ listeners.fn.apply(listeners.context, args);
199
+ } else {
200
+ var length = listeners.length
201
+ , j;
202
+
203
+ for (i = 0; i < length; i++) {
204
+ if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
205
+
206
+ switch (len) {
207
+ case 1: listeners[i].fn.call(listeners[i].context); break;
208
+ case 2: listeners[i].fn.call(listeners[i].context, a1); break;
209
+ case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
210
+ case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
211
+ default:
212
+ if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
213
+ args[j - 1] = arguments[j];
214
+ }
215
+
216
+ listeners[i].fn.apply(listeners[i].context, args);
217
+ }
218
+ }
219
+ }
220
+
221
+ return true;
222
+ };
223
+
224
+ /**
225
+ * Add a listener for a given event.
226
+ *
227
+ * @param {(String|Symbol)} event The event name.
228
+ * @param {Function} fn The listener function.
229
+ * @param {*} [context=this] The context to invoke the listener with.
230
+ * @returns {EventEmitter} `this`.
231
+ * @public
232
+ */
233
+ EventEmitter.prototype.on = function on(event, fn, context) {
234
+ return addListener(this, event, fn, context, false);
235
+ };
236
+
237
+ /**
238
+ * Add a one-time listener for a given event.
239
+ *
240
+ * @param {(String|Symbol)} event The event name.
241
+ * @param {Function} fn The listener function.
242
+ * @param {*} [context=this] The context to invoke the listener with.
243
+ * @returns {EventEmitter} `this`.
244
+ * @public
245
+ */
246
+ EventEmitter.prototype.once = function once(event, fn, context) {
247
+ return addListener(this, event, fn, context, true);
248
+ };
249
+
250
+ /**
251
+ * Remove the listeners of a given event.
252
+ *
253
+ * @param {(String|Symbol)} event The event name.
254
+ * @param {Function} fn Only remove the listeners that match this function.
255
+ * @param {*} context Only remove the listeners that have this context.
256
+ * @param {Boolean} once Only remove one-time listeners.
257
+ * @returns {EventEmitter} `this`.
258
+ * @public
259
+ */
260
+ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
261
+ var evt = prefix ? prefix + event : event;
262
+
263
+ if (!this._events[evt]) return this;
264
+ if (!fn) {
265
+ clearEvent(this, evt);
266
+ return this;
267
+ }
268
+
269
+ var listeners = this._events[evt];
270
+
271
+ if (listeners.fn) {
272
+ if (
273
+ listeners.fn === fn &&
274
+ (!once || listeners.once) &&
275
+ (!context || listeners.context === context)
276
+ ) {
277
+ clearEvent(this, evt);
278
+ }
279
+ } else {
280
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
281
+ if (
282
+ listeners[i].fn !== fn ||
283
+ (once && !listeners[i].once) ||
284
+ (context && listeners[i].context !== context)
285
+ ) {
286
+ events.push(listeners[i]);
287
+ }
288
+ }
289
+
290
+ //
291
+ // Reset the array, or remove it completely if we have no more listeners.
292
+ //
293
+ if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
294
+ else clearEvent(this, evt);
295
+ }
296
+
297
+ return this;
298
+ };
299
+
300
+ /**
301
+ * Remove all listeners, or those of the specified event.
302
+ *
303
+ * @param {(String|Symbol)} [event] The event name.
304
+ * @returns {EventEmitter} `this`.
305
+ * @public
306
+ */
307
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
308
+ var evt;
309
+
310
+ if (event) {
311
+ evt = prefix ? prefix + event : event;
312
+ if (this._events[evt]) clearEvent(this, evt);
313
+ } else {
314
+ this._events = new Events();
315
+ this._eventsCount = 0;
316
+ }
317
+
318
+ return this;
319
+ };
320
+
321
+ //
322
+ // Alias methods names because people roll like that.
323
+ //
324
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
325
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
326
+
327
+ //
328
+ // Expose the prefix.
329
+ //
330
+ EventEmitter.prefixed = prefix;
331
+
332
+ //
333
+ // Allow `EventEmitter` to be imported as module namespace.
334
+ //
335
+ EventEmitter.EventEmitter = EventEmitter;
336
+
337
+ //
338
+ // Expose the module.
339
+ //
340
+ {
341
+ module.exports = EventEmitter;
342
+ }
343
+ } (eventemitter3));
344
+
345
+ var EventEmitter = eventemitter3Exports;
346
+
347
+ export { EventEmitter, EventEmitter as default };
@@ -0,0 +1 @@
1
+ var e={};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,s,i){var c=n?n+e:e;if(!this._events[c])return!1;var f,a,u=this._events[c],v=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),v){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,s),!0;case 6:return u.fn.call(u.context,t,r,o,s,i),!0}for(a=1,f=new Array(v-1);a<v;a++)f[a-1]=arguments[a];u.fn.apply(u.context,f)}else{var l,p=u.length;for(a=0;a<p;a++)switch(u[a].once&&this.removeListener(e,u[a].fn,void 0,!0),v){case 1:u[a].fn.call(u[a].context);break;case 2:u[a].fn.call(u[a].context,t);break;case 3:u[a].fn.call(u[a].context,t,r);break;case 4:u[a].fn.call(u[a].context,t,r,o);break;default:if(!f)for(l=1,f=new Array(v-1);l<v;l++)f[l-1]=arguments[l];u[a].fn.apply(u[a].context,f)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var f=0,a=[],u=c.length;f<u;f++)(c[f].fn!==t||o&&!c[f].once||r&&c[f].context!==r)&&a.push(c[f]);a.length?this._events[s]=1===a.length?a[0]:a:i(this,s)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c}({get exports(){return e},set exports(t){e=t}});var t=e;export{t as EventEmitter,t as default};//# sourceMappingURL=eventemitter3.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventemitter3.esm.min.js","sources":["../index.js"],"sourcesContent":["'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n"],"names":["has","Object","prototype","hasOwnProperty","prefix","Events","EE","fn","context","once","this","addListener","emitter","event","TypeError","listener","evt","_events","push","_eventsCount","clearEvent","EventEmitter","create","__proto__","eventNames","events","name","names","call","slice","getOwnPropertySymbols","concat","listeners","handlers","i","l","length","ee","Array","listenerCount","emit","a1","a2","a3","a4","a5","args","len","arguments","removeListener","undefined","apply","j","on","removeAllListeners","off","prefixed","module","exports"],"mappings":"sBAEA,IAAIA,EAAMC,OAAOC,UAAUC,eACvBC,EAAS,IASb,SAASC,IAAW,CA4BpB,SAASC,EAAGC,EAAIC,EAASC,GACvBC,KAAKH,GAAKA,EACVG,KAAKF,QAAUA,EACfE,KAAKD,KAAOA,IAAQ,CACrB,CAaD,SAASE,EAAYC,EAASC,EAAON,EAAIC,EAASC,GAChD,GAAkB,mBAAPF,EACT,MAAM,IAAIO,UAAU,mCAGtB,IAAIC,EAAW,IAAIT,EAAGC,EAAIC,GAAWI,EAASH,GAC1CO,EAAMZ,EAASA,EAASS,EAAQA,EAMpC,OAJKD,EAAQK,QAAQD,GACXJ,EAAQK,QAAQD,GAAKT,GAC1BK,EAAQK,QAAQD,GAAO,CAACJ,EAAQK,QAAQD,GAAMD,GADhBH,EAAQK,QAAQD,GAAKE,KAAKH,IADlCH,EAAQK,QAAQD,GAAOD,EAAUH,EAAQO,gBAI7DP,CACR,CASD,SAASQ,EAAWR,EAASI,GACI,KAAzBJ,EAAQO,aAAoBP,EAAQK,QAAU,IAAIZ,SAC5CO,EAAQK,QAAQD,EAC7B,CASD,SAASK,IACPX,KAAKO,QAAU,IAAIZ,EACnBK,KAAK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