New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rwh/keystrokes

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rwh/keystrokes - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3

158

dist/keystrokes.js
var w = Object.defineProperty;
var A = (n, e, t) => e in n ? w(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var a = (n, e, t) => (A(n, typeof e != "symbol" ? e + "" : e, t), t);
var o = (n, e, t) => (A(n, typeof e != "symbol" ? e + "" : e, t), t);
const R = {

@@ -23,8 +23,8 @@ /*

userAgent: ""
}, m = () => typeof document < "u" ? document : R, x = () => typeof navigator < "u" ? navigator : E, q = () => x().userAgent.toLowerCase().includes("mac");
let v = !1;
}, p = () => typeof document < "u" ? document : R, x = () => typeof navigator < "u" ? navigator : E, q = () => x().userAgent.toLowerCase().includes("mac");
let C = !1;
const I = (n) => {
!q() || n.key !== "Meta" || (v = !0);
!q() || n.key !== "Meta" || (C = !0);
}, M = (n) => {
!v || n.key !== "Meta" || (v = !1, k());
!C || n.key !== "Meta" || (C = !1, k());
}, b = /* @__PURE__ */ new Map(), B = (n) => {

@@ -42,3 +42,3 @@ b.set(n.key, n);

});
m().dispatchEvent(e);
p().dispatchEvent(e);
}

@@ -73,3 +73,3 @@ b.clear();

};
return m().addEventListener("keydown", e), () => m().removeEventListener("keydown", e);
return p().addEventListener("keydown", e), () => p().removeEventListener("keydown", e);
} catch {

@@ -88,3 +88,3 @@ }

};
return m().addEventListener("keyup", e), () => m().removeEventListener("keyup", e);
return p().addEventListener("keyup", e), () => p().removeEventListener("keyup", e);
} catch {

@@ -95,7 +95,7 @@ }

constructor(e) {
a(this, "_onPressed");
a(this, "_onPressedWithRepeat");
a(this, "_onReleased");
a(this, "_isPressed");
a(this, "_identity");
o(this, "_onPressed");
o(this, "_onPressedWithRepeat");
o(this, "_onReleased");
o(this, "_isPressed");
o(this, "_identity");
this._isPressed = !1, this._identity = e, typeof e == "function" ? this._onPressedWithRepeat = e : (this._onPressed = e.onPressed, this._onPressedWithRepeat = e.onPressedWithRepeat, this._onReleased = e.onReleased);

@@ -120,12 +120,12 @@ }

constructor(e, t, i = {}) {
a(this, "_normalizedKeyCombo");
a(this, "_parsedKeyCombo");
a(this, "_handlerState");
a(this, "_keyComboEventMapper");
a(this, "_movingToNextSequenceAt");
a(this, "_sequenceIndex");
a(this, "_unitIndex");
a(this, "_lastActiveKeyPresses");
a(this, "_lastActiveKeyCount");
a(this, "_isPressedWithFinalUnit");
o(this, "_normalizedKeyCombo");
o(this, "_parsedKeyCombo");
o(this, "_handlerState");
o(this, "_keyComboEventMapper");
o(this, "_movingToNextSequenceAt");
o(this, "_sequenceIndex");
o(this, "_unitIndex");
o(this, "_lastActiveKeyPresses");
o(this, "_lastActiveKeyCount");
o(this, "_isPressedWithFinalUnit");
this._normalizedKeyCombo = h.normalizeKeyCombo(e), this._parsedKeyCombo = h.parseKeyCombo(e), this._handlerState = new S(i), this._keyComboEventMapper = t, this._movingToNextSequenceAt = 0, this._sequenceIndex = 0, this._unitIndex = 0, this._lastActiveKeyPresses = [], this._lastActiveKeyCount = 0, this._isPressedWithFinalUnit = null;

@@ -137,3 +137,3 @@ }

const t = e.toLowerCase();
let i = "", s = [], o = [s], r = [o];
let i = "", s = [], a = [s], r = [a];
const K = [r];

@@ -149,3 +149,3 @@ let _ = !1;

} else
t[c].match(/[^\s]/) && (i && (i === "," ? (s = [], o = [s], r = [o], K.push(r)) : i === ">" ? (s = [], o = [s], r.push(o)) : i === "+" && (s = [], o.push(s)), i = ""), _ = !1, s.push(t[c]));
t[c].match(/[^\s]/) && (i && (i === "," ? (s = [], a = [s], r = [a], K.push(r)) : i === ">" ? (s = [], a = [s], r.push(a)) : i === "+" && (s = [], a.push(s)), i = ""), _ = !1, s.push(t[c]));
const d = K.map((c) => c.map((u) => u.map((f) => f.join(""))));

@@ -173,4 +173,7 @@ return h._parseCache[e] = d, d;

executePressed(e) {
var t;
(t = this._isPressedWithFinalUnit) != null && t.has(e.key) && this._handlerState.executePressed(this._wrapEvent(this._lastActiveKeyPresses, {
var t, i;
!((t = this._isPressedWithFinalUnit) != null && t.has(e.key)) && !((i = e.aliases) != null && i.some((s) => {
var a;
return (a = this._isPressedWithFinalUnit) == null ? void 0 : a.has(s);
})) || this._handlerState.executePressed(this._wrapEvent(this._lastActiveKeyPresses, {
key: e.key,

@@ -182,4 +185,7 @@ aliases: new Set(e.aliases),

executeReleased(e) {
var t;
(t = this._isPressedWithFinalUnit) != null && t.has(e.key) && (this._handlerState.executeReleased(this._wrapEvent(this._lastActiveKeyPresses, {
var t, i;
!((t = this._isPressedWithFinalUnit) != null && t.has(e.key)) && !((i = e.aliases) != null && i.some((s) => {
var a;
return (a = this._isPressedWithFinalUnit) == null ? void 0 : a.has(s);
})) || (this._handlerState.executeReleased(this._wrapEvent(this._lastActiveKeyPresses, {
key: e.key,

@@ -193,3 +199,3 @@ aliases: new Set(e.aliases),

this._lastActiveKeyCount = i;
const o = this._parsedKeyCombo[this._sequenceIndex], r = o.slice(0, this._unitIndex), K = o.slice(this._unitIndex), _ = () => {
const a = this._parsedKeyCombo[this._sequenceIndex], r = a.slice(0, this._unitIndex), K = a.slice(this._unitIndex), _ = () => {
this._movingToNextSequenceAt = 0, this._sequenceIndex = 0, this._unitIndex = 0, this._lastActiveKeyPresses.length = 0, this._handlerState.isEmpty && (this._isPressedWithFinalUnit = null);

@@ -239,3 +245,3 @@ };

}
this._isPressedWithFinalUnit = new Set(o[o.length - 1]);
this._isPressedWithFinalUnit = new Set(a[a.length - 1]);
}

@@ -252,23 +258,23 @@ }

};
a(h, "_parseCache", {}), a(h, "_normalizationCache", {});
o(h, "_parseCache", {}), o(h, "_normalizationCache", {});
let y = h;
const U = 1e3;
class g {
class P {
constructor(e = {}) {
a(this, "sequenceTimeout");
a(this, "_isActive");
a(this, "_unbinder");
a(this, "_onActiveBinder");
a(this, "_onInactiveBinder");
a(this, "_onKeyPressedBinder");
a(this, "_onKeyReleasedBinder");
a(this, "_keyComboEventMapper");
a(this, "_selfReleasingKeys");
a(this, "_keyRemap");
a(this, "_handlerStates");
a(this, "_keyComboStates");
a(this, "_keyComboStatesArray");
a(this, "_activeKeyPresses");
a(this, "_activeKeyMap");
a(this, "_watchedKeyComboStates");
o(this, "sequenceTimeout");
o(this, "_isActive");
o(this, "_unbinder");
o(this, "_onActiveBinder");
o(this, "_onInactiveBinder");
o(this, "_onKeyPressedBinder");
o(this, "_onKeyReleasedBinder");
o(this, "_keyComboEventMapper");
o(this, "_selfReleasingKeys");
o(this, "_keyRemap");
o(this, "_handlerStates");
o(this, "_keyComboStates");
o(this, "_keyComboStatesArray");
o(this, "_activeKeyPresses");
o(this, "_activeKeyMap");
o(this, "_watchedKeyComboStates");
this.sequenceTimeout = U, this._isActive = !0, this._onActiveBinder = () => {

@@ -286,4 +292,4 @@ }, this._onInactiveBinder = () => {

if (typeof e == "object") {
for (const o of e)
this.bindKey(o, t);
for (const a of e)
this.bindKey(a, t);
return;

@@ -313,4 +319,4 @@ }

if (typeof e == "object") {
for (const o of e)
this.bindKeyCombo(o, t);
for (const a of e)
this.bindKeyCombo(a, t);
return;

@@ -334,4 +340,4 @@ }

if (i[s].isOwnHandler(t)) {
for (let o = 0; o < this._keyComboStatesArray.length; o += 1)
this._keyComboStatesArray[o] === i[s] && (this._keyComboStatesArray.splice(o, 1), o -= 1);
for (let a = 0; a < this._keyComboStatesArray.length; a += 1)
this._keyComboStatesArray[a] === i[s] && (this._keyComboStatesArray.splice(a, 1), a -= 1);
i.splice(s, 1), s -= 1;

@@ -359,7 +365,7 @@ }

this._handleKeyPress(r);
}), o = this._onKeyReleasedBinder((r) => {
}), a = this._onKeyReleasedBinder((r) => {
this._handleKeyRelease(r);
});
this._unbinder = () => {
t == null || t(), i == null || i(), s == null || s(), o == null || o();
t == null || t(), i == null || i(), s == null || s(), a == null || a();
};

@@ -382,10 +388,10 @@ }

if (t && (e.key = t), e.aliases)
for (let o = 0; o < e.aliases.length; o += 1) {
const r = this._keyRemap[e.aliases[o]];
r && (e.aliases[o] = r);
for (let a = 0; a < e.aliases.length; a += 1) {
const r = this._keyRemap[e.aliases[a]];
r && (e.aliases[a] = r);
}
const i = this._handlerStates[e.key];
if (i)
for (const o of i)
o.executePressed(e);
for (const a of i)
a.executePressed(e);
const s = this._activeKeyMap.get(e.key);

@@ -395,3 +401,3 @@ if (s)

else {
const o = {
const a = {
key: e.key,

@@ -401,7 +407,7 @@ aliases: new Set(e.aliases),

};
this._activeKeyMap.set(e.key, o), this._activeKeyPresses.push(o);
this._activeKeyMap.set(e.key, a), this._activeKeyPresses.push(a);
}
this._updateKeyComboStates();
for (const o of this._keyComboStatesArray)
o.executePressed(e);
for (const a of this._keyComboStatesArray)
a.executePressed(e);
}

@@ -413,4 +419,4 @@ _handleKeyRelease(e) {

for (let s = 0; s < e.aliases.length; s += 1) {
const o = this._keyRemap[e.aliases[s]];
o && (e.aliases[s] = o);
const a = this._keyRemap[e.aliases[s]];
a && (e.aliases[s] = a);
}

@@ -443,10 +449,10 @@ const i = this._handlerStates[e.key];

}
let P, C;
let g, v;
const F = (n) => {
C = n ?? new g(P);
}, p = () => (C || F(), C), H = (n) => {
P = n;
}, N = (...n) => p().bindKey(...n), D = (...n) => p().unbindKey(...n), G = (...n) => p().bindKeyCombo(...n), $ = (...n) => p().unbindKeyCombo(...n), J = (...n) => p().checkKey(...n), Q = (...n) => p().checkKeyCombo(...n), V = y.normalizeKeyCombo, X = y.stringifyKeyCombo, Y = y.parseKeyCombo, Z = (n = {}) => {
v = n ?? new P(g);
}, m = () => (v || F(), v), H = (n) => {
g = n;
}, N = (...n) => m().bindKey(...n), D = (...n) => m().unbindKey(...n), G = (...n) => m().bindKeyCombo(...n), $ = (...n) => m().unbindKeyCombo(...n), J = (...n) => m().checkKey(...n), Q = (...n) => m().checkKeyCombo(...n), V = y.normalizeKeyCombo, X = y.stringifyKeyCombo, Y = y.parseKeyCombo, Z = (n = {}) => {
let e, t, i, s;
return Object.assign(new g({
return Object.assign(new P({
...n,

@@ -483,3 +489,3 @@ onActive(r) {

y as KeyComboState,
g as Keystrokes,
P as Keystrokes,
N as bindKey,

@@ -495,3 +501,3 @@ G as bindKeyCombo,

U as defaultSequenceTimeout,
p as getGlobalKeystrokes,
m as getGlobalKeystrokes,
V as normalizeKeyCombo,

@@ -498,0 +504,0 @@ Y as parseKeyCombo,

{
"name": "@rwh/keystrokes",
"version": "1.5.2",
"version": "1.5.3",
"description": "Keystrokes is an easy to use library for binding functions to keys and key combos. It can be used with any TypeScript or JavaScript project, even in non-browser environments.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

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