diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-04-23 01:59:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 23:59:21 +0000 |
commit | d02644f7c41150709795e57bfd40351b4da35a7b (patch) | |
tree | 2403fb76bd5fae1703f8b55172ffce9e0a5d2bce /src/features/basicAuth | |
parent | Complete tray icons redesign for all platforms (#28) (diff) | |
download | ferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.tar.gz ferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.tar.zst ferdium-app-d02644f7c41150709795e57bfd40351b4da35a7b.zip |
Preload safe debug shim (#29)
In https://github.com/ferdium/ferdium-app/pull/23 we removed usages of
the debug package due to an electron bug.
This patch aims to restore some debug functionality by introducing a
shim. The shim detect whether if it is being introduced in a preload
script where the electron but would be triggered, and falls back to a
simple replacement for debug. However, in the main and renderer
processes, where a preload script is not being used, we still get full
debug functionality.
In this way, a module can be used both in a preload script and outside
of it, while still preserving debug functionality whenever possible.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'src/features/basicAuth')
-rw-r--r-- | src/features/basicAuth/index.ts | 2 | ||||
-rw-r--r-- | src/features/basicAuth/mainIpcHandler.ts | 2 | ||||
-rw-r--r-- | src/features/basicAuth/store.ts | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/src/features/basicAuth/index.ts b/src/features/basicAuth/index.ts index dd02a3bdc..ae698cba8 100644 --- a/src/features/basicAuth/index.ts +++ b/src/features/basicAuth/index.ts | |||
@@ -2,7 +2,7 @@ import { AuthInfo, BrowserWindow, ipcRenderer } from 'electron'; | |||
2 | 2 | ||
3 | import { state as ModalState } from './store'; | 3 | import { state as ModalState } from './store'; |
4 | 4 | ||
5 | const debug = require('debug')('Ferdium:feature:basicAuth'); | 5 | const debug = require('../../preload-safe-debug')('Ferdium:feature:basicAuth'); |
6 | 6 | ||
7 | const state = ModalState; | 7 | const state = ModalState; |
8 | 8 | ||
diff --git a/src/features/basicAuth/mainIpcHandler.ts b/src/features/basicAuth/mainIpcHandler.ts index 2f78b1497..5d320df5c 100644 --- a/src/features/basicAuth/mainIpcHandler.ts +++ b/src/features/basicAuth/mainIpcHandler.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { BrowserWindow } from 'electron'; | 1 | import { BrowserWindow } from 'electron'; |
2 | 2 | ||
3 | const debug = require('debug')('Ferdium:feature:basicAuth:main'); | 3 | const debug = require('../../preload-safe-debug')('Ferdium:feature:basicAuth:main'); |
4 | 4 | ||
5 | export default function mainIpcHandler(mainWindow: BrowserWindow, authInfo) { | 5 | export default function mainIpcHandler(mainWindow: BrowserWindow, authInfo) { |
6 | debug('Sending basic auth call', authInfo); | 6 | debug('Sending basic auth call', authInfo); |
diff --git a/src/features/basicAuth/store.ts b/src/features/basicAuth/store.ts index 4b71d32fd..e0ae8ba17 100644 --- a/src/features/basicAuth/store.ts +++ b/src/features/basicAuth/store.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { observable } from 'mobx'; | 1 | import { observable } from 'mobx'; |
2 | import { ipcRenderer } from 'electron'; | 2 | import { ipcRenderer } from 'electron'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdium:feature:basicAuth'); | 4 | const debug = require('../../preload-safe-debug')('Ferdium:feature:basicAuth'); |
5 | 5 | ||
6 | const defaultState = { | 6 | const defaultState = { |
7 | isModalVisible: true, | 7 | isModalVisible: true, |