Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { app, BrowserWindow } from "electron";
import electronReload from "electron-reload";
import electronWindowState from "electron-window-state";
electronReload(__dirname);
// To avoid garbage collector; don't remove!
let mainWindow;
const createWindow = () => {
let windowState = electronWindowState({
defaultWidth: 420,
defaultHeight: 640
});
mainWindow = new BrowserWindow({
x: windowState.x,
y: windowState.y,
width: windowState.width,
height: windowState.height,
minWidth: 370,
const init = () => {
if (isDevelopment) {
electronReload(__dirname, {
electron: path.join(__dirname, '../node_modules/.bin/electron'),
})
}
app.on('ready', () => {
if (getOsType === 'windows') {
// https://electronjs.org/docs/tutorial/notifications#windows
if (isDevelopment) app.setAppUserModelId(process.execPath)
else app.setAppUserModelId(pkg.appId)
}
const url = getUrlToLoad(store)
const { searchParams, protocol } = new URL(url)
const page = searchParams.get('page')
if (page === 'connectionError' && protocol === 'file:') {
import setupElectronReload from 'electron-reload';
import { setupErrorHandling } from './errorHandling';
import appData from './main/appData';
import './main/basicAuth';
import { processDeepLink } from './main/deepLinks';
import { getMainWindow } from './main/mainWindow';
import i18n from './i18n';
export { default as dock } from './main/dock';
export { default as menus } from './main/menus';
export { default as tray } from './main/tray';
export { default as certificate } from './main/certificateStore';
if (process.env.NODE_ENV) {
setupElectronReload(__dirname, {
electron: process.execPath,
});
}
async function prepareApp() {
setupErrorHandling('main');
app.setAsDefaultProtocolClient('rocketchat');
app.setAppUserModelId('chat.rocket');
await appData.initialize();
const canStart = process.mas || app.requestSingleInstanceLock();
if (!canStart) {
app.quit();
import autoReload from "electron-reload"
import path from "path"
const webappDistDir = path.join(__dirname)
autoReload(webappDistDir, {
electron: path.join(__dirname, "..", "..", "node_modules", ".bin", "electron")
})