<commit_before>const electron = require('electron')
const path = require('path')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
const ipc = electron.ipcMain
const shell = electron.shell
// Module to create native application menu
const Menu = electron.Menu

// map ID to window object
const windows = {}

const isProduction = process.env.NODE_ENV !== 'development'
const signalExtensionId = 'iopnjipkpnmbpjaalcjcpcbfcnjknmmo'
const signalExtensionPath = process.env.NODE_ENV === 'production'
  ? path.join(__dirname, '..', '..', 'Signal-Desktop')
  : path.join(__dirname, 'Signal-Desktop')

// use a separate data directory for development
if (!isProduction) {
  app.setPath('userData', path.join(app.getPath('appData'), 'signal-muon'))
}

const messages = {
  CALLBACK: 'callback',
  CREATE_WINDOW: 'create-window',
  GET_CURRENT_WINDOW: 'get-current-window',
  FOCUS_WINDOW: 'focus-window',
  REMOVE_WINDOW: 'remove-window',
  RESTART: 'restart',
  OPEN_LINK: 'open-link'
}

const fileUrl = (str) => {
  let pathName = path.resolve(str).replace(/\\/g, '/')

  // Windows drive letter must be prefixed with a slash
  if (pathName[0] !== '/') {
    pathName = '/' + pathName
  }

  return encodeURI('file://' + pathName)
}

function createWindow (options) {
  // Create the browser window.
  let mainWindow = new BrowserWindow({
    title: 'Signal Private Messenger',
    icon: path.join(__dirname, 'Signal-Desktop', 'images', 'icon_128.png'),
    width: 800,
    height: 700
  })

  windows[options.id] = mainWindow
  mainWindow.id = options.id

  // and load the index.html of the app.
  mainWindow.loadURL(fileUrl(path.join(__dirname, `index.html#${options.url}`)))
  // Open the DevTools.
  // mainWindow.webContents.openDevTools()

  // Emitted when the window is closed.
  mainWindow.on('closed', function () {
    // 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
    delete windows[options.id]
  })

  return mainWindow
}

// Template for the application menu
var applicationMenuTemplate = [
  {
    label: 'Signal',
    submenu: [
      { label: 'About Application', selector: 'orderFrontStandardAboutPanel:' },
      { type: 'separator' },
      { label: 'Quit', accelerator: 'Command+Q', click: function () { app.quit() } }
    ]
  },
  {
    label: 'Edit',
    submenu: [
      { label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
      { label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
      { type: 'separator' },
      { label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
      { label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
      { label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
      { label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
    ]
  }
]

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
  init()<commit_msg>Small fix for making Ctrl+Q quitting the app<commit_after>const electron = require('electron')
const path = require('path')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
const ipc = electron.ipcMain
const shell = electron.shell
// Module to create native application menu
const Menu = electron.Menu

// map ID to window object
const windows = {}

const isProduction = process.env.NODE_ENV !== 'development'
const signalExtensionId = 'iopnjipkpnmbpjaalcjcpcbfcnjknmmo'
const signalExtensionPath = process.env.NODE_ENV === 'production'
  ? path.join(__dirname, '..', '..', 'Signal-Desktop')
  : path.join(__dirname, 'Signal-Desktop')

// use a separate data directory for development
if (!isProduction) {
  app.setPath('userData', path.join(app.getPath('appData'), 'signal-muon'))
}

const messages = {
  CALLBACK: 'callback',
  CREATE_WINDOW: 'create-window',
  GET_CURRENT_WINDOW: 'get-current-window',
  FOCUS_WINDOW: 'focus-window',
  REMOVE_WINDOW: 'remove-window',
  RESTART: 'restart',
  OPEN_LINK: 'open-link'
}

const fileUrl = (str) => {
  let pathName = path.resolve(str).replace(/\\/g, '/')

  // Windows drive letter must be prefixed with a slash
  if (pathName[0] !== '/') {
    pathName = '/' + pathName
  }

  return encodeURI('file://' + pathName)
}

function createWindow (options) {
  // Create the browser window.
  let mainWindow = new BrowserWindow({
    title: 'Signal Private Messenger',
    icon: path.join(__dirname, 'Signal-Desktop', 'images', 'icon_128.png'),
    width: 800,
    height: 700
  })

  windows[options.id] = mainWindow
  mainWindow.id = options.id

  // and load the index.html of the app.
  mainWindow.loadURL(fileUrl(path.join(__dirname, `index.html#${options.url}`)))
  // Open the DevTools.
  // mainWindow.webContents.openDevTools()

  // Emitted when the window is closed.
  mainWindow.on('closed', function () {
    // 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
    delete windows[options.id]
  })

  return mainWindow
}

// Template for the application menu
var applicationMenuTemplate = [
  {
    label: 'Signal',
    submenu: [
      { label: 'About Application', selector: 'orderFrontStandardAboutPanel:' },
      { type: 'separator' },
      { label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: function () { app.quit() } }
    ]
  },
  {
    label: 'Edit',
    submenu: [
      { label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
      { label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
      { type: 'separator' },
      { label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
      { label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
      { label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
      { label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
    ]
  }
]

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
  init()
{'fraction_non_alphanumeric': 0.14390355562337862, 'fraction_numerical': 0.003052037234854265, 'mean_word_length': 3.694842406876791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '4760598', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1986, 'n_words': 584}