diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/webview/lib/RecipeWebview.js | 32 | ||||
-rw-r--r-- | src/webview/recipe.js | 16 |
3 files changed, 39 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f60e651..7491c3932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -3,6 +3,8 @@ | |||
3 | ### Under the hood | 3 | ### Under the hood |
4 | 4 | ||
5 | - Progressing towards converting the whole code base from JS to TS (#1959) 💖 @mhatvan | 5 | - Progressing towards converting the whole code base from JS to TS (#1959) 💖 @mhatvan |
6 | - Fix accent color customization (#1963) (#1965) 💖 @kris7t | ||
7 | - Improved context isolation for sandboxing services (#1964) 💖 @kris7t | ||
6 | 8 | ||
7 | # [v5.6.3-nightly.4](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.3...v5.6.3-nightly.4) (2021-09-16) | 9 | # [v5.6.3-nightly.4](https://github.com/getferdi/ferdi/compare/v5.6.3-nightly.3...v5.6.3-nightly.4) (2021-09-16) |
8 | 10 | ||
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index 4085b925b..a4951ed69 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js | |||
@@ -1,12 +1,14 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { BrowserWindow, desktopCapturer, getCurrentWebContents } from '@electron/remote'; | ||
2 | import { pathExistsSync, readFileSync, existsSync } from 'fs-extra'; | 3 | import { pathExistsSync, readFileSync, existsSync } from 'fs-extra'; |
3 | 4 | ||
4 | const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); | 5 | const debug = require('debug')('Ferdi:Plugin:RecipeWebview'); |
5 | 6 | ||
6 | class RecipeWebview { | 7 | class RecipeWebview { |
7 | constructor(badgeHandler, notificationsHandler) { | 8 | constructor(badgeHandler, notificationsHandler, sessionHandler) { |
8 | this.badgeHandler = badgeHandler; | 9 | this.badgeHandler = badgeHandler; |
9 | this.notificationsHandler = notificationsHandler; | 10 | this.notificationsHandler = notificationsHandler; |
11 | this.sessionHandler = sessionHandler; | ||
10 | 12 | ||
11 | ipcRenderer.on('poll', () => { | 13 | ipcRenderer.on('poll', () => { |
12 | this.loopFunc(); | 14 | this.loopFunc(); |
@@ -23,6 +25,26 @@ class RecipeWebview { | |||
23 | 25 | ||
24 | darkModeHandler = false; | 26 | darkModeHandler = false; |
25 | 27 | ||
28 | // TODO Remove this once we implement a proper wrapper. | ||
29 | get ipcRenderer() { | ||
30 | return ipcRenderer; | ||
31 | } | ||
32 | |||
33 | // TODO Remove this once we implement a proper wrapper. | ||
34 | get desktopCapturer() { | ||
35 | return desktopCapturer; | ||
36 | } | ||
37 | |||
38 | // TODO Remove this once we implement a proper wrapper. | ||
39 | get BrowserWindow() { | ||
40 | return BrowserWindow; | ||
41 | } | ||
42 | |||
43 | // TODO Remove this once we implement a proper wrapper. | ||
44 | get getCurrentWebContents() { | ||
45 | return getCurrentWebContents; | ||
46 | } | ||
47 | |||
26 | /** | 48 | /** |
27 | * Initialize the loop | 49 | * Initialize the loop |
28 | * | 50 | * |
@@ -113,6 +135,14 @@ class RecipeWebview { | |||
113 | fn(); | 135 | fn(); |
114 | } | 136 | } |
115 | } | 137 | } |
138 | |||
139 | clearStorageData(storageLocations) { | ||
140 | this.sessionHandler.clearStorageData(storageLocations); | ||
141 | } | ||
142 | |||
143 | releaseServiceWorkers() { | ||
144 | this.sessionHandler.releaseServiceWorkers(); | ||
145 | } | ||
116 | } | 146 | } |
117 | 147 | ||
118 | export default RecipeWebview; | 148 | export default RecipeWebview; |
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index d7032da3f..32df0f756 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -1,7 +1,6 @@ | |||
1 | /* eslint-disable global-require */ | 1 | /* eslint-disable global-require */ |
2 | /* eslint-disable import/first */ | 2 | /* eslint-disable import/first */ |
3 | import { contextBridge, desktopCapturer, ipcRenderer } from 'electron'; | 3 | import { contextBridge, ipcRenderer } from 'electron'; |
4 | import { BrowserWindow, getCurrentWebContents } from '@electron/remote'; | ||
5 | import { join } from 'path'; | 4 | import { join } from 'path'; |
6 | import { autorun, computed, observable } from 'mobx'; | 5 | import { autorun, computed, observable } from 'mobx'; |
7 | import { pathExistsSync, readFileSync } from 'fs-extra'; | 6 | import { pathExistsSync, readFileSync } from 'fs-extra'; |
@@ -109,15 +108,8 @@ contextBridge.exposeInMainWorld('ferdi', { | |||
109 | safeParseInt: text => badgeHandler.safeParseInt(text), | 108 | safeParseInt: text => badgeHandler.safeParseInt(text), |
110 | displayNotification: (title, options) => | 109 | displayNotification: (title, options) => |
111 | notificationsHandler.displayNotification(title, options), | 110 | notificationsHandler.displayNotification(title, options), |
112 | clearStorageData: storageLocations => | ||
113 | sessionHandler.clearStorageData(storageLocations), | ||
114 | releaseServiceWorkers: () => sessionHandler.releaseServiceWorkers(), | 111 | releaseServiceWorkers: () => sessionHandler.releaseServiceWorkers(), |
115 | getDisplayMediaSelector, | 112 | getDisplayMediaSelector, |
116 | getCurrentWebContents, | ||
117 | BrowserWindow, | ||
118 | ipcRenderer, | ||
119 | // TODO: When the discord recipe is changed to use the screenshare.js, this can be removed | ||
120 | desktopCapturer, | ||
121 | }); | 113 | }); |
122 | 114 | ||
123 | ipcRenderer.sendToHost( | 115 | ipcRenderer.sendToHost( |
@@ -207,7 +199,11 @@ class RecipeController { | |||
207 | // Delete module from cache | 199 | // Delete module from cache |
208 | delete require.cache[require.resolve(modulePath)]; | 200 | delete require.cache[require.resolve(modulePath)]; |
209 | try { | 201 | try { |
210 | this.recipe = new RecipeWebview(badgeHandler, notificationsHandler); | 202 | this.recipe = new RecipeWebview( |
203 | badgeHandler, | ||
204 | notificationsHandler, | ||
205 | sessionHandler, | ||
206 | ); | ||
211 | // eslint-disable-next-line import/no-dynamic-require | 207 | // eslint-disable-next-line import/no-dynamic-require |
212 | require(modulePath)(this.recipe, { ...config, recipe }); | 208 | require(modulePath)(this.recipe, { ...config, recipe }); |
213 | debug('Initialize Recipe', config, recipe); | 209 | debug('Initialize Recipe', config, recipe); |