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

atom-keymap

Package Overview
Dependencies
Maintainers
8
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-keymap - npm Package Compare versions

Comparing version 6.3.0 to 6.3.1

34

api.json

@@ -6,3 +6,3 @@ {

"filename": "src/keymap-manager.coffee",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L66",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L66",
"sections": [

@@ -42,3 +42,3 @@ {

"sectionName": "Class Methods",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L83",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L83",
"visibility": "Public",

@@ -105,3 +105,3 @@ "summary": "Create a keydown DOM event for testing purposes.",

"sectionName": "Construction and Destruction",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L109",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L109",
"visibility": "Public",

@@ -130,3 +130,3 @@ "summary": "Create a new KeymapManager.",

"sectionName": "Construction and Destruction",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L117",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L117",
"visibility": "Public",

@@ -139,3 +139,3 @@ "summary": "Clear all registered key bindings and enqueued keystrokes. For use\nin tests. ",

"sectionName": "Construction and Destruction",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L124",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L125",
"visibility": "Public",

@@ -148,3 +148,3 @@ "summary": "Unwatch all watched paths. ",

"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L150",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L151",
"visibility": "Public",

@@ -199,3 +199,3 @@ "summary": "Invoke the given callback when one or more keystrokes completely\nmatch a key binding.",

"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L166",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L167",
"visibility": "Public",

@@ -250,3 +250,3 @@ "summary": "Invoke the given callback when one or more keystrokes partially\nmatch a binding.",

"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L180",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L181",
"visibility": "Public",

@@ -295,3 +295,3 @@ "summary": "Invoke the given callback when one or more keystrokes fail to match\nany bindings.",

"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L211",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L212",
"visibility": "Public",

@@ -340,3 +340,3 @@ "summary": "Invoke the given callback when a keymap file not able to be loaded.",

"sectionName": "Adding and Removing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L226",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L227",
"visibility": "Public",

@@ -369,3 +369,3 @@ "summary": "Add sets of key bindings grouped by CSS selector.",

"sectionName": "Accessing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L265",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L266",
"visibility": "Public",

@@ -384,3 +384,3 @@ "summary": "Get all current key bindings.",

"sectionName": "Accessing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L280",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L281",
"visibility": "Public",

@@ -427,3 +427,3 @@ "summary": "Get the key bindings for a given command and optional target.",

"sectionName": "Managing Keymap Files",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L317",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L318",
"visibility": "Public",

@@ -464,3 +464,3 @@ "summary": "Load the key bindings from the given path.",

"sectionName": "Managing Keymap Files",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L340",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L341",
"visibility": "Public",

@@ -495,3 +495,3 @@ "summary": "Cause the keymap to reload the key bindings file at the given path\nwhenever it changes.",

"sectionName": "Managing Keyboard Events",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L412",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L413",
"visibility": "Public",

@@ -512,3 +512,3 @@ "summary": "Dispatch a custom event associated with the matching key binding for\nthe given `KeyboardEvent` if one can be found.",

"sectionName": "Managing Keyboard Events",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L513",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L616",
"visibility": "Public",

@@ -535,3 +535,3 @@ "summary": "Translate a keydown event to a keystroke string.",

"sectionName": "Managing Keyboard Events",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.0/src/keymap-manager.coffee#L520",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v6.3.1/src/keymap-manager.coffee#L623",
"visibility": "Public",

@@ -538,0 +538,0 @@ "summary": "Get the number of milliseconds allowed before pending states caused\nby partial matches of multi-keystroke bindings are terminated.",

(function() {
var AtomModifierRegex, AtomModifiers, ExactMatch, KeyboardEventModifiers, LowerCaseLetterRegex, NumPadToASCII, PartialMatch, UpperCaseLetterRegex, WhitespaceRegex, WindowsAndLinuxCharCodeTranslations, WindowsAndLinuxKeyIdentifierTranslations, calculateSpecificity, charCodeFromKeyIdentifier, isASCII, keyForKeyboardEvent, keyFromCharCode, keyboardEvent, modifier, normalizeKeystroke, numpadToASCII, parseKeystroke, translateCharCodeForWindowsAndLinuxChromiumBug, translateKeyIdentifierForWindowsAndLinuxChromiumBug, _i, _j, _len, _len1, _ref, _ref1;
var AtomModifierRegex, AtomModifiers, ExactMatch, KeyboardEventModifiers, KeydownExactMatch, LowerCaseLetterRegex, NumPadToASCII, PartialMatch, UpperCaseLetterRegex, WhitespaceRegex, WindowsAndLinuxCharCodeTranslations, WindowsAndLinuxKeyIdentifierTranslations, calculateSpecificity, charCodeFromKeyIdentifier, isASCII, keyForKeyboardEvent, keyFromCharCode, keyboardEvent, modifier, normalizeKeystroke, numpadToASCII, parseKeystroke, translateCharCodeForWindowsAndLinuxChromiumBug, translateKeyIdentifierForWindowsAndLinuxChromiumBug, _i, _j, _len, _len1, _ref, _ref1;

@@ -24,2 +24,4 @@ calculateSpecificity = require('clear-cut').calculateSpecificity;

KeydownExactMatch = 'keydownExact';
PartialMatch = 'partial';

@@ -301,3 +303,3 @@

exports.keystrokesMatch = function(bindingKeystrokes, userKeystrokes) {
var bindingKeystroke, doesMatch, matchesNextUserKeystroke, userKeystrokeIndex, userKeystrokesHasKeydownEvent, _k, _len2;
var bindingKeystroke, bindingKeystrokeIndex, bindingRemainderContainsOnlyKeyups, doesMatch, isPartialMatch, matchesNextUserKeystroke, userKeystrokeIndex, userKeystrokesHasKeydownEvent, _k, _len2;
userKeystrokeIndex = -1;

@@ -322,22 +324,35 @@ userKeystrokesHasKeydownEvent = false;

};
isPartialMatch = false;
bindingRemainderContainsOnlyKeyups = true;
bindingKeystrokeIndex = 0;
for (_k = 0, _len2 = bindingKeystrokes.length; _k < _len2; _k++) {
bindingKeystroke = bindingKeystrokes[_k];
doesMatch = matchesNextUserKeystroke(bindingKeystroke);
if (doesMatch === false) {
return false;
} else if (doesMatch === null) {
if (userKeystrokesHasKeydownEvent) {
return PartialMatch;
} else {
if (!isPartialMatch) {
doesMatch = matchesNextUserKeystroke(bindingKeystroke);
if (doesMatch === false) {
return false;
} else if (doesMatch === null) {
if (userKeystrokesHasKeydownEvent) {
isPartialMatch = true;
} else {
return false;
}
}
}
}
while (userKeystrokeIndex < userKeystrokes.length - 1) {
userKeystrokeIndex += 1;
if (!userKeystrokes[userKeystrokeIndex].startsWith('^')) {
return false;
if (isPartialMatch) {
if (!bindingKeystroke.startsWith('^')) {
bindingRemainderContainsOnlyKeyups = false;
}
}
}
return ExactMatch;
if (userKeystrokeIndex < userKeystrokes.length - 1) {
return false;
}
if (isPartialMatch && bindingRemainderContainsOnlyKeyups) {
return KeydownExactMatch;
} else if (isPartialMatch) {
return PartialMatch;
} else {
return ExactMatch;
}
};

@@ -344,0 +359,0 @@

@@ -82,3 +82,4 @@ (function() {

this.queuedKeyboardEvents = [];
return this.queuedKeystrokes = [];
this.queuedKeystrokes = [];
return this.bindingsToDisable = [];
};

@@ -324,11 +325,12 @@

KeymapManager.prototype.handleKeyboardEvent = function(event) {
var currentTarget, enableTimeout, exactMatch, exactMatchCandidates, exactMatches, foundMatch, keystroke, keystrokes, partialMatchCandidates, partialMatches, target, _i, _len, _ref2;
KeymapManager.prototype.handleKeyboardEvent = function(event, _arg) {
var allPartialMatchesContainKeyupRemainder, currentTarget, disabledBindings, dispatchedExactMatch, enableTimeout, eventHandled, exactMatchCandidate, exactMatchCandidates, exactMatches, hasPartialMatches, keydownExactMatchCandidates, keystroke, keystrokes, partialMatch, partialMatchCandidates, partialMatches, replay, shouldUsePartialMatches, target, _i, _j, _len, _len1, _ref2, _ref3;
_ref2 = _arg != null ? _arg : {}, replay = _ref2.replay, disabledBindings = _ref2.disabledBindings;
keystroke = this.keystrokeForKeyboardEvent(event);
if (event.type !== 'keyup' && this.queuedKeystrokes.length > 0 && isAtomModifier(keystroke)) {
if (event.type === 'keydown' && this.queuedKeystrokes.length > 0 && isAtomModifier(keystroke)) {
event.preventDefault();
return;
}
this.queuedKeystrokes.push(keystroke);
this.queuedKeyboardEvents.push(event);
this.queuedKeystrokes.push(keystroke);
keystrokes = this.queuedKeystrokes.join(' ');

@@ -339,37 +341,46 @@ target = event.target;

}
_ref2 = this.findMatchCandidates(this.queuedKeystrokes), partialMatchCandidates = _ref2.partialMatchCandidates, exactMatchCandidates = _ref2.exactMatchCandidates;
_ref3 = this.findMatchCandidates(this.queuedKeystrokes, disabledBindings), partialMatchCandidates = _ref3.partialMatchCandidates, keydownExactMatchCandidates = _ref3.keydownExactMatchCandidates, exactMatchCandidates = _ref3.exactMatchCandidates;
dispatchedExactMatch = null;
partialMatches = this.findPartialMatches(partialMatchCandidates, target);
hasPartialMatches = partialMatches.length > 0;
shouldUsePartialMatches = hasPartialMatches;
if (exactMatchCandidates.length > 0) {
currentTarget = target;
while ((currentTarget != null) && currentTarget !== document) {
eventHandled = false;
while (!eventHandled && (currentTarget != null) && currentTarget !== document) {
exactMatches = this.findExactMatches(exactMatchCandidates, currentTarget);
for (_i = 0, _len = exactMatches.length; _i < _len; _i++) {
exactMatch = exactMatches[_i];
if (exactMatch.command === 'native!') {
this.clearQueuedKeystrokes();
return;
exactMatchCandidate = exactMatches[_i];
if (exactMatchCandidate.command === 'native!') {
shouldUsePartialMatches = false;
eventHandled = true;
break;
}
if (exactMatch.command === 'abort!') {
this.clearQueuedKeystrokes();
if (exactMatchCandidate.command === 'abort!') {
event.preventDefault();
return;
eventHandled = true;
break;
}
if (exactMatch.command === 'unset!') {
if (exactMatchCandidate.command === 'unset!') {
break;
}
foundMatch = true;
if (partialMatches.length > 0) {
if (hasPartialMatches) {
allPartialMatchesContainKeyupRemainder = true;
for (_j = 0, _len1 = partialMatches.length; _j < _len1; _j++) {
partialMatch = partialMatches[_j];
if (keydownExactMatchCandidates.indexOf(partialMatch) < 0) {
allPartialMatchesContainKeyupRemainder = false;
}
}
if (allPartialMatchesContainKeyupRemainder === false) {
break;
}
} else {
shouldUsePartialMatches = false;
}
if (this.dispatchCommandEvent(exactMatchCandidate.command, target, event)) {
dispatchedExactMatch = exactMatchCandidate;
eventHandled = true;
break;
}
this.clearQueuedKeystrokes();
this.cancelPendingState();
if (this.dispatchCommandEvent(exactMatch.command, target, event)) {
this.emitter.emit('did-match-binding', {
keystrokes: keystrokes,
eventType: event.type,
binding: exactMatch,
keyboardEventTarget: target
});
return;
}
}

@@ -379,7 +390,12 @@ currentTarget = currentTarget.parentElement;

}
if (partialMatches.length > 0) {
if (dispatchedExactMatch != null) {
this.emitter.emit('did-match-binding', {
keystrokes: keystrokes,
eventType: event.type,
binding: dispatchedExactMatch,
keyboardEventTarget: target
});
} else if (hasPartialMatches && shouldUsePartialMatches) {
event.preventDefault();
enableTimeout = (this.pendingStateTimeoutHandle != null) || foundMatch || (characterForKeyboardEvent(this.queuedKeyboardEvents[0]) != null);
this.enterPendingState(partialMatches, enableTimeout);
return this.emitter.emit('did-partially-match-binding', {
this.emitter.emit('did-partially-match-binding', {
keystrokes: keystrokes,

@@ -390,3 +406,3 @@ eventType: event.type,

});
} else {
} else if ((dispatchedExactMatch == null) && !hasPartialMatches) {
this.emitter.emit('did-fail-to-match-binding', {

@@ -397,11 +413,20 @@ keystrokes: keystrokes,

});
if (this.pendingPartialMatches != null) {
return this.terminatePendingState();
} else {
if (event.defaultPrevented) {
this.simulateTextInput(event);
}
return this.clearQueuedKeystrokes();
if (event.defaultPrevented && event.type === 'keydown') {
this.simulateTextInput(event);
}
}
if (dispatchedExactMatch) {
this.bindingsToDisable.push(dispatchedExactMatch);
}
if (hasPartialMatches && shouldUsePartialMatches) {
enableTimeout = (this.pendingStateTimeoutHandle != null) || (dispatchedExactMatch != null) || (characterForKeyboardEvent(this.queuedKeyboardEvents[0]) != null);
if (replay) {
enableTimeout = false;
}
return this.enterPendingState(partialMatches, enableTimeout);
} else if ((dispatchedExactMatch == null) && !hasPartialMatches && (this.pendingPartialMatches != null)) {
return this.terminatePendingState();
} else {
return this.clearQueuedKeystrokes();
}
};

@@ -435,10 +460,12 @@

KeymapManager.prototype.findMatchCandidates = function(keystrokeArray) {
var binding, doesMatch, exactMatchCandidates, partialMatchCandidates, _i, _len, _ref2;
KeymapManager.prototype.findMatchCandidates = function(keystrokeArray, disabledBindings) {
var binding, disabledBindingSet, doesMatch, exactMatchCandidates, keydownExactMatchCandidates, partialMatchCandidates, _i, _len, _ref2;
partialMatchCandidates = [];
exactMatchCandidates = [];
keydownExactMatchCandidates = [];
disabledBindingSet = new Set(disabledBindings);
_ref2 = this.keyBindings;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
binding = _ref2[_i];
if (!binding.enabled) {
if (!(!disabledBindingSet.has(binding))) {
continue;

@@ -451,2 +478,5 @@ }

partialMatchCandidates.push(binding);
} else if (doesMatch === 'keydownExact') {
partialMatchCandidates.push(binding);
keydownExactMatchCandidates.push(binding);
}

@@ -456,2 +486,3 @@ }

partialMatchCandidates: partialMatchCandidates,
keydownExactMatchCandidates: keydownExactMatchCandidates,
exactMatchCandidates: exactMatchCandidates

@@ -496,3 +527,4 @@ };

this.queuedKeyboardEvents = [];
return this.queuedKeystrokes = [];
this.queuedKeystrokes = [];
return this.bindingsToDisable = [];
};

@@ -516,27 +548,21 @@

KeymapManager.prototype.terminatePendingState = function(timeout) {
var binding, bindingsToDisable, event, eventsToReplay, _i, _j, _k, _len, _len1, _len2;
bindingsToDisable = this.pendingPartialMatches;
KeymapManager.prototype.terminatePendingState = function(fromTimeout) {
var bindingsToDisable, event, eventsToReplay, keyEventOptions, _i, _len;
bindingsToDisable = this.pendingPartialMatches.concat(this.bindingsToDisable);
eventsToReplay = this.queuedKeyboardEvents;
this.cancelPendingState();
this.clearQueuedKeystrokes();
for (_i = 0, _len = bindingsToDisable.length; _i < _len; _i++) {
binding = bindingsToDisable[_i];
binding.enabled = false;
}
for (_j = 0, _len1 = eventsToReplay.length; _j < _len1; _j++) {
event = eventsToReplay[_j];
this.handleKeyboardEvent(event);
keyEventOptions = {
replay: true,
disabledBindings: bindingsToDisable
};
for (_i = 0, _len = eventsToReplay.length; _i < _len; _i++) {
event = eventsToReplay[_i];
keyEventOptions.disabledBindings = bindingsToDisable;
this.handleKeyboardEvent(event, keyEventOptions);
if ((bindingsToDisable != null) && (this.pendingPartialMatches == null)) {
for (_k = 0, _len2 = bindingsToDisable.length; _k < _len2; _k++) {
binding = bindingsToDisable[_k];
binding.enabled = true;
}
bindingsToDisable = null;
}
}
if (typeof atom !== "undefined" && atom !== null) {
atom.assert(bindingsToDisable == null, "Invalid keymap state");
}
if (timeout && (this.pendingPartialMatches != null)) {
if (fromTimeout && (this.pendingPartialMatches != null)) {
this.terminatePendingState(true);

@@ -543,0 +569,0 @@ }

{
"name": "atom-keymap",
"version": "6.3.0",
"version": "6.3.1",
"description": "Atom's DOM-aware keymap module",

@@ -5,0 +5,0 @@ "main": "./lib/keymap-manager",

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