-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
56 lines (47 loc) · 1.59 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(function () {
'use strict';
console.log('preload');
const electron = require('electron');
window.PROTO_ROOT = 'protos';
window.config = require('url').parse(window.location.toString(), true).query;
const ipc = electron.ipcRenderer;
window.config.localeMessages = ipc.sendSync('locale-data');
window.setBadgeCount = function(count) {
ipc.send('set-badge-count', count);
};
window.drawAttention = function() {
console.log('draw attention');
ipc.send('draw-attention');
};
window.showWindow = function() {
console.log('show window');
ipc.send('show-window');
};
window.setAutoHideMenuBar = function(autoHide) {
ipc.send('set-auto-hide-menu-bar', autoHide);
};
window.setMenuBarVisibility = function(visibility) {
ipc.send('set-menu-bar-visibility', visibility);
};
window.restart = function() {
console.log('restart');
ipc.send('restart');
};
ipc.on('debug-log', function() {
Whisper.events.trigger('showDebugLog');
});
// We pull these dependencies in now, from here, because they have Node.js dependencies
require('./js/logging');
require('./js/spell_check');
require('./js/backup');
window.nodeSetImmediate = setImmediate;
window.nodeWebSocket = require("websocket").w3cwebsocket;
// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(function() {
window.nodeSetImmediate(function() {});
}, 1000);
window.EmojiConvertor = require('emoji-js');
window.nodeFetch = require('node-fetch');
window.httpsAgent = require('https').Agent;
window.nodeBuffer = Buffer;
})();