diff options
author | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2021-10-02 05:47:36 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-02 05:47:36 +0530 |
commit | 7612949b153ca25b8d36920732dd37defec7a581 (patch) | |
tree | 17cf03fce793afb1a51ffdb778a47e36cc39fd50 /src/electron-util.ts | |
parent | fix: fix issue with past commit related to 'environment-remote' (diff) | |
download | ferdium-app-7612949b153ca25b8d36920732dd37defec7a581.tar.gz ferdium-app-7612949b153ca25b8d36920732dd37defec7a581.tar.zst ferdium-app-7612949b153ca25b8d36920732dd37defec7a581.zip |
refactor: remove 'electron-util' and 'electron-is-dev' as dependencies (#2008)
(pre-requisite for electron v14)
Diffstat (limited to 'src/electron-util.ts')
-rw-r--r-- | src/electron-util.ts | 30 |
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 | |||
3 | import electron from 'electron'; | ||
4 | import { initialize } from '@electron/remote/main'; | ||
5 | |||
6 | export 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 | |||
14 | export 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 | |||
22 | export 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 | }); | ||