diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/badge.ts | 5 | ||||
-rw-r--r-- | src/webview/darkmode.ts | 7 | ||||
-rw-r--r-- | src/webview/dialogTitle.ts | 5 | ||||
-rw-r--r-- | src/webview/lib/RecipeWebview.ts | 11 | ||||
-rw-r--r-- | src/webview/notifications.ts | 5 | ||||
-rw-r--r-- | src/webview/recipe.js | 57 | ||||
-rw-r--r-- | src/webview/sessionHandler.ts | 7 | ||||
-rw-r--r-- | src/webview/spellchecker.ts | 9 |
8 files changed, 49 insertions, 57 deletions
diff --git a/src/webview/badge.ts b/src/webview/badge.ts index 0ff1ecaf6..898f8cdcf 100644 --- a/src/webview/badge.ts +++ b/src/webview/badge.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | 2 | ||
3 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 3 | const debug = require('../preload-safe-debug')('Ferdium:Plugin:BadgeHandler'); |
4 | // const debug = require('debug')('Ferdium:Plugin:BadgeHandler'); | ||
5 | 4 | ||
6 | export class BadgeHandler { | 5 | export class BadgeHandler { |
7 | // TODO: Need to extract this into a utility class and reuse outside of the recipes | 6 | // TODO: Need to extract this into a utility class and reuse outside of the recipes |
@@ -27,7 +26,7 @@ export class BadgeHandler { | |||
27 | indirect: this.safeParseInt(indirect), | 26 | indirect: this.safeParseInt(indirect), |
28 | }; | 27 | }; |
29 | 28 | ||
30 | console.log('Sending badge count to host: %j', count); | 29 | debug('Sending badge count to host: %j', count); |
31 | ipcRenderer.sendToHost('message-counts', count); | 30 | ipcRenderer.sendToHost('message-counts', count); |
32 | } | 31 | } |
33 | } | 32 | } |
diff --git a/src/webview/darkmode.ts b/src/webview/darkmode.ts index 99ee68757..34f987b51 100644 --- a/src/webview/darkmode.ts +++ b/src/webview/darkmode.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { join } from 'path'; | 1 | import { join } from 'path'; |
2 | import { pathExistsSync, readFileSync } from 'fs-extra'; | 2 | import { pathExistsSync, readFileSync } from 'fs-extra'; |
3 | 3 | ||
4 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 4 | const debug = require('../preload-safe-debug')('Ferdium:DarkMode'); |
5 | // const debug = require('debug')('Ferdium:DarkMode'); | ||
6 | 5 | ||
7 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; | 6 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; |
8 | 7 | ||
@@ -27,7 +26,7 @@ export function injectDarkModeStyle(recipePath: string) { | |||
27 | 26 | ||
28 | document.querySelector('head')?.appendChild(styles); | 27 | document.querySelector('head')?.appendChild(styles); |
29 | 28 | ||
30 | console.log('Injected Dark Mode style with ID', ID); | 29 | debug('Injected Dark Mode style with ID', ID); |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
@@ -37,7 +36,7 @@ export function removeDarkModeStyle() { | |||
37 | if (style) { | 36 | if (style) { |
38 | style.remove(); | 37 | style.remove(); |
39 | 38 | ||
40 | console.log('Removed Dark Mode Style with ID', ID); | 39 | debug('Removed Dark Mode Style with ID', ID); |
41 | } | 40 | } |
42 | } | 41 | } |
43 | 42 | ||
diff --git a/src/webview/dialogTitle.ts b/src/webview/dialogTitle.ts index a5bcb4c41..12e007e26 100644 --- a/src/webview/dialogTitle.ts +++ b/src/webview/dialogTitle.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | 2 | ||
3 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 3 | const debug = require('../preload-safe-debug')('Ferdium:Plugin:DialogTitleHandler'); |
4 | // const debug = require('debug')('Ferdium:Plugin:DialogTitleHandler'); | ||
5 | 4 | ||
6 | export class DialogTitleHandler { | 5 | export class DialogTitleHandler { |
7 | titleCache: { title: string }; | 6 | titleCache: { title: string }; |
@@ -26,7 +25,7 @@ export class DialogTitleHandler { | |||
26 | return; | 25 | return; |
27 | } | 26 | } |
28 | 27 | ||
29 | console.log('Sending active dialog title to host %s', newTitle); | 28 | debug('Sending active dialog title to host %s', newTitle); |
30 | ipcRenderer.sendToHost('active-dialog-title', newTitle); | 29 | ipcRenderer.sendToHost('active-dialog-title', newTitle); |
31 | 30 | ||
32 | this.titleCache.title = newTitle; | 31 | this.titleCache.title = newTitle; |
diff --git a/src/webview/lib/RecipeWebview.ts b/src/webview/lib/RecipeWebview.ts index cf70164ef..e7a39579b 100644 --- a/src/webview/lib/RecipeWebview.ts +++ b/src/webview/lib/RecipeWebview.ts | |||
@@ -2,8 +2,7 @@ import { ipcRenderer } from 'electron'; | |||
2 | import { BrowserWindow } from '@electron/remote'; | 2 | import { BrowserWindow } from '@electron/remote'; |
3 | import { pathExistsSync, readFileSync, existsSync } from 'fs-extra'; | 3 | import { pathExistsSync, readFileSync, existsSync } from 'fs-extra'; |
4 | 4 | ||
5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 5 | const debug = require('../../preload-safe-debug')('Ferdium:Plugin:RecipeWebview'); |
6 | // const debug = require('debug')('Ferdium:Plugin:RecipeWebview'); | ||
7 | 6 | ||
8 | class RecipeWebview { | 7 | class RecipeWebview { |
9 | badgeHandler: any; | 8 | badgeHandler: any; |
@@ -28,7 +27,7 @@ class RecipeWebview { | |||
28 | ipcRenderer.on('poll', () => { | 27 | ipcRenderer.on('poll', () => { |
29 | this.loopFunc(); | 28 | this.loopFunc(); |
30 | 29 | ||
31 | console.log('Poll event'); | 30 | debug('Poll event'); |
32 | 31 | ||
33 | // This event is for checking if the service recipe is still actively | 32 | // This event is for checking if the service recipe is still actively |
34 | // communicating with the client | 33 | // communicating with the client |
@@ -110,7 +109,7 @@ class RecipeWebview { | |||
110 | 109 | ||
111 | if (head) { | 110 | if (head) { |
112 | head.append(styles); | 111 | head.append(styles); |
113 | console.log('Append styles', styles); | 112 | debug('Append styles', styles); |
114 | } | 113 | } |
115 | } | 114 | } |
116 | }); | 115 | }); |
@@ -122,13 +121,13 @@ class RecipeWebview { | |||
122 | if (existsSync(file)) { | 121 | if (existsSync(file)) { |
123 | return readFileSync(file, 'utf8'); | 122 | return readFileSync(file, 'utf8'); |
124 | } | 123 | } |
125 | console.log('Script not found', file); | 124 | debug('Script not found', file); |
126 | return null; | 125 | return null; |
127 | }), | 126 | }), |
128 | ).then(scripts => { | 127 | ).then(scripts => { |
129 | const scriptsFound = scripts.filter(script => script !== null); | 128 | const scriptsFound = scripts.filter(script => script !== null); |
130 | if (scriptsFound.length > 0) { | 129 | if (scriptsFound.length > 0) { |
131 | console.log('Inject scripts to main world', scriptsFound); | 130 | debug('Inject scripts to main world', scriptsFound); |
132 | ipcRenderer.sendToHost('inject-js-unsafe', ...scriptsFound); | 131 | ipcRenderer.sendToHost('inject-js-unsafe', ...scriptsFound); |
133 | } | 132 | } |
134 | }); | 133 | }); |
diff --git a/src/webview/notifications.ts b/src/webview/notifications.ts index ff9c844d0..8b2831754 100644 --- a/src/webview/notifications.ts +++ b/src/webview/notifications.ts | |||
@@ -2,8 +2,7 @@ import { ipcRenderer } from 'electron'; | |||
2 | 2 | ||
3 | import { v1 as uuidV1 } from 'uuid'; | 3 | import { v1 as uuidV1 } from 'uuid'; |
4 | 4 | ||
5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 5 | const debug = require('../preload-safe-debug')('Ferdium:Notifications'); |
6 | // const debug = require('debug')('Ferdium:Notifications'); | ||
7 | 6 | ||
8 | export class NotificationsHandler { | 7 | export class NotificationsHandler { |
9 | onNotify = (data: { title: string; options: any; notificationId: string }) => | 8 | onNotify = (data: { title: string; options: any; notificationId: string }) => |
@@ -11,7 +10,7 @@ export class NotificationsHandler { | |||
11 | 10 | ||
12 | displayNotification(title: string, options: any) { | 11 | displayNotification(title: string, options: any) { |
13 | return new Promise(resolve => { | 12 | return new Promise(resolve => { |
14 | console.log('New notification', title, options); | 13 | debug('New notification', title, options); |
15 | 14 | ||
16 | const notificationId = uuidV1(); | 15 | const notificationId = uuidV1(); |
17 | 16 | ||
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 1f3017ccd..eff20c2d3 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -50,8 +50,7 @@ import { | |||
50 | 50 | ||
51 | import { DEFAULT_APP_SETTINGS } from '../config'; | 51 | import { DEFAULT_APP_SETTINGS } from '../config'; |
52 | 52 | ||
53 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 53 | const debug = require('../preload-safe-debug')('Ferdium:Plugin'); |
54 | // const debug = require('debug')('Ferdium:Plugin'); | ||
55 | 54 | ||
56 | const badgeHandler = new BadgeHandler(); | 55 | const badgeHandler = new BadgeHandler(); |
57 | 56 | ||
@@ -65,7 +64,7 @@ const notificationsHandler = new NotificationsHandler(); | |||
65 | const originalWindowOpen = window.open; | 64 | const originalWindowOpen = window.open; |
66 | 65 | ||
67 | window.open = (url, frameName, features) => { | 66 | window.open = (url, frameName, features) => { |
68 | console.log('window.open', url, frameName, features); | 67 | debug('window.open', url, frameName, features); |
69 | if (!url) { | 68 | if (!url) { |
70 | // The service hasn't yet supplied a URL (as used in Skype). | 69 | // The service hasn't yet supplied a URL (as used in Skype). |
71 | // Return a new dummy window object and wait for the service to change the properties | 70 | // Return a new dummy window object and wait for the service to change the properties |
@@ -171,12 +170,12 @@ class RecipeController { | |||
171 | async initialize() { | 170 | async initialize() { |
172 | for (const channel of Object.keys(this.ipcEvents)) { | 171 | for (const channel of Object.keys(this.ipcEvents)) { |
173 | ipcRenderer.on(channel, (...args) => { | 172 | ipcRenderer.on(channel, (...args) => { |
174 | console.log('Received IPC event for channel', channel, 'with', ...args); | 173 | debug('Received IPC event for channel', channel, 'with', ...args); |
175 | this[this.ipcEvents[channel]](...args); | 174 | this[this.ipcEvents[channel]](...args); |
176 | }); | 175 | }); |
177 | } | 176 | } |
178 | 177 | ||
179 | console.log('Send "hello" to host'); | 178 | debug('Send "hello" to host'); |
180 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); | 179 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); |
181 | 180 | ||
182 | this.spellcheckingProvider = null; | 181 | this.spellcheckingProvider = null; |
@@ -199,9 +198,9 @@ class RecipeController { | |||
199 | } | 198 | } |
200 | 199 | ||
201 | loadRecipeModule(event, config, recipe) { | 200 | loadRecipeModule(event, config, recipe) { |
202 | console.log('loadRecipeModule'); | 201 | debug('loadRecipeModule'); |
203 | const modulePath = join(recipe.path, 'webview.js'); | 202 | const modulePath = join(recipe.path, 'webview.js'); |
204 | console.log('module path', modulePath); | 203 | debug('module path', modulePath); |
205 | // Delete module from cache | 204 | // Delete module from cache |
206 | delete require.cache[require.resolve(modulePath)]; | 205 | delete require.cache[require.resolve(modulePath)]; |
207 | try { | 206 | try { |
@@ -214,7 +213,7 @@ class RecipeController { | |||
214 | if (existsSync(modulePath)) { | 213 | if (existsSync(modulePath)) { |
215 | // eslint-disable-next-line import/no-dynamic-require | 214 | // eslint-disable-next-line import/no-dynamic-require |
216 | require(modulePath)(this.recipe, { ...config, recipe }); | 215 | require(modulePath)(this.recipe, { ...config, recipe }); |
217 | console.log('Initialize Recipe', config, recipe); | 216 | debug('Initialize Recipe', config, recipe); |
218 | } | 217 | } |
219 | 218 | ||
220 | this.settings.service = Object.assign(config, { recipe }); | 219 | this.settings.service = Object.assign(config, { recipe }); |
@@ -266,18 +265,18 @@ class RecipeController { | |||
266 | } | 265 | } |
267 | 266 | ||
268 | update() { | 267 | update() { |
269 | console.log('enableSpellchecking', this.settings.app.enableSpellchecking); | 268 | debug('enableSpellchecking', this.settings.app.enableSpellchecking); |
270 | console.log('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); | 269 | debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); |
271 | console.log( | 270 | debug( |
272 | 'System spellcheckerLanguage', | 271 | 'System spellcheckerLanguage', |
273 | this.settings.app.spellcheckerLanguage, | 272 | this.settings.app.spellcheckerLanguage, |
274 | ); | 273 | ); |
275 | console.log( | 274 | debug( |
276 | 'Service spellcheckerLanguage', | 275 | 'Service spellcheckerLanguage', |
277 | this.settings.service.spellcheckerLanguage, | 276 | this.settings.service.spellcheckerLanguage, |
278 | ); | 277 | ); |
279 | console.log('darkReaderSettigs', this.settings.service.darkReaderSettings); | 278 | debug('darkReaderSettigs', this.settings.service.darkReaderSettings); |
280 | console.log('searchEngine', this.settings.app.searchEngine); | 279 | debug('searchEngine', this.settings.app.searchEngine); |
281 | 280 | ||
282 | if (this.userscript && this.userscript.internal_setSettings) { | 281 | if (this.userscript && this.userscript.internal_setSettings) { |
283 | this.userscript.internal_setSettings(this.settings); | 282 | this.userscript.internal_setSettings(this.settings); |
@@ -285,10 +284,10 @@ class RecipeController { | |||
285 | 284 | ||
286 | if (this.settings.app.enableSpellchecking) { | 285 | if (this.settings.app.enableSpellchecking) { |
287 | let { spellcheckerLanguage } = this; | 286 | let { spellcheckerLanguage } = this; |
288 | console.log(`Setting spellchecker language to ${spellcheckerLanguage}`); | 287 | debug(`Setting spellchecker language to ${spellcheckerLanguage}`); |
289 | if (spellcheckerLanguage.includes('automatic')) { | 288 | if (spellcheckerLanguage.includes('automatic')) { |
290 | this.automaticLanguageDetection(); | 289 | this.automaticLanguageDetection(); |
291 | console.log( | 290 | debug( |
292 | 'Found `automatic` locale, falling back to user locale until detected', | 291 | 'Found `automatic` locale, falling back to user locale until detected', |
293 | this.settings.app.locale, | 292 | this.settings.app.locale, |
294 | ); | 293 | ); |
@@ -296,14 +295,14 @@ class RecipeController { | |||
296 | } | 295 | } |
297 | switchDict(spellcheckerLanguage, this.settings.service.id); | 296 | switchDict(spellcheckerLanguage, this.settings.service.id); |
298 | } else { | 297 | } else { |
299 | console.log('Disable spellchecker'); | 298 | debug('Disable spellchecker'); |
300 | } | 299 | } |
301 | 300 | ||
302 | if (!this.recipe) { | 301 | if (!this.recipe) { |
303 | this.hasUpdatedBeforeRecipeLoaded = true; | 302 | this.hasUpdatedBeforeRecipeLoaded = true; |
304 | } | 303 | } |
305 | 304 | ||
306 | console.log( | 305 | debug( |
307 | 'Darkmode enabled?', | 306 | 'Darkmode enabled?', |
308 | this.settings.service.isDarkModeEnabled, | 307 | this.settings.service.isDarkModeEnabled, |
309 | 'Dark theme active?', | 308 | 'Dark theme active?', |
@@ -323,11 +322,11 @@ class RecipeController { | |||
323 | this.settings.service.isDarkModeEnabled && | 322 | this.settings.service.isDarkModeEnabled && |
324 | this.settings.app.isDarkThemeActive !== false | 323 | this.settings.app.isDarkThemeActive !== false |
325 | ) { | 324 | ) { |
326 | console.log('Enable dark mode'); | 325 | debug('Enable dark mode'); |
327 | 326 | ||
328 | // Check if recipe has a custom dark mode handler | 327 | // Check if recipe has a custom dark mode handler |
329 | if (this.recipe && this.recipe.darkModeHandler) { | 328 | if (this.recipe && this.recipe.darkModeHandler) { |
330 | console.log('Using custom dark mode handler'); | 329 | debug('Using custom dark mode handler'); |
331 | 330 | ||
332 | // Remove other dark mode styles if they were already loaded | 331 | // Remove other dark mode styles if they were already loaded |
333 | if (this.hasUpdatedBeforeRecipeLoaded) { | 332 | if (this.hasUpdatedBeforeRecipeLoaded) { |
@@ -338,7 +337,7 @@ class RecipeController { | |||
338 | 337 | ||
339 | this.recipe.darkModeHandler(true, handlerConfig); | 338 | this.recipe.darkModeHandler(true, handlerConfig); |
340 | } else if (darkModeStyleExists(this.settings.service.recipe.path)) { | 339 | } else if (darkModeStyleExists(this.settings.service.recipe.path)) { |
341 | console.log('Injecting darkmode from recipe'); | 340 | debug('Injecting darkmode from recipe'); |
342 | injectDarkModeStyle(this.settings.service.recipe.path); | 341 | injectDarkModeStyle(this.settings.service.recipe.path); |
343 | 342 | ||
344 | // Make sure universal dark mode is disabled | 343 | // Make sure universal dark mode is disabled |
@@ -348,7 +347,7 @@ class RecipeController { | |||
348 | this.settings.app.universalDarkMode && | 347 | this.settings.app.universalDarkMode && |
349 | !ignoreList.includes(window.location.host) | 348 | !ignoreList.includes(window.location.host) |
350 | ) { | 349 | ) { |
351 | console.log('Injecting Dark Reader'); | 350 | debug('Injecting Dark Reader'); |
352 | 351 | ||
353 | // Use Dark Reader instead | 352 | // Use Dark Reader instead |
354 | const { brightness, contrast, sepia } = | 353 | const { brightness, contrast, sepia } = |
@@ -362,8 +361,8 @@ class RecipeController { | |||
362 | this.universalDarkModeInjected = true; | 361 | this.universalDarkModeInjected = true; |
363 | } | 362 | } |
364 | } else { | 363 | } else { |
365 | console.log('Remove dark mode'); | 364 | debug('Remove dark mode'); |
366 | console.log('DarkMode disabled - removing remaining styles'); | 365 | debug('DarkMode disabled - removing remaining styles'); |
367 | 366 | ||
368 | if (this.recipe && this.recipe.darkModeHandler) { | 367 | if (this.recipe && this.recipe.darkModeHandler) { |
369 | // Remove other dark mode styles if they were already loaded | 368 | // Remove other dark mode styles if they were already loaded |
@@ -375,10 +374,10 @@ class RecipeController { | |||
375 | 374 | ||
376 | this.recipe.darkModeHandler(false, handlerConfig); | 375 | this.recipe.darkModeHandler(false, handlerConfig); |
377 | } else if (isDarkModeStyleInjected()) { | 376 | } else if (isDarkModeStyleInjected()) { |
378 | console.log('Removing injected darkmode from recipe'); | 377 | debug('Removing injected darkmode from recipe'); |
379 | removeDarkModeStyle(); | 378 | removeDarkModeStyle(); |
380 | } else { | 379 | } else { |
381 | console.log('Removing Dark Reader'); | 380 | debug('Removing Dark Reader'); |
382 | 381 | ||
383 | disableDarkMode(); | 382 | disableDarkMode(); |
384 | this.universalDarkModeInjected = false; | 383 | this.universalDarkModeInjected = false; |
@@ -406,7 +405,7 @@ class RecipeController { | |||
406 | } | 405 | } |
407 | 406 | ||
408 | serviceIdEcho(event) { | 407 | serviceIdEcho(event) { |
409 | console.log('Received a service echo ping'); | 408 | debug('Received a service echo ping'); |
410 | event.sender.send('service-id', this.settings.service.id); | 409 | event.sender.send('service-id', this.settings.service.id); |
411 | } | 410 | } |
412 | 411 | ||
@@ -428,7 +427,7 @@ class RecipeController { | |||
428 | // Force a minimum length to get better detection results | 427 | // Force a minimum length to get better detection results |
429 | if (value.length < 25) return; | 428 | if (value.length < 25) return; |
430 | 429 | ||
431 | console.log('Detecting language for', value); | 430 | debug('Detecting language for', value); |
432 | const locale = await ipcRenderer.invoke('detect-language', { | 431 | const locale = await ipcRenderer.invoke('detect-language', { |
433 | sample: value, | 432 | sample: value, |
434 | }); | 433 | }); |
@@ -438,7 +437,7 @@ class RecipeController { | |||
438 | 437 | ||
439 | const spellcheckerLocale = | 438 | const spellcheckerLocale = |
440 | getSpellcheckerLocaleByFuzzyIdentifier(locale); | 439 | getSpellcheckerLocaleByFuzzyIdentifier(locale); |
441 | console.log( | 440 | debug( |
442 | 'Language detected reliably, setting spellchecker language to', | 441 | 'Language detected reliably, setting spellchecker language to', |
443 | spellcheckerLocale, | 442 | spellcheckerLocale, |
444 | ); | 443 | ); |
diff --git a/src/webview/sessionHandler.ts b/src/webview/sessionHandler.ts index a2906113d..00eacdf50 100644 --- a/src/webview/sessionHandler.ts +++ b/src/webview/sessionHandler.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 1 | const debug = require('../preload-safe-debug')('Ferdium:Plugin:SessionHandler'); |
2 | // const debug = require('debug')('Ferdium:Plugin:SessionHandler'); | ||
3 | 2 | ||
4 | export class SessionHandler { | 3 | export class SessionHandler { |
5 | async releaseServiceWorkers() { | 4 | async releaseServiceWorkers() { |
@@ -8,10 +7,10 @@ export class SessionHandler { | |||
8 | await window.navigator.serviceWorker.getRegistrations(); | 7 | await window.navigator.serviceWorker.getRegistrations(); |
9 | for (const registration of registrations) { | 8 | for (const registration of registrations) { |
10 | registration.unregister(); | 9 | registration.unregister(); |
11 | console.log('ServiceWorker unregistered'); | 10 | debug('ServiceWorker unregistered'); |
12 | } | 11 | } |
13 | } catch (error) { | 12 | } catch (error) { |
14 | console.log(error); | 13 | debug(error); |
15 | } | 14 | } |
16 | } | 15 | } |
17 | } | 16 | } |
diff --git a/src/webview/spellchecker.ts b/src/webview/spellchecker.ts index 8cf16a7ba..8e452c791 100644 --- a/src/webview/spellchecker.ts +++ b/src/webview/spellchecker.ts | |||
@@ -2,8 +2,7 @@ import { ipcRenderer } from 'electron'; | |||
2 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 2 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
3 | import { isMac } from '../environment'; | 3 | import { isMac } from '../environment'; |
4 | 4 | ||
5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 5 | const debug = require('../preload-safe-debug')('Ferdium:spellchecker'); |
6 | // const debug = require('debug')('Ferdium:spellchecker'); | ||
7 | 6 | ||
8 | export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { | 7 | export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { |
9 | const locales = Object.keys(SPELLCHECKER_LOCALES).filter( | 8 | const locales = Object.keys(SPELLCHECKER_LOCALES).filter( |
@@ -17,14 +16,14 @@ export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { | |||
17 | 16 | ||
18 | export function switchDict(fuzzyLocale: string, serviceId: string) { | 17 | export function switchDict(fuzzyLocale: string, serviceId: string) { |
19 | if (isMac) { | 18 | if (isMac) { |
20 | console.log('Ignoring dictionary changes on macOS'); | 19 | debug('Ignoring dictionary changes on macOS'); |
21 | return; | 20 | return; |
22 | } | 21 | } |
23 | 22 | ||
24 | console.log(`Setting spellchecker locale from: ${fuzzyLocale}`); | 23 | debug(`Setting spellchecker locale from: ${fuzzyLocale}`); |
25 | const locale = getSpellcheckerLocaleByFuzzyIdentifier(fuzzyLocale); | 24 | const locale = getSpellcheckerLocaleByFuzzyIdentifier(fuzzyLocale); |
26 | if (locale) { | 25 | if (locale) { |
27 | console.log(`Sending spellcheck locales to host: ${locale}`); | 26 | debug(`Sending spellcheck locales to host: ${locale}`); |
28 | ipcRenderer.send('set-spellchecker-locales', { locale, serviceId }); | 27 | ipcRenderer.send('set-spellchecker-locales', { locale, serviceId }); |
29 | } | 28 | } |
30 | } | 29 | } |