<file_sep>## Dev

Built with [Electron](http://electron.atom.io).

###### Commands

- Init: `$ yarn install`
- Run: `$ yarn start`
- Package: `$ yarn dist`<file_sep>var electron = require('electron');
const {app} = require('electron');
// const {webContents} = require('electron');
// try {
//     require('electron-debug')({enabled: true});
// } catch (e) {
//     console.log(e);
// }

// try {
//     require('devtron').install();
// } catch (e) {
//     console.log(e);
// }

var BrowserWindow = electron.BrowserWindow;

var mainWindow = null;

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

app.on('ready', function () {
    var size = electron.screen.getPrimaryDisplay().workAreaSize;
    mainWindow = new BrowserWindow({
        'title': app.getName(),
        'show': true,
        frame: true,
        // titleBarStyle: 'hiddenInset',
        width: size.width,
        height: size.height,
        minWidth: 400,
        minHeight: 200,
        resizable: true,
        webPreferences: {
            // fails without this because of CommonJS script detection
            'node-integration': false,
            'experimental-canvas-features': true,
            'experimental-features': true,
            'web-security': true,
            'plugins': true,
            nativeWindowOpen: true
        }
    });
    mainWindow.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
        event.preventDefault();
        if (url.startsWith("https://wave.video/editor")) {
            mainWindow.loadURL(url);
        } else {
            // console.log(event.browserWindowOptions.width);
            // console.log(event.browserWindowOptions.width);

            Object.assign(options, {
                modal: true,
                parent: mainWindow,
                width: 1000,
                height: 1000
            });
            const modal = event.newGuest = new BrowserWindow(options);
            modal.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => {
                event.preventDefault();
                modal.close();
                mainWindow.loadURL(url);
            });
        }
        // }
    });
    // mainWindow.loadURL('https://editor.animatron.com');
    mainWindow.loadURL('https://wave.video/editor');
    //mainWindow.loadURL('localhost:8888/wave.html#new=1');


    mainWindow.on('closed', function () {
        mainWindow = null;
    });
});