<commit_before>'use strict'

import { join } from 'path'
import { stat, unlinkSync } from 'fs'
import { app, protocol, BrowserWindow, dialog, Menu, Tray } from 'electron'
import {
  createProtocol,
  installVueDevtools
} from 'vue-cli-plugin-electron-builder/lib'

import './startUp'
import './services'
import { dir } from './utils'
import { localFiles, mpv as setupMPV } from './externals'
import external from './events'
import menuTemplate from './menu'

const isDevelopment = process.env.NODE_ENV !== 'production'
const baseConfig = localFiles.getFile('config.json')
const userConfig = baseConfig.config

const menu = Menu.buildFromTemplate(menuTemplate.menu)
const gotTheLock = app.requestSingleInstanceLock()

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
let tray

// Standard scheme must be registered before the app is ready
protocol.registerStandardSchemes(['app'], { secure: true })

// When upgrading to Electron 5
// protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])

setupMPV(app)

function createWindow () {
  // Create the browser window.
  win = new BrowserWindow({
    title: 'KawAnime',
    width: userConfig.bounds.width || 1200,
    height: userConfig.bounds.height || 800,
    x: userConfig.system.center
      ? null
      : userConfig.bounds.x,
    y: userConfig.system.center
      ? null
      : userConfig.bounds.y,
    center: userConfig.system.center || false,
    titleBarStyle: 'hidden',
    frame: process.platform === 'darwin',
    show: false,
    useContentSize: process.platform !== 'linux',
    webPreferences: {
      nodeIntegration: true,
      plugins: true // For mpv.js
    }
  })

  if (isDevelopment && process.env.WEBPACK_DEV_SERVER_URL && !process.env.IS_TEST) {
    // Load the url of the dev server if in development mode
    win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
  } else {
    createProtocol('app')
    // Load the index.html when not in development
    win.loadURL('app://./index.html')
  }

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

  win.on('close', () => {
    const bounds = win.getBounds()<commit_msg>Enabled offscreen rendering<commit_after>'use strict'

import { join } from 'path'
import { stat, unlinkSync } from 'fs'
import { app, protocol, BrowserWindow, dialog, Menu, Tray } from 'electron'
import {
  createProtocol,
  installVueDevtools
} from 'vue-cli-plugin-electron-builder/lib'

import './startUp'
import './services'
import { dir } from './utils'
import { localFiles, mpv as setupMPV } from './externals'
import external from './events'
import menuTemplate from './menu'

const isDevelopment = process.env.NODE_ENV !== 'production'
const baseConfig = localFiles.getFile('config.json')
const userConfig = baseConfig.config

const menu = Menu.buildFromTemplate(menuTemplate.menu)
const gotTheLock = app.requestSingleInstanceLock()

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
let tray

// Standard scheme must be registered before the app is ready
protocol.registerStandardSchemes(['app'], { secure: true })

// When upgrading to Electron 5
// protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])

setupMPV(app)

function createWindow () {
  // Create the browser window.
  win = new BrowserWindow({
    title: 'KawAnime',
    width: userConfig.bounds.width || 1200,
    height: userConfig.bounds.height || 800,
    x: userConfig.system.center
      ? null
      : userConfig.bounds.x,
    y: userConfig.system.center
      ? null
      : userConfig.bounds.y,
    center: userConfig.system.center || false,
    titleBarStyle: 'hidden',
    frame: process.platform === 'darwin',
    show: false,
    useContentSize: process.platform !== 'linux',
    offscreen: true,
    webPreferences: {
      nodeIntegration: true,
      plugins: true // For mpv.js
    }
  })

  if (isDevelopment && process.env.WEBPACK_DEV_SERVER_URL && !process.env.IS_TEST) {
    // Load the url of the dev server if in development mode
    win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
  } else {
    createProtocol('app')
    // Load the index.html when not in development
    win.loadURL('app://./index.html')
  }

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

  win.on('close', () => {
    const bounds = win.getBounds()
{'fraction_non_alphanumeric': 0.12497249724972498, 'fraction_numerical': 0.0035203520352035203, 'mean_word_length': 3.6340468909276247, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5748700', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1344, 'n_words': 395}