@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
47 lines (46 loc) • 1.7 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Utilities_1 = __importDefault(require("../core/Utilities"));
class LocalCommandHandler {
_window;
_ipcMain;
_env;
constructor(browserWindow, incomingIpcMain, env, utils) {
this._window = browserWindow;
this._ipcMain = incomingIpcMain;
this._env = env;
this.convertFile = this.convertFile.bind(this);
this._ipcMain.handle("asyncconvertFile", this.convertFile);
}
async convertFile(evt, data) {
const slargs = data.split("|");
const serverState = slargs[1];
console.log("Converting: " + data);
const req = this.convertStringToConversionSettings(serverState);
let commandResult = false;
if (req === undefined) {
console.log("No conversion data was specified.");
}
else {
const result = await this._env.utilities.processConversion(req);
if (!result) {
this._window.webContents.send("appsvc", "convertFileError|Could not process a conversion request.");
}
else {
commandResult = true;
}
}
this._window.webContents.send("appsvc", "asyncconvertFileComplete|" + slargs[0] + "|");
}
convertStringToConversionSettings(serverState) {
let req = undefined;
if (serverState !== "") {
req = Utilities_1.default.parseJson(serverState);
}
return req;
}
}
exports.default = LocalCommandHandler;