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

phosphor-command

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phosphor-command - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

430

lib/index.d.ts

@@ -1,69 +0,126 @@

import { ISignal, Signal } from 'phosphor-signaling';
import { ISignal } from 'phosphor-signaling';
/**
* An object which implements the command pattern.
* An abstract base class for implementing concrete commands.
*/
export interface ICommand {
export declare abstract class Command {
/**
* Execute the command with the specified arguments.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* #### Notes
* Calling `execute` when `isEnabled` returns `false` may result in
* undefined behavior.
*
* This abstract method must be implemented by a subclass.
*/
abstract execute(args: any): void;
/**
* A signal emitted when the command's state changes.
*
* #### Notes
* Consumers of the command can subscribe to this signal in order to
* update their visual representation of the command when it changes.
* A subclass should emit this signal when the command state changes.
*/
changed: ISignal<ICommand, void>;
changed: ISignal<Command, void>;
/**
* Test whether the command is enabled.
* Get the display text for the command.
*
* @returns `true` if the command is enabled, `false` otherwise.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The display text for the command.
*
* #### Notes
* The [[changed]] signal should be emitted if the return value
* changes at runtime.
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* use this as the text for the primary DOM node for the command.
*
* The default implementation of this method returns an empty string.
*/
isEnabled(): boolean;
text(args: any): string;
/**
* Test whether the command is checked.
* Get the class name(s) for the command icon.
*
* @returns `true` if the command is checked, `false` otherwise.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the command icon node.
*
* #### Notes
* The [[changed]] signal should be emitted if the return value
* changes at runtime.
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* add the class name(s) to the DOM node for the command icon.
*
* Multiple class names can be separated with whitespace.
*
* The default implementation of this method returns an empty string.
*/
isChecked(): boolean;
icon(args: any): string;
/**
* Execute the command with the specified arguments.
* Get the short caption for the command.
*
* @param args - The arguments for the command. The args should be
* simple JSON types. If the command does not require arguments,
* this may be `null`.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The short caption for the command.
*
* #### Notes
* Calling `execute` when `isEnabled` returns `false` will result
* in undefined behavior.
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This value is used by UI elements where displaying a short command
* description is relevant, such as tooltips and command palettes.
*
* The default implementation of this method returns an empty string.
*/
execute(args: any): void;
}
/**
* An abstract base class for implementing concrete commands.
*/
export declare abstract class Command implements ICommand {
caption(args: any): string;
/**
* A signal emitted when the command's state changes.
* Get the category for the command.
*
* **See also:** [[changed]]
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The category for the command.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This value is used by UI elements which group commands together
* based on category, such as toolbars and command palettes.
*
* The default implementation of this method returns an empty string.
*/
static changedSignal: Signal<Command, void>;
category(args: any): string;
/**
* A signal emitted when the command's state changes.
* Get the class name(s) for the primary command node.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the primary command node.
*
* #### Notes
* This should be emitted by a subclass as necessary.
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This is a pure delegate to the [[changedSignal]].
* UI elements which have a visual representation of a command will
* add the class name(s) to the primary DOM node for the command.
*
* Multiple class names can be separated with whitespace.
*
* The default implementation of this method returns an empty string.
*/
changed: ISignal<Command, void>;
className(args: any): string;
/**
* Test whether the command is enabled.
* Test whether the command is enabled for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is enabled, `false` otherwise.

@@ -75,10 +132,16 @@ *

*
* UI elements which have a visual representation of a command will
* typically display a non-enabled command as greyed-out.
*
* The default implementation of this method returns `true`.
*/
isEnabled(): boolean;
isEnabled(args: any): boolean;
/**
* Test whether the command is checked.
* Test whether the command is visible for its current state.
*
* @returns `true` if the command is checked, `false` otherwise.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is visible, `false` otherwise.
*
* #### Notes

@@ -88,86 +151,301 @@ * A subclass may reimplement this method as needed. If the state

*
* The default implementation of this method returns `false`.
* UI elements which have a visual representation of a command will
* typically not display a non-visible command.
*
* The default implementation of this method returns `true`.
*/
isChecked(): boolean;
isVisible(args: any): boolean;
/**
* Execute the command with the specified arguments.
* Test whether the command is checked for its current state.
*
* @param args - The arguments for the command. The args should be
* simple JSON types. If the command does not require arguments,
* this may be `null`.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is checked, `false` otherwise.
*
* #### Notes
* Calling `execute` when `isEnabled` returns `false` will result
* in undefined behavior.
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This abstract method must be implemented by a subclass.
* UI elements which have a visual representation of a command will
* typically add extra class names to the node of a checked command.
*
* The default implementation of this method returns `false`.
*/
abstract execute(args: any): void;
isChecked(args: any): boolean;
}
/**
* A concrete implementation of [[ICommand]].
* Safely execute a command.
*
* A `DelegateCommand` wraps a function to facilitate the creation of
* simple commands without requiring subclassing or extra boilerplate.
* @param command - The command to execute.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* #### Notes
* If the commmand throws an exception, it will be caught and logged.
*/
export declare class DelegateCommand extends Command {
export declare function safeExecute(command: Command, args: any): void;
/**
* An options object for initializing a [[SimpleCommand]].
*/
export interface ISimpleCommandOptions {
/**
* Construct a new delegate command.
* The handler function for the command.
*/
handler: (args: any) => void;
/**
* The initial display text for the command.
*/
text?: string;
/**
* The initial icon class for the command.
*/
icon?: string;
/**
* The initial short caption for the command.
*/
caption?: string;
/**
* The initial category for the command.
*/
category?: string;
/**
* The initial extra class name for the command.
*/
className?: string;
/**
* The initial enabled state of the command.
*/
enabled?: boolean;
/**
* The initial visible state of the command.
*/
visible?: boolean;
/**
* The initial checked state of the command.
*/
checked?: boolean;
}
/**
* A concrete implementation of [[Command]].
*
* A `SimpleCommand` is useful for creating commands which do not rely
* on complex state and which can be implemented by a single function.
*
* A `SimpleCommand` should not be used when fine grained control over
* the command state is required. For those cases, the `Command` class
* should be subclassed directly.
*/
export declare class SimpleCommand extends Command {
/**
* Construct a new simple command.
*
* @param execute - The function which executes the command logic.
* @param options - The options for initializing the command.
*/
constructor(execute: (args: any) => void);
constructor(options: ISimpleCommandOptions);
/**
* Get the enabled state of the delegate command.
* Get the display text for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The display text for the command.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setText]]
*/
text(args: any): string;
/**
* Set the enabled state of the delegate command.
* Get the class name(s) for the command icon.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the command icon node.
*
* #### Notes
* This will emit the [[changed]] signal if the state changes.
* This method ignores the command arguments.
*
* **See also** [[setIcon]]
*/
enabled: boolean;
icon(args: any): string;
/**
* Get the checked state of the delegate command.
* Get the short caption for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The short caption for the command.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setCaption]]
*/
caption(args: any): string;
/**
* Set the checked state of the delegate command.
* Get the category for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The category for the command.
*
* #### Notes
* This will emit the [[changed]] signal if the state changes.
* This method ignores the command arguments.
*
* **See also** [[setCategory]]
*/
checked: boolean;
category(args: any): string;
/**
* Test whether the command is enabled.
* Get the class name(s) for the primary command node.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the primary command node.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setClassName]]
*/
className(args: any): string;
/**
* Test whether the command is enabled for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is enabled, `false` otherwise.
*
* #### Notes
* This returns the command's [[enabled]] state.
* This method ignores the command arguments.
*
* **See also** [[setEnabled]]
*/
isEnabled(): boolean;
isEnabled(args: any): boolean;
/**
* Test whether the command is checked.
* Test whether the command is visible for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is visible, `false` otherwise.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setVisible]]
*/
isVisible(args: any): boolean;
/**
* Test whether the command is checked for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is checked, `false` otherwise.
*
* #### Notes
* This returns the command's [[checked]] state.
* This method ignores the command arguments.
*
* **See also** [[setChecked]]
*/
isChecked(): boolean;
isChecked(args: any): boolean;
/**
* Set the text for the command.
*
* @param value - The text for the command.
*
* #### Notes
* If the text changes, the [[changed]] signal will be emitted.
*/
setText(value: string): void;
/**
* Set the icon for the command.
*
* @param value - The icon for the command.
*
* #### Notes
* If the icon changes, the [[changed]] signal will be emitted.
*/
setIcon(value: string): void;
/**
* Set the caption for the command.
*
* @param value - The caption for the command.
*
* #### Notes
* If the caption changes, the [[changed]] signal will be emitted.
*/
setCaption(value: string): void;
/**
* Set the category for the command.
*
* @param value - The category for the command.
*
* #### Notes
* If the category changes, the [[changed]] signal will be emitted.
*/
setCategory(value: string): void;
/**
* Set the class name for the command.
*
* @param value - The class name for the command.
*
* #### Notes
* If the class name changes, the [[changed]] signal will be emitted.
*/
setClassName(value: string): void;
/**
* Set the enabled state for the command.
*
* @param value - The enabled state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
setEnabled(value: boolean): void;
/**
* Set the visible state for the command.
*
* @param value - The visible state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
setVisible(value: boolean): void;
/**
* Set the checked state for the command.
*
* @param value - The checked state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
setChecked(value: boolean): void;
/**
* Execute the command with the specified arguments.
*
* @param args - The arguments for the command. The args should be
* simple JSON types. If the command does not require arguments,
* this may be `null`.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* #### Notes
* Calling `execute` when `isEnabled` returns `false` will result
* in undefined behavior.
* Calling `execute` when `isEnabled` returns `false` may result in
* undefined behavior.
*/
execute(args: any): void;
private _text;
private _icon;
private _caption;
private _category;
private _className;
private _enabled;
private _visible;
private _checked;
private _execute;
private _handler;
}

@@ -26,8 +26,6 @@ /*-----------------------------------------------------------------------------

* #### Notes
* This should be emitted by a subclass as necessary.
*
* This is a pure delegate to the [[changedSignal]].
* A subclass should emit this signal when the command state changes.
*/
get: function () {
return Command.changedSignal.bind(this);
return CommandPrivate.changedSignal.bind(this);
},

@@ -38,4 +36,111 @@ enumerable: true,

/**
* Test whether the command is enabled.
* Get the display text for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The display text for the command.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* use this as the text for the primary DOM node for the command.
*
* The default implementation of this method returns an empty string.
*/
Command.prototype.text = function (args) {
return '';
};
/**
* Get the class name(s) for the command icon.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the command icon node.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* add the class name(s) to the DOM node for the command icon.
*
* Multiple class names can be separated with whitespace.
*
* The default implementation of this method returns an empty string.
*/
Command.prototype.icon = function (args) {
return '';
};
/**
* Get the short caption for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The short caption for the command.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This value is used by UI elements where displaying a short command
* description is relevant, such as tooltips and command palettes.
*
* The default implementation of this method returns an empty string.
*/
Command.prototype.caption = function (args) {
return '';
};
/**
* Get the category for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The category for the command.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* This value is used by UI elements which group commands together
* based on category, such as toolbars and command palettes.
*
* The default implementation of this method returns an empty string.
*/
Command.prototype.category = function (args) {
return '';
};
/**
* Get the class name(s) for the primary command node.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the primary command node.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* add the class name(s) to the primary DOM node for the command.
*
* Multiple class names can be separated with whitespace.
*
* The default implementation of this method returns an empty string.
*/
Command.prototype.className = function (args) {
return '';
};
/**
* Test whether the command is enabled for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is enabled, `false` otherwise.

@@ -47,10 +152,36 @@ *

*
* UI elements which have a visual representation of a command will
* typically display a non-enabled command as greyed-out.
*
* The default implementation of this method returns `true`.
*/
Command.prototype.isEnabled = function () {
Command.prototype.isEnabled = function (args) {
return true;
};
/**
* Test whether the command is checked.
* Test whether the command is visible for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is visible, `false` otherwise.
*
* #### Notes
* A subclass may reimplement this method as needed. If the state
* changes at runtime, the [[changed]] signal should be emitted.
*
* UI elements which have a visual representation of a command will
* typically not display a non-visible command.
*
* The default implementation of this method returns `true`.
*/
Command.prototype.isVisible = function (args) {
return true;
};
/**
* Test whether the command is checked for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is checked, `false` otherwise.

@@ -62,13 +193,10 @@ *

*
* UI elements which have a visual representation of a command will
* typically add extra class names to the node of a checked command.
*
* The default implementation of this method returns `false`.
*/
Command.prototype.isChecked = function () {
Command.prototype.isChecked = function (args) {
return false;
};
/**
* A signal emitted when the command's state changes.
*
* **See also:** [[changed]]
*/
Command.changedSignal = new phosphor_signaling_1.Signal();
return Command;

@@ -78,105 +206,347 @@ })();

/**
* A concrete implementation of [[ICommand]].
* Safely execute a command.
*
* A `DelegateCommand` wraps a function to facilitate the creation of
* simple commands without requiring subclassing or extra boilerplate.
* @param command - The command to execute.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* #### Notes
* If the commmand throws an exception, it will be caught and logged.
*/
var DelegateCommand = (function (_super) {
__extends(DelegateCommand, _super);
function safeExecute(command, args) {
try {
command.execute(args);
}
catch (err) {
console.error(err);
}
}
exports.safeExecute = safeExecute;
/**
* A concrete implementation of [[Command]].
*
* A `SimpleCommand` is useful for creating commands which do not rely
* on complex state and which can be implemented by a single function.
*
* A `SimpleCommand` should not be used when fine grained control over
* the command state is required. For those cases, the `Command` class
* should be subclassed directly.
*/
var SimpleCommand = (function (_super) {
__extends(SimpleCommand, _super);
/**
* Construct a new delegate command.
* Construct a new simple command.
*
* @param execute - The function which executes the command logic.
* @param options - The options for initializing the command.
*/
function DelegateCommand(execute) {
function SimpleCommand(options) {
_super.call(this);
this._text = '';
this._icon = '';
this._caption = '';
this._category = '';
this._className = '';
this._enabled = true;
this._visible = true;
this._checked = false;
this._execute = execute;
this._handler = options.handler;
if (options.text !== void 0) {
this._text = options.text;
}
if (options.icon !== void 0) {
this._icon = options.icon;
}
if (options.caption !== void 0) {
this._caption = options.caption;
}
if (options.category !== void 0) {
this._category = options.category;
}
if (options.className !== void 0) {
this._className = options.className;
}
if (options.enabled !== void 0) {
this._enabled = options.enabled;
}
if (options.visible !== void 0) {
this._visible = options.visible;
}
if (options.checked !== void 0) {
this._checked = options.checked;
}
}
Object.defineProperty(DelegateCommand.prototype, "enabled", {
/**
* Get the enabled state of the delegate command.
*/
get: function () {
return this._enabled;
},
/**
* Set the enabled state of the delegate command.
*
* #### Notes
* This will emit the [[changed]] signal if the state changes.
*/
set: function (value) {
if (this._enabled === value) {
return;
}
this._enabled = value;
this.changed.emit(void 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DelegateCommand.prototype, "checked", {
/**
* Get the checked state of the delegate command.
*/
get: function () {
return this._checked;
},
/**
* Set the checked state of the delegate command.
*
* #### Notes
* This will emit the [[changed]] signal if the state changes.
*/
set: function (value) {
if (this._checked === value) {
return;
}
this._checked = value;
this.changed.emit(void 0);
},
enumerable: true,
configurable: true
});
/**
* Test whether the command is enabled.
* Get the display text for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The display text for the command.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setText]]
*/
SimpleCommand.prototype.text = function (args) {
return this._text;
};
/**
* Get the class name(s) for the command icon.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the command icon node.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setIcon]]
*/
SimpleCommand.prototype.icon = function (args) {
return this._icon;
};
/**
* Get the short caption for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The short caption for the command.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setCaption]]
*/
SimpleCommand.prototype.caption = function (args) {
return this._caption;
};
/**
* Get the category for the command.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The category for the command.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setCategory]]
*/
SimpleCommand.prototype.category = function (args) {
return this._category;
};
/**
* Get the class name(s) for the primary command node.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns The class name(s) to add to the primary command node.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setClassName]]
*/
SimpleCommand.prototype.className = function (args) {
return this._className;
};
/**
* Test whether the command is enabled for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is enabled, `false` otherwise.
*
* #### Notes
* This returns the command's [[enabled]] state.
* This method ignores the command arguments.
*
* **See also** [[setEnabled]]
*/
DelegateCommand.prototype.isEnabled = function () {
SimpleCommand.prototype.isEnabled = function (args) {
return this._enabled;
};
/**
* Test whether the command is checked.
* Test whether the command is visible for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is visible, `false` otherwise.
*
* #### Notes
* This method ignores the command arguments.
*
* **See also** [[setVisible]]
*/
SimpleCommand.prototype.isVisible = function (args) {
return this._visible;
};
/**
* Test whether the command is checked for its current state.
*
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* @returns `true` if the command is checked, `false` otherwise.
*
* #### Notes
* This returns the command's [[checked]] state.
* This method ignores the command arguments.
*
* **See also** [[setChecked]]
*/
DelegateCommand.prototype.isChecked = function () {
SimpleCommand.prototype.isChecked = function (args) {
return this._checked;
};
/**
* Set the text for the command.
*
* @param value - The text for the command.
*
* #### Notes
* If the text changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setText = function (value) {
if (this._text === value) {
return;
}
this._text = value;
this.changed.emit(void 0);
};
/**
* Set the icon for the command.
*
* @param value - The icon for the command.
*
* #### Notes
* If the icon changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setIcon = function (value) {
if (this._icon === value) {
return;
}
this._icon = value;
this.changed.emit(void 0);
};
/**
* Set the caption for the command.
*
* @param value - The caption for the command.
*
* #### Notes
* If the caption changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setCaption = function (value) {
if (this._caption === value) {
return;
}
this._caption = value;
this.changed.emit(void 0);
};
/**
* Set the category for the command.
*
* @param value - The category for the command.
*
* #### Notes
* If the category changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setCategory = function (value) {
if (this._category === value) {
return;
}
this._category = value;
this.changed.emit(void 0);
};
/**
* Set the class name for the command.
*
* @param value - The class name for the command.
*
* #### Notes
* If the class name changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setClassName = function (value) {
if (this._className === value) {
return;
}
this._className = value;
this.changed.emit(void 0);
};
/**
* Set the enabled state for the command.
*
* @param value - The enabled state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setEnabled = function (value) {
if (this._enabled === value) {
return;
}
this._enabled = value;
this.changed.emit(void 0);
};
/**
* Set the visible state for the command.
*
* @param value - The visible state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setVisible = function (value) {
if (this._visible === value) {
return;
}
this._visible = value;
this.changed.emit(void 0);
};
/**
* Set the checked state for the command.
*
* @param value - The checked state for the command.
*
* #### Notes
* If the state changes, the [[changed]] signal will be emitted.
*/
SimpleCommand.prototype.setChecked = function (value) {
if (this._checked === value) {
return;
}
this._checked = value;
this.changed.emit(void 0);
};
/**
* Execute the command with the specified arguments.
*
* @param args - The arguments for the command. The args should be
* simple JSON types. If the command does not require arguments,
* this may be `null`.
* @param args - The arguments for the command. If the command does
* not require arguments, this may be `null`.
*
* #### Notes
* Calling `execute` when `isEnabled` returns `false` will result
* in undefined behavior.
* Calling `execute` when `isEnabled` returns `false` may result in
* undefined behavior.
*/
DelegateCommand.prototype.execute = function (args) {
this._execute.call(void 0, args);
SimpleCommand.prototype.execute = function (args) {
this._handler.call(void 0, args);
};
return DelegateCommand;
return SimpleCommand;
})(Command);
exports.DelegateCommand = DelegateCommand;
//# sourceMappingURL=index.js.map
exports.SimpleCommand = SimpleCommand;
/**
* The namespace for the `Command` class private data.
*/
var CommandPrivate;
(function (CommandPrivate) {
/**
* A signal emitted when a command's state changes.
*/
CommandPrivate.changedSignal = new phosphor_signaling_1.Signal();
})(CommandPrivate || (CommandPrivate = {}));

2

package.json
{
"name": "phosphor-command",
"version": "0.5.0",
"version": "0.6.0",
"description": "A module for expressing the command pattern.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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