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

hotstuff

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotstuff - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

8

dist/HotStuff.js

@@ -196,4 +196,8 @@ "use strict";

// when the window loses focus, trigger all key up events
window.addEventListener("blur", function () {
// when the window loses or gains focus, trigger all key up events that haven't been triggered
(function (arr, func) {
arr.forEach(function (x) {
return window.addEventListener(x, func);
});
})(['blur', 'focus'], function () {
_this._unresolvedKeyUps.forEach(function (listenerGroup) {

@@ -200,0 +204,0 @@ createFakeEvent(listenerGroup._events[listenerGroup._events.length - 1], _this.el);

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

"use strict";var _typeof="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};!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=t():e.HotStuff=t()}(window,function(){function e(e,t){var n=document.createEventObject?document.createEventObject():document.createEvent("Event");n.initEvent&&n.initEvent("keyup",!0,!0);for(var i in e)try{n[i]=e[i]}catch(e){}t.dispatchEvent?t.dispatchEvent(n):t.fireEvent("onkeyup",n)}var t={"+":"plus","-":"subtract",",":"comma"," ":"space"," ":"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",control:"ctrl",delete:"del"},n=function(){for(var e={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"equals",91:"meta",92:"meta",93:"select",106:"multiply",107:"plus",109:"subtract",110:"decimal",111:"divide",144:"numlock",145:"scrolllock",186:";",187:"equals",189:"minus",190:".",191:"/",192:"grave",219:"[",220:"\\",221:"]",222:"'",223:"`"},t=0;t<=9;t++)e[48+t]=String.fromCharCode(48+t),e[96+t]="numpad"+t;for(var n=0;n<=11;n++)e[112+n]="f"+(n+1);for(var i=65;i<91;i++)e[i]=String.fromCharCode(i).toLowerCase();return e}(),i=function(e){return t[e]?t[e]:e},r=function(e,t){return"ctrl"!==e&&"control"!==e||(e="\0"),"alt"===e&&(e=""),"shift"===e&&(e=""),"ctrl"!==t&&"control"!==t||(t="\0"),"alt"===t&&(t=""),"shift"===t&&(t=""),e>t},o=function(e){return e.toLowerCase().split(/[+-]/)},s=function(e,t){return void 0===e._keyListeners[t]&&(e._keyListeners[t]=[]),e._keyListeners[t]},c=function(e,t){return void 0===(e=e._keys)[t]&&(e[t]={trigger:!1,event:null}),e[t]},u=function(e){return function(t,n){return Object.defineProperty(e,t,n)}},a=function e(){if(!(this instanceof e))return new(Function.prototype.bind.apply(e,[null].concat(Array.prototype.slice.call(arguments))));this.init.apply(this,arguments)};return Object.assign(a.prototype,{constructor:a,init:function(t){var n=this;if(null===t||void 0===t){if(!window)throw new Error("No element found to attach HotStuff to and could not find window object.");t=window}u(this)("el",{get:function(){return t},readOnly:!0,enumerable:!0}),this._keyListeners={},this._keysActive=[],this._unresolvedKeyUps=[],this._genericKeyListeners=[],t.addEventListener("keydown",this.handleKeyDown.bind(this)),t.addEventListener("keyup",this.handleKeyUp.bind(this)),window.addEventListener("blur",function(){n._unresolvedKeyUps.forEach(function(t){e(t._events[t._events.length-1],n.el),t._events.splice()}),n._genericKeyListeners.forEach(function(t){var i=t._keys;for(var r in i)i.hasOwnProperty(r)&&i[r].trigger&&(e(i[r].event,n.el),i[r].trigger=!1)})})},addListener:function(e,t,n){var c=this;if("string"==typeof e&&(e=[e]),null===e&&(e=[]),e instanceof Function&&(n=t,t=e,e=[]),!(e instanceof Array))throw new Error("Invalid Keys provided");if(null==n&&null==t)throw new Error("No handlers provided");null==t&&(t=function(e){return e}),null==n&&(n=function(e){return e});var u={};if(0===e.length){var a=[],l={};return t=t.bind(this),n=n.bind(this),void this._genericKeyListeners.push({keyDown:function(e){return a.push(e),t(e,u,c._keysActive.slice())},keyUp:function(e){return n(e,u,c._keysActive.slice())},_keys:l,_events:a})}e.forEach(function(e){e=o(e).map(i).sort(r);var a=[],l=[];t=t.bind(c),n=n.bind(c),s(c,e.join("+")).push({keyDown:function(e){return l.push(e),a=c._keysActive.slice(),t(e,u,c._keysActive.slice())},keyUp:function(e){return n(e,u,a)},_events:l})})},handleKeyDown:function(e){var t=this,o=(e.which&&e.keyCode?n[e.which||e.keyCode]:e.key).toLowerCase();this._keysActive.includes(o)||(this._keysActive.push(o),this._keysActive.sort(r));var s=this._keysActive.map(i).join("+");null!=this._keyListeners[s]&&this._keyListeners[s].forEach(function(n){!1!==n.keyDown(e)&&(t._unresolvedKeyUps.includes(n)||t._unresolvedKeyUps.push(n))}),this._genericKeyListeners.forEach(function(t){var n=c(t,o);n.trigger=!1!==t.keyDown(e),n.event=e})},handleKeyUp:function(e){var t=(e.which&&e.keyCode?n[e.which||e.keyCode]:e.key).toLowerCase();this._keysActive.includes(t)&&(this._keysActive.splice(this._keysActive.indexOf(t),1),this._keysActive.sort(r)),this._unresolvedKeyUps.forEach(function(t){return t.keyUp(e)}),this._unresolvedKeyUps.splice(0),this._genericKeyListeners.forEach(function(n){var i=c(n,t);!1!==i.trigger&&(n.keyUp(e),i.trigger=!1,i.event=null)})}}),a});
"use strict";var _typeof="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};!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=t():e.HotStuff=t()}(window,function(){function e(e,t){var n=document.createEventObject?document.createEventObject():document.createEvent("Event");n.initEvent&&n.initEvent("keyup",!0,!0);for(var r in e)try{n[r]=e[r]}catch(e){}t.dispatchEvent?t.dispatchEvent(n):t.fireEvent("onkeyup",n)}var t={"+":"plus","-":"subtract",",":"comma"," ":"space"," ":"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",control:"ctrl",delete:"del"},n=function(){for(var e={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"equals",91:"meta",92:"meta",93:"select",106:"multiply",107:"plus",109:"subtract",110:"decimal",111:"divide",144:"numlock",145:"scrolllock",186:";",187:"equals",189:"minus",190:".",191:"/",192:"grave",219:"[",220:"\\",221:"]",222:"'",223:"`"},t=0;t<=9;t++)e[48+t]=String.fromCharCode(48+t),e[96+t]="numpad"+t;for(var n=0;n<=11;n++)e[112+n]="f"+(n+1);for(var r=65;r<91;r++)e[r]=String.fromCharCode(r).toLowerCase();return e}(),r=function(e){return t[e]?t[e]:e},i=function(e,t){return"ctrl"!==e&&"control"!==e||(e="\0"),"alt"===e&&(e=""),"shift"===e&&(e=""),"ctrl"!==t&&"control"!==t||(t="\0"),"alt"===t&&(t=""),"shift"===t&&(t=""),e>t},o=function(e){return e.toLowerCase().split(/[+-]/)},s=function(e,t){return void 0===e._keyListeners[t]&&(e._keyListeners[t]=[]),e._keyListeners[t]},c=function(e,t){return void 0===(e=e._keys)[t]&&(e[t]={trigger:!1,event:null}),e[t]},u=function(e){return function(t,n){return Object.defineProperty(e,t,n)}},a=function e(){if(!(this instanceof e))return new(Function.prototype.bind.apply(e,[null].concat(Array.prototype.slice.call(arguments))));this.init.apply(this,arguments)};return Object.assign(a.prototype,{constructor:a,init:function(t){var n=this;if(null===t||void 0===t){if(!window)throw new Error("No element found to attach HotStuff to and could not find window object.");t=window}u(this)("el",{get:function(){return t},readOnly:!0,enumerable:!0}),this._keyListeners={},this._keysActive=[],this._unresolvedKeyUps=[],this._genericKeyListeners=[],t.addEventListener("keydown",this.handleKeyDown.bind(this)),t.addEventListener("keyup",this.handleKeyUp.bind(this)),function(e,t){["blur","focus"].forEach(function(e){return window.addEventListener(e,t)})}(0,function(){n._unresolvedKeyUps.forEach(function(t){e(t._events[t._events.length-1],n.el),t._events.splice()}),n._genericKeyListeners.forEach(function(t){var r=t._keys;for(var i in r)r.hasOwnProperty(i)&&r[i].trigger&&(e(r[i].event,n.el),r[i].trigger=!1)})})},addListener:function(e,t,n){var c=this;if("string"==typeof e&&(e=[e]),null===e&&(e=[]),e instanceof Function&&(n=t,t=e,e=[]),!(e instanceof Array))throw new Error("Invalid Keys provided");if(null==n&&null==t)throw new Error("No handlers provided");null==t&&(t=function(e){return e}),null==n&&(n=function(e){return e});var u={};if(0===e.length){var a=[],l={};return t=t.bind(this),n=n.bind(this),void this._genericKeyListeners.push({keyDown:function(e){return a.push(e),t(e,u,c._keysActive.slice())},keyUp:function(e){return n(e,u,c._keysActive.slice())},_keys:l,_events:a})}e.forEach(function(e){e=o(e).map(r).sort(i);var a=[],l=[];t=t.bind(c),n=n.bind(c),s(c,e.join("+")).push({keyDown:function(e){return l.push(e),a=c._keysActive.slice(),t(e,u,c._keysActive.slice())},keyUp:function(e){return n(e,u,a)},_events:l})})},handleKeyDown:function(e){var t=this,o=(e.which&&e.keyCode?n[e.which||e.keyCode]:e.key).toLowerCase();this._keysActive.includes(o)||(this._keysActive.push(o),this._keysActive.sort(i));var s=this._keysActive.map(r).join("+");null!=this._keyListeners[s]&&this._keyListeners[s].forEach(function(n){!1!==n.keyDown(e)&&(t._unresolvedKeyUps.includes(n)||t._unresolvedKeyUps.push(n))}),this._genericKeyListeners.forEach(function(t){var n=c(t,o);n.trigger=!1!==t.keyDown(e),n.event=e})},handleKeyUp:function(e){var t=(e.which&&e.keyCode?n[e.which||e.keyCode]:e.key).toLowerCase();this._keysActive.includes(t)&&(this._keysActive.splice(this._keysActive.indexOf(t),1),this._keysActive.sort(i)),this._unresolvedKeyUps.forEach(function(t){return t.keyUp(e)}),this._unresolvedKeyUps.splice(0),this._genericKeyListeners.forEach(function(n){var r=c(n,t);!1!==r.trigger&&(n.keyUp(e),r.trigger=!1,r.event=null)})}}),a});
{
"name": "hotstuff",
"version": "0.0.4",
"version": "0.1.0",
"description": "A small package to provide an easy way to add Hotkeys easily to any element.",
"main": "dist/HotStuff.js",
"keywords" : [
"keyboard",
"events",
"keyboard events",
"hotkeys",
"hotkey",
"es2015",
"shortcuts"
],
"scripts": {

@@ -7,0 +16,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

@@ -192,4 +192,6 @@ (function (root, factory) {

// when the window loses focus, trigger all key up events
window.addEventListener("blur", () => {
// when the window loses or gains focus, trigger all key up events that haven't been triggered
(function (arr, func) {
arr.forEach(x => window.addEventListener(x, func));
})(['blur', 'focus'], () => {
this._unresolvedKeyUps.forEach(listenerGroup => {

@@ -196,0 +198,0 @@ createFakeEvent(

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