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

atom-keymap

Package Overview
Dependencies
Maintainers
5
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 2.1.0 to 2.1.1

225

api.json

@@ -6,9 +6,42 @@ {

"filename": "src/keymap-manager.coffee",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L67",
"sections": [],
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L67",
"sections": [
{
"name": "Class Methods",
"description": ""
},
{
"name": "Properties",
"description": ""
},
{
"name": "Construction and Destruction",
"description": ""
},
{
"name": "Event Subscription",
"description": ""
},
{
"name": "Adding and Removing Bindings",
"description": ""
},
{
"name": "Accessing Bindings",
"description": ""
},
{
"name": "Managing Keymap Files",
"description": ""
},
{
"name": "Managing Keyboard Events",
"description": ""
}
],
"classMethods": [
{
"name": "keydownEvent",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L82",
"sectionName": "Class Methods",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L86",
"visibility": "Public",

@@ -74,4 +107,4 @@ "summary": "Create a keydown DOM event for testing purposes.",

"name": "constructor",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L99",
"sectionName": "Construction and Destruction",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L111",
"visibility": "Public",

@@ -98,5 +131,13 @@ "summary": "Create a new KeymapManager.",

{
"name": "destroy",
"sectionName": "Construction and Destruction",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L120",
"visibility": "Public",
"summary": "Unwatch all watched paths. ",
"description": "Unwatch all watched paths. "
},
{
"name": "onDidMatchBinding",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L118",
"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L140",
"visibility": "Public",

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

"name": "onDidPartiallyMatchBindings",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L134",
"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L156",
"visibility": "Public",

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

"name": "onDidFailToMatchBinding",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L148",
"sectionName": "Event Subscription",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L170",
"visibility": "Public",

@@ -245,27 +286,5 @@ "summary": "Invoke the given callback when one or more keystrokes fail to match\nany bindings.",

{
"name": "destroy",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L189",
"visibility": "Public",
"summary": "Unwatch all watched paths. ",
"description": "Unwatch all watched paths. "
},
{
"name": "getKeyBindings",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L197",
"visibility": "Public",
"summary": "Get all current key bindings.",
"description": "Get all current key bindings.",
"returnValues": [
{
"type": "Array",
"description": "Returns an {Array} of {KeyBinding}s."
}
]
},
{
"name": "add",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L206",
"sectionName": "Adding and Removing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L220",
"visibility": "Public",

@@ -290,43 +309,5 @@ "summary": "Add sets of key bindings grouped by CSS selector.",

{
"name": "loadKeymap",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L230",
"visibility": "Public",
"summary": "Load the key bindings from the given path.",
"description": "Load the key bindings from the given path.",
"arguments": [
{
"name": "path",
"description": "A {String} containing a path to a file or a directory. If the path is a directory, all files inside it will be loaded.",
"type": "String",
"isOptional": false
},
{
"children": [
{
"name": "watch",
"description": "If `true`, the keymap will also reload the file at the given path whenever it changes. This option cannot be used with directory paths. ",
"type": null,
"isOptional": false
}
],
"name": "options",
"description": "An {Object} containing the following optional keys:",
"type": "Object",
"isOptional": false
}
]
},
{
"name": "watchKeymap",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L247",
"visibility": "Public",
"summary": "Cause the keymap to reload the key bindings file at the given path\nwhenever it changes.",
"description": "Cause the keymap to reload the key bindings file at the given path\nwhenever it changes.\n\nThis method doesn't perform the initial load of the key bindings file. If\nthat's what you're looking for, call {::loadKeymap} with `watch: true`. "
},
{
"name": "remove",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L263",
"sectionName": "Adding and Removing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L241",
"visibility": "Public",

@@ -345,13 +326,19 @@ "summary": "Remove the key bindings added with {::add} or {::loadKeymap}.",

{
"name": "handleKeyboardEvent",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L286",
"name": "getKeyBindings",
"sectionName": "Accessing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L252",
"visibility": "Public",
"summary": "Dispatch a custom event associated with the matching key binding for\nthe given `KeyboardEvent` if one can be found.",
"description": "Dispatch a custom event associated with the matching key binding for\nthe given `KeyboardEvent` if one can be found.\n\nIf a matching binding is found on the event's target or one of its\nancestors, `.preventDefault()` is called on the keyboard event and the\nbinding's command is emitted as a custom event on the matching element.\n\nIf the matching binding's command is 'native!', the method will terminate\nwithout calling `.preventDefault()` on the keyboard event, allowing the\nbrowser to handle it as normal.\n\nIf the matching binding's command is 'unset!', the search will continue from\nthe current element's parent.\n\nIf the matching binding's command is 'abort!', the search will terminate\nwithout dispatching a command event.\n\nIf the event's target is `document.body`, it will be treated as if its\ntarget is `.defaultTarget` if that property is assigned on the keymap. "
"summary": "Get all current key bindings.",
"description": "Get all current key bindings.",
"returnValues": [
{
"type": "Array",
"description": "Returns an {Array} of {KeyBinding}s."
}
]
},
{
"name": "findKeyBindings",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L371",
"sectionName": "Accessing Bindings",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L267",
"visibility": "Public",

@@ -396,5 +383,67 @@ "summary": "Get the key bindings for a given command and optional target.",

{
"name": "loadKeymap",
"sectionName": "Managing Keymap Files",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L302",
"visibility": "Public",
"summary": "Load the key bindings from the given path.",
"description": "Load the key bindings from the given path.",
"arguments": [
{
"name": "path",
"description": "A {String} containing a path to a file or a directory. If the path is a directory, all files inside it will be loaded.",
"type": "String",
"isOptional": false
},
{
"children": [
{
"name": "watch",
"description": "If `true`, the keymap will also reload the file at the given path whenever it changes. This option cannot be used with directory paths. ",
"type": null,
"isOptional": false
}
],
"name": "options",
"description": "An {Object} containing the following optional keys:",
"type": "Object",
"isOptional": false
}
]
},
{
"name": "watchKeymap",
"sectionName": "Managing Keymap Files",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L322",
"visibility": "Public",
"summary": "Cause the keymap to reload the key bindings file at the given path\nwhenever it changes.",
"description": "Cause the keymap to reload the key bindings file at the given path\nwhenever it changes.\n\nThis method doesn't perform the initial load of the key bindings file. If\nthat's what you're looking for, call {::loadKeymap} with `watch: true`.",
"arguments": [
{
"name": "path",
"description": "A {String} containing a path to a file or a directory. If the path is a directory, all files inside it will be loaded. ",
"type": "String",
"isOptional": false
}
]
},
{
"name": "handleKeyboardEvent",
"sectionName": "Managing Keyboard Events",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L393",
"visibility": "Public",
"summary": "Dispatch a custom event associated with the matching key binding for\nthe given `KeyboardEvent` if one can be found.",
"description": "Dispatch a custom event associated with the matching key binding for\nthe given `KeyboardEvent` if one can be found.\n\nIf a matching binding is found on the event's target or one of its\nancestors, `.preventDefault()` is called on the keyboard event and the\nbinding's command is emitted as a custom event on the matching element.\n\nIf the matching binding's command is 'native!', the method will terminate\nwithout calling `.preventDefault()` on the keyboard event, allowing the\nbrowser to handle it as normal.\n\nIf the matching binding's command is 'unset!', the search will continue from\nthe current element's parent.\n\nIf the matching binding's command is 'abort!', the search will terminate\nwithout dispatching a command event.\n\nIf the event's target is `document.body`, it will be treated as if its\ntarget is `.defaultTarget` if that property is assigned on the keymap.",
"arguments": [
{
"name": "event",
"description": "A `KeyboardEvent` of type 'keydown' ",
"type": null,
"isOptional": false
}
]
},
{
"name": "keystrokeForKeyboardEvent",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L544",
"sectionName": "Managing Keyboard Events",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L471",
"visibility": "Public",

@@ -423,4 +472,4 @@ "summary": "Translate a keydown event to a keystroke string.",

"name": "partialMatchTimeout",
"sectionName": null,
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.0/src/keymap-manager.coffee#L86",
"sectionName": "Properties",
"srcUrl": "https://github.com/atom/atom-keymap/blob/v2.1.1/src/keymap-manager.coffee#L94",
"visibility": "Public",

@@ -431,3 +480,3 @@ "summary": "The number of milliseconds allowed before pending states caused\nby partial matches of multi-keystroke bindings are terminated. ",

],
"visibility": "Public",
"visibility": "Extended",
"summary": "Allows commands to be associated with keystrokes in a\ncontext-sensitive way. In Atom, you can access a global instance of this\nobject via `atom.keymap`.",

@@ -434,0 +483,0 @@ "description": "Allows commands to be associated with keystrokes in a\ncontext-sensitive way. In Atom, you can access a global instance of this\nobject via `atom.keymap`.\n\nKey bindings are plain JavaScript objects containing **CSS selectors** as\ntheir top level keys, then **keystroke patterns** mapped to commands.\n\n```cson\n'.workspace':\n 'ctrl-l': 'package:do-something'\n 'ctrl-z': 'package:do-something-else'\n'.mini.editor':\n 'enter': 'core:confirm'\n```\n\nWhen a keystroke sequence matches a binding in a given context, a custom DOM\nevent with a type based on the command is dispatched on the target of the\nkeyboard event.\n\nTo match a keystroke sequence, the keymap starts at the target element for the\nkeyboard event. It looks for key bindings associated with selectors that match\nthe target element. If multiple match, the most specific is selected. If there\nis a tie in specificity, the most recently added binding wins. If no bindings\nare found for the events target, the search is repeated again for the target's\nparent node and so on recursively until a binding is found or we traverse off\nthe top of the document.\n\nWhen a binding is found, its command event is always dispatched on the\noriginal target of the keyboard event, even if the matching element is higher\nup in the DOM. In addition, `.preventDefault()` is called on the keyboard\nevent to prevent the browser from taking action. `.preventDefault` is only\ncalled if a matching binding is found.\n\nCommand event objects have a non-standard method called `.abortKeyBinding()`.\nIf your command handler is invoked but you programmatically determine that no\naction can be taken and you want to allow other bindings to be matched, call\n`.abortKeyBinding()` on the event object. An example of where this is useful\nis binding snippet expansion to `tab`. If `snippets:expand` is invoked when\nthe cursor does not follow a valid snippet prefix, we abort the binding and\nallow `tab` to be handled by the default handler, which inserts whitespace.\n\nMulti-keystroke bindings are possible. If a sequence of one or more keystrokes\n*partially* matches a multi-keystroke binding, the keymap enters a pending\nstate. The pending state is terminated on the next keystroke, or after\n{::partialMatchTimeout} milliseconds has elapsed. When the pending state is\nterminated via a timeout or a keystroke that leads to no matches, the longest\nambiguous bindings that caused the pending state are temporarily disabled and\nthe previous keystrokes are replayed. If there is ambiguity again during the\nreplay, the next longest bindings are disabled and the keystrokes are replayed\nagain. "

@@ -36,2 +36,7 @@ (function() {

/*
Section: Class Methods
*/
KeymapManager.keydownEvent = function(key, options) {

@@ -41,2 +46,7 @@ return keydownEvent(key, options);

/*
Section: Properties
*/
KeymapManager.prototype.partialMatchTimeout = 1000;

@@ -50,2 +60,7 @@

/*
Section: Construction and Destruction
*/
function KeymapManager(options) {

@@ -67,2 +82,17 @@ var key, value;

KeymapManager.prototype.destroy = function() {
var filePath, subscription, _ref2;
_ref2 = this.watchSubscriptions;
for (filePath in _ref2) {
subscription = _ref2[filePath];
subscription.dispose();
}
return void 0;
};
/*
Section: Event Subscription
*/
KeymapManager.prototype.onDidMatchBinding = function(callback) {

@@ -111,15 +141,6 @@ return this.emitter.on('did-match-binding', callback);

KeymapManager.prototype.destroy = function() {
var filePath, subscription, _ref2;
_ref2 = this.watchSubscriptions;
for (filePath in _ref2) {
subscription = _ref2[filePath];
subscription.dispose();
}
return void 0;
};
KeymapManager.prototype.getKeyBindings = function() {
return this.keyBindings.slice();
};
/*
Section: Adding and Removing Bindings
*/

@@ -150,2 +171,57 @@ KeymapManager.prototype.add = function(source, keyBindingsBySelector) {

KeymapManager.prototype.remove = function(source) {
this.keyBindings = this.keyBindings.filter(function(keyBinding) {
return keyBinding.source !== source;
});
return void 0;
};
/*
Section: Accessing Bindings
*/
KeymapManager.prototype.getKeyBindings = function() {
return this.keyBindings.slice();
};
KeymapManager.prototype.findKeyBindings = function(params) {
var bindings, candidateBindings, command, element, keyBindings, keystrokes, matchingBindings, target;
if (params == null) {
params = {};
}
keystrokes = params.keystrokes, command = params.command, target = params.target, keyBindings = params.keyBindings;
bindings = keyBindings != null ? keyBindings : this.keyBindings;
if (command != null) {
bindings = bindings.filter(function(binding) {
return binding.command === command;
});
}
if (keystrokes != null) {
bindings = bindings.filter(function(binding) {
return binding.keystrokes === keystrokes;
});
}
if (target != null) {
candidateBindings = bindings;
bindings = [];
element = target;
while ((element != null) && element !== document) {
matchingBindings = candidateBindings.filter(function(binding) {
return element.webkitMatchesSelector(binding.selector);
}).sort(function(a, b) {
return a.compare(b);
});
bindings.push.apply(bindings, matchingBindings);
element = element.parentElement;
}
}
return bindings;
};
/*
Section: Managing Keymap Files
*/
KeymapManager.prototype.loadKeymap = function(bindingsPath, options) {

@@ -187,9 +263,55 @@ var checkIfDirectory, filePath, _i, _len, _ref2, _ref3;

KeymapManager.prototype.remove = function(source) {
this.keyBindings = this.keyBindings.filter(function(keyBinding) {
return keyBinding.source !== source;
});
return void 0;
KeymapManager.prototype.reloadKeymap = function(filePath) {
var bindings;
if (fs.isFileSync(filePath)) {
if (bindings = this.readKeymap(filePath, true)) {
this.remove(filePath);
this.addKeymap(filePath, bindings);
this.emit('reloaded-key-bindings', filePath);
return this.emitter.emit('did-reload-keymap', {
path: filePath
});
}
} else {
this.remove(filePath);
this.emit('unloaded-key-bindings', filePath);
return this.emitter.emit('did-unload-keymap', {
path: filePath
});
}
};
KeymapManager.prototype.readKeymap = function(filePath, suppressErrors) {
var error, _ref2;
if (suppressErrors) {
try {
return CSON.readFileSync(filePath);
} catch (_error) {
error = _error;
console.warn("Failed to reload key bindings file: " + filePath, (_ref2 = error.stack) != null ? _ref2 : error);
return void 0;
}
} else {
return CSON.readFileSync(filePath);
}
};
KeymapManager.prototype.filePathMatchesPlatform = function(filePath) {
var component, otherPlatforms, _i, _len, _ref2;
otherPlatforms = this.getOtherPlatforms();
_ref2 = path.basename(filePath).split('.').slice(0, -1);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
component = _ref2[_i];
if (__indexOf.call(otherPlatforms, component) >= 0) {
return false;
}
}
return true;
};
/*
Section: Managing Keyboard Events
*/
KeymapManager.prototype.handleKeyboardEvent = function(event, replaying) {

@@ -271,84 +393,11 @@ var currentTarget, enableTimeout, exactMatch, exactMatchCandidates, exactMatches, foundMatch, keystroke, keystrokes, partialMatchCandidates, partialMatches, target, _i, _len, _ref2;

KeymapManager.prototype.findKeyBindings = function(params) {
var bindings, candidateBindings, command, element, keyBindings, keystrokes, matchingBindings, target;
if (params == null) {
params = {};
}
keystrokes = params.keystrokes, command = params.command, target = params.target, keyBindings = params.keyBindings;
bindings = keyBindings != null ? keyBindings : this.keyBindings;
if (command != null) {
bindings = bindings.filter(function(binding) {
return binding.command === command;
});
}
if (keystrokes != null) {
bindings = bindings.filter(function(binding) {
return binding.keystrokes === keystrokes;
});
}
if (target != null) {
candidateBindings = bindings;
bindings = [];
element = target;
while ((element != null) && element !== document) {
matchingBindings = candidateBindings.filter(function(binding) {
return element.webkitMatchesSelector(binding.selector);
}).sort(function(a, b) {
return a.compare(b);
});
bindings.push.apply(bindings, matchingBindings);
element = element.parentElement;
}
}
return bindings;
KeymapManager.prototype.keystrokeForKeyboardEvent = function(event) {
return keystrokeForKeyboardEvent(event);
};
KeymapManager.prototype.reloadKeymap = function(filePath) {
var bindings;
if (fs.isFileSync(filePath)) {
if (bindings = this.readKeymap(filePath, true)) {
this.remove(filePath);
this.addKeymap(filePath, bindings);
this.emit('reloaded-key-bindings', filePath);
return this.emitter.emit('did-reload-keymap', {
path: filePath
});
}
} else {
this.remove(filePath);
this.emit('unloaded-key-bindings', filePath);
return this.emitter.emit('did-unload-keymap', {
path: filePath
});
}
};
KeymapManager.prototype.readKeymap = function(filePath, suppressErrors) {
var error, _ref2;
if (suppressErrors) {
try {
return CSON.readFileSync(filePath);
} catch (_error) {
error = _error;
console.warn("Failed to reload key bindings file: " + filePath, (_ref2 = error.stack) != null ? _ref2 : error);
return void 0;
}
} else {
return CSON.readFileSync(filePath);
}
};
/*
Section: Private
*/
KeymapManager.prototype.filePathMatchesPlatform = function(filePath) {
var component, otherPlatforms, _i, _len, _ref2;
otherPlatforms = this.getOtherPlatforms();
_ref2 = path.basename(filePath).split('.').slice(0, -1);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
component = _ref2[_i];
if (__indexOf.call(otherPlatforms, component) >= 0) {
return false;
}
}
return true;
};
KeymapManager.prototype.getOtherPlatforms = function() {

@@ -502,6 +551,2 @@ return OtherPlatforms;

KeymapManager.prototype.keystrokeForKeyboardEvent = function(event) {
return keystrokeForKeyboardEvent(event);
};
KeymapManager.prototype.addKeymap = function(source, bindings) {

@@ -508,0 +553,0 @@ return this.add(source, bindings);

{
"name": "atom-keymap",
"version": "2.1.0",
"version": "2.1.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