Socket
Socket
Sign inDemoInstall

@stoplight/command

Package Overview
Dependencies
Maintainers
5
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/command - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

6

lib/command.d.ts

@@ -53,3 +53,3 @@ import { Event, IDisposable } from '@stoplight/common/lib/types';

*/
isEnabled(commandId: string, ...args: any[]): boolean;
isActive(commandId: string, ...args: any[]): boolean;
/**

@@ -70,6 +70,2 @@ * Test whether there is a visible handler for the given command.

/**
* Get a handler of specific type or `undefined`.
*/
getHandler(type: string, commandId: string, ...args: any[]): ICommandHandler | void;
/**
* Get a visible handler for the given command or `undefined`.

@@ -76,0 +72,0 @@ */

49

lib/command.js

@@ -198,3 +198,3 @@ "use strict";

if (commandId) {
if (_this.isEnabled(commandId)) {
if (_this.isActive(commandId)) {
_this.executeCommand(commandId);

@@ -218,3 +218,3 @@ }

*/
CommandRegistry.prototype.isEnabled = function (commandId) {
CommandRegistry.prototype.isActive = function (commandId) {
var args = [];

@@ -263,8 +263,8 @@ for (var _i = 1; _i < arguments.length; _i++) {

/**
* Get a handler of specific type or `undefined`.
* Get a visible handler for the given command or `undefined`.
*/
CommandRegistry.prototype.getHandler = function (type, commandId) {
CommandRegistry.prototype.getVisibleHandler = function (commandId) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}

@@ -275,3 +275,3 @@ var handlers = this._handlers[commandId];

var handler = handlers_1[_a];
if (!handler[type] || handler[type].apply(handler, args)) {
if (!handler.isVisible || handler.isVisible.apply(handler, args)) {
return handler;

@@ -281,14 +281,5 @@ }

}
// return this.getHandlerWithState('isVisible', true, commandId, ...args);
};
/**
* Get a visible handler for the given command or `undefined`.
*/
CommandRegistry.prototype.getVisibleHandler = function (commandId) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return this.getHandler.apply(this, ['isVisible', commandId].concat(args));
};
/**
* Get a handler that is currently executing for the given command or `undefined`.

@@ -301,3 +292,12 @@ */

}
return this.getHandler.apply(this, ['isExecuting', commandId].concat(args));
var handlers = this._handlers[commandId];
if (handlers) {
for (var _a = 0, handlers_2 = handlers; _a < handlers_2.length; _a++) {
var handler = handlers_2[_a];
if (handler.isExecuting && handler.isExecuting.apply(handler, args)) {
return handler;
}
}
}
// return this.getHandlerWithState('isExecuting', false, commandId, ...args);
};

@@ -312,3 +312,12 @@ /**

}
return this.getHandler.apply(this, ['isEnabled', commandId].concat(args));
var handlers = this._handlers[commandId];
if (handlers) {
for (var _a = 0, handlers_3 = handlers; _a < handlers_3.length; _a++) {
var handler = handlers_3[_a];
if (!handler.isActive || handler.isActive.apply(handler, args)) {
return handler;
}
}
}
// return this.getHandlerWithState('isActive', true, commandId, ...args);
};

@@ -327,3 +336,3 @@ /**

command.update({
enabled: this.isEnabled.apply(this, [commandId].concat(args)),
enabled: this.isActive.apply(this, [commandId].concat(args)),
executing: this.isExecuting.apply(this, [commandId].concat(args)),

@@ -330,0 +339,0 @@ visible: this.isVisible.apply(this, [commandId].concat(args)),

@@ -39,3 +39,3 @@ import { Event, IDisposable } from '@stoplight/common/lib/types';

isExecuting?(...args: any[]): boolean;
isEnabled?(...args: any[]): boolean;
isActive?(...args: any[]): boolean;
isVisible?(...args: any[]): boolean;

@@ -62,3 +62,3 @@ }

registerShortcut(shortcut: string, options: IShortcutOptions): IDisposable;
isEnabled(commandId: string, ...args: any[]): boolean;
isActive(commandId: string, ...args: any[]): boolean;
isVisible(commandId: string, ...args: any[]): boolean;

@@ -65,0 +65,0 @@ getCommand(commandId: string): ICommand | undefined;

{
"name": "@stoplight/command",
"version": "0.0.19",
"version": "0.0.20",
"description": "Stoplight command registry implementation.",

@@ -22,8 +22,8 @@ "main": "lib/index.js",

"dependencies": {
"@stoplight/common": "^0.0.19",
"@stoplight/ioc": "^0.0.19",
"@stoplight/common": "^0.0.20",
"@stoplight/ioc": "^0.0.20",
"keyboardjs": "2.4.x",
"tslib": "1.x.x"
},
"gitHead": "5651dde9d1be1c234b9282bbc5bc155c47f39e66"
"gitHead": "707a4f511ebf9fc6c31c630f3ee155598f2fd5a1"
}

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