@difizen/mana-core
Version:
50 lines (49 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CommandService = exports.Command = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* A command is a unique identifier of a function
* which can be executed by a user via a keyboard shortcut,
* a menu action or directly.
*/
var Command;
(function (_Command) {
function is(arg) {
return !!arg && arg === Object(arg) && 'id' in arg;
}
_Command.is = is;
function compareCommands(a, b) {
if (a.label && b.label) {
var aCommand = (a.category ? "".concat(a.category, ": ").concat(a.label) : a.label).toLowerCase();
var bCommand = (b.category ? "".concat(b.category, ": ").concat(b.label) : b.label).toLowerCase();
return aCommand.localeCompare(bCommand);
}
return 0;
}
_Command.compareCommands = compareCommands;
function equals(a, b) {
return a.id === b.id && a.label === b.label && a.category === b.category;
}
_Command.equals = equals;
})(Command || (exports.Command = Command = {}));
/**
* A command handler is an implementation of a command.
*
* A command can have multiple handlers
* but they should be active in different contexts,
* otherwise first active will be executed.
*/
/**
* A command handler is an implementation of a command.
*
* A command can have multiple handlers
* but they should be active in different contexts,
* otherwise first active will be executed.
*/
var CommandService = exports.CommandService = Symbol('CommandService');
/**
* The command service should be used to execute commands.
*/