@alilc/lowcode-shell
Version:
Shell Layer for AliLowCodeEngine
37 lines • 1.54 kB
JavaScript
import { commandSymbol, pluginContextSymbol } from '../symbols';
var optionsSymbol = Symbol('options');
var commandScopeSet = new Set();
export var Command = /*#__PURE__*/function () {
function Command(innerCommand, pluginContext, options) {
this[commandSymbol] = void 0;
this[optionsSymbol] = void 0;
this[pluginContextSymbol] = void 0;
this[commandSymbol] = innerCommand;
this[optionsSymbol] = options;
this[pluginContextSymbol] = pluginContext;
var commandScope = options === null || options === void 0 ? void 0 : options.commandScope;
if (commandScope && commandScopeSet.has(commandScope)) {
throw new Error("Command scope \"" + commandScope + "\" has been registered.");
}
}
var _proto = Command.prototype;
_proto.registerCommand = function registerCommand(command) {
this[commandSymbol].registerCommand(command, this[optionsSymbol]);
};
_proto.batchExecuteCommand = function batchExecuteCommand(commands) {
this[commandSymbol].batchExecuteCommand(commands, this[pluginContextSymbol]);
};
_proto.executeCommand = function executeCommand(name, args) {
this[commandSymbol].executeCommand(name, args);
};
_proto.listCommands = function listCommands() {
return this[commandSymbol].listCommands();
};
_proto.unregisterCommand = function unregisterCommand(name) {
this[commandSymbol].unregisterCommand(name);
};
_proto.onCommandError = function onCommandError(callback) {
this[commandSymbol].onCommandError(callback);
};
return Command;
}();