aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron-util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/electron-util.ts')
-rw-r--r--src/electron-util.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/electron-util.ts b/src/electron-util.ts
new file mode 100644
index 000000000..f4b26cb10
--- /dev/null
+++ b/src/electron-util.ts
@@ -0,0 +1,30 @@
1// Enhanced from: https://github.com/dertieran/electron-util/blob/replace-remote/source/api.js
2
3import electron from 'electron';
4import { initialize } from '@electron/remote/main';
5
6export const initializeRemote = () => {
7 if (process.type !== 'browser') {
8 throw new Error('The remote api must be initialized from the main process.');
9 }
10
11 initialize();
12};
13
14export const remote = new Proxy({}, {
15 get: (_target, property) => {
16 // eslint-disable-next-line global-require
17 const remote = require('@electron/remote');
18 return remote[property];
19 },
20});
21
22export const api = new Proxy(electron, {
23 get: (target, property) => {
24 if (target[property]) {
25 return target[property];
26 }
27
28 return remote[property];
29 },
30});