{"size": 1034, "ext": "js", "max_stars_repo_path": "app/index.js", "max_stars_repo_name": "mimorisuzuko/electron", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/index.js", "max_issues_repo_name": "mimorisuzuko/electron", "max_issues_repo_issues_event_min_datetime": "2017-10-10T10:30:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:37:16.000Z", "max_forks_repo_path": "app/index.js", "max_forks_repo_name": "mimorisuzuko/electron-template", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 16, "max_forks_count": null, "avg_line_length": 20.2745098039, "max_line_length": 67, "alphanum_fraction": 0.5464216634}
const { app, BrowserWindow } = require('electron');
const libpath = require('path');
const {
    env: { NODE_ENV }
} = process;
const {
    default: installExtension,
    REACT_DEVELOPER_TOOLS
} = require('electron-devtools-installer');

/** @type {Electron.BrowserWindow} */
let browserWindow = null;

const create = () => {
    const w = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            nodeIntegration: true
        }
    });

    w.loadURL(
        NODE_ENV === 'development'
            ? 'http://localhost:3000'
            : `file://${libpath.join(__dirname, 'dst/index.html')}`
    );
    w.on('closed', () => {
        browserWindow = null;
    });

    browserWindow = w;
};

app.on('ready', () => {
    create();
    installExtension(REACT_DEVELOPER_TOOLS).catch(console.error);
});

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', () => {
    if (!browserWindow) {
        create();
    }
});
