-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'f7c6cc14592f6af21d8922ae7a477e871a88c91e' into release
- Loading branch information
Showing
7 changed files
with
2,548 additions
and
6 deletions.
There are no files selected for viewing
Submodule drawio
updated
21 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
disableUpdate: function() | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const { | ||
contextBridge, | ||
ipcRenderer | ||
} = require("electron"); | ||
|
||
let reqId = 1; | ||
let reqInfo = {}; | ||
let fileChangedListeners = {}; | ||
|
||
ipcRenderer.on('mainResp', (event, resp) => | ||
{ | ||
var callbacks = reqInfo[resp.reqId]; | ||
|
||
if (resp.error) | ||
{ | ||
callbacks.error(resp.msg, resp.e); | ||
} | ||
else | ||
{ | ||
callbacks.callback(resp.data); | ||
} | ||
|
||
delete reqInfo[resp.reqId]; | ||
}); | ||
|
||
ipcRenderer.on('fileChanged', (event, resp) => | ||
{ | ||
var listener = fileChangedListeners[resp.path]; | ||
|
||
if (listener) | ||
{ | ||
listener(resp.curr, resp.prev); | ||
} | ||
}); | ||
|
||
contextBridge.exposeInMainWorld( | ||
'electron', { | ||
request: (msg, callback, error) => | ||
{ | ||
msg.reqId = reqId++; | ||
reqInfo[msg.reqId] = {callback: callback, error: error}; | ||
|
||
//TODO Maybe a special function for this better than this hack? | ||
//File watch special case where the callback is called multiple times | ||
if (msg.action == 'watchFile') | ||
{ | ||
fileChangedListeners[msg.path] = msg.listener; | ||
delete msg.listener; | ||
} | ||
|
||
ipcRenderer.send('rendererReq', msg); | ||
}, | ||
registerMsgListener: function(action, callback) | ||
{ | ||
ipcRenderer.on(action, function(event, args) | ||
{ | ||
callback(args); | ||
}); | ||
}, | ||
sendMessage: function(action, args) | ||
{ | ||
ipcRenderer.send(action, args); | ||
}, | ||
listenOnce: function(action, callback) | ||
{ | ||
ipcRenderer.once(action, function(event, args) | ||
{ | ||
callback(args); | ||
}); | ||
} | ||
} | ||
); | ||
|
||
contextBridge.exposeInMainWorld( | ||
'process', { | ||
type: process.type, | ||
versions: process.versions | ||
} | ||
); |
Oops, something went wrong.