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.3.2 to 1.3.3

2

dist/index.esm.js

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

import{Uuid as t}from"@govflanders/vl-widget-utility";var e=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 n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function r(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 o(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 i,s=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 r(this,void 0,void 0,function(){var e,n,r,i,s;return o(this,function(o){switch(o.label){case 0:if(!(e=this.eventListeners[t.getEventName()]||[]))return[3,2];for(n=[],r=0,i=e;r<i.length;r++)s=i[r],n.push(s(t));return[4,Promise.all(n)];case 1:o.sent(),o.label=2;case 2:return[2]}})})},t}();!function(t){t.Self="self",t.Broadcast="broadcast"}(i||(i={}));var a=function(){function t(){this.eventListenerManager=new s,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,i=Array.isArray(t)?t:[t],s=function(t){a.addEventListener(t,function i(s){return r(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return this.removeEventListener(t,i),[4,e(s)];case 1:return n.sent(),[2]}})})})},a=this,c=0,u=i;c<u.length;c++){s(u[c])}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 r(this,void 0,void 0,function(){var e,n;return o(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()===i.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}(),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(a),u=function(){function t(){}return t.prototype.createEventEmitter=function(){return new c},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}(),v=function(){function e(e,n,r){void 0===r&&(r=i.Broadcast),this.eventId=t.generate(),this.eventName=e,this.sender=n,this.eventScope=r}return e.prototype.getEventId=function(){return this.eventId},e.prototype.getEventScope=function(){return this.eventScope},e.prototype.getEventName=function(){return this.eventName},e.prototype.getSender=function(){return this.sender},e.prototype.rename=function(t){var e=Object.create(this);return e.eventName=t,e},e.prototype.prefix=function(t){var e=this.getEventName();return t.length>0&&(e=t+"."+e),this.rename(e)},e.prototype.suffix=function(t){var e=this.getEventName();return t.length>0&&(e=e+"."+t),this.rename(e)},e.prototype.toString=function(){return this.getEventName()},e}(),h=function(t){function e(e,n,r,o){void 0===o&&(o=i.Broadcast);var s=t.call(this,e,n,o)||this;return s.eventData=r,s}return n(e,t),e.prototype.getEventData=function(){return this.eventData},e}(v);export{h as CustomEvent,c as DefaultEventEmitter,v as EventBase,a as EventEmitterBase,s as EventListenerManager,i as EventScope,u as EventSourceBase};
import{Uuid as t}from"@govflanders/vl-widget-utility";var e=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 n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function r(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 o(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 i,s=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 r(this,void 0,void 0,function(){var e,n,r,i,s,a;return o(this,function(o){switch(o.label){case 0:if(!(e=this.eventListeners[t.getEventName()]||[]))return[3,2];for(n=[],r=0,i=e;r<i.length;r++){s=i[r];try{a=Promise.resolve(s(t)).catch(function(t){console.error(t)}),n.push(a)}catch(t){console.error(t)}}return[4,Promise.all(n)];case 1:o.sent(),o.label=2;case 2:return[2]}})})},t}();!function(t){t.Self="self",t.Broadcast="broadcast"}(i||(i={}));var a=function(){function t(){this.eventListenerManager=new s,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,i=Array.isArray(t)?t:[t],s=function(t){a.addEventListener(t,function i(s){return r(n,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return this.removeEventListener(t,i),[4,e(s)];case 1:return n.sent(),[2]}})})})},a=this,c=0,u=i;c<u.length;c++){s(u[c])}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 r(this,void 0,void 0,function(){var e,n;return o(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()===i.Broadcast&&this.subscribedEventBroadcasts.forEach(function(n){try{var r=Promise.resolve(n(t)).catch(function(t){console.error(t)});e.push(r)}catch(t){console.error(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}(),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(a),u=function(){function t(){}return t.prototype.createEventEmitter=function(){return new c},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}(),v=function(){function e(e,n,r){void 0===r&&(r=i.Broadcast),this.eventId=t.generate(),this.eventName=e,this.sender=n,this.eventScope=r}return e.prototype.getEventId=function(){return this.eventId},e.prototype.getEventScope=function(){return this.eventScope},e.prototype.getEventName=function(){return this.eventName},e.prototype.getSender=function(){return this.sender},e.prototype.rename=function(t){var e=Object.create(this);return e.eventName=t,e},e.prototype.prefix=function(t){var e=this.getEventName();return t.length>0&&(e=t+"."+e),this.rename(e)},e.prototype.suffix=function(t){var e=this.getEventName();return t.length>0&&(e=e+"."+t),this.rename(e)},e.prototype.toString=function(){return this.getEventName()},e}(),h=function(t){function e(e,n,r,o){void 0===o&&(o=i.Broadcast);var s=t.call(this,e,n,o)||this;return s.eventData=r,s}return n(e,t),e.prototype.getEventData=function(){return this.eventData},e}(v);export{h as CustomEvent,c as DefaultEventEmitter,v as EventBase,a as EventEmitterBase,s as EventListenerManager,i as EventScope,u as EventSourceBase};

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

"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;
"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,s;return __generator(this,function(a){switch(a.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];try{s=Promise.resolve(i(t)).catch(function(t){console.error(t)}),n.push(s)}catch(t){console.error(t)}}return[4,Promise.all(n)];case 1:a.sent(),a.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){try{var r=Promise.resolve(n(t)).catch(function(t){console.error(t)});e.push(r)}catch(t){console.error(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.3.2",
"version": "1.3.3",
"license": "MIT",

@@ -27,4 +27,4 @@ "contributors": [

"dependencies": {
"@govflanders/vl-widget-utility": "^1.3.2"
"@govflanders/vl-widget-utility": "^1.3.3"
}
}

@@ -45,3 +45,3 @@ import { Event as IEvent } from './event';

export interface EventListener<Event extends IEvent> {
(event: Event): Promise<void>;
(event: Event): Promise<void> | void;
}

@@ -48,0 +48,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