<commit_before>const {app, BrowserWindow} = require('electron');
const windowStateKeeper = require('electron-window-state');
const EVENT = require('./app/services/events');
const helper = require('./app/services/helper');
const updater = require('./app/updater/main');

let win;


// auto-handle file downloads with progressbar
require('electron-dl')();

const send = (name, val) => win.webContents.send(name, val);
function openUrl (ev, url) {
	console.log(ev, url);
	if (win && win.webContents) {
		win.restore();
		send(EVENT.frame.goto, url);
		if (ev) ev.preventDefault();
	}
	else global.appArgs = [url];		// opening URL in closed GHB
}

function createWindow () {
	const mainWindowState = windowStateKeeper({ defaultWidth: 1000, defaultHeight: 800 });

	win = new BrowserWindow({
		title: helper.appName,
		icon: __dirname + '/assets/icon.png',
		show: false,
		vibrancy: 'dark',
		titleBarStyle: 'hiddenInset',
		x: mainWindowState.x,
		y: mainWindowState.y,
		width: mainWindowState.width,
		height: mainWindowState.height,
	});
	win.on('closed', () => win = null);
	win.on('scroll-touch-begin', () => send('event', EVENT.swipe.start));
	win.on('scroll-touch-end', () => send('event', EVENT.swipe.end));
	win.webContents.on('crashed', () => { win.destroy(); createWindow(); });

	mainWindowState.manage(win);

	win.loadURL(`file://${__dirname}/index.html`);
	win.show();

	// win.webContents.openDevTools();

	updater.init(win);
}

app.on('window-all-closed', app.quit);
app.on('ready', createWindow);
app.on('open-url', openUrl);			// opening URL in GHB

global.appArgs = process.argv;			// opening URL from CLI<commit_msg>default browser - dont ask<commit_after>const {app, BrowserWindow} = require('electron');
const windowStateKeeper = require('electron-window-state');
const EVENT = require('./app/services/events');
const config = require('./app/services/config');
const helper = require('./app/services/helper');
const updater = require('./app/updater/main');

let win;


// auto-handle file downloads with progressbar
require('electron-dl')();

const send = (name, val) => win.webContents.send(name, val);
function openUrl (ev, url) {
	console.log(ev, url);
	if (win && win.webContents) {
		win.restore();
		send(EVENT.frame.goto, url);
		if (ev) ev.preventDefault();
	}
	else global.appArgs = [url];		// opening URL in closed GHB
}

function createWindow () {
	const mainWindowState = windowStateKeeper({ defaultWidth: 1000, defaultHeight: 800 });

	win = new BrowserWindow({
		title: helper.appName,
		icon: __dirname + '/assets/icon.png',
		show: false,
		vibrancy: 'dark',
		titleBarStyle: 'hiddenInset',
		x: mainWindowState.x,
		y: mainWindowState.y,
		width: mainWindowState.width,
		height: mainWindowState.height,
	});
	win.on('closed', () => win = null);
	win.on('scroll-touch-begin', () => send('event', EVENT.swipe.start));
	win.on('scroll-touch-end', () => send('event', EVENT.swipe.end));
	win.webContents.on('crashed', () => { win.destroy(); createWindow(); });

	mainWindowState.manage(win);

	win.loadURL(`file://${__dirname}/index.html`);
	win.show();

	// win.webContents.openDevTools();

	updater.init(win);
}

app.on('window-all-closed', app.quit);
app.on('ready', createWindow);
app.on('open-url', openUrl);			// opening URL in GHB

const dontAsk = config.get('defaultBrowser-dont-ask');
if (!app.isDefaultProtocolClient('http') && !dontAsk) {
	app.setAsDefaultProtocolClient('http');
	config.set('defaultBrowser-dont-ask', true);
}

global.appArgs = process.argv;			// opening URL from CLI
{'fraction_non_alphanumeric': 0.1864550864267498, 'fraction_numerical': 0.003967129498441485, 'mean_word_length': 4.76797385620915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3029514', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1173, 'n_words': 248}