blob: f4b26cb10aabe059c47d8781168301fbc30592dc (
plain) (
blame)
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
|
// Enhanced from: https://github.com/dertieran/electron-util/blob/replace-remote/source/api.js
import electron from 'electron';
import { initialize } from '@electron/remote/main';
export const initializeRemote = () => {
if (process.type !== 'browser') {
throw new Error('The remote api must be initialized from the main process.');
}
initialize();
};
export const remote = new Proxy({}, {
get: (_target, property) => {
// eslint-disable-next-line global-require
const remote = require('@electron/remote');
return remote[property];
},
});
export const api = new Proxy(electron, {
get: (target, property) => {
if (target[property]) {
return target[property];
}
return remote[property];
},
});
|