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.4 to 1.5.5

112

dist/keystrokes.js

@@ -28,3 +28,3 @@ var w = Object.defineProperty;

}, M = (a) => {
!C || a.key !== "Meta" || (C = !1, k());
!C || a.key !== "Meta" || (C = !1, v());
}, b = /* @__PURE__ */ new Map(), B = (a) => {

@@ -34,3 +34,3 @@ b.set(a.key, a);

b.delete(a.key);
}, k = () => {
}, v = () => {
for (const a of b.values()) {

@@ -57,3 +57,3 @@ const e = new KeyboardEvent("keyup", {

const e = () => {
k(), a();
v(), a();
};

@@ -116,3 +116,3 @@ return addEventListener("blur", e), () => removeEventListener("blur", e);

}
const h = class h {
const l = class l {
constructor(e, t, s = {}) {

@@ -129,10 +129,10 @@ r(this, "_normalizedKeyCombo");

r(this, "_isPressedWithFinalUnit");
this._normalizedKeyCombo = h.normalizeKeyCombo(e), this._parsedKeyCombo = h.parseKeyCombo(e), this._handlerState = new S(s), this._keyComboEventMapper = t, this._movingToNextSequenceAt = 0, this._sequenceIndex = 0, this._unitIndex = 0, this._lastActiveKeyPresses = [], this._lastActiveKeyCount = 0, this._isPressedWithFinalUnit = null;
this._normalizedKeyCombo = l.normalizeKeyCombo(e), this._parsedKeyCombo = l.parseKeyCombo(e), this._handlerState = new S(s), this._keyComboEventMapper = t, this._movingToNextSequenceAt = 0, this._sequenceIndex = 0, this._unitIndex = 0, this._lastActiveKeyPresses = [], this._lastActiveKeyCount = 0, this._isPressedWithFinalUnit = null;
}
static parseKeyCombo(e) {
if (h._parseCache[e])
return h._parseCache[e];
if (l._parseCache[e])
return l._parseCache[e];
const t = e.toLowerCase();
let s = "", i = [], n = [i], o = [n];
const _ = [o];
const h = [o];
let u = !1;

@@ -147,5 +147,5 @@ for (let c = 0; c < e.length; c += 1)

} else
t[c].match(/[^\s]/) && (s && (s === "," ? (i = [], n = [i], o = [n], _.push(o)) : s === ">" ? (i = [], n = [i], o.push(n)) : s === "+" && (i = [], n.push(i)), s = ""), u = !1, i.push(t[c]));
const d = _.map((c) => c.map((m) => m.map((f) => f.join(""))));
return h._parseCache[e] = d, d;
t[c].match(/[^\s]/) && (s && (s === "," ? (i = [], n = [i], o = [n], h.push(o)) : s === ">" ? (i = [], n = [i], o.push(n)) : s === "+" && (i = [], n.push(i)), s = ""), u = !1, i.push(t[c]));
const y = h.map((c) => c.map((f) => f.map((m) => m.join(""))));
return l._parseCache[e] = y, y;
}

@@ -156,6 +156,6 @@ static stringifyKeyCombo(e) {

static normalizeKeyCombo(e) {
if (h._normalizationCache[e])
return h._normalizationCache[e];
if (l._normalizationCache[e])
return l._normalizationCache[e];
const t = this.stringifyKeyCombo(this.parseKeyCombo(e));
return h._normalizationCache[e] = t, t;
return l._normalizationCache[e] = t, t;
}

@@ -196,6 +196,6 @@ get isPressed() {

this._lastActiveKeyCount = s;
const n = this._parsedKeyCombo[this._sequenceIndex], o = n.slice(0, this._unitIndex), _ = n.slice(this._unitIndex), u = () => {
const n = this._parsedKeyCombo[this._sequenceIndex], o = n.slice(0, this._unitIndex), h = n.slice(this._unitIndex), u = () => {
this._movingToNextSequenceAt = 0, this._sequenceIndex = 0, this._unitIndex = 0, this._lastActiveKeyPresses.length = 0, this._handlerState.isEmpty && (this._isPressedWithFinalUnit = null);
};
let d = 0;
let y = 0;
if (i) {

@@ -210,29 +210,29 @@ if (this._movingToNextSequenceAt === 0)

for (const c of o) {
for (const m of c) {
let f = !1;
for (let l = d; l < e.length && l < d + c.length; l += 1)
if (e[l].key === m || e[l].aliases.has(m)) {
f = !0;
for (const f of c) {
let m = !1;
for (let d = y; d < e.length && d < y + c.length; d += 1)
if (e[d].key === f || e[d].aliases.has(f)) {
m = !0;
break;
}
if (!f)
if (!m)
return u();
}
d += c.length;
y += c.length;
}
if (this._movingToNextSequenceAt === 0) {
for (const c of _) {
for (const m of c) {
let f = !1;
for (let l = d; l < e.length && l < d + c.length; l += 1)
if (e[l].key === m || e[l].aliases.has(m)) {
f = !0;
for (const c of h) {
for (const f of c) {
let m = !1;
for (let d = y; d < e.length && d < y + c.length; d += 1)
if (e[d].key === f || e[d].aliases.has(f)) {
m = !0;
break;
}
if (!f)
if (!m)
return;
}
this._unitIndex += 1, d += c.length;
this._unitIndex += 1, y += c.length;
}
if (d < s - 1)
if (y < s - 1)
return u();

@@ -255,4 +255,4 @@ if (this._lastActiveKeyPresses[this._sequenceIndex] = e.slice(0), this._sequenceIndex < this._parsedKeyCombo.length - 1) {

};
r(h, "_parseCache", {}), r(h, "_normalizationCache", {});
let y = h;
r(l, "_parseCache", {}), r(l, "_normalizationCache", {});
let _ = l;
const U = 1e3;

@@ -319,4 +319,4 @@ class P {

}
e = y.normalizeKeyCombo(e);
const s = new y(e, this._keyComboEventMapper, t);
e = _.normalizeKeyCombo(e);
const s = new _(e, this._keyComboEventMapper, t);
(i = this._keyComboStates)[e] ?? (i[e] = []), this._keyComboStates[e].push(s), this._keyComboStatesArray.push(s);

@@ -330,3 +330,3 @@ }

}
e = y.normalizeKeyCombo(e);
e = _.normalizeKeyCombo(e);
const s = this._keyComboStates[e];

@@ -345,3 +345,3 @@ if (s)

checkKey(e) {
return this._activeKeyMap.has(e.toLowerCase());
return this._activeKeyPresses.some((t) => t.key === e || t.aliases.has(e));
}

@@ -374,3 +374,3 @@ checkKeyCombo(e) {

_ensureCachedKeyComboState(e) {
e = y.normalizeKeyCombo(e), this._watchedKeyComboStates[e] || (this._watchedKeyComboStates[e] = new y(e, this._keyComboEventMapper));
e = _.normalizeKeyCombo(e), this._watchedKeyComboStates[e] || (this._watchedKeyComboStates[e] = new _(e, this._keyComboEventMapper));
const t = this._watchedKeyComboStates[e];

@@ -389,7 +389,7 @@ return t.updateState(this._activeKeyPresses, this.sequenceTimeout), t;

const t = this._keyRemap[e.key];
if (t && (e.key = t), e.aliases)
for (let o = 0; o < e.aliases.length; o += 1) {
const _ = this._keyRemap[e.aliases[o]];
_ && (e.aliases[o] = _);
}
t && (e.key = t);
for (let o = 0; o < e.aliases.length; o += 1) {
const h = this._keyRemap[e.aliases[o]];
h && (e.aliases[o] = h);
}
const s = this._handlerStates[e.key];

@@ -399,2 +399,8 @@ if (s)

o.executePressed(e);
for (let o = 0; o < e.aliases.length; o += 1) {
const h = this._handlerStates[e.aliases[o]];
if (h)
for (const u of h)
u.executePressed(e);
}
const i = this._activeKeyMap.get(e.key);

@@ -432,2 +438,8 @@ if (i)

n.executeReleased(e);
for (let n = 0; n < e.aliases.length; n += 1) {
const o = this._handlerStates[e.aliases[n]];
if (o)
for (const h of o)
h.executeReleased(e);
}
if (this._activeKeyMap.has(e.key)) {

@@ -455,8 +467,8 @@ this._activeKeyMap.delete(e.key);

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

@@ -494,3 +506,3 @@ return Object.assign(new P({

S as HandlerState,
y as KeyComboState,
_ as KeyComboState,
P as Keystrokes,

@@ -511,3 +523,3 @@ N as bindKey,

F as setGlobalKeystrokes,
H as setGlobalKeystrokesOptions,
j as setGlobalKeystrokesOptions,
X as stringifyKeyCombo,

@@ -514,0 +526,0 @@ D as unbindKey,

{
"name": "@rwh/keystrokes",
"version": "1.5.4",
"version": "1.5.5",
"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.",

@@ -49,3 +49,3 @@ "type": "module",

"typescript": "^5.1.6",
"vite": "^4.4.12",
"vite": "^4.5.2",
"vitest": "^0.34.1"

@@ -52,0 +52,0 @@ },

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