<commit_before>const {
  default: installExtension,
  REACT_DEVELOPER_TOOLS,
  REDUX_DEVTOOLS,
} = require('electron-devtools-installer');
const {
  app,
  ipcMain,
  nativeImage,
  BrowserWindow,
  Menu,
  Tray,
} = require('electron');
const platform = require('electron-platform');
const path = require('path');
const url = require('url');
const getOption = require('./store').getOption;

let win;
let tray;
let icon = nativeImage.createFromPath(
  path.resolve(__dirname, 'resources', 'media', 'icon.png')
);

function changeWindowTitle(artist, title) {
  win.setTitle(`${artist} - ${title} - nuclear music player`);
}

function createWindow() {
  win = new BrowserWindow({
    width: 1366,
    height: 768,
    frame: !getOption('framelessWindow'),
    icon: icon,
    show: false,
    webPreferences: {
      experimentalFeatures: true,
      webSecurity: false,
    },
  });

  win.setTitle('nuclear music player');

  // Needs to be commented for now
  // https://github.com/electron/electron/issues/13008
  // installExtension(REACT_DEVELOPER_TOOLS)
  // .then((name) => console.log(`Added Extension:  ${name}`))
  // .catch((err) => console.log('An error occurred: ', err));

  // installExtension(REDUX_DEVTOOLS)
  // .then((name) => console.log(`Added Extension:  ${name}`))
  // .catch((err) => console.log('An error occurred: ', err));

  win.loadURL(
    url.format({
      pathname: 'localhost:8080',
      protocol: 'http:',
      slashes: true,
    })
  );

  win.once('ready-to-show', () => {
    win.show();
  });

  win.webContents.openDevTools();

  win.on('closed', () => {
    win = null;
  });

  // MacOS specific
  if (platform.isDarwin) {
    app.dock.setIcon(icon);
    icon = nativeImage.createFromPath(
      path.resolve(__dirname, 'resources', 'media', 'icon_apple.png')
    );
  }

  const trayMenu = Menu.buildFromTemplate([
    {
      label: 'Quit',
      type: 'normal',
      click: (menuItem, browserWindow, event) => {
        app.quit();
      },
    },
  ]);

  tray = new Tray(icon);
  tray.setTitle('nuclear music player');
  tray.setToolTip('nuclear music player');
  tray.setContextMenu(trayMenu);

  ipcMain.on('close', () => {
    app.quit();
  });

  ipcMain.on('minimize', () => {
    win.minimize();
  });

  ipcMain.on('maximize', () => {
    win.isMaximized() ? win.unmaximize() : win.maximize();
  });

  ipcMain.on('songChange', (event, arg) => {
    if (arg === null) {
      return;
    }
    changeWindowTitle(arg.artist, arg.name);
  });
}

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  app.quit();
});<commit_msg>#154 changed Maximized window to full screen window (OK for mac, could not test on other platforms)<commit_after>const {
  default: installExtension,
  REACT_DEVELOPER_TOOLS,
  REDUX_DEVTOOLS,
} = require('electron-devtools-installer');
const {
  app,
  ipcMain,
  nativeImage,
  BrowserWindow,
  Menu,
  Tray,
} = require('electron');
const platform = require('electron-platform');
const path = require('path');
const url = require('url');
const getOption = require('./store').getOption;

let win;
let tray;
let icon = nativeImage.createFromPath(
  path.resolve(__dirname, 'resources', 'media', 'icon.png')
);

function changeWindowTitle (artist, title) {
  win.setTitle(`${artist} - ${title} - nuclear music player`);
}

function createWindow () {
  win = new BrowserWindow({
    width: 1366,
    height: 768,
    frame: !getOption('framelessWindow'),
    icon: icon,
    show: false,
    webPreferences: {
      experimentalFeatures: true,
      webSecurity: false,
    },
  });

  win.setTitle('nuclear music player');

  // Needs to be commented for now
  // https://github.com/electron/electron/issues/13008
  // installExtension(REACT_DEVELOPER_TOOLS)
  // .then((name) => console.log(`Added Extension:  ${name}`))
  // .catch((err) => console.log('An error occurred: ', err));

  // installExtension(REDUX_DEVTOOLS)
  // .then((name) => console.log(`Added Extension:  ${name}`))
  // .catch((err) => console.log('An error occurred: ', err));

  win.loadURL(
    url.format({
      pathname: 'localhost:8080',
      protocol: 'http:',
      slashes: true,
    })
  );

  win.once('ready-to-show', () => {
    win.show();
  });

  win.webContents.openDevTools();

  win.on('closed', () => {
    win = null;
  });

  // MacOS specific
  if (platform.isDarwin) {
    app.dock.setIcon(icon);
    icon = nativeImage.createFromPath(
      path.resolve(__dirname, 'resources', 'media', 'icon_apple.png')
    );
  }

  const trayMenu = Menu.buildFromTemplate([
    {
      label: 'Quit',
      type: 'normal',
      click: (menuItem, browserWindow, event) => {
        app.quit();
      },
    },
  ]);

  tray = new Tray(icon);
  tray.setTitle('nuclear music player');
  tray.setToolTip('nuclear music player');
  tray.setContextMenu(trayMenu);

  ipcMain.on('close', () => {
    app.quit();
  });

  ipcMain.on('minimize', () => {
    win.minimize();
  });

  ipcMain.on('maximize', () => {
    //win.isMaximized() ? win.unmaximize() : win.maximize();
    win.isFullScreen() ? win.setFullScreen(false) : win.setFullScreen(true)
  });

  ipcMain.on('songChange', (event, arg) => {
    if (arg === null) {
      return;
    }
    changeWindowTitle(arg.artist, arg.name);
  });
}

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  app.quit();
});
{'fraction_non_alphanumeric': 0.18295412159641924, 'fraction_numerical': 0.006527415143603133, 'mean_word_length': 3.31456154465004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513839', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1817, 'n_words': 346}