diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-07-06 13:15:57 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-07-12 10:09:19 +0200 |
| commit | f3191b3d5d50b6aec641d0d0167f86085eba31c1 (patch) | |
| tree | 24ed35a363234da45155c51cd5614c6e01b5998e /gui | |
| parent | a2fa8669485e4d3188cb2e3392b8e292bde70d7c (diff) | |
| download | mullvadvpn-f3191b3d5d50b6aec641d0d0167f86085eba31c1.tar.xz mullvadvpn-f3191b3d5d50b6aec641d0d0167f86085eba31c1.zip | |
Retrieve platform and node env in preload
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/main/index.ts | 2 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 3 | ||||
| -rw-r--r-- | gui/src/renderer/preload.ts | 5 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 2 | ||||
| -rw-r--r-- | gui/tasks/scripts.js | 1 | ||||
| -rw-r--r-- | gui/types/global/index.d.ts | 3 |
6 files changed, 7 insertions, 9 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 4377b0a9b2..8cacf4a7b7 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1085,8 +1085,6 @@ class ApplicationMain { guiSettings: this.guiSettings.state, wireguardPublicKey: this.wireguardPublicKey, translations: this.translations, - platform: process.platform, - runningInDevelopment: process.env.NODE_ENV === 'development', windowsSplitTunnelingApplications: this.windowsSplitTunnelingApplications, })); diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index febcaf8bc8..681086ee0a 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -208,9 +208,6 @@ export default class AppRenderer { // Request the initial state from the main process const initialState = IpcRendererEventChannel.state.get(); - window.platform = initialState.platform; - window.runningInDevelopment = initialState.runningInDevelopment; - this.setLocale(initialState.locale); loadTranslations( messages, diff --git a/gui/src/renderer/preload.ts b/gui/src/renderer/preload.ts index 5c44b71eeb..4df178fcc2 100644 --- a/gui/src/renderer/preload.ts +++ b/gui/src/renderer/preload.ts @@ -2,3 +2,8 @@ import { contextBridge } from 'electron'; import { IpcRendererEventChannel } from './lib/ipc-event-channel'; contextBridge.exposeInMainWorld('ipc', IpcRendererEventChannel); + +contextBridge.exposeInMainWorld('env', { + development: process.env.NODE_ENV === 'development', + platform: process.platform, +}); diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index e2b3ebbed3..f463765a32 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -54,8 +54,6 @@ export interface IAppStateSnapshot { guiSettings: IGuiSettingsState; wireguardPublicKey?: IWireguardPublicKey; translations: ITranslations; - platform: NodeJS.Platform; - runningInDevelopment: boolean; windowsSplitTunnelingApplications?: IApplication[]; } diff --git a/gui/tasks/scripts.js b/gui/tasks/scripts.js index eda057d983..ec38c7c3fa 100644 --- a/gui/tasks/scripts.js +++ b/gui/tasks/scripts.js @@ -82,6 +82,7 @@ function makeBrowserifyPreload(debug) { let stream = browserify({ entries: './build/src/renderer/preload.js', debug, + detectGlobals: false, }) .exclude('electron') .bundle() diff --git a/gui/types/global/index.d.ts b/gui/types/global/index.d.ts index 9065f4d8a5..fe60baf4ca 100644 --- a/gui/types/global/index.d.ts +++ b/gui/types/global/index.d.ts @@ -3,7 +3,6 @@ import { IpcRendererEventChannel } from '../../src/renderer/lib/ipc-event-channe declare global { interface Window { ipc: typeof IpcRendererEventChannel; - platform: NodeJS.Platform; - runningInDevelopment: boolean; + env: { platform: NodeJS.Platform; development: boolean }; } } |
