-
Notifications
You must be signed in to change notification settings - Fork 2
/
preload.js
94 lines (73 loc) · 1.93 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// ==============
// Preload script
// ==============
const {ipcRenderer,shell} = require('electron');
const remote = require('@electron/remote');
const machine = remote.require('./machine')
window.interop = {
getGitInfo(dir) {
return machine.getGitInfo(dir);
},
selectDirectory(o) {
var opts = Object.assign({
title: "Open folder...",
message: "Open folder...",
properties: ['openDirectory']
},o || {});
var res = remote.dialog.showOpenDialogSync(remote.getCurrentWindow(),opts);
return res && res[0];
},
ipcSend(channel,args){
ipcRenderer.send(channel,args);
},
ipcListen(channel,cb){
ipcRenderer.on(channel,cb);
},
ipc: {
on(channel,cb){
ipcRenderer.on(channel,cb);
},
send(channel,args){
ipcRenderer.send(channel,args);
},
openExternal(url){
shell.openExternal(url);
},
openEditor(data) {
return machine.openEditor(data)
},
getAvailableEditors() {
return machine.getAvailableEditors()
},
getSync(key){
return ipcRenderer.sendSync('state.get',key)
},
getGitInfo(dir) {
return machine.getGitInfo(dir);
},
fstat(dir) {
return ipcRenderer.sendSync('fstat',dir)
// return machine.fstat(dir);
},
tunnelUrl(){
let port = this.getSync('tunnelPort');
return "ws://127.0.0.1:" + port;
},
setBadgeCount(count) {
return remote.app.setBadgeCount(count);
},
getGitBlob(localDirectory, sha, refToFetch) {
return machine.getGitBlob(localDirectory, sha, refToFetch)
},
getGitTree(localDirectory, sha, refToFetch) {
return machine.getGitTree(localDirectory, sha, refToFetch)
},
getGitDiff(localDirectory, base, head, includePatch) {
return machine.getGitDiff(localDirectory, base, head, includePatch)
},
sendNotification(data){
new machine.Notification(data).show();
},
},
win: remote.getCurrentWindow()
};