<commit_before>'use strict';
const app = require('app');
const globalShortcut = require('global-shortcut');
const BrowserWindow = require('browser-window');
const isOSX = process.platform === 'darwin';

function devTools() {
	const win = BrowserWindow.getFocusedWindow();

	if (win) {
		win.toggleDevTools();
	}
}

function refresh() {
	const win = BrowserWindow.getFocusedWindow();

	if (win) {
		win.reloadIgnoringCache();
	}
}

function activateDebugContextMenu(e) {
	const webContents = e.sender;
	webContents.executeJavaScript(`require('${__dirname}/context-menu').install();`);
}

function deactivateDebugContextMenu(e) {
	const webContents = e.sender;
	webContents.executeJavaScript(`require('${__dirname}/context-menu').uninstall();`);
}

function installDebugContextMenu(win) {
	win.webContents.on('devtools-opened', activateDebugContextMenu);
	win.webContents.on('devtools-closed', deactivateDebugContextMenu);

	if (win.webContents.isDevToolsOpened()) {
		activateDebugContextMenu({sender: win.webContents});
	}
}

function uninstallDebugContextMenu(win) {
	win.webContents.removeListener('devtools-opened', activateDebugContextMenu);
	win.webContents.removeListener('devtools-closed', deactivateDebugContextMenu);
}

module.exports = () => {
	app.on('ready', () => {
		app.on('browser-window-focus', (e, win) => {
			globalShortcut.register(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I', devTools);
			globalShortcut.register('F12', devTools);

			globalShortcut.register('CmdOrCtrl+R', refresh);
			globalShortcut.register('F5', refresh);

			installDebugContextMenu(win);
		});

		app.on('browser-window-blur', (e, win) => {
			globalShortcut.unregister(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I');
			globalShortcut.unregister('F12');

			globalShortcut.unregister('CmdOrCtrl+R');
			globalShortcut.unregister('F5');

			uninstallDebugContextMenu(win);
		});
	});
};<commit_msg>saved require to window.__electron_debug.require on win creation<commit_after>'use strict';
const app = require('app');
const globalShortcut = require('global-shortcut');
const BrowserWindow = require('browser-window');
const isOSX = process.platform === 'darwin';

function devTools() {
	const win = BrowserWindow.getFocusedWindow();

	if (win) {
		win.toggleDevTools();
	}
}

function refresh() {
	const win = BrowserWindow.getFocusedWindow();

	if (win) {
		win.reloadIgnoringCache();
	}
}

function activateDebugContextMenu(e) {
	const webContents = e.sender;
	webContents.executeJavaScript(`window.__electron_debug.require('${__dirname}/context-menu').install();`);
}

function deactivateDebugContextMenu(e) {
	const webContents = e.sender;
	webContents.executeJavaScript(`window.__electron_debug.require('${__dirname}/context-menu').uninstall();`);
}

function installDebugContextMenu(win) {
	win.webContents.on('devtools-opened', activateDebugContextMenu);
	win.webContents.on('devtools-closed', deactivateDebugContextMenu);

	if (win.webContents.isDevToolsOpened()) {
		activateDebugContextMenu({sender: win.webContents});
	}
}

function uninstallDebugContextMenu(win) {
	win.webContents.removeListener('devtools-opened', activateDebugContextMenu);
	win.webContents.removeListener('devtools-closed', deactivateDebugContextMenu);
}

module.exports = () => {
	app.on('browser-window-created', (e, win) => {
		win.webContents.executeJavaScript('window.__electron_debug = {require: window.require};');
	});

	app.on('browser-window-focus', (e, win) => {
		globalShortcut.register(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I', devTools);
		globalShortcut.register('F12', devTools);

		globalShortcut.register('CmdOrCtrl+R', refresh);
		globalShortcut.register('F5', refresh);

		installDebugContextMenu(win);
	});

	app.on('browser-window-blur', (e, win) => {
		globalShortcut.unregister(isOSX ? 'Cmd+Alt+I' : 'Ctrl+Shift+I');
		globalShortcut.unregister('F12');

		globalShortcut.unregister('CmdOrCtrl+R');
		globalShortcut.unregister('F5');

		uninstallDebugContextMenu(win);
	});
};
{'fraction_non_alphanumeric': 0.16195048004042445, 'fraction_numerical': 0.003031834259727135, 'mean_word_length': 6.569789674952199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2778734', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1250, 'n_words': 181}