Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@govflanders/vl-widget-event

Package Overview
Dependencies
Maintainers
13
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@govflanders/vl-widget-event - npm Package Compare versions

Comparing version 1.2.2 to 1.3.2-0

dist/index.esm.js

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var eventemitter2=require("eventemitter2"),vlWidgetUtility=require("@govflanders/vl-widget-utility"),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function __extends(t,e){function n(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function suppressEventEmitter2UnhandledError(){}!function(t){t.Self="self",t.Broadcast="broadcast"}(exports.EventScope||(exports.EventScope={}));var EventEmitterBase=function(){function t(t){this.emitter=new eventemitter2.EventEmitter2(t),this.subscribedEventBroadcasts=[],this.eventLocks={},this.emitter.on("error",suppressEventEmitter2UnhandledError)}return t.prototype.hasEventLock=function(t){return!!this.eventLocks[t.getEventId()]},t.prototype.acquireEventLock=function(t){return this.eventLocks[t.getEventId()]=!0,this},t.prototype.releaseEventLock=function(t){return delete this.eventLocks[t.getEventId()],this},t.prototype.resolveEventBroadcast=function(t){var e=null;"function"==typeof t.getEventBroadcast?e=t.getEventBroadcast():"function"==typeof t&&(e=t);return e},t.prototype.createEventBroadcast=function(){var e=this;return function(t){return e.emit(t)}},t.prototype.getEventBroadcast=function(){return void 0===this.eventBroadcast&&(this.eventBroadcast=this.createEventBroadcast()),this.eventBroadcast},t.prototype.on=function(t,e){return this.addEventListener(t,e)},t.prototype.off=function(t,e){return this.removeEventListener(t,e)},t.prototype.once=function(t,e){return this.emitter.once(t,e),this},t.prototype.addEventListener=function(t,e){for(var n=0,r=Array.isArray(t)?t:[t];n<r.length;n++){var o=r[n];this.emitter.addListener(o,e)}return this},t.prototype.removeEventListener=function(t,e){for(var n=0,r=Array.isArray(t)?t:[t];n<r.length;n++){var o=r[n];this.emitter.removeListener(o,e)}return this},t.prototype.addEventBroadcast=function(t){var e=this.resolveEventBroadcast(t);return null!==e&&-1===this.subscribedEventBroadcasts.indexOf(e)&&this.subscribedEventBroadcasts.push(e),this},t.prototype.removeEventBroadcast=function(t){var e=this.resolveEventBroadcast(t);if(null!==e){var n=this.subscribedEventBroadcasts.indexOf(e);-1<n&&this.subscribedEventBroadcasts.slice(n,1)}return this},t.prototype.emit=function(r){var o=this;return new Promise(function(t,e){if(o.hasEventLock(r))t();else{o.acquireEventLock(r);var n=[o.emitter.emitAsync(r.getEventName(),r)];r.getEventScope()===exports.EventScope.Broadcast&&o.subscribedEventBroadcasts.forEach(function(t){n.push(t(r))}),Promise.all(n).then(function(){o.releaseEventLock(r),t()}).catch(function(t){o.releaseEventLock(r),e(t)})}})},t}(),defaultEventEmitterOptions={newListener:!1,maxListeners:0},DefaultEventEmitter=function(e){function t(t){return e.call(this,Object.assign({},defaultEventEmitterOptions,t))||this}return __extends(t,e),t}(EventEmitterBase),EventSourceBase=function(){function t(){}return t.prototype.createEventEmitter=function(){return new DefaultEventEmitter},t.prototype.getEventEmitter=function(){return void 0===this.eventEmitter&&(this.eventEmitter=this.createEventEmitter()),this.eventEmitter},t.prototype.getEventBroadcast=function(){return this.getEventEmitter().getEventBroadcast()},t.prototype.on=function(t,e){return this.getEventEmitter().on(t,e),this},t.prototype.off=function(t,e){return this.getEventEmitter().off(t,e),this},t.prototype.once=function(t,e){return this.getEventEmitter().once(t,e),this},t.prototype.addEventListener=function(t,e){return this.getEventEmitter().addEventListener(t,e),this},t.prototype.removeEventListener=function(t,e){return this.getEventEmitter().removeEventListener(t,e),this},t.prototype.addEventBroadcast=function(t){return this.getEventEmitter().addEventBroadcast(t),this},t.prototype.removeEventBroadcast=function(t){return this.getEventEmitter().removeEventBroadcast(t),this},t.prototype.emit=function(t){return this.getEventEmitter().emit(t)},t}(),EventBase=function(){function t(t,e,n){void 0===n&&(n=exports.EventScope.Broadcast),this.eventId=vlWidgetUtility.Uuid.generate(),this.eventName=t,this.sender=e,this.eventScope=n}return t.prototype.getEventId=function(){return this.eventId},t.prototype.getEventScope=function(){return this.eventScope},t.prototype.getEventName=function(){return this.eventName},t.prototype.getSender=function(){return this.sender},t.prototype.rename=function(t){var e=Object.create(this);return e.eventName=t,e},t.prototype.prefix=function(t){var e=this.getEventName();return 0<t.length&&(e=t+"."+e),this.rename(e)},t.prototype.suffix=function(t){var e=this.getEventName();return 0<t.length&&(e=e+"."+t),this.rename(e)},t.prototype.toString=function(){return this.getEventName()},t}(),CustomEvent=function(i){function t(t,e,n,r){void 0===r&&(r=exports.EventScope.Broadcast);var o=i.call(this,t,e,r)||this;return o.eventData=n,o}return __extends(t,i),t.prototype.getEventData=function(){return this.eventData},t}(EventBase);exports.CustomEvent=CustomEvent,exports.DefaultEventEmitter=DefaultEventEmitter,exports.EventBase=EventBase,exports.EventEmitterBase=EventEmitterBase,exports.EventSourceBase=EventSourceBase,exports.defaultEventEmitterOptions=defaultEventEmitterOptions;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var vlWidgetUtility=require("@govflanders/vl-widget-utility"),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function __extends(t,e){function n(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function __awaiter(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(s,a)}c((r=r.apply(t,e||[])).next())})}function __generator(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var EventListenerManager=function(){function t(){this.eventListeners={}}return t.prototype.add=function(t,e){this.eventListeners[t]?-1===this.eventListeners[t].indexOf(e)&&this.eventListeners[t].push(e):this.eventListeners[t]=[e]},t.prototype.remove=function(t,e){var n=(this.eventListeners[t]||[]).indexOf(e);n>-1&&(this.eventListeners[t].splice(n,1),0===this.eventListeners[t].length&&delete this.eventListeners[t])},t.prototype.emit=function(t){return __awaiter(this,void 0,void 0,function(){var e,n,r,o,i;return __generator(this,function(s){switch(s.label){case 0:if(!(e=this.eventListeners[t.getEventName()]||[]))return[3,2];for(n=[],r=0,o=e;r<o.length;r++)i=o[r],n.push(i(t));return[4,Promise.all(n)];case 1:s.sent(),s.label=2;case 2:return[2]}})})},t}();!function(t){t.Self="self",t.Broadcast="broadcast"}(exports.EventScope||(exports.EventScope={}));var EventEmitterBase=function(){function t(){this.eventListenerManager=new EventListenerManager,this.eventLocks={},this.subscribedEventBroadcasts=[]}return t.prototype.hasEventLock=function(t){return!!this.eventLocks[t.getEventId()]},t.prototype.acquireEventLock=function(t){return this.eventLocks[t.getEventId()]=!0,this},t.prototype.releaseEventLock=function(t){return delete this.eventLocks[t.getEventId()],this},t.prototype.resolveEventBroadcast=function(t){var e=null;"function"==typeof t.getEventBroadcast?e=t.getEventBroadcast():"function"==typeof t&&(e=t);return e},t.prototype.createEventBroadcast=function(){var t=this;return function(e){return t.emit(e)}},t.prototype.getEventBroadcast=function(){return void 0===this.eventBroadcast&&(this.eventBroadcast=this.createEventBroadcast()),this.eventBroadcast},t.prototype.on=function(t,e){return this.addEventListener(t,e)},t.prototype.off=function(t,e){return this.removeEventListener(t,e)},t.prototype.once=function(t,e){for(var n=this,r=Array.isArray(t)?t:[t],o=function(t){i.addEventListener(t,function r(o){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return this.removeEventListener(t,r),[4,e(o)];case 1:return n.sent(),[2]}})})})},i=this,s=0,a=r;s<a.length;s++){o(a[s])}return this},t.prototype.addEventListener=function(t,e){for(var n=0,r=Array.isArray(t)?t:[t];n<r.length;n++){var o=r[n];this.eventListenerManager.add(o,e)}return this},t.prototype.removeEventListener=function(t,e){for(var n=0,r=Array.isArray(t)?t:[t];n<r.length;n++){var o=r[n];this.eventListenerManager.remove(o,e)}return this},t.prototype.addEventBroadcast=function(t){var e=this.resolveEventBroadcast(t);return null!==e&&-1===this.subscribedEventBroadcasts.indexOf(e)&&this.subscribedEventBroadcasts.push(e),this},t.prototype.removeEventBroadcast=function(t){var e=this.resolveEventBroadcast(t);if(null!==e){var n=this.subscribedEventBroadcasts.indexOf(e);n>-1&&this.subscribedEventBroadcasts.slice(n,1)}return this},t.prototype.emit=function(t){return __awaiter(this,void 0,void 0,function(){var e,n;return __generator(this,function(r){switch(r.label){case 0:if(this.hasEventLock(t))return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.acquireEventLock(t),e=[this.eventListenerManager.emit(t)],t.getEventScope()===exports.EventScope.Broadcast&&this.subscribedEventBroadcasts.forEach(function(n){e.push(n(t))}),[4,Promise.all(e)];case 2:return r.sent(),this.releaseEventLock(t),[3,4];case 3:throw n=r.sent(),this.releaseEventLock(t),n;case 4:return[2]}})})},t}(),DefaultEventEmitter=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(EventEmitterBase),EventSourceBase=function(){function t(){}return t.prototype.createEventEmitter=function(){return new DefaultEventEmitter},t.prototype.getEventEmitter=function(){return void 0===this.eventEmitter&&(this.eventEmitter=this.createEventEmitter()),this.eventEmitter},t.prototype.getEventBroadcast=function(){return this.getEventEmitter().getEventBroadcast()},t.prototype.on=function(t,e){return this.getEventEmitter().on(t,e),this},t.prototype.off=function(t,e){return this.getEventEmitter().off(t,e),this},t.prototype.once=function(t,e){return this.getEventEmitter().once(t,e),this},t.prototype.addEventListener=function(t,e){return this.getEventEmitter().addEventListener(t,e),this},t.prototype.removeEventListener=function(t,e){return this.getEventEmitter().removeEventListener(t,e),this},t.prototype.addEventBroadcast=function(t){return this.getEventEmitter().addEventBroadcast(t),this},t.prototype.removeEventBroadcast=function(t){return this.getEventEmitter().removeEventBroadcast(t),this},t.prototype.emit=function(t){return this.getEventEmitter().emit(t)},t}(),EventBase=function(){function t(t,e,n){void 0===n&&(n=exports.EventScope.Broadcast),this.eventId=vlWidgetUtility.Uuid.generate(),this.eventName=t,this.sender=e,this.eventScope=n}return t.prototype.getEventId=function(){return this.eventId},t.prototype.getEventScope=function(){return this.eventScope},t.prototype.getEventName=function(){return this.eventName},t.prototype.getSender=function(){return this.sender},t.prototype.rename=function(t){var e=Object.create(this);return e.eventName=t,e},t.prototype.prefix=function(t){var e=this.getEventName();return t.length>0&&(e=t+"."+e),this.rename(e)},t.prototype.suffix=function(t){var e=this.getEventName();return t.length>0&&(e=e+"."+t),this.rename(e)},t.prototype.toString=function(){return this.getEventName()},t}(),CustomEvent=function(t){function e(e,n,r,o){void 0===o&&(o=exports.EventScope.Broadcast);var i=t.call(this,e,n,o)||this;return i.eventData=r,i}return __extends(e,t),e.prototype.getEventData=function(){return this.eventData},e}(EventBase);exports.CustomEvent=CustomEvent,exports.DefaultEventEmitter=DefaultEventEmitter,exports.EventBase=EventBase,exports.EventEmitterBase=EventEmitterBase,exports.EventListenerManager=EventListenerManager,exports.EventSourceBase=EventSourceBase;
{
"name": "@govflanders/vl-widget-event",
"version": "1.2.2",
"version": "1.3.2-0",
"license": "MIT",

@@ -24,7 +24,7 @@ "contributors": [

"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "types/index.d.ts",
"dependencies": {
"@govflanders/vl-widget-utility": "^1.2.2",
"eventemitter2": "5.0.1"
"@govflanders/vl-widget-utility": "^1.3.2-0"
}
}

@@ -1,11 +0,5 @@

import { EventEmitter2 as InternalEventEmitter, ConstructorOptions } from 'eventemitter2';
import { Event as IEvent } from './event';
import { EventListener, EventBroadcast, EventBroadcastReceiver } from './event-listener';
import { EventListenerManager, EventListener, EventBroadcast, EventBroadcastReceiver } from './event-listener';
import { EventSubscriber } from './event-subscriber';
/**
* Interface which describes the event emitter options.
*/
export interface EventEmitterOptions extends ConstructorOptions {
}
/**
* Interface which describes an event emitter.

@@ -30,7 +24,7 @@ */

/**
* The internal event emitter.
* Holds the manager for all registered event listeners.
*
* @var {InternalEventEmitter}
* @var {EventListenerManager}
*/
protected emitter: InternalEventEmitter;
protected eventListenerManager: EventListenerManager;
/**

@@ -57,10 +51,2 @@ * Holds the acquired event locks.

/**
* Create a DefaultEventEmitter object.
*
* @param {EventEmitterOptions} options
* Optional. An object which contains the emitter
* options.
*/
constructor(options?: EventEmitterOptions);
/**
* Get a value indicating whether given event is locked.

@@ -150,19 +136,5 @@ *

/**
* Default event emitter options.
*
* @var {ConstructorOptions}
*/
export declare const defaultEventEmitterOptions: ConstructorOptions;
/**
* Default event emitter implementation.
*/
export declare class DefaultEventEmitter extends EventEmitterBase {
/**
* Create a DefaultEventEmitter object.
*
* @param {ConstructorOptions} options
* Optional. An object which contains the emitter
* options.
*/
constructor(options?: ConstructorOptions);
}
import { Event as IEvent } from './event';
/**
* Default implementation of an event listener tree which provides basic operations.
*/
export declare class EventListenerManager {
/**
* Holds the registered event listeners.
*
* @var {object}
*/
private eventListeners;
/**
* Add a listener for given event.
*
* @param {string} event
* Name of the event.
* @param {EventListener<IEvent>} listener
* Listener which should be added.
*/
add(event: string, listener: EventListener<IEvent>): void;
/**
* Remove a listener for given event.
*
* @param {string} event
* Name of the event.
* @param {EventListener<IEvent>} listener
* Listener which should be removed.
*/
remove(event: string, listener: EventListener<IEvent>): void;
/**
* Emit an event through the event listener tree.
*
* @param {Event} event
* An object which holds the event.
*
* @returns {Promise<void>}
* A promise to emit the event.
*/
emit(event: IEvent): Promise<void>;
}
/**
* Interface which describes an event listener callback.
*/
export interface EventListener<Event extends IEvent> {
(event: Event): void;
(event: Event): Promise<void>;
}

@@ -8,0 +47,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc