UNPKG

generator-theia

Version:

Theia Generator

35 lines 2.8 kB
"use strict"; /* * Copyright (C) 2017 TypeFox and others. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var common_1 = require("../common"); var ElectronFrontendGenerator = (function (_super) { __extends(ElectronFrontendGenerator, _super); function ElectronFrontendGenerator() { return _super !== null && _super.apply(this, arguments) || this; } ElectronFrontendGenerator.prototype.generate = function (fs) { this.doGenerate(fs, this.model.frontendElectronModules); fs.write(this.frontend('electron-main.js'), this.compileElectronMain()); }; ElectronFrontendGenerator.prototype.compileElectronMain = function () { return this.compileCopyright() + "\n// @ts-check\n// Workaround for https://github.com/electron/electron/issues/9225. Chrome has an issue where\n// in certain locales (e.g. PL), image metrics are wrongly computed. We explicitly set the\n// LC_NUMERIC to prevent this from happening (selects the numeric formatting category of the\n// C locale, http://en.cppreference.com/w/cpp/locale/LC_categories).\nif (process.env.LC_ALL) {\n process.env.LC_ALL = 'C';\n}\nprocess.env.LC_NUMERIC = 'C';\n\nconst electron = require('electron');\nconst path = require('path');\n\nelectron.app.on('window-all-closed', function () {\n if (process.platform !== 'darwin') {\n electron.app.quit();\n }\n});\n\nelectron.app.on('ready', function () {\n const mainWindow = new electron.BrowserWindow({ width: 1024, height: 728 });\n require(\"../backend/main\").then(server => {\n mainWindow.loadURL(`file://${path.join(__dirname, '../../lib/index.html')}?port=${server.address().port}`);\n mainWindow.webContents.openDevTools();\n }).catch(() => {\n electron.app.exit(1);\n });\n mainWindow.on('closed', function () {\n electron.app.exit(0);\n });\n});"; }; return ElectronFrontendGenerator; }(common_1.AbstractFrontendGenerator)); exports.ElectronFrontendGenerator = ElectronFrontendGenerator; //# sourceMappingURL=electron-frontend-generator.js.map