Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mainWindow.webContents.once("dom-ready", () => {
// In development install extensions
if (process.env.MH_ENV === "development") {
console.log("Development mode. Adding dev-tools.");
const Installer = require("electron-devtools-installer");
Promise.all([
Installer.default(Installer.REACT_DEVELOPER_TOOLS),
Installer.default(Installer.REDUX_DEVTOOLS)
]).catch(err => {
console.log(`DevTools: ${err}`);
});
}
});
}
app.on('ready', () => {
if (global.willAppQuit) {
return;
}
if (global.isDev) {
installExtension.default(installExtension.REACT_DEVELOPER_TOOLS).
then((name) => console.log(`Added Extension: ${name}`)).
catch((err) => console.log('An error occurred: ', err));
}
mainWindow = createMainWindow(config, {
hideOnStartup,
linuxAppIcon: path.join(assetsDir, 'appicon.png')
});
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.on('unresponsive', () => {
console.log('The application has become unresponsive.');
const { BrowserWindow, app } = require('electron')
const installExtension = require('electron-devtools-installer')
const extensionList = [
installExtension.REACT_DEVELOPER_TOOLS,
installExtension.REDUX_DEVTOOLS
]
let mainWindow
let loadingWindow
let loadUrl = process.env.NODE_ENV === 'development'
? 'http://localhost:3000/'
: `file://${__dirname}/build/index.html`
function createMainWindows () {
mainWindow = new BrowserWindow({
height: 670,
useContentSize: true,
width: 1020,
// autoHideMenuBar: true,
titleBarStyle: 'hiddenInset',
import { remote } from 'electron';
if (remote.getGlobal('DEV_MODE')) {
// Attempt to install DevTron
try {
if (!remote.BrowserWindow.getDevToolsExtensions().hasOwnProperty('devtron')) {
require('devtron').install();
}
} catch (e) {
// Who cares
}
// Attempt to install React Developer Tools
try {
const devtoolsInstaller = require('electron-devtools-installer');
devtoolsInstaller.default(devtoolsInstaller.REACT_DEVELOPER_TOOLS);
} catch (err) {
// Whoe cares
}
window.addEventListener('load', () => {
const webview = document.querySelector('webview');
if (!webview) {
return;
}
window.openGPMDevTools = () => {
webview.openDevTools();
};
});
}
'use strict';
var electron = require('electron');
var _require = require('electron-devtools-installer'),
installExtension = _require.default,
REACT_DEVELOPER_TOOLS = _require.REACT_DEVELOPER_TOOLS;
// Module to control application life.
var app = electron.app;
// Module to create native browser window.
var BrowserWindow = electron.BrowserWindow;
var path = require('path');
var url = require('url');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = void 0;
function createWindow() {
var _electron$screen$getP = electron.screen.getPrimaryDisplay().workAreaSize,
Menu.setApplicationMenu(Menu.buildFromTemplate(menus));
};
// Save userData in separate folders for each environment.
// Thanks to this you can use production and development versions of the app
// on same machine like those are two separate apps.
if (env.name !== "production") {
const userDataPath = app.getPath("userData");
app.setPath("userData", `${userDataPath} (${env.name})`);
}
let installExtension, REACT_DEVELOPER_TOOLS;
if (env.name === "development") {
let devtools = require("electron-devtools-installer");
installExtension = devtools.default;
REACT_DEVELOPER_TOOLS = devtools.REACT_DEVELOPER_TOOLS;
}
app.on("ready", () => {
setApplicationMenu();
const mainWindow = createWindow("main", {
width: 1000,
height: 600
});
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, "app.html"),
protocol: "file:",
slashes: true
})
function installDevtools() {
const devtoolsInstaller = require('electron-devtools-installer')
devtoolsInstaller.default(devtoolsInstaller.REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err))
}
app.on('ready', () => {
let installExtension = require('electron-devtools-installer')
installExtension.default(installExtension.REACT_DEVELOPER_TOOLS).then(() => {
}).catch(err => {
console.log('Unable to install `react-developer-tools`: \n', err)
})
})
}
(function() {
if (process.env.NODE_ENV === 'development') {
const devtoolsInstaller = require('electron-devtools-installer');
devtoolsInstaller.default(devtoolsInstaller.REACT_DEVELOPER_TOOLS).catch(() => {});
}
const script = document.createElement('script');
script.src = (process.env.HOT) ? 'http://localhost:3000/app/dist/bundle.js' : '../dist/bundle.js';
document.write(script.outerHTML);
}());