diff options
author | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-04-22 15:04:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 20:04:21 +0000 |
commit | 759d93dc198a3cc8c5265245c0144efa5435682b (patch) | |
tree | 53e963a085d3d12af5a2efa2f1ab6f3e5574edc7 | |
parent | Added build scripts for linux, macos and windows to help new contributors get... (diff) | |
download | ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.gz ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.zst ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.zip |
Turn off usage of 'debug' npm package using with electron-16 (fixes #17)
32 files changed, 289 insertions, 259 deletions
diff --git a/package-lock.json b/package-lock.json index c3781a376..9f3bc966b 100644 --- a/package-lock.json +++ b/package-lock.json | |||
@@ -33,7 +33,7 @@ | |||
33 | "csstype": "^3.0.9", | 33 | "csstype": "^3.0.9", |
34 | "darkreader": "^4.9.39", | 34 | "darkreader": "^4.9.39", |
35 | "dbus-next": "^0.10.2", | 35 | "dbus-next": "^0.10.2", |
36 | "debug": "^4.3.2", | 36 | "debug": "4.3.4", |
37 | "electron-dl": "^3.2.1", | 37 | "electron-dl": "^3.2.1", |
38 | "electron-find": "^1.0.7", | 38 | "electron-find": "^1.0.7", |
39 | "electron-react-titlebar": "^1.1.0", | 39 | "electron-react-titlebar": "^1.1.0", |
@@ -9873,9 +9873,9 @@ | |||
9873 | } | 9873 | } |
9874 | }, | 9874 | }, |
9875 | "node_modules/debug": { | 9875 | "node_modules/debug": { |
9876 | "version": "4.3.3", | 9876 | "version": "4.3.4", |
9877 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", | 9877 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", |
9878 | "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", | 9878 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", |
9879 | "dependencies": { | 9879 | "dependencies": { |
9880 | "ms": "2.1.2" | 9880 | "ms": "2.1.2" |
9881 | }, | 9881 | }, |
@@ -38628,9 +38628,9 @@ | |||
38628 | } | 38628 | } |
38629 | }, | 38629 | }, |
38630 | "debug": { | 38630 | "debug": { |
38631 | "version": "4.3.3", | 38631 | "version": "4.3.4", |
38632 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", | 38632 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", |
38633 | "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", | 38633 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", |
38634 | "requires": { | 38634 | "requires": { |
38635 | "ms": "2.1.2" | 38635 | "ms": "2.1.2" |
38636 | }, | 38636 | }, |
diff --git a/package.json b/package.json index 6f0653cf2..42381a659 100644 --- a/package.json +++ b/package.json | |||
@@ -68,7 +68,7 @@ | |||
68 | "csstype": "^3.0.9", | 68 | "csstype": "^3.0.9", |
69 | "darkreader": "^4.9.39", | 69 | "darkreader": "^4.9.39", |
70 | "dbus-next": "^0.10.2", | 70 | "dbus-next": "^0.10.2", |
71 | "debug": "^4.3.2", | 71 | "debug": "4.3.4", |
72 | "electron-dl": "^3.2.1", | 72 | "electron-dl": "^3.2.1", |
73 | "electron-find": "^1.0.7", | 73 | "electron-find": "^1.0.7", |
74 | "electron-react-titlebar": "^1.1.0", | 74 | "electron-react-titlebar": "^1.1.0", |
diff --git a/src/api/server/LocalApi.ts b/src/api/server/LocalApi.ts index 5e205cbe4..28028bf80 100644 --- a/src/api/server/LocalApi.ts +++ b/src/api/server/LocalApi.ts | |||
@@ -4,14 +4,15 @@ import fastFolderSize from 'fast-folder-size'; | |||
4 | 4 | ||
5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; | 5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:LocalApi'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:LocalApi'); | ||
8 | 9 | ||
9 | export default class LocalApi { | 10 | export default class LocalApi { |
10 | // Settings | 11 | // Settings |
11 | getAppSettings(type: string) { | 12 | getAppSettings(type: string) { |
12 | return new Promise(resolve => { | 13 | return new Promise(resolve => { |
13 | ipcRenderer.once('appSettings', (_event, resp) => { | 14 | ipcRenderer.once('appSettings', (_event, resp) => { |
14 | debug('LocalApi::getAppSettings resolves', resp.type, resp.data); | 15 | console.log('LocalApi::getAppSettings resolves', resp.type, resp.data); |
15 | resolve(resp); | 16 | resolve(resp); |
16 | }); | 17 | }); |
17 | 18 | ||
@@ -20,7 +21,7 @@ export default class LocalApi { | |||
20 | } | 21 | } |
21 | 22 | ||
22 | async updateAppSettings(type: string, data: any) { | 23 | async updateAppSettings(type: string, data: any) { |
23 | debug('LocalApi::updateAppSettings resolves', type, data); | 24 | console.log('LocalApi::updateAppSettings resolves', type, data); |
24 | ipcRenderer.send('updateAppSettings', { | 25 | ipcRenderer.send('updateAppSettings', { |
25 | type, | 26 | type, |
26 | data, | 27 | data, |
@@ -39,7 +40,7 @@ export default class LocalApi { | |||
39 | reject(err); | 40 | reject(err); |
40 | } | 41 | } |
41 | 42 | ||
42 | debug('LocalApi::getAppCacheSize resolves', bytes); | 43 | console.log('LocalApi::getAppCacheSize resolves', bytes); |
43 | resolve(bytes); | 44 | resolve(bytes); |
44 | }, | 45 | }, |
45 | ); | 46 | ); |
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 9dc3a9a0e..dc29c7b89 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts | |||
@@ -35,7 +35,8 @@ import { | |||
35 | 35 | ||
36 | import { removeServicePartitionDirectory } from '../../helpers/service-helpers'; | 36 | import { removeServicePartitionDirectory } from '../../helpers/service-helpers'; |
37 | 37 | ||
38 | const debug = require('debug')('Ferdium:ServerApi'); | 38 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
39 | // const debug = require('debug')('Ferdium:ServerApi'); | ||
39 | 40 | ||
40 | module.paths.unshift(getDevRecipeDirectory(), getRecipeDirectory()); | 41 | module.paths.unshift(getDevRecipeDirectory(), getRecipeDirectory()); |
41 | 42 | ||
@@ -61,7 +62,7 @@ export default class ServerApi { | |||
61 | } | 62 | } |
62 | const u = await request.json(); | 63 | const u = await request.json(); |
63 | 64 | ||
64 | debug('ServerApi::login resolves', u); | 65 | console.log('ServerApi::login resolves', u); |
65 | return u.token; | 66 | return u.token; |
66 | } | 67 | } |
67 | 68 | ||
@@ -79,7 +80,7 @@ export default class ServerApi { | |||
79 | } | 80 | } |
80 | const u = await request.json(); | 81 | const u = await request.json(); |
81 | 82 | ||
82 | debug('ServerApi::signup resolves', u); | 83 | console.log('ServerApi::signup resolves', u); |
83 | return u.token; | 84 | return u.token; |
84 | } | 85 | } |
85 | 86 | ||
@@ -92,7 +93,7 @@ export default class ServerApi { | |||
92 | throw new Error(request.statusText); | 93 | throw new Error(request.statusText); |
93 | } | 94 | } |
94 | 95 | ||
95 | debug('ServerApi::inviteUser'); | 96 | console.log('ServerApi::inviteUser'); |
96 | return true; | 97 | return true; |
97 | } | 98 | } |
98 | 99 | ||
@@ -112,7 +113,7 @@ export default class ServerApi { | |||
112 | } | 113 | } |
113 | const r = await request.json(); | 114 | const r = await request.json(); |
114 | 115 | ||
115 | debug('ServerApi::retrievePassword'); | 116 | console.log('ServerApi::retrievePassword'); |
116 | return r; | 117 | return r; |
117 | } | 118 | } |
118 | 119 | ||
@@ -128,7 +129,7 @@ export default class ServerApi { | |||
128 | const data = await request.json(); | 129 | const data = await request.json(); |
129 | 130 | ||
130 | const user = new UserModel(data); | 131 | const user = new UserModel(data); |
131 | debug('ServerApi::userInfo resolves', user); | 132 | console.log('ServerApi::userInfo resolves', user); |
132 | 133 | ||
133 | return user; | 134 | return user; |
134 | } | 135 | } |
@@ -146,7 +147,7 @@ export default class ServerApi { | |||
146 | const user = Object.assign(updatedData, { | 147 | const user = Object.assign(updatedData, { |
147 | data: new UserModel(updatedData.data), | 148 | data: new UserModel(updatedData.data), |
148 | }); | 149 | }); |
149 | debug('ServerApi::updateUserInfo resolves', user); | 150 | console.log('ServerApi::updateUserInfo resolves', user); |
150 | return user; | 151 | return user; |
151 | } | 152 | } |
152 | 153 | ||
@@ -159,7 +160,7 @@ export default class ServerApi { | |||
159 | } | 160 | } |
160 | const data = await request.json(); | 161 | const data = await request.json(); |
161 | 162 | ||
162 | debug('ServerApi::deleteAccount resolves', data); | 163 | console.log('ServerApi::deleteAccount resolves', data); |
163 | return data; | 164 | return data; |
164 | } | 165 | } |
165 | 166 | ||
@@ -177,7 +178,7 @@ export default class ServerApi { | |||
177 | 178 | ||
178 | const services = await this._mapServiceModels(data); | 179 | const services = await this._mapServiceModels(data); |
179 | const filteredServices = services.filter(service => !!service); | 180 | const filteredServices = services.filter(service => !!service); |
180 | debug('ServerApi::getServices resolves', filteredServices); | 181 | console.log('ServerApi::getServices resolves', filteredServices); |
181 | return filteredServices; | 182 | return filteredServices; |
182 | } | 183 | } |
183 | 184 | ||
@@ -204,7 +205,7 @@ export default class ServerApi { | |||
204 | data: await this._prepareServiceModel(serviceData.data), | 205 | data: await this._prepareServiceModel(serviceData.data), |
205 | }); | 206 | }); |
206 | 207 | ||
207 | debug('ServerApi::createService resolves', service); | 208 | console.log('ServerApi::createService resolves', service); |
208 | return service; | 209 | return service; |
209 | } | 210 | } |
210 | 211 | ||
@@ -230,7 +231,7 @@ export default class ServerApi { | |||
230 | data: await this._prepareServiceModel(serviceData.data), | 231 | data: await this._prepareServiceModel(serviceData.data), |
231 | }); | 232 | }); |
232 | 233 | ||
233 | debug('ServerApi::updateService resolves', service); | 234 | console.log('ServerApi::updateService resolves', service); |
234 | return service; | 235 | return service; |
235 | } | 236 | } |
236 | 237 | ||
@@ -270,7 +271,7 @@ export default class ServerApi { | |||
270 | throw new Error(request.statusText); | 271 | throw new Error(request.statusText); |
271 | } | 272 | } |
272 | const serviceData = await request.json(); | 273 | const serviceData = await request.json(); |
273 | debug('ServerApi::reorderService resolves', serviceData); | 274 | console.log('ServerApi::reorderService resolves', serviceData); |
274 | return serviceData; | 275 | return serviceData; |
275 | } | 276 | } |
276 | 277 | ||
@@ -285,7 +286,7 @@ export default class ServerApi { | |||
285 | 286 | ||
286 | removeServicePartitionDirectory(id, true); | 287 | removeServicePartitionDirectory(id, true); |
287 | 288 | ||
288 | debug('ServerApi::deleteService resolves', data); | 289 | console.log('ServerApi::deleteService resolves', data); |
289 | return data; | 290 | return data; |
290 | } | 291 | } |
291 | 292 | ||
@@ -298,7 +299,7 @@ export default class ServerApi { | |||
298 | const data = await request.json(); | 299 | const data = await request.json(); |
299 | 300 | ||
300 | const features = data; | 301 | const features = data; |
301 | debug('ServerApi::getDefaultFeatures resolves', features); | 302 | console.log('ServerApi::getDefaultFeatures resolves', features); |
302 | return features; | 303 | return features; |
303 | } | 304 | } |
304 | 305 | ||
@@ -314,7 +315,7 @@ export default class ServerApi { | |||
314 | const data = await request.json(); | 315 | const data = await request.json(); |
315 | 316 | ||
316 | const features = data; | 317 | const features = data; |
317 | debug('ServerApi::getFeatures resolves', features); | 318 | console.log('ServerApi::getFeatures resolves', features); |
318 | return features; | 319 | return features; |
319 | } | 320 | } |
320 | 321 | ||
@@ -339,7 +340,7 @@ export default class ServerApi { | |||
339 | // eslint-disable-next-line unicorn/prefer-spread | 340 | // eslint-disable-next-line unicorn/prefer-spread |
340 | this.recipes = this.recipes.concat(this._getDevRecipes()); | 341 | this.recipes = this.recipes.concat(this._getDevRecipes()); |
341 | 342 | ||
342 | debug('StubServerApi::getInstalledRecipes resolves', this.recipes); | 343 | console.log('StubServerApi::getInstalledRecipes resolves', this.recipes); |
343 | return this.recipes; | 344 | return this.recipes; |
344 | } | 345 | } |
345 | 346 | ||
@@ -352,7 +353,7 @@ export default class ServerApi { | |||
352 | throw new Error(request.statusText); | 353 | throw new Error(request.statusText); |
353 | } | 354 | } |
354 | const recipes = await request.json(); | 355 | const recipes = await request.json(); |
355 | debug('ServerApi::getRecipeUpdates resolves', recipes); | 356 | console.log('ServerApi::getRecipeUpdates resolves', recipes); |
356 | return recipes; | 357 | return recipes; |
357 | } | 358 | } |
358 | 359 | ||
@@ -362,7 +363,7 @@ export default class ServerApi { | |||
362 | if (!request.ok) throw new Error(request.statusText); | 363 | if (!request.ok) throw new Error(request.statusText); |
363 | const data = await request.json(); | 364 | const data = await request.json(); |
364 | const recipePreviews = this._mapRecipePreviewModel(data); | 365 | const recipePreviews = this._mapRecipePreviewModel(data); |
365 | debug('ServerApi::getRecipes resolves', recipePreviews); | 366 | console.log('ServerApi::getRecipes resolves', recipePreviews); |
366 | return recipePreviews; | 367 | return recipePreviews; |
367 | } | 368 | } |
368 | 369 | ||
@@ -374,7 +375,7 @@ export default class ServerApi { | |||
374 | // data = this._addLocalRecipesToPreviews(data); | 375 | // data = this._addLocalRecipesToPreviews(data); |
375 | 376 | ||
376 | const recipePreviews = this._mapRecipePreviewModel(data); | 377 | const recipePreviews = this._mapRecipePreviewModel(data); |
377 | debug('ServerApi::getFeaturedRecipes resolves', recipePreviews); | 378 | console.log('ServerApi::getFeaturedRecipes resolves', recipePreviews); |
378 | return recipePreviews; | 379 | return recipePreviews; |
379 | } | 380 | } |
380 | 381 | ||
@@ -385,7 +386,7 @@ export default class ServerApi { | |||
385 | 386 | ||
386 | const data = await request.json(); | 387 | const data = await request.json(); |
387 | const recipePreviews = this._mapRecipePreviewModel(data); | 388 | const recipePreviews = this._mapRecipePreviewModel(data); |
388 | debug('ServerApi::searchRecipePreviews resolves', recipePreviews); | 389 | console.log('ServerApi::searchRecipePreviews resolves', recipePreviews); |
389 | return recipePreviews; | 390 | return recipePreviews; |
390 | } | 391 | } |
391 | 392 | ||
@@ -401,21 +402,21 @@ export default class ServerApi { | |||
401 | let archivePath: PathOrFileDescriptor; | 402 | let archivePath: PathOrFileDescriptor; |
402 | 403 | ||
403 | if (pathExistsSync(internalRecipeFile)) { | 404 | if (pathExistsSync(internalRecipeFile)) { |
404 | debug('[ServerApi::getRecipePackage] Using internal recipe file'); | 405 | console.log('[ServerApi::getRecipePackage] Using internal recipe file'); |
405 | archivePath = internalRecipeFile; | 406 | archivePath = internalRecipeFile; |
406 | } else { | 407 | } else { |
407 | debug('[ServerApi::getRecipePackage] Downloading recipe from server'); | 408 | console.log('[ServerApi::getRecipePackage] Downloading recipe from server'); |
408 | archivePath = tempArchivePath; | 409 | archivePath = tempArchivePath; |
409 | 410 | ||
410 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; | 411 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; |
411 | 412 | ||
412 | const res = await window.fetch(packageUrl); | 413 | const res = await window.fetch(packageUrl); |
413 | debug('Recipe downloaded', recipeId); | 414 | console.log('Recipe downloaded', recipeId); |
414 | const blob = await res.blob(); | 415 | const blob = await res.blob(); |
415 | const buffer = await blob.arrayBuffer(); | 416 | const buffer = await blob.arrayBuffer(); |
416 | writeFileSync(tempArchivePath, Buffer.from(buffer)); | 417 | writeFileSync(tempArchivePath, Buffer.from(buffer)); |
417 | } | 418 | } |
418 | debug(archivePath); | 419 | console.log(archivePath); |
419 | 420 | ||
420 | await sleep(10); | 421 | await sleep(10); |
421 | 422 | ||
@@ -426,7 +427,7 @@ export default class ServerApi { | |||
426 | preservePaths: true, | 427 | preservePaths: true, |
427 | unlink: true, | 428 | unlink: true, |
428 | preserveOwner: false, | 429 | preserveOwner: false, |
429 | onwarn: x => debug('warn', recipeId, x), | 430 | onwarn: x => console.log('warn', recipeId, x), |
430 | }); | 431 | }); |
431 | 432 | ||
432 | await sleep(10); | 433 | await sleep(10); |
@@ -456,7 +457,7 @@ export default class ServerApi { | |||
456 | if (!request.ok) { | 457 | if (!request.ok) { |
457 | throw new Error(request.statusText); | 458 | throw new Error(request.statusText); |
458 | } | 459 | } |
459 | debug('ServerApi::healthCheck resolves'); | 460 | console.log('ServerApi::healthCheck resolves'); |
460 | } | 461 | } |
461 | 462 | ||
462 | async getLegacyServices() { | 463 | async getLegacyServices() { |
@@ -483,7 +484,7 @@ export default class ServerApi { | |||
483 | }), | 484 | }), |
484 | ); | 485 | ); |
485 | 486 | ||
486 | debug('ServerApi::getLegacyServices resolves', services); | 487 | console.log('ServerApi::getLegacyServices resolves', services); |
487 | return services; | 488 | return services; |
488 | } | 489 | } |
489 | } catch { | 490 | } catch { |
@@ -516,7 +517,7 @@ export default class ServerApi { | |||
516 | 517 | ||
517 | return new ServiceModel(service, recipe); | 518 | return new ServiceModel(service, recipe); |
518 | } catch (error) { | 519 | } catch (error) { |
519 | debug(error); | 520 | console.log(error); |
520 | return null; | 521 | return null; |
521 | } | 522 | } |
522 | } | 523 | } |
@@ -539,7 +540,7 @@ export default class ServerApi { | |||
539 | 540 | ||
540 | await this.getRecipePackage(recipeId); | 541 | await this.getRecipePackage(recipeId); |
541 | 542 | ||
542 | debug('Rerun ServerAPI::getInstalledRecipes'); | 543 | console.log('Rerun ServerAPI::getInstalledRecipes'); |
543 | await this.getInstalledRecipes(); | 544 | await this.getInstalledRecipes(); |
544 | 545 | ||
545 | recipe = this.recipes.find(r => r.id === recipeId); | 546 | recipe = this.recipes.find(r => r.id === recipeId); |
@@ -604,7 +605,7 @@ export default class ServerApi { | |||
604 | 605 | ||
605 | return recipes; | 606 | return recipes; |
606 | } catch { | 607 | } catch { |
607 | debug('Could not load dev recipes'); | 608 | console.log('Could not load dev recipes'); |
608 | return false; | 609 | return false; |
609 | } | 610 | } |
610 | } | 611 | } |
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index b30a8d9b0..f1c4251ba 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js | |||
@@ -7,7 +7,8 @@ import { join } from 'path'; | |||
7 | 7 | ||
8 | import ServiceModel from '../../../models/Service'; | 8 | import ServiceModel from '../../../models/Service'; |
9 | 9 | ||
10 | const debug = require('debug')('Ferdium:Services'); | 10 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
11 | // const debug = require('debug')('Ferdium:Services'); | ||
11 | 12 | ||
12 | class ServiceWebview extends Component { | 13 | class ServiceWebview extends Component { |
13 | static propTypes = { | 14 | static propTypes = { |
@@ -27,7 +28,7 @@ class ServiceWebview extends Component { | |||
27 | () => { | 28 | () => { |
28 | if (this.webview && this.webview.view) { | 29 | if (this.webview && this.webview.view) { |
29 | this.webview.view.addEventListener('console-message', e => { | 30 | this.webview.view.addEventListener('console-message', e => { |
30 | debug('Service logged a message:', e.message); | 31 | console.log('Service logged a message:', e.message); |
31 | }); | 32 | }); |
32 | this.webview.view.addEventListener('did-navigate', () => { | 33 | this.webview.view.addEventListener('did-navigate', () => { |
33 | if (this.props.service._webview) { | 34 | if (this.props.service._webview) { |
@@ -50,7 +51,7 @@ class ServiceWebview extends Component { | |||
50 | 51 | ||
51 | refocusWebview = () => { | 52 | refocusWebview = () => { |
52 | const { webview } = this; | 53 | const { webview } = this; |
53 | debug('Refocus Webview is called', this.props.service); | 54 | console.log('Refocus Webview is called', this.props.service); |
54 | if (!webview) return; | 55 | if (!webview) return; |
55 | if (this.props.service.isActive) { | 56 | if (this.props.service.isActive) { |
56 | webview.view.blur(); | 57 | webview.view.blur(); |
@@ -63,7 +64,7 @@ class ServiceWebview extends Component { | |||
63 | } ${`- ${this.props.service._webview.getTitle()}`}`; | 64 | } ${`- ${this.props.service._webview.getTitle()}`}`; |
64 | }, 100); | 65 | }, 100); |
65 | } else { | 66 | } else { |
66 | debug('Refocus not required - Not active service'); | 67 | console.log('Refocus not required - Not active service'); |
67 | } | 68 | } |
68 | }; | 69 | }; |
69 | 70 | ||
diff --git a/src/electron/ipc-api/download.ts b/src/electron/ipc-api/download.ts index cb2aa7383..3631e8fee 100644 --- a/src/electron/ipc-api/download.ts +++ b/src/electron/ipc-api/download.ts | |||
@@ -4,7 +4,8 @@ import mime from 'mime-types'; | |||
4 | import { writeFileSync } from 'fs-extra'; | 4 | import { writeFileSync } from 'fs-extra'; |
5 | import { PathLike } from 'fs'; | 5 | import { PathLike } from 'fs'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:ipcApi:download'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:ipcApi:download'); | ||
8 | 9 | ||
9 | function decodeBase64Image(dataString: string) { | 10 | function decodeBase64Image(dataString: string) { |
10 | const matches = dataString.match(/^data:([+/A-Za-z-]+);base64,(.+)$/); | 11 | const matches = dataString.match(/^data:([+/A-Za-z-]+);base64,(.+)$/); |
@@ -27,7 +28,7 @@ export default (params: { mainWindow: BrowserWindow }) => { | |||
27 | const dl = await download(win!, url, { | 28 | const dl = await download(win!, url, { |
28 | saveAs: true, | 29 | saveAs: true, |
29 | }); | 30 | }); |
30 | debug('File saved to', dl.savePath); | 31 | console.log('File saved to', dl.savePath); |
31 | } else { | 32 | } else { |
32 | const extension = mime.extension(fileOptions.mime); | 33 | const extension = mime.extension(fileOptions.mime); |
33 | const filename = `${fileOptions.name}.${extension}`; | 34 | const filename = `${fileOptions.name}.${extension}`; |
@@ -46,7 +47,7 @@ export default (params: { mainWindow: BrowserWindow }) => { | |||
46 | 'binary', | 47 | 'binary', |
47 | ); | 48 | ); |
48 | 49 | ||
49 | debug('File blob saved to', saveDialog.filePath); | 50 | console.log('File blob saved to', saveDialog.filePath); |
50 | } catch (error) { | 51 | } catch (error) { |
51 | console.error(error); | 52 | console.error(error); |
52 | } | 53 | } |
diff --git a/src/electron/ipc-api/sessionStorage.ts b/src/electron/ipc-api/sessionStorage.ts index 20f0ac9d2..96acacd12 100644 --- a/src/electron/ipc-api/sessionStorage.ts +++ b/src/electron/ipc-api/sessionStorage.ts | |||
@@ -2,7 +2,8 @@ import { ipcMain, Session, session } from 'electron'; | |||
2 | 2 | ||
3 | import { TODOS_PARTITION_ID } from '../../config'; | 3 | import { TODOS_PARTITION_ID } from '../../config'; |
4 | 4 | ||
5 | const debug = require('debug')('Ferdium:ipcApi:sessionStorage'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:ipcApi:sessionStorage'); | ||
6 | 7 | ||
7 | function deduceSession(serviceId: string | undefined | null): Session { | 8 | function deduceSession(serviceId: string | undefined | null): Session { |
8 | if (serviceId) { | 9 | if (serviceId) { |
@@ -21,14 +22,14 @@ export default async () => { | |||
21 | const serviceSession = deduceSession(serviceId); | 22 | const serviceSession = deduceSession(serviceId); |
22 | serviceSession.flushStorageData(); | 23 | serviceSession.flushStorageData(); |
23 | if (targetsToClear) { | 24 | if (targetsToClear) { |
24 | debug('Clearing targets:', targetsToClear); | 25 | console.log('Clearing targets:', targetsToClear); |
25 | serviceSession.clearStorageData(targetsToClear); | 26 | serviceSession.clearStorageData(targetsToClear); |
26 | } else { | 27 | } else { |
27 | debug('Clearing all targets'); | 28 | console.log('Clearing all targets'); |
28 | serviceSession.clearStorageData(); | 29 | serviceSession.clearStorageData(); |
29 | } | 30 | } |
30 | } catch (error) { | 31 | } catch (error) { |
31 | debug(error); | 32 | console.log(error); |
32 | } | 33 | } |
33 | }); | 34 | }); |
34 | 35 | ||
diff --git a/src/electron/macOSPermissions.ts b/src/electron/macOSPermissions.ts index 7e4bb3c4d..07caaaada 100644 --- a/src/electron/macOSPermissions.ts +++ b/src/electron/macOSPermissions.ts | |||
@@ -6,11 +6,12 @@ import { dirname } from 'path'; | |||
6 | import { askForScreenCaptureAccess } from 'node-mac-permissions'; | 6 | import { askForScreenCaptureAccess } from 'node-mac-permissions'; |
7 | import { userDataPath } from '../environment-remote'; | 7 | import { userDataPath } from '../environment-remote'; |
8 | 8 | ||
9 | const debug = require('debug')('Ferdium:macOSPermissions'); | 9 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
10 | // const debug = require('debug')('Ferdium:macOSPermissions'); | ||
10 | 11 | ||
11 | const isExplicitScreenCapturePermissionReqd = | 12 | const isExplicitScreenCapturePermissionReqd = |
12 | macosVersion.isGreaterThanOrEqualTo('10.15'); | 13 | macosVersion.isGreaterThanOrEqualTo('10.15'); |
13 | debug( | 14 | console.log( |
14 | `Should check explicitly for screen-capture permissions: ${isExplicitScreenCapturePermissionReqd}`, | 15 | `Should check explicitly for screen-capture permissions: ${isExplicitScreenCapturePermissionReqd}`, |
15 | ); | 16 | ); |
16 | 17 | ||
@@ -21,7 +22,7 @@ function hasPromptedForScreenCapturePermission(): string | boolean { | |||
21 | return false; | 22 | return false; |
22 | } | 23 | } |
23 | 24 | ||
24 | debug('Checking if status file exists'); | 25 | console.log('Checking if status file exists'); |
25 | return filePath && pathExistsSync(filePath); | 26 | return filePath && pathExistsSync(filePath); |
26 | } | 27 | } |
27 | 28 | ||
@@ -31,7 +32,7 @@ function hasScreenCapturePermissionAlreadyBeenGranted(): boolean { | |||
31 | } | 32 | } |
32 | 33 | ||
33 | const screenCaptureStatus = systemPreferences.getMediaAccessStatus('screen'); | 34 | const screenCaptureStatus = systemPreferences.getMediaAccessStatus('screen'); |
34 | debug(`screen-capture permissions status: ${screenCaptureStatus}`); | 35 | console.log(`screen-capture permissions status: ${screenCaptureStatus}`); |
35 | return screenCaptureStatus === 'granted'; | 36 | return screenCaptureStatus === 'granted'; |
36 | } | 37 | } |
37 | 38 | ||
@@ -49,18 +50,18 @@ function createStatusFile() { | |||
49 | } | 50 | } |
50 | 51 | ||
51 | export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { | 52 | export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { |
52 | debug('Checking camera & microphone permissions'); | 53 | console.log('Checking camera & microphone permissions'); |
53 | systemPreferences.askForMediaAccess('camera'); | 54 | systemPreferences.askForMediaAccess('camera'); |
54 | systemPreferences.askForMediaAccess('microphone'); | 55 | systemPreferences.askForMediaAccess('microphone'); |
55 | 56 | ||
56 | if (hasScreenCapturePermissionAlreadyBeenGranted()) { | 57 | if (hasScreenCapturePermissionAlreadyBeenGranted()) { |
57 | debug('Already obtained screen-capture permissions - writing status file'); | 58 | console.log('Already obtained screen-capture permissions - writing status file'); |
58 | createStatusFile(); | 59 | createStatusFile(); |
59 | return; | 60 | return; |
60 | } | 61 | } |
61 | 62 | ||
62 | if (!hasPromptedForScreenCapturePermission()) { | 63 | if (!hasPromptedForScreenCapturePermission()) { |
63 | debug('Checking screen capture permissions'); | 64 | console.log('Checking screen capture permissions'); |
64 | 65 | ||
65 | const { response } = await dialog.showMessageBox(mainWindow, { | 66 | const { response } = await dialog.showMessageBox(mainWindow, { |
66 | type: 'info', | 67 | type: 'info', |
@@ -73,11 +74,11 @@ export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { | |||
73 | }); | 74 | }); |
74 | 75 | ||
75 | if (response === 0) { | 76 | if (response === 0) { |
76 | debug('Asking for access'); | 77 | console.log('Asking for access'); |
77 | askForScreenCaptureAccess(); | 78 | askForScreenCaptureAccess(); |
78 | createStatusFile(); | 79 | createStatusFile(); |
79 | } else if (response === 1) { | 80 | } else if (response === 1) { |
80 | debug("Don't ask again"); | 81 | console.log("Don't ask again"); |
81 | createStatusFile(); | 82 | createStatusFile(); |
82 | } | 83 | } |
83 | } | 84 | } |
diff --git a/src/features/communityRecipes/store.ts b/src/features/communityRecipes/store.ts index 407a63860..afd7d0f01 100644 --- a/src/features/communityRecipes/store.ts +++ b/src/features/communityRecipes/store.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { computed } from 'mobx'; | 1 | import { computed } from 'mobx'; |
2 | import { FeatureStore } from '../utils/FeatureStore'; | 2 | import { FeatureStore } from '../utils/FeatureStore'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdium:feature:communityRecipes:store'); | 4 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
5 | // const debug = require('debug')('Ferdium:feature:communityRecipes:store'); | ||
5 | 6 | ||
6 | export class CommunityRecipesStore extends FeatureStore { | 7 | export class CommunityRecipesStore extends FeatureStore { |
7 | stores: any; | 8 | stores: any; |
@@ -9,13 +10,13 @@ export class CommunityRecipesStore extends FeatureStore { | |||
9 | actions: any; | 10 | actions: any; |
10 | 11 | ||
11 | start(stores: any, actions: any) { | 12 | start(stores: any, actions: any) { |
12 | debug('start'); | 13 | console.log('start'); |
13 | this.stores = stores; | 14 | this.stores = stores; |
14 | this.actions = actions; | 15 | this.actions = actions; |
15 | } | 16 | } |
16 | 17 | ||
17 | stop() { | 18 | stop() { |
18 | debug('stop'); | 19 | console.log('stop'); |
19 | super.stop(); | 20 | super.stop(); |
20 | } | 21 | } |
21 | 22 | ||
diff --git a/src/features/serviceProxy/index.ts b/src/features/serviceProxy/index.ts index bdc21e97e..b3705b190 100644 --- a/src/features/serviceProxy/index.ts +++ b/src/features/serviceProxy/index.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { autorun, observable } from 'mobx'; | 1 | import { autorun, observable } from 'mobx'; |
2 | import { session } from '@electron/remote'; | 2 | import { session } from '@electron/remote'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdium:feature:serviceProxy'); | 4 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
5 | // const debug = require('debug')('Ferdium:feature:serviceProxy'); | ||
5 | 6 | ||
6 | export const config = observable({ | 7 | export const config = observable({ |
7 | isEnabled: true, | 8 | isEnabled: true, |
@@ -11,7 +12,7 @@ export default function init(stores: { | |||
11 | services: { enabled: any }; | 12 | services: { enabled: any }; |
12 | settings: { proxy: any }; | 13 | settings: { proxy: any }; |
13 | }) { | 14 | }) { |
14 | debug('Initializing `serviceProxy` feature'); | 15 | console.log('Initializing `serviceProxy` feature'); |
15 | 16 | ||
16 | autorun(() => { | 17 | autorun(() => { |
17 | config.isEnabled = true; | 18 | config.isEnabled = true; |
@@ -19,7 +20,7 @@ export default function init(stores: { | |||
19 | const services = stores.services.enabled; | 20 | const services = stores.services.enabled; |
20 | const proxySettings = stores.settings.proxy; | 21 | const proxySettings = stores.settings.proxy; |
21 | 22 | ||
22 | debug('Service Proxy autorun'); | 23 | console.log('Service Proxy autorun'); |
23 | 24 | ||
24 | for (const service of services) { | 25 | for (const service of services) { |
25 | const s = session.fromPartition(`persist:service-${service.id}`); | 26 | const s = session.fromPartition(`persist:service-${service.id}`); |
@@ -35,14 +36,14 @@ export default function init(stores: { | |||
35 | const proxyHost = `${serviceProxyConfig.host}${ | 36 | const proxyHost = `${serviceProxyConfig.host}${ |
36 | serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : '' | 37 | serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : '' |
37 | }`; | 38 | }`; |
38 | debug( | 39 | console.log( |
39 | `Setting proxy config from service settings for "${service.name}" (${service.id}) to`, | 40 | `Setting proxy config from service settings for "${service.name}" (${service.id}) to`, |
40 | proxyHost, | 41 | proxyHost, |
41 | ); | 42 | ); |
42 | 43 | ||
43 | s.setProxy({ proxyRules: proxyHost }) | 44 | s.setProxy({ proxyRules: proxyHost }) |
44 | .then(() => { | 45 | .then(() => { |
45 | debug( | 46 | console.log( |
46 | `Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, | 47 | `Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, |
47 | ); | 48 | ); |
48 | }) | 49 | }) |
diff --git a/src/features/todos/preload.ts b/src/features/todos/preload.ts index 896d82bdf..4ccee39a0 100644 --- a/src/features/todos/preload.ts +++ b/src/features/todos/preload.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { IPC } from './constants'; | 2 | import { IPC } from './constants'; |
3 | 3 | ||
4 | const debug = require('debug')('Ferdium:feature:todos:preload'); | 4 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
5 | // const debug = require('debug')('Ferdium:feature:todos:preload'); | ||
5 | 6 | ||
6 | debug('Preloading Todos Webview'); | 7 | console.log('Preloading Todos Webview'); |
7 | 8 | ||
8 | let hostMessageListener = ({ action }) => { | 9 | let hostMessageListener = ({ action }) => { |
9 | switch (action) { | 10 | switch (action) { |
@@ -27,7 +28,7 @@ window['ferdium'] = { | |||
27 | }; | 28 | }; |
28 | 29 | ||
29 | ipcRenderer.on(IPC.TODOS_HOST_CHANNEL, (event, message) => { | 30 | ipcRenderer.on(IPC.TODOS_HOST_CHANNEL, (event, message) => { |
30 | debug('Received host message', event, message); | 31 | console.log('Received host message', event, message); |
31 | hostMessageListener(message); | 32 | hostMessageListener(message); |
32 | }); | 33 | }); |
33 | 34 | ||
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index 90ea47c71..41e632b49 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -18,7 +18,8 @@ import { createActionBindings } from '../utils/ActionBinding'; | |||
18 | import { IPC, TODOS_ROUTES } from './constants'; | 18 | import { IPC, TODOS_ROUTES } from './constants'; |
19 | import UserAgent from '../../models/UserAgent'; | 19 | import UserAgent from '../../models/UserAgent'; |
20 | 20 | ||
21 | const debug = require('debug')('Ferdium:feature:todos:store'); | 21 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
22 | // const debug = require('debug')('Ferdium:feature:todos:store'); | ||
22 | 23 | ||
23 | export default class TodoStore extends FeatureStore { | 24 | export default class TodoStore extends FeatureStore { |
24 | @observable stores = null; | 25 | @observable stores = null; |
@@ -96,7 +97,7 @@ export default class TodoStore extends FeatureStore { | |||
96 | // ========== PUBLIC API ========= // | 97 | // ========== PUBLIC API ========= // |
97 | 98 | ||
98 | @action start(stores, actions) { | 99 | @action start(stores, actions) { |
99 | debug('TodoStore::start'); | 100 | console.log('TodoStore::start'); |
100 | this.stores = stores; | 101 | this.stores = stores; |
101 | this.actions = actions; | 102 | this.actions = actions; |
102 | 103 | ||
@@ -133,7 +134,7 @@ export default class TodoStore extends FeatureStore { | |||
133 | 134 | ||
134 | @action stop() { | 135 | @action stop() { |
135 | super.stop(); | 136 | super.stop(); |
136 | debug('TodoStore::stop'); | 137 | console.log('TodoStore::stop'); |
137 | this.reset(); | 138 | this.reset(); |
138 | this.isFeatureActive = false; | 139 | this.isFeatureActive = false; |
139 | } | 140 | } |
@@ -162,7 +163,7 @@ export default class TodoStore extends FeatureStore { | |||
162 | }; | 163 | }; |
163 | 164 | ||
164 | @action _setTodosWebview = ({ webview }) => { | 165 | @action _setTodosWebview = ({ webview }) => { |
165 | debug('_setTodosWebview', webview); | 166 | console.log('_setTodosWebview', webview); |
166 | if (this.webview !== webview) { | 167 | if (this.webview !== webview) { |
167 | this.webview = webview; | 168 | this.webview = webview; |
168 | this.userAgentModel.setWebviewReference(webview); | 169 | this.userAgentModel.setWebviewReference(webview); |
@@ -170,14 +171,14 @@ export default class TodoStore extends FeatureStore { | |||
170 | }; | 171 | }; |
171 | 172 | ||
172 | @action _handleHostMessage = message => { | 173 | @action _handleHostMessage = message => { |
173 | debug('_handleHostMessage', message); | 174 | console.log('_handleHostMessage', message); |
174 | if (message.action === 'todos:create') { | 175 | if (message.action === 'todos:create') { |
175 | this.webview.send(IPC.TODOS_HOST_CHANNEL, message); | 176 | this.webview.send(IPC.TODOS_HOST_CHANNEL, message); |
176 | } | 177 | } |
177 | }; | 178 | }; |
178 | 179 | ||
179 | @action _handleClientMessage = ({ channel, message = {} }) => { | 180 | @action _handleClientMessage = ({ channel, message = {} }) => { |
180 | debug('_handleClientMessage', channel, message); | 181 | console.log('_handleClientMessage', channel, message); |
181 | switch (message.action) { | 182 | switch (message.action) { |
182 | case 'todos:initialized': | 183 | case 'todos:initialized': |
183 | this._onTodosClientInitialized(); | 184 | this._onTodosClientInitialized(); |
@@ -186,7 +187,7 @@ export default class TodoStore extends FeatureStore { | |||
186 | this._goToService(message.data); | 187 | this._goToService(message.data); |
187 | break; | 188 | break; |
188 | default: | 189 | default: |
189 | debug('Other message received', channel, message); | 190 | console.log('Other message received', channel, message); |
190 | if (this.stores.services.isTodosServiceAdded) { | 191 | if (this.stores.services.isTodosServiceAdded) { |
191 | this.actions.service.handleIPCMessage({ | 192 | this.actions.service.handleIPCMessage({ |
192 | serviceId: this.stores.services.isTodosServiceAdded.id, | 193 | serviceId: this.stores.services.isTodosServiceAdded.id, |
@@ -202,7 +203,7 @@ export default class TodoStore extends FeatureStore { | |||
202 | }; | 203 | }; |
203 | 204 | ||
204 | @action _toggleTodosFeatureVisibility = () => { | 205 | @action _toggleTodosFeatureVisibility = () => { |
205 | debug('_toggleTodosFeatureVisibility'); | 206 | console.log('_toggleTodosFeatureVisibility'); |
206 | 207 | ||
207 | this._updateSettings({ | 208 | this._updateSettings({ |
208 | isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, | 209 | isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, |
@@ -210,14 +211,14 @@ export default class TodoStore extends FeatureStore { | |||
210 | }; | 211 | }; |
211 | 212 | ||
212 | _openDevTools = () => { | 213 | _openDevTools = () => { |
213 | debug('_openDevTools'); | 214 | console.log('_openDevTools'); |
214 | 215 | ||
215 | const webview = document.querySelector('#todos-panel webview'); | 216 | const webview = document.querySelector('#todos-panel webview'); |
216 | if (webview) webview.openDevTools(); | 217 | if (webview) webview.openDevTools(); |
217 | }; | 218 | }; |
218 | 219 | ||
219 | _reload = () => { | 220 | _reload = () => { |
220 | debug('_reload'); | 221 | console.log('_reload'); |
221 | 222 | ||
222 | const webview = document.querySelector('#todos-panel webview'); | 223 | const webview = document.querySelector('#todos-panel webview'); |
223 | if (webview) webview.reload(); | 224 | if (webview) webview.reload(); |
@@ -285,7 +286,7 @@ export default class TodoStore extends FeatureStore { | |||
285 | const { pathname } = this.stores.router.location; | 286 | const { pathname } = this.stores.router.location; |
286 | 287 | ||
287 | if (pathname === TODOS_ROUTES.TARGET) { | 288 | if (pathname === TODOS_ROUTES.TARGET) { |
288 | debug('Router is on todos route, show todos panel'); | 289 | console.log('Router is on todos route, show todos panel'); |
289 | // todosStore.start(stores, actions); | 290 | // todosStore.start(stores, actions); |
290 | this.stores.router.push('/'); | 291 | this.stores.router.push('/'); |
291 | 292 | ||
diff --git a/src/features/workspaces/api.ts b/src/features/workspaces/api.ts index 3c8cbbceb..582433527 100644 --- a/src/features/workspaces/api.ts +++ b/src/features/workspaces/api.ts | |||
@@ -4,14 +4,15 @@ import Request from '../../stores/lib/Request'; | |||
4 | import Workspace from './models/Workspace'; | 4 | import Workspace from './models/Workspace'; |
5 | import apiBase from '../../api/apiBase'; | 5 | import apiBase from '../../api/apiBase'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:feature:workspaces:api'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:feature:workspaces:api'); | ||
8 | 9 | ||
9 | export const workspaceApi = { | 10 | export const workspaceApi = { |
10 | getUserWorkspaces: async () => { | 11 | getUserWorkspaces: async () => { |
11 | const url = `${apiBase()}/workspace`; | 12 | const url = `${apiBase()}/workspace`; |
12 | debug('getUserWorkspaces GET', url); | 13 | console.log('getUserWorkspaces GET', url); |
13 | const result = await sendAuthRequest(url, { method: 'GET' }); | 14 | const result = await sendAuthRequest(url, { method: 'GET' }); |
14 | debug('getUserWorkspaces RESULT', result); | 15 | console.log('getUserWorkspaces RESULT', result); |
15 | if (!result.ok) { | 16 | if (!result.ok) { |
16 | throw new Error("Couldn't getUserWorkspaces"); | 17 | throw new Error("Couldn't getUserWorkspaces"); |
17 | } | 18 | } |
@@ -25,9 +26,9 @@ export const workspaceApi = { | |||
25 | method: 'POST', | 26 | method: 'POST', |
26 | body: JSON.stringify({ name }), | 27 | body: JSON.stringify({ name }), |
27 | }; | 28 | }; |
28 | debug('createWorkspace POST', url, options); | 29 | console.log('createWorkspace POST', url, options); |
29 | const result = await sendAuthRequest(url, options); | 30 | const result = await sendAuthRequest(url, options); |
30 | debug('createWorkspace RESULT', result); | 31 | console.log('createWorkspace RESULT', result); |
31 | if (!result.ok) { | 32 | if (!result.ok) { |
32 | throw new Error("Couldn't createWorkspace"); | 33 | throw new Error("Couldn't createWorkspace"); |
33 | } | 34 | } |
@@ -36,9 +37,9 @@ export const workspaceApi = { | |||
36 | 37 | ||
37 | deleteWorkspace: async workspace => { | 38 | deleteWorkspace: async workspace => { |
38 | const url = `${apiBase()}/workspace/${workspace.id}`; | 39 | const url = `${apiBase()}/workspace/${workspace.id}`; |
39 | debug('deleteWorkspace DELETE', url); | 40 | console.log('deleteWorkspace DELETE', url); |
40 | const result = await sendAuthRequest(url, { method: 'DELETE' }); | 41 | const result = await sendAuthRequest(url, { method: 'DELETE' }); |
41 | debug('deleteWorkspace RESULT', result); | 42 | console.log('deleteWorkspace RESULT', result); |
42 | if (!result.ok) { | 43 | if (!result.ok) { |
43 | throw new Error("Couldn't deleteWorkspace"); | 44 | throw new Error("Couldn't deleteWorkspace"); |
44 | } | 45 | } |
@@ -51,9 +52,9 @@ export const workspaceApi = { | |||
51 | method: 'PUT', | 52 | method: 'PUT', |
52 | body: JSON.stringify(pick(workspace, ['name', 'services'])), | 53 | body: JSON.stringify(pick(workspace, ['name', 'services'])), |
53 | }; | 54 | }; |
54 | debug('updateWorkspace UPDATE', url, options); | 55 | console.log('updateWorkspace UPDATE', url, options); |
55 | const result = await sendAuthRequest(url, options); | 56 | const result = await sendAuthRequest(url, options); |
56 | debug('updateWorkspace RESULT', result); | 57 | console.log('updateWorkspace RESULT', result); |
57 | if (!result.ok) { | 58 | if (!result.ok) { |
58 | throw new Error("Couldn't updateWorkspace"); | 59 | throw new Error("Couldn't updateWorkspace"); |
59 | } | 60 | } |
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 1f3d57c24..d2ccfeccf 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -15,7 +15,8 @@ import { createActionBindings } from '../utils/ActionBinding'; | |||
15 | 15 | ||
16 | import { KEEP_WS_LOADED_USID } from '../../config'; | 16 | import { KEEP_WS_LOADED_USID } from '../../config'; |
17 | 17 | ||
18 | const debug = require('debug')('Ferdium:feature:workspaces:store'); | 18 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
19 | // const debug = require('debug')('Ferdium:feature:workspaces:store'); | ||
19 | 20 | ||
20 | export default class WorkspacesStore extends FeatureStore { | 21 | export default class WorkspacesStore extends FeatureStore { |
21 | @observable isFeatureActive = false; | 22 | @observable isFeatureActive = false; |
@@ -69,7 +70,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
69 | // ========== PUBLIC API ========= // | 70 | // ========== PUBLIC API ========= // |
70 | 71 | ||
71 | @action start(stores, actions) { | 72 | @action start(stores, actions) { |
72 | debug('WorkspacesStore::start'); | 73 | console.log('WorkspacesStore::start'); |
73 | this.stores = stores; | 74 | this.stores = stores; |
74 | this.actions = actions; | 75 | this.actions = actions; |
75 | 76 | ||
@@ -115,7 +116,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
115 | 116 | ||
116 | @action stop() { | 117 | @action stop() { |
117 | super.stop(); | 118 | super.stop(); |
118 | debug('WorkspacesStore::stop'); | 119 | console.log('WorkspacesStore::stop'); |
119 | this.reset(); | 120 | this.reset(); |
120 | this.isFeatureActive = false; | 121 | this.isFeatureActive = false; |
121 | } | 122 | } |
@@ -273,7 +274,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
273 | }; | 274 | }; |
274 | 275 | ||
275 | _activateLastUsedWorkspaceReaction = () => { | 276 | _activateLastUsedWorkspaceReaction = () => { |
276 | debug('_activateLastUsedWorkspaceReaction'); | 277 | console.log('_activateLastUsedWorkspaceReaction'); |
277 | if (!this.activeWorkspace && this.userHasWorkspaces) { | 278 | if (!this.activeWorkspace && this.userHasWorkspaces) { |
278 | const { lastActiveWorkspace } = this.settings; | 279 | const { lastActiveWorkspace } = this.settings; |
279 | if (lastActiveWorkspace) { | 280 | if (lastActiveWorkspace) { |
diff --git a/src/helpers/url-helpers.ts b/src/helpers/url-helpers.ts index bd9796ab0..abe123577 100644 --- a/src/helpers/url-helpers.ts +++ b/src/helpers/url-helpers.ts | |||
@@ -6,7 +6,8 @@ import { shell } from 'electron'; | |||
6 | 6 | ||
7 | import { ALLOWED_PROTOCOLS } from '../config'; | 7 | import { ALLOWED_PROTOCOLS } from '../config'; |
8 | 8 | ||
9 | const debug = require('debug')('Ferdium:Helpers:url'); | 9 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
10 | // const debug = require('debug')('Ferdium:Helpers:url'); | ||
10 | 11 | ||
11 | export function isValidExternalURL(url: string | URL) { | 12 | export function isValidExternalURL(url: string | URL) { |
12 | let parsedUrl: URL; | 13 | let parsedUrl: URL; |
@@ -18,7 +19,7 @@ export function isValidExternalURL(url: string | URL) { | |||
18 | 19 | ||
19 | const isAllowed = ALLOWED_PROTOCOLS.includes(parsedUrl.protocol); | 20 | const isAllowed = ALLOWED_PROTOCOLS.includes(parsedUrl.protocol); |
20 | 21 | ||
21 | debug('protocol check is', isAllowed, 'for:', url); | 22 | console.log('protocol check is', isAllowed, 'for:', url); |
22 | 23 | ||
23 | return isAllowed; | 24 | return isAllowed; |
24 | } | 25 | } |
@@ -37,7 +38,7 @@ export function openExternalUrl( | |||
37 | url: string | URL, | 38 | url: string | URL, |
38 | skipValidityCheck: boolean = false, | 39 | skipValidityCheck: boolean = false, |
39 | ) { | 40 | ) { |
40 | debug('Open url:', url, 'with skipValidityCheck:', skipValidityCheck); | 41 | console.log('Open url:', url, 'with skipValidityCheck:', skipValidityCheck); |
41 | if (skipValidityCheck || isValidExternalURL(url)) { | 42 | if (skipValidityCheck || isValidExternalURL(url)) { |
42 | shell.openExternal(url.toString()); | 43 | shell.openExternal(url.toString()); |
43 | } | 44 | } |
diff --git a/src/index.ts b/src/index.ts index 1721651e4..6be4f3f18 100644 --- a/src/index.ts +++ b/src/index.ts | |||
@@ -44,10 +44,11 @@ import { asarPath } from './helpers/asar-helpers'; | |||
44 | import { openExternalUrl } from './helpers/url-helpers'; | 44 | import { openExternalUrl } from './helpers/url-helpers'; |
45 | import userAgent from './helpers/userAgent-helpers'; | 45 | import userAgent from './helpers/userAgent-helpers'; |
46 | 46 | ||
47 | const debug = require('debug')('Ferdium:App'); | 47 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
48 | // const debug = require('debug')('Ferdium:App'); | ||
48 | 49 | ||
49 | // Globally set useragent to fix user agent override in service workers | 50 | // Globally set useragent to fix user agent override in service workers |
50 | debug('Set userAgent to ', userAgent()); | 51 | console.log('Set userAgent to', userAgent()); |
51 | app.userAgentFallback = userAgent(); | 52 | app.userAgentFallback = userAgent(); |
52 | 53 | ||
53 | // Keep a global reference of the window object, if you don't, the window will | 54 | // Keep a global reference of the window object, if you don't, the window will |
@@ -126,7 +127,7 @@ if (!gotTheLock) { | |||
126 | if (argv.includes('--reset-window')) { | 127 | if (argv.includes('--reset-window')) { |
127 | // Needs to be delayed to not interfere with mainWindow.restore(); | 128 | // Needs to be delayed to not interfere with mainWindow.restore(); |
128 | setTimeout(() => { | 129 | setTimeout(() => { |
129 | debug('Resetting windows via Task'); | 130 | console.log('Resetting windows via Task'); |
130 | window.setPosition( | 131 | window.setPosition( |
131 | DEFAULT_WINDOW_OPTIONS.x + 100, | 132 | DEFAULT_WINDOW_OPTIONS.x + 100, |
132 | DEFAULT_WINDOW_OPTIONS.y + 100, | 133 | DEFAULT_WINDOW_OPTIONS.y + 100, |
@@ -139,7 +140,7 @@ if (!gotTheLock) { | |||
139 | } else if (argv.includes('--quit')) { | 140 | } else if (argv.includes('--quit')) { |
140 | // Needs to be delayed to not interfere with mainWindow.restore(); | 141 | // Needs to be delayed to not interfere with mainWindow.restore(); |
141 | setTimeout(() => { | 142 | setTimeout(() => { |
142 | debug('Quitting Ferdium via Task'); | 143 | console.log('Quitting Ferdium via Task'); |
143 | app.quit(); | 144 | app.quit(); |
144 | }, 1); | 145 | }, 1); |
145 | } | 146 | } |
@@ -161,7 +162,7 @@ if ( | |||
161 | 162 | ||
162 | // Disable GPU acceleration | 163 | // Disable GPU acceleration |
163 | if (!retrieveSettingValue('enableGPUAcceleration', false)) { | 164 | if (!retrieveSettingValue('enableGPUAcceleration', false)) { |
164 | debug('Disable GPU Acceleration'); | 165 | console.log('Disable GPU Acceleration'); |
165 | app.disableHardwareAcceleration(); | 166 | app.disableHardwareAcceleration(); |
166 | } | 167 | } |
167 | 168 | ||
@@ -183,7 +184,7 @@ const createWindow = () => { | |||
183 | let posY = mainWindowState.y || DEFAULT_WINDOW_OPTIONS.y; | 184 | let posY = mainWindowState.y || DEFAULT_WINDOW_OPTIONS.y; |
184 | 185 | ||
185 | if (!isPositionValid({ x: posX, y: posY })) { | 186 | if (!isPositionValid({ x: posX, y: posY })) { |
186 | debug('Window is out of screen bounds, resetting window'); | 187 | console.log('Window is out of screen bounds, resetting window'); |
187 | posX = DEFAULT_WINDOW_OPTIONS.x; | 188 | posX = DEFAULT_WINDOW_OPTIONS.x; |
188 | posY = DEFAULT_WINDOW_OPTIONS.y; | 189 | posY = DEFAULT_WINDOW_OPTIONS.y; |
189 | } | 190 | } |
@@ -284,7 +285,7 @@ const createWindow = () => { | |||
284 | 285 | ||
285 | // Emitted when the window is closed. | 286 | // Emitted when the window is closed. |
286 | mainWindow.on('close', e => { | 287 | mainWindow.on('close', e => { |
287 | debug('Window: close window'); | 288 | console.log('Window: close window'); |
288 | // Dereference the window object, usually you would store windows | 289 | // Dereference the window object, usually you would store windows |
289 | // in an array if your app supports multi windows, this is the time | 290 | // in an array if your app supports multi windows, this is the time |
290 | // when you should delete the corresponding element. | 291 | // when you should delete the corresponding element. |
@@ -297,7 +298,7 @@ const createWindow = () => { | |||
297 | ) { | 298 | ) { |
298 | e.preventDefault(); | 299 | e.preventDefault(); |
299 | if (isWindows) { | 300 | if (isWindows) { |
300 | debug('Window: minimize'); | 301 | console.log('Window: minimize'); |
301 | mainWindow?.minimize(); | 302 | mainWindow?.minimize(); |
302 | 303 | ||
303 | if ( | 304 | if ( |
@@ -306,16 +307,16 @@ const createWindow = () => { | |||
306 | DEFAULT_APP_SETTINGS.closeToSystemTray, | 307 | DEFAULT_APP_SETTINGS.closeToSystemTray, |
307 | ) | 308 | ) |
308 | ) { | 309 | ) { |
309 | debug('Skip taskbar: true'); | 310 | console.log('Skip taskbar: true'); |
310 | mainWindow?.setSkipTaskbar(true); | 311 | mainWindow?.setSkipTaskbar(true); |
311 | } | 312 | } |
312 | } else if (isMac && mainWindow?.isFullScreen()) { | 313 | } else if (isMac && mainWindow?.isFullScreen()) { |
313 | debug('Window: leaveFullScreen and hide'); | 314 | console.log('Window: leaveFullScreen and hide'); |
314 | mainWindow.once('show', () => mainWindow?.setFullScreen(true)); | 315 | mainWindow.once('show', () => mainWindow?.setFullScreen(true)); |
315 | mainWindow.once('leave-full-screen', () => mainWindow?.hide()); | 316 | mainWindow.once('leave-full-screen', () => mainWindow?.hide()); |
316 | mainWindow.setFullScreen(false); | 317 | mainWindow.setFullScreen(false); |
317 | } else { | 318 | } else { |
318 | debug('Window: hide'); | 319 | console.log('Window: hide'); |
319 | mainWindow?.hide(); | 320 | mainWindow?.hide(); |
320 | } | 321 | } |
321 | } else { | 322 | } else { |
@@ -336,31 +337,31 @@ const createWindow = () => { | |||
336 | DEFAULT_APP_SETTINGS.minimizeToSystemTray, | 337 | DEFAULT_APP_SETTINGS.minimizeToSystemTray, |
337 | ) | 338 | ) |
338 | ) { | 339 | ) { |
339 | debug('Skip taskbar: true'); | 340 | console.log('Skip taskbar: true'); |
340 | mainWindow?.setSkipTaskbar(true); | 341 | mainWindow?.setSkipTaskbar(true); |
341 | trayIcon.show(); | 342 | trayIcon.show(); |
342 | } | 343 | } |
343 | }); | 344 | }); |
344 | 345 | ||
345 | mainWindow.on('maximize', () => { | 346 | mainWindow.on('maximize', () => { |
346 | debug('Window: maximize'); | 347 | console.log('Window: maximize'); |
347 | // @ts-expect-error Property 'isMaximized' does not exist on type 'App'. | 348 | // @ts-expect-error Property 'isMaximized' does not exist on type 'App'. |
348 | app.isMaximized = true; | 349 | app.isMaximized = true; |
349 | }); | 350 | }); |
350 | 351 | ||
351 | mainWindow.on('unmaximize', () => { | 352 | mainWindow.on('unmaximize', () => { |
352 | debug('Window: unmaximize'); | 353 | console.log('Window: unmaximize'); |
353 | // @ts-expect-error Property 'isMaximized' does not exist on type 'App'. | 354 | // @ts-expect-error Property 'isMaximized' does not exist on type 'App'. |
354 | app.isMaximized = false; | 355 | app.isMaximized = false; |
355 | }); | 356 | }); |
356 | 357 | ||
357 | mainWindow.on('restore', () => { | 358 | mainWindow.on('restore', () => { |
358 | debug('Window: restore'); | 359 | console.log('Window: restore'); |
359 | mainWindow?.setSkipTaskbar(false); | 360 | mainWindow?.setSkipTaskbar(false); |
360 | 361 | ||
361 | // @ts-expect-error Property 'wasMaximized' does not exist on type 'App'. | 362 | // @ts-expect-error Property 'wasMaximized' does not exist on type 'App'. |
362 | if (app.wasMaximized) { | 363 | if (app.wasMaximized) { |
363 | debug('Window: was maximized before, maximize window'); | 364 | console.log('Window: was maximized before, maximize window'); |
364 | mainWindow?.maximize(); | 365 | mainWindow?.maximize(); |
365 | } | 366 | } |
366 | 367 | ||
@@ -370,7 +371,7 @@ const createWindow = () => { | |||
370 | DEFAULT_APP_SETTINGS.enableSystemTray, | 371 | DEFAULT_APP_SETTINGS.enableSystemTray, |
371 | ) | 372 | ) |
372 | ) { | 373 | ) { |
373 | debug('Tray: hiding tray icon'); | 374 | console.log('Tray: hiding tray icon'); |
374 | trayIcon.hide(); | 375 | trayIcon.hide(); |
375 | } | 376 | } |
376 | }); | 377 | }); |
@@ -382,7 +383,7 @@ const createWindow = () => { | |||
382 | } | 383 | } |
383 | 384 | ||
384 | mainWindow.on('show', () => { | 385 | mainWindow.on('show', () => { |
385 | debug('Skip taskbar: true'); | 386 | console.log('Skip taskbar: true'); |
386 | mainWindow?.setSkipTaskbar(false); | 387 | mainWindow?.setSkipTaskbar(false); |
387 | }); | 388 | }); |
388 | 389 | ||
@@ -499,18 +500,18 @@ let authCallback = noop; | |||
499 | app.on('login', (event, _webContents, _request, authInfo, callback) => { | 500 | app.on('login', (event, _webContents, _request, authInfo, callback) => { |
500 | // @ts-expect-error Type '(username?: string | undefined, password?: string | undefined) => void' is not assignable to type '() => null'. | 501 | // @ts-expect-error Type '(username?: string | undefined, password?: string | undefined) => void' is not assignable to type '() => null'. |
501 | authCallback = callback; | 502 | authCallback = callback; |
502 | debug('browser login event', authInfo); | 503 | console.log('browser login event', authInfo); |
503 | event.preventDefault(); | 504 | event.preventDefault(); |
504 | 505 | ||
505 | if (!authInfo.isProxy && authInfo.scheme === 'basic') { | 506 | if (!authInfo.isProxy && authInfo.scheme === 'basic') { |
506 | debug('basic auth handler', authInfo); | 507 | console.log('basic auth handler', authInfo); |
507 | basicAuthHandler(mainWindow!, authInfo); | 508 | basicAuthHandler(mainWindow!, authInfo); |
508 | } | 509 | } |
509 | }); | 510 | }); |
510 | 511 | ||
511 | // TODO: evaluate if we need to store the authCallback for every service | 512 | // TODO: evaluate if we need to store the authCallback for every service |
512 | ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => { | 513 | ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => { |
513 | debug('Received basic auth credentials', user, '********'); | 514 | console.log('Received basic auth credentials', user, '********'); |
514 | 515 | ||
515 | // @ts-expect-error Expected 0 arguments, but got 2. | 516 | // @ts-expect-error Expected 0 arguments, but got 2. |
516 | authCallback(user, password); | 517 | authCallback(user, password); |
@@ -529,13 +530,13 @@ ipcMain.on('open-browser-window', (_e, { url, serviceId }) => { | |||
529 | enableWebContents(child.webContents); | 530 | enableWebContents(child.webContents); |
530 | child.show(); | 531 | child.show(); |
531 | child.loadURL(url); | 532 | child.loadURL(url); |
532 | debug('Received open-browser-window', url); | 533 | console.log('Received open-browser-window', url); |
533 | }); | 534 | }); |
534 | 535 | ||
535 | ipcMain.on( | 536 | ipcMain.on( |
536 | 'modifyRequestHeaders', | 537 | 'modifyRequestHeaders', |
537 | (_e, { modifiedRequestHeaders, serviceId }) => { | 538 | (_e, { modifiedRequestHeaders, serviceId }) => { |
538 | debug( | 539 | console.log( |
539 | `Received modifyRequestHeaders ${modifiedRequestHeaders} for serviceId ${serviceId}`, | 540 | `Received modifyRequestHeaders ${modifiedRequestHeaders} for serviceId ${serviceId}`, |
540 | ); | 541 | ); |
541 | for (const headerFilterSet of modifiedRequestHeaders) { | 542 | for (const headerFilterSet of modifiedRequestHeaders) { |
@@ -556,7 +557,7 @@ ipcMain.on( | |||
556 | ); | 557 | ); |
557 | 558 | ||
558 | ipcMain.on('knownCertificateHosts', (_e, { knownHosts, serviceId }) => { | 559 | ipcMain.on('knownCertificateHosts', (_e, { knownHosts, serviceId }) => { |
559 | debug( | 560 | console.log( |
560 | `Received knownCertificateHosts ${knownHosts} for serviceId ${serviceId}`, | 561 | `Received knownCertificateHosts ${knownHosts} for serviceId ${serviceId}`, |
561 | ); | 562 | ); |
562 | session | 563 | session |
@@ -576,7 +577,7 @@ ipcMain.on('knownCertificateHosts', (_e, { knownHosts, serviceId }) => { | |||
576 | }); | 577 | }); |
577 | 578 | ||
578 | ipcMain.on('feature-basic-auth-cancel', () => { | 579 | ipcMain.on('feature-basic-auth-cancel', () => { |
579 | debug('Cancel basic auth'); | 580 | console.log('Cancel basic auth'); |
580 | 581 | ||
581 | // @ts-expect-error Expected 0 arguments, but got 2. | 582 | // @ts-expect-error Expected 0 arguments, but got 2. |
582 | authCallback(null); | 583 | authCallback(null); |
@@ -595,7 +596,7 @@ ipcMain.on('find-in-page', (e, text, options) => { | |||
595 | } | 596 | } |
596 | } | 597 | } |
597 | const requestId = webContents.findInPage(text, sanitizedOptions); | 598 | const requestId = webContents.findInPage(text, sanitizedOptions); |
598 | debug('Find in page', text, options, requestId); | 599 | console.log('Find in page', text, options, requestId); |
599 | e.returnValue = requestId; | 600 | e.returnValue = requestId; |
600 | } else { | 601 | } else { |
601 | e.returnValue = null; | 602 | e.returnValue = null; |
@@ -624,10 +625,10 @@ ipcMain.on('set-spellchecker-locales', (_e, { locale, serviceId }) => { | |||
624 | 625 | ||
625 | const serviceSession = session.fromPartition(`persist:service-${serviceId}`); | 626 | const serviceSession = session.fromPartition(`persist:service-${serviceId}`); |
626 | const [defaultLocale] = serviceSession.getSpellCheckerLanguages(); | 627 | const [defaultLocale] = serviceSession.getSpellCheckerLanguages(); |
627 | debug(`Spellchecker default locale is: ${defaultLocale}`); | 628 | console.log(`Spellchecker default locale is: ${defaultLocale}`); |
628 | 629 | ||
629 | const locales = [locale, defaultLocale, DEFAULT_APP_SETTINGS.fallbackLocale]; | 630 | const locales = [locale, defaultLocale, DEFAULT_APP_SETTINGS.fallbackLocale]; |
630 | debug(`Setting spellchecker locales to: ${locales}`); | 631 | console.log(`Setting spellchecker locales to: ${locales}`); |
631 | serviceSession.setSpellCheckerLanguages(locales); | 632 | serviceSession.setSpellCheckerLanguages(locales); |
632 | }); | 633 | }); |
633 | 634 | ||
@@ -645,10 +646,10 @@ app.on('window-all-closed', () => { | |||
645 | DEFAULT_APP_SETTINGS.runInBackground, | 646 | DEFAULT_APP_SETTINGS.runInBackground, |
646 | ) | 647 | ) |
647 | ) { | 648 | ) { |
648 | debug('Window: all windows closed, quit app'); | 649 | console.log('Window: all windows closed, quit app'); |
649 | app.quit(); | 650 | app.quit(); |
650 | } else { | 651 | } else { |
651 | debug("Window: don't quit app"); | 652 | console.log("Window: don't quit app"); |
652 | } | 653 | } |
653 | }); | 654 | }); |
654 | 655 | ||
@@ -694,7 +695,7 @@ app.on('will-finish-launching', () => { | |||
694 | event.preventDefault(); | 695 | event.preventDefault(); |
695 | 696 | ||
696 | onDidLoad((window: BrowserWindow) => { | 697 | onDidLoad((window: BrowserWindow) => { |
697 | debug('open-url event', url); | 698 | console.log('open-url event', url); |
698 | handleDeepLink(window, url); | 699 | handleDeepLink(window, url); |
699 | }); | 700 | }); |
700 | }); | 701 | }); |
diff --git a/src/models/Service.js b/src/models/Service.js index 94b907d4e..9f345375f 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -14,7 +14,8 @@ import { | |||
14 | ifUndefinedNumber, | 14 | ifUndefinedNumber, |
15 | } from '../jsUtils'; | 15 | } from '../jsUtils'; |
16 | 16 | ||
17 | const debug = require('debug')('Ferdium:Service'); | 17 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
18 | // const debug = require('debug')('Ferdium:Service'); | ||
18 | 19 | ||
19 | export default class Service { | 20 | export default class Service { |
20 | id = ''; | 21 | id = ''; |
@@ -305,25 +306,25 @@ export default class Service { | |||
305 | // Send those headers to ipcMain so that it can be set in session | 306 | // Send those headers to ipcMain so that it can be set in session |
306 | if (typeof this.recipe.modifyRequestHeaders === 'function') { | 307 | if (typeof this.recipe.modifyRequestHeaders === 'function') { |
307 | const modifiedRequestHeaders = this.recipe.modifyRequestHeaders(); | 308 | const modifiedRequestHeaders = this.recipe.modifyRequestHeaders(); |
308 | debug(this.name, 'modifiedRequestHeaders', modifiedRequestHeaders); | 309 | console.log(this.name, 'modifiedRequestHeaders', modifiedRequestHeaders); |
309 | ipcRenderer.send('modifyRequestHeaders', { | 310 | ipcRenderer.send('modifyRequestHeaders', { |
310 | modifiedRequestHeaders, | 311 | modifiedRequestHeaders, |
311 | serviceId: this.id, | 312 | serviceId: this.id, |
312 | }); | 313 | }); |
313 | } else { | 314 | } else { |
314 | debug(this.name, 'modifyRequestHeaders is not defined in the recipe'); | 315 | console.log(this.name, 'modifyRequestHeaders is not defined in the recipe'); |
315 | } | 316 | } |
316 | 317 | ||
317 | // if the recipe has implemented 'knownCertificateHosts' | 318 | // if the recipe has implemented 'knownCertificateHosts' |
318 | if (typeof this.recipe.knownCertificateHosts === 'function') { | 319 | if (typeof this.recipe.knownCertificateHosts === 'function') { |
319 | const knownHosts = this.recipe.knownCertificateHosts(); | 320 | const knownHosts = this.recipe.knownCertificateHosts(); |
320 | debug(this.name, 'knownCertificateHosts', knownHosts); | 321 | console.log(this.name, 'knownCertificateHosts', knownHosts); |
321 | ipcRenderer.send('knownCertificateHosts', { | 322 | ipcRenderer.send('knownCertificateHosts', { |
322 | knownHosts, | 323 | knownHosts, |
323 | serviceId: this.id, | 324 | serviceId: this.id, |
324 | }); | 325 | }); |
325 | } else { | 326 | } else { |
326 | debug(this.name, 'knownCertificateHosts is not defined in the recipe'); | 327 | console.log(this.name, 'knownCertificateHosts is not defined in the recipe'); |
327 | } | 328 | } |
328 | 329 | ||
329 | this.webview.addEventListener('ipc-message', async e => { | 330 | this.webview.addEventListener('ipc-message', async e => { |
@@ -347,7 +348,7 @@ export default class Service { | |||
347 | this.webview.addEventListener( | 348 | this.webview.addEventListener( |
348 | 'new-window', | 349 | 'new-window', |
349 | (event, url, frameName, options) => { | 350 | (event, url, frameName, options) => { |
350 | debug('new-window', event, url, frameName, options); | 351 | console.log('new-window', event, url, frameName, options); |
351 | if (!isValidExternalURL(event.url)) { | 352 | if (!isValidExternalURL(event.url)) { |
352 | return; | 353 | return; |
353 | } | 354 | } |
@@ -371,7 +372,7 @@ export default class Service { | |||
371 | ); | 372 | ); |
372 | 373 | ||
373 | this.webview.addEventListener('did-start-loading', event => { | 374 | this.webview.addEventListener('did-start-loading', event => { |
374 | debug('Did start load', this.name, event); | 375 | console.log('Did start load', this.name, event); |
375 | 376 | ||
376 | this.hasCrashed = false; | 377 | this.hasCrashed = false; |
377 | this.isLoading = true; | 378 | this.isLoading = true; |
@@ -390,7 +391,7 @@ export default class Service { | |||
390 | this.webview.addEventListener('did-navigate', didLoad.bind(this)); | 391 | this.webview.addEventListener('did-navigate', didLoad.bind(this)); |
391 | 392 | ||
392 | this.webview.addEventListener('did-fail-load', event => { | 393 | this.webview.addEventListener('did-fail-load', event => { |
393 | debug('Service failed to load', this.name, event); | 394 | console.log('Service failed to load', this.name, event); |
394 | if ( | 395 | if ( |
395 | event.isMainFrame && | 396 | event.isMainFrame && |
396 | event.errorCode !== -21 && | 397 | event.errorCode !== -21 && |
@@ -403,33 +404,33 @@ export default class Service { | |||
403 | }); | 404 | }); |
404 | 405 | ||
405 | this.webview.addEventListener('crashed', () => { | 406 | this.webview.addEventListener('crashed', () => { |
406 | debug('Service crashed', this.name); | 407 | console.log('Service crashed', this.name); |
407 | this.hasCrashed = true; | 408 | this.hasCrashed = true; |
408 | }); | 409 | }); |
409 | 410 | ||
410 | this.webview.addEventListener('found-in-page', ({ result }) => { | 411 | this.webview.addEventListener('found-in-page', ({ result }) => { |
411 | debug('Found in page', result); | 412 | console.log('Found in page', result); |
412 | this.webview.send('found-in-page', result); | 413 | this.webview.send('found-in-page', result); |
413 | }); | 414 | }); |
414 | 415 | ||
415 | webviewWebContents.on('login', (event, request, authInfo, callback) => { | 416 | webviewWebContents.on('login', (event, request, authInfo, callback) => { |
416 | // const authCallback = callback; | 417 | // const authCallback = callback; |
417 | debug('browser login event', authInfo); | 418 | console.log('browser login event', authInfo); |
418 | event.preventDefault(); | 419 | event.preventDefault(); |
419 | 420 | ||
420 | if (authInfo.isProxy && authInfo.scheme === 'basic') { | 421 | if (authInfo.isProxy && authInfo.scheme === 'basic') { |
421 | debug('Sending service echo ping'); | 422 | console.log('Sending service echo ping'); |
422 | webviewWebContents.send('get-service-id'); | 423 | webviewWebContents.send('get-service-id'); |
423 | 424 | ||
424 | debug('Received service id', this.id); | 425 | console.log('Received service id', this.id); |
425 | 426 | ||
426 | const ps = stores.settings.proxy[this.id]; | 427 | const ps = stores.settings.proxy[this.id]; |
427 | 428 | ||
428 | if (ps) { | 429 | if (ps) { |
429 | debug('Sending proxy auth callback for service', this.id); | 430 | console.log('Sending proxy auth callback for service', this.id); |
430 | callback(ps.user, ps.password); | 431 | callback(ps.user, ps.password); |
431 | } else { | 432 | } else { |
432 | debug('No proxy auth config found for', this.id); | 433 | console.log('No proxy auth config found for', this.id); |
433 | } | 434 | } |
434 | } | 435 | } |
435 | }); | 436 | }); |
diff --git a/src/models/UserAgent.js b/src/models/UserAgent.js index caacb6797..f818ee9d0 100644 --- a/src/models/UserAgent.js +++ b/src/models/UserAgent.js | |||
@@ -2,7 +2,8 @@ import { action, computed, observe, observable } from 'mobx'; | |||
2 | 2 | ||
3 | import defaultUserAgent from '../helpers/userAgent-helpers'; | 3 | import defaultUserAgent from '../helpers/userAgent-helpers'; |
4 | 4 | ||
5 | const debug = require('debug')('Ferdium:UserAgent'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:UserAgent'); | ||
6 | 7 | ||
7 | export default class UserAgent { | 8 | export default class UserAgent { |
8 | _willNavigateListener = null; | 9 | _willNavigateListener = null; |
@@ -78,7 +79,7 @@ export default class UserAgent { | |||
78 | @action _handleNavigate(url, forwardingHack = false) { | 79 | @action _handleNavigate(url, forwardingHack = false) { |
79 | if (url.startsWith('https://accounts.google.com')) { | 80 | if (url.startsWith('https://accounts.google.com')) { |
80 | if (!this.chromelessUserAgent) { | 81 | if (!this.chromelessUserAgent) { |
81 | debug('Setting user agent to chromeless for url', url); | 82 | console.log('Setting user agent to chromeless for url', url); |
82 | this.chromelessUserAgent = true; | 83 | this.chromelessUserAgent = true; |
83 | this.webview.userAgent = this.userAgent; | 84 | this.webview.userAgent = this.userAgent; |
84 | if (forwardingHack) { | 85 | if (forwardingHack) { |
@@ -86,14 +87,14 @@ export default class UserAgent { | |||
86 | } | 87 | } |
87 | } | 88 | } |
88 | } else if (this.chromelessUserAgent) { | 89 | } else if (this.chromelessUserAgent) { |
89 | debug('Setting user agent to contain chrome for url', url); | 90 | console.log('Setting user agent to contain chrome for url', url); |
90 | this.chromelessUserAgent = false; | 91 | this.chromelessUserAgent = false; |
91 | this.webview.userAgent = this.userAgent; | 92 | this.webview.userAgent = this.userAgent; |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | _addWebviewEvents(webview) { | 96 | _addWebviewEvents(webview) { |
96 | debug('Adding event handlers'); | 97 | console.log('Adding event handlers'); |
97 | 98 | ||
98 | this._willNavigateListener = event => this._handleNavigate(event.url, true); | 99 | this._willNavigateListener = event => this._handleNavigate(event.url, true); |
99 | webview.addEventListener('will-navigate', this._willNavigateListener); | 100 | webview.addEventListener('will-navigate', this._willNavigateListener); |
@@ -103,7 +104,7 @@ export default class UserAgent { | |||
103 | } | 104 | } |
104 | 105 | ||
105 | _removeWebviewEvents(webview) { | 106 | _removeWebviewEvents(webview) { |
106 | debug('Removing event handlers'); | 107 | console.log('Removing event handlers'); |
107 | 108 | ||
108 | webview.removeEventListener('will-navigate', this._willNavigateListener); | 109 | webview.removeEventListener('will-navigate', this._willNavigateListener); |
109 | webview.removeEventListener('did-navigate', this._didNavigateListener); | 110 | webview.removeEventListener('did-navigate', this._didNavigateListener); |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 68796b692..55cdce5f2 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -29,7 +29,8 @@ import { | |||
29 | import { openExternalUrl } from '../helpers/url-helpers'; | 29 | import { openExternalUrl } from '../helpers/url-helpers'; |
30 | import { sleep } from '../helpers/async-helpers'; | 30 | import { sleep } from '../helpers/async-helpers'; |
31 | 31 | ||
32 | const debug = require('debug')('Ferdium:AppStore'); | 32 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
33 | // const debug = require('debug')('Ferdium:AppStore'); | ||
33 | 34 | ||
34 | const mainWindow = getCurrentWindow(); | 35 | const mainWindow = getCurrentWindow(); |
35 | 36 | ||
@@ -195,7 +196,7 @@ export default class AppStore extends Store { | |||
195 | 196 | ||
196 | // Handle deep linking (ferdium://) | 197 | // Handle deep linking (ferdium://) |
197 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | 198 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { |
198 | debug('Navigate from deep link', data); | 199 | console.log('Navigate from deep link', data); |
199 | let { url } = data; | 200 | let { url } = data; |
200 | if (!url) return; | 201 | if (!url) return; |
201 | 202 | ||
@@ -217,28 +218,28 @@ export default class AppStore extends Store { | |||
217 | this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors; | 218 | this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors; |
218 | 219 | ||
219 | ipcRenderer.on('isWindowFocused', (event, isFocused) => { | 220 | ipcRenderer.on('isWindowFocused', (event, isFocused) => { |
220 | debug('Setting is focused to', isFocused); | 221 | console.log('Setting is focused to', isFocused); |
221 | this.isFocused = isFocused; | 222 | this.isFocused = isFocused; |
222 | }); | 223 | }); |
223 | 224 | ||
224 | powerMonitor.on('suspend', () => { | 225 | powerMonitor.on('suspend', () => { |
225 | debug('System suspended starting timer'); | 226 | console.log('System suspended starting timer'); |
226 | 227 | ||
227 | this.timeSuspensionStart = moment(); | 228 | this.timeSuspensionStart = moment(); |
228 | }); | 229 | }); |
229 | 230 | ||
230 | powerMonitor.on('resume', () => { | 231 | powerMonitor.on('resume', () => { |
231 | debug('System resumed, last suspended on', this.timeSuspensionStart); | 232 | console.log('System resumed, last suspended on', this.timeSuspensionStart); |
232 | this.actions.service.resetLastPollTimer(); | 233 | this.actions.service.resetLastPollTimer(); |
233 | 234 | ||
234 | if ( | 235 | if ( |
235 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && | 236 | this.timeSuspensionStart.add(10, 'm').isBefore(moment()) && |
236 | this.stores.settings.app.get('reloadAfterResume') | 237 | this.stores.settings.app.get('reloadAfterResume') |
237 | ) { | 238 | ) { |
238 | debug('Reloading services, user info and features'); | 239 | console.log('Reloading services, user info and features'); |
239 | 240 | ||
240 | setInterval(() => { | 241 | setInterval(() => { |
241 | debug('Reload app interval is starting'); | 242 | console.log('Reload app interval is starting'); |
242 | if (this.isOnline) { | 243 | if (this.isOnline) { |
243 | window.location.reload(); | 244 | window.location.reload(); |
244 | } | 245 | } |
@@ -250,7 +251,7 @@ export default class AppStore extends Store { | |||
250 | // notifications got stuck after upgrade but forcing a notification | 251 | // notifications got stuck after upgrade but forcing a notification |
251 | // via `new Notification` triggered the permission request | 252 | // via `new Notification` triggered the permission request |
252 | if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { | 253 | if (isMac && !localStorage.getItem(CATALINA_NOTIFICATION_HACK_KEY)) { |
253 | debug('Triggering macOS Catalina notification permission trigger'); | 254 | console.log('Triggering macOS Catalina notification permission trigger'); |
254 | // eslint-disable-next-line no-new | 255 | // eslint-disable-next-line no-new |
255 | new window.Notification('Welcome to Ferdium 5', { | 256 | new window.Notification('Welcome to Ferdium 5', { |
256 | body: 'Have a wonderful day & happy messaging.', | 257 | body: 'Have a wonderful day & happy messaging.', |
@@ -319,7 +320,7 @@ export default class AppStore extends Store { | |||
319 | 320 | ||
320 | const notification = new window.Notification(title, options); | 321 | const notification = new window.Notification(title, options); |
321 | 322 | ||
322 | debug('New notification', title, options); | 323 | console.log('New notification', title, options); |
323 | 324 | ||
324 | notification.addEventListener('click', () => { | 325 | notification.addEventListener('click', () => { |
325 | if (serviceId) { | 326 | if (serviceId) { |
@@ -341,7 +342,7 @@ export default class AppStore extends Store { | |||
341 | } | 342 | } |
342 | mainWindow.focus(); | 343 | mainWindow.focus(); |
343 | 344 | ||
344 | debug('Notification click handler'); | 345 | console.log('Notification click handler'); |
345 | } | 346 | } |
346 | }); | 347 | }); |
347 | } | 348 | } |
@@ -370,10 +371,10 @@ export default class AppStore extends Store { | |||
370 | 371 | ||
371 | try { | 372 | try { |
372 | if (enable) { | 373 | if (enable) { |
373 | debug('enabling launch on startup', executablePath); | 374 | console.log('enabling launch on startup', executablePath); |
374 | autoLauncher.enable(); | 375 | autoLauncher.enable(); |
375 | } else { | 376 | } else { |
376 | debug('disabling launch on startup'); | 377 | console.log('disabling launch on startup'); |
377 | autoLauncher.disable(); | 378 | autoLauncher.disable(); |
378 | } | 379 | } |
379 | } catch (error) { | 380 | } catch (error) { |
@@ -388,7 +389,7 @@ export default class AppStore extends Store { | |||
388 | 389 | ||
389 | @action _checkForUpdates() { | 390 | @action _checkForUpdates() { |
390 | if (this.isOnline && this.stores.settings.app.automaticUpdates && (isMac || isWindows || process.env.APPIMAGE)) { | 391 | if (this.isOnline && this.stores.settings.app.automaticUpdates && (isMac || isWindows || process.env.APPIMAGE)) { |
391 | debug('_checkForUpdates: sending event to autoUpdate:check'); | 392 | console.log('_checkForUpdates: sending event to autoUpdate:check'); |
392 | this.updateStatus = this.updateStatusTypes.CHECKING; | 393 | this.updateStatus = this.updateStatusTypes.CHECKING; |
393 | ipcRenderer.send('autoUpdate', { | 394 | ipcRenderer.send('autoUpdate', { |
394 | action: 'check', | 395 | action: 'check', |
@@ -401,7 +402,7 @@ export default class AppStore extends Store { | |||
401 | } | 402 | } |
402 | 403 | ||
403 | @action _installUpdate() { | 404 | @action _installUpdate() { |
404 | debug('_installUpdate: sending event to autoUpdate:install'); | 405 | console.log('_installUpdate: sending event to autoUpdate:install'); |
405 | ipcRenderer.send('autoUpdate', { | 406 | ipcRenderer.send('autoUpdate', { |
406 | action: 'install', | 407 | action: 'install', |
407 | }); | 408 | }); |
@@ -487,7 +488,7 @@ export default class AppStore extends Store { | |||
487 | } | 488 | } |
488 | 489 | ||
489 | moment.locale(this.locale); | 490 | moment.locale(this.locale); |
490 | debug(`Set locale to "${this.locale}"`); | 491 | console.log(`Set locale to "${this.locale}"`); |
491 | } | 492 | } |
492 | 493 | ||
493 | _getDefaultLocale() { | 494 | _getDefaultLocale() { |
@@ -541,7 +542,7 @@ export default class AppStore extends Store { | |||
541 | this.autoLaunchOnStart = await this._checkAutoStart(); | 542 | this.autoLaunchOnStart = await this._checkAutoStart(); |
542 | 543 | ||
543 | if (this.stores.settings.all.stats.appStarts === 1) { | 544 | if (this.stores.settings.all.stats.appStarts === 1) { |
544 | debug('Set app to launch on start'); | 545 | console.log('Set app to launch on start'); |
545 | this.actions.app.launchOnStartup({ | 546 | this.actions.app.launchOnStartup({ |
546 | enable: true, | 547 | enable: true, |
547 | }); | 548 | }); |
@@ -553,9 +554,9 @@ export default class AppStore extends Store { | |||
553 | } | 554 | } |
554 | 555 | ||
555 | async _systemDND() { | 556 | async _systemDND() { |
556 | debug('Checking if Do Not Disturb Mode is on'); | 557 | console.log('Checking if Do Not Disturb Mode is on'); |
557 | const dnd = await ipcRenderer.invoke('get-dnd'); | 558 | const dnd = await ipcRenderer.invoke('get-dnd'); |
558 | debug('Do not disturb mode is', dnd); | 559 | console.log('Do not disturb mode is', dnd); |
559 | if ( | 560 | if ( |
560 | dnd !== this.stores.settings.all.app.isAppMuted && | 561 | dnd !== this.stores.settings.all.app.isAppMuted && |
561 | !this.isSystemMuteOverridden | 562 | !this.isSystemMuteOverridden |
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index 0a3db2488..d39b87401 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js | |||
@@ -8,7 +8,8 @@ import Request from './lib/Request'; | |||
8 | import { matchRoute } from '../helpers/routing-helpers'; | 8 | import { matchRoute } from '../helpers/routing-helpers'; |
9 | import { asarRecipesPath } from '../helpers/asar-helpers'; | 9 | import { asarRecipesPath } from '../helpers/asar-helpers'; |
10 | 10 | ||
11 | const debug = require('debug')('Ferdium:RecipeStore'); | 11 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
12 | // const debug = require('debug')('Ferdium:RecipeStore'); | ||
12 | 13 | ||
13 | export default class RecipesStore extends Store { | 14 | export default class RecipesStore extends Store { |
14 | @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all'); | 15 | @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all'); |
@@ -47,7 +48,7 @@ export default class RecipesStore extends Store { | |||
47 | return activeRecipe; | 48 | return activeRecipe; |
48 | } | 49 | } |
49 | 50 | ||
50 | debug(`Recipe ${match.id} not installed`); | 51 | console.log(`Recipe ${match.id} not installed`); |
51 | } | 52 | } |
52 | 53 | ||
53 | return null; | 54 | return null; |
@@ -78,7 +79,7 @@ export default class RecipesStore extends Store { | |||
78 | const recipes = {}; | 79 | const recipes = {}; |
79 | 80 | ||
80 | // Hackfix, reference this.all to fetch services | 81 | // Hackfix, reference this.all to fetch services |
81 | debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); | 82 | console.log(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); |
82 | 83 | ||
83 | for (const r of recipeIds) { | 84 | for (const r of recipeIds) { |
84 | const recipe = this.one(r); | 85 | const recipe = this.one(r); |
@@ -107,7 +108,7 @@ export default class RecipesStore extends Store { | |||
107 | } | 108 | } |
108 | 109 | ||
109 | const updates = [...remoteUpdates, ...localUpdates]; | 110 | const updates = [...remoteUpdates, ...localUpdates]; |
110 | debug( | 111 | console.log( |
111 | 'Got update information (local, remote):', | 112 | 'Got update information (local, remote):', |
112 | localUpdates, | 113 | localUpdates, |
113 | remoteUpdates, | 114 | remoteUpdates, |
@@ -145,7 +146,7 @@ export default class RecipesStore extends Store { | |||
145 | 146 | ||
146 | if (!this.stores.recipes.isInstalled(recipeId)) { | 147 | if (!this.stores.recipes.isInstalled(recipeId)) { |
147 | router.push('/settings/recipes'); | 148 | router.push('/settings/recipes'); |
148 | debug(`Recipe ${recipeId} is not installed, trying to install it`); | 149 | console.log(`Recipe ${recipeId} is not installed, trying to install it`); |
149 | 150 | ||
150 | const recipe = await this.installRecipeRequest.execute(recipeId) | 151 | const recipe = await this.installRecipeRequest.execute(recipeId) |
151 | ._promise; | 152 | ._promise; |
diff --git a/src/stores/RequestStore.js b/src/stores/RequestStore.js index 2e76a7023..a6991409c 100644 --- a/src/stores/RequestStore.js +++ b/src/stores/RequestStore.js | |||
@@ -4,7 +4,8 @@ import ms from 'ms'; | |||
4 | 4 | ||
5 | import Store from './lib/Store'; | 5 | import Store from './lib/Store'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:RequestsStore'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:RequestsStore'); | ||
8 | 9 | ||
9 | export default class RequestStore extends Store { | 10 | export default class RequestStore extends Store { |
10 | @observable userInfoRequest; | 11 | @observable userInfoRequest; |
@@ -65,7 +66,7 @@ export default class RequestStore extends Store { | |||
65 | } | 66 | } |
66 | 67 | ||
67 | this._autoRetry(); | 68 | this._autoRetry(); |
68 | debug(`Retry required requests delayed in ${delay / 1000}s`); | 69 | console.log(`Retry required requests delayed in ${delay / 1000}s`); |
69 | }, delay); | 70 | }, delay); |
70 | } | 71 | } |
71 | } | 72 | } |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 1c800df59..3847536ca 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -19,7 +19,8 @@ import { DEFAULT_SERVICE_SETTINGS, KEEP_WS_LOADED_USID } from '../config'; | |||
19 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 19 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
20 | import { ferdiumVersion } from '../environment-remote'; | 20 | import { ferdiumVersion } from '../environment-remote'; |
21 | 21 | ||
22 | const debug = require('debug')('Ferdium:ServiceStore'); | 22 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
23 | // const debug = require('debug')('Ferdium:ServiceStore'); | ||
23 | 24 | ||
24 | export default class ServicesStore extends Store { | 25 | export default class ServicesStore extends Store { |
25 | @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); | 26 | @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); |
@@ -212,7 +213,7 @@ export default class ServicesStore extends Store { | |||
212 | serviceMaintenanceTick = debounce(() => { | 213 | serviceMaintenanceTick = debounce(() => { |
213 | this._serviceMaintenance(); | 214 | this._serviceMaintenance(); |
214 | this.serviceMaintenanceTick(); | 215 | this.serviceMaintenanceTick(); |
215 | debug('Service maintenance tick'); | 216 | console.log('Service maintenance tick'); |
216 | }, ms('10s')); | 217 | }, ms('10s')); |
217 | 218 | ||
218 | /** | 219 | /** |
@@ -250,7 +251,7 @@ export default class ServicesStore extends Store { | |||
250 | // If service did not reply for more than 1m try to reload. | 251 | // If service did not reply for more than 1m try to reload. |
251 | if (!service.isActive) { | 252 | if (!service.isActive) { |
252 | if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) { | 253 | if (this.stores.app.isOnline && service.lostRecipeReloadAttempt < 3) { |
253 | debug( | 254 | console.log( |
254 | `Reloading service: ${service.name} (${service.id}). Attempt: ${service.lostRecipeReloadAttempt}`, | 255 | `Reloading service: ${service.name} (${service.id}). Attempt: ${service.lostRecipeReloadAttempt}`, |
255 | ); | 256 | ); |
256 | // service.webview.reload(); | 257 | // service.webview.reload(); |
@@ -259,7 +260,7 @@ export default class ServicesStore extends Store { | |||
259 | service.lostRecipeConnection = false; | 260 | service.lostRecipeConnection = false; |
260 | } | 261 | } |
261 | } else { | 262 | } else { |
262 | debug(`Service lost connection: ${service.name} (${service.id}).`); | 263 | console.log(`Service lost connection: ${service.name} (${service.id}).`); |
263 | service.lostRecipeConnection = true; | 264 | service.lostRecipeConnection = true; |
264 | } | 265 | } |
265 | } else { | 266 | } else { |
@@ -363,7 +364,7 @@ export default class ServicesStore extends Store { | |||
363 | return activeService; | 364 | return activeService; |
364 | } | 365 | } |
365 | 366 | ||
366 | debug('Service not available'); | 367 | console.log('Service not available'); |
367 | } | 368 | } |
368 | 369 | ||
369 | return null; | 370 | return null; |
@@ -397,9 +398,9 @@ export default class ServicesStore extends Store { | |||
397 | skipCleanup = false, | 398 | skipCleanup = false, |
398 | }) { | 399 | }) { |
399 | if (!this.stores.recipes.isInstalled(recipeId)) { | 400 | if (!this.stores.recipes.isInstalled(recipeId)) { |
400 | debug(`Recipe "${recipeId}" is not installed, installing recipe`); | 401 | console.log(`Recipe "${recipeId}" is not installed, installing recipe`); |
401 | await this.stores.recipes._install({ recipeId }); | 402 | await this.stores.recipes._install({ recipeId }); |
402 | debug(`Recipe "${recipeId}" installed`); | 403 | console.log(`Recipe "${recipeId}" installed`); |
403 | } | 404 | } |
404 | 405 | ||
405 | // set default values for serviceData | 406 | // set default values for serviceData |
@@ -616,7 +617,7 @@ export default class ServicesStore extends Store { | |||
616 | if (service) { | 617 | if (service) { |
617 | service.isActive = false; | 618 | service.isActive = false; |
618 | } else { | 619 | } else { |
619 | debug('No service is active'); | 620 | console.log('No service is active'); |
620 | } | 621 | } |
621 | } | 622 | } |
622 | 623 | ||
@@ -659,7 +660,7 @@ export default class ServicesStore extends Store { | |||
659 | service.webview = webview; | 660 | service.webview = webview; |
660 | 661 | ||
661 | if (!service.isAttached) { | 662 | if (!service.isAttached) { |
662 | debug('Webview is not attached, initializing'); | 663 | console.log('Webview is not attached, initializing'); |
663 | service.initializeWebViewEvents({ | 664 | service.initializeWebViewEvents({ |
664 | handleIPCMessage: this.actions.service.handleIPCMessage, | 665 | handleIPCMessage: this.actions.service.handleIPCMessage, |
665 | openWindow: this.actions.service.openWindow, | 666 | openWindow: this.actions.service.openWindow, |
@@ -708,7 +709,7 @@ export default class ServicesStore extends Store { | |||
708 | } | 709 | } |
709 | } | 710 | } |
710 | } else { | 711 | } else { |
711 | debug('No service is active'); | 712 | console.log('No service is active'); |
712 | } | 713 | } |
713 | } else { | 714 | } else { |
714 | this.allServicesRequest.invalidate(); | 715 | this.allServicesRequest.invalidate(); |
@@ -727,7 +728,7 @@ export default class ServicesStore extends Store { | |||
727 | // eslint-disable-next-line default-case | 728 | // eslint-disable-next-line default-case |
728 | switch (channel) { | 729 | switch (channel) { |
729 | case 'hello': { | 730 | case 'hello': { |
730 | debug('Received hello event from', serviceId); | 731 | console.log('Received hello event from', serviceId); |
731 | 732 | ||
732 | this._initRecipePolling(service.id); | 733 | this._initRecipePolling(service.id); |
733 | this._initializeServiceRecipeInWebview(serviceId); | 734 | this._initializeServiceRecipeInWebview(serviceId); |
@@ -741,7 +742,7 @@ export default class ServicesStore extends Store { | |||
741 | break; | 742 | break; |
742 | } | 743 | } |
743 | case 'message-counts': { | 744 | case 'message-counts': { |
744 | debug(`Received unread message info from '${serviceId}'`, args[0]); | 745 | console.log(`Received unread message info from '${serviceId}'`, args[0]); |
745 | 746 | ||
746 | this.actions.service.setUnreadMessageCount({ | 747 | this.actions.service.setUnreadMessageCount({ |
747 | serviceId, | 748 | serviceId, |
@@ -754,7 +755,7 @@ export default class ServicesStore extends Store { | |||
754 | break; | 755 | break; |
755 | } | 756 | } |
756 | case 'active-dialog-title': { | 757 | case 'active-dialog-title': { |
757 | debug(`Received active dialog title from '${serviceId}'`, args[0]); | 758 | console.log(`Received active dialog title from '${serviceId}'`, args[0]); |
758 | 759 | ||
759 | this.actions.service.setDialogTitle({ | 760 | this.actions.service.setDialogTitle({ |
760 | serviceId, | 761 | serviceId, |
@@ -919,7 +920,7 @@ export default class ServicesStore extends Store { | |||
919 | serviceId: service.id, | 920 | serviceId: service.id, |
920 | }); | 921 | }); |
921 | } else { | 922 | } else { |
922 | debug('No service is active'); | 923 | console.log('No service is active'); |
923 | } | 924 | } |
924 | } | 925 | } |
925 | 926 | ||
@@ -1027,7 +1028,7 @@ export default class ServicesStore extends Store { | |||
1027 | if (service) { | 1028 | if (service) { |
1028 | this._openDevTools({ serviceId: service.id }); | 1029 | this._openDevTools({ serviceId: service.id }); |
1029 | } else { | 1030 | } else { |
1030 | debug('No service is active'); | 1031 | console.log('No service is active'); |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | 1034 | ||
@@ -1037,7 +1038,7 @@ export default class ServicesStore extends Store { | |||
1037 | return; | 1038 | return; |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | debug(`Hibernate ${service.name}`); | 1041 | console.log(`Hibernate ${service.name}`); |
1041 | 1042 | ||
1042 | service.isHibernationRequested = true; | 1043 | service.isHibernationRequested = true; |
1043 | service.lastHibernated = Date.now(); | 1044 | service.lastHibernated = Date.now(); |
@@ -1047,7 +1048,7 @@ export default class ServicesStore extends Store { | |||
1047 | const now = Date.now(); | 1048 | const now = Date.now(); |
1048 | const service = this.one(serviceId); | 1049 | const service = this.one(serviceId); |
1049 | const automaticTag = automatic ? ' automatically ' : ' '; | 1050 | const automaticTag = automatic ? ' automatically ' : ' '; |
1050 | debug( | 1051 | console.log( |
1051 | `Waking up${automaticTag}from service hibernation for ${service.name}`, | 1052 | `Waking up${automaticTag}from service hibernation for ${service.name}`, |
1052 | ); | 1053 | ); |
1053 | 1054 | ||
@@ -1068,8 +1069,8 @@ export default class ServicesStore extends Store { | |||
1068 | // | 1069 | // |
1069 | const mainStrategy = this.stores.settings.all.app.hibernationStrategy; | 1070 | const mainStrategy = this.stores.settings.all.app.hibernationStrategy; |
1070 | let strategy = this.stores.settings.all.app.wakeUpHibernationStrategy; | 1071 | let strategy = this.stores.settings.all.app.wakeUpHibernationStrategy; |
1071 | debug(`wakeUpHibernationStrategy = ${strategy}`); | 1072 | console.log(`wakeUpHibernationStrategy = ${strategy}`); |
1072 | debug(`hibernationStrategy = ${mainStrategy}`); | 1073 | console.log(`hibernationStrategy = ${mainStrategy}`); |
1073 | if (!strategy || strategy < 1) { | 1074 | if (!strategy || strategy < 1) { |
1074 | strategy = this.stores.settings.all.app.hibernationStrategy; | 1075 | strategy = this.stores.settings.all.app.hibernationStrategy; |
1075 | } | 1076 | } |
@@ -1081,16 +1082,16 @@ export default class ServicesStore extends Store { | |||
1081 | ) { | 1082 | ) { |
1082 | // Add 10 additional seconds 50% of the time. | 1083 | // Add 10 additional seconds 50% of the time. |
1083 | splay = 10; | 1084 | splay = 10; |
1084 | debug('Added splay'); | 1085 | console.log('Added splay'); |
1085 | } else { | 1086 | } else { |
1086 | debug('skipping splay'); | 1087 | console.log('skipping splay'); |
1087 | } | 1088 | } |
1088 | // wake up again in strategy + splay seconds instead of mainStrategy seconds. | 1089 | // wake up again in strategy + splay seconds instead of mainStrategy seconds. |
1089 | service.lastUsed = now - ms(`${mainStrategy - (strategy + splay)}s`); | 1090 | service.lastUsed = now - ms(`${mainStrategy - (strategy + splay)}s`); |
1090 | } else { | 1091 | } else { |
1091 | service.lastUsed = now; | 1092 | service.lastUsed = now; |
1092 | } | 1093 | } |
1093 | debug( | 1094 | console.log( |
1094 | `Setting service.lastUsed to ${service.lastUsed} (${ | 1095 | `Setting service.lastUsed to ${service.lastUsed} (${ |
1095 | (now - service.lastUsed) / 1000 | 1096 | (now - service.lastUsed) / 1000 |
1096 | }s ago)`, | 1097 | }s ago)`, |
@@ -1100,7 +1101,7 @@ export default class ServicesStore extends Store { | |||
1100 | } | 1101 | } |
1101 | 1102 | ||
1102 | @action _resetLastPollTimer({ serviceId = null }) { | 1103 | @action _resetLastPollTimer({ serviceId = null }) { |
1103 | debug( | 1104 | console.log( |
1104 | `Reset last poll timer for ${ | 1105 | `Reset last poll timer for ${ |
1105 | serviceId ? `service: "${serviceId}"` : 'all services' | 1106 | serviceId ? `service: "${serviceId}"` : 'all services' |
1106 | }`, | 1107 | }`, |
@@ -1131,7 +1132,7 @@ export default class ServicesStore extends Store { | |||
1131 | service.dialogTitle ? ` - ${service.dialogTitle}` : '' | 1132 | service.dialogTitle ? ` - ${service.dialogTitle}` : '' |
1132 | } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; | 1133 | } ${service._webview ? `- ${service._webview.getTitle()}` : ''}`; |
1133 | } else { | 1134 | } else { |
1134 | debug('No service is active'); | 1135 | console.log('No service is active'); |
1135 | } | 1136 | } |
1136 | } | 1137 | } |
1137 | 1138 | ||
@@ -1145,7 +1146,7 @@ export default class ServicesStore extends Store { | |||
1145 | }, | 1146 | }, |
1146 | }); | 1147 | }); |
1147 | } else { | 1148 | } else { |
1148 | debug('No service is active'); | 1149 | console.log('No service is active'); |
1149 | } | 1150 | } |
1150 | } | 1151 | } |
1151 | 1152 | ||
@@ -1261,7 +1262,7 @@ export default class ServicesStore extends Store { | |||
1261 | this.allDisplayed.findIndex(service => service.isActive) === -1 && | 1262 | this.allDisplayed.findIndex(service => service.isActive) === -1 && |
1262 | this.allDisplayed.length > 0 | 1263 | this.allDisplayed.length > 0 |
1263 | ) { | 1264 | ) { |
1264 | debug('No active service found, setting active service to index 0'); | 1265 | console.log('No active service found, setting active service to index 0'); |
1265 | 1266 | ||
1266 | this._setActive({ serviceId: this.allDisplayed[0].id }); | 1267 | this._setActive({ serviceId: this.allDisplayed[0].id }); |
1267 | } | 1268 | } |
@@ -1277,7 +1278,7 @@ export default class ServicesStore extends Store { | |||
1277 | JSON.stringify(service.shareWithWebview), | 1278 | JSON.stringify(service.shareWithWebview), |
1278 | ); | 1279 | ); |
1279 | 1280 | ||
1280 | debug('Initialize recipe', service.recipe.id, service.name); | 1281 | console.log('Initialize recipe', service.recipe.id, service.name); |
1281 | service.webview.send( | 1282 | service.webview.send( |
1282 | 'initialize-recipe', | 1283 | 'initialize-recipe', |
1283 | { | 1284 | { |
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index cfd73c705..3ba791239 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -11,7 +11,8 @@ import { hash } from '../helpers/password-helpers'; | |||
11 | import Request from './lib/Request'; | 11 | import Request from './lib/Request'; |
12 | import Store from './lib/Store'; | 12 | import Store from './lib/Store'; |
13 | 13 | ||
14 | const debug = require('debug')('Ferdium:SettingsStore'); | 14 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
15 | // const debug = require('debug')('Ferdium:SettingsStore'); | ||
15 | 16 | ||
16 | export default class SettingsStore extends Store { | 17 | export default class SettingsStore extends Store { |
17 | @observable updateAppSettingsRequest = new Request( | 18 | @observable updateAppSettingsRequest = new Request( |
@@ -94,7 +95,7 @@ export default class SettingsStore extends Store { | |||
94 | } | 95 | } |
95 | }); | 96 | }); |
96 | } | 97 | } |
97 | debug('Get appSettings resolves', resp.type, resp.data); | 98 | console.log('Get appSettings resolves', resp.type, resp.data); |
98 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); | 99 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); |
99 | this.loaded = true; | 100 | this.loaded = true; |
100 | ipcRenderer.send('initialAppSettings', resp); | 101 | ipcRenderer.send('initialAppSettings', resp); |
@@ -146,10 +147,10 @@ export default class SettingsStore extends Store { | |||
146 | @action async _update({ type, data }) { | 147 | @action async _update({ type, data }) { |
147 | const appSettings = this.all; | 148 | const appSettings = this.all; |
148 | if (!this.fileSystemSettingsTypes.includes(type)) { | 149 | if (!this.fileSystemSettingsTypes.includes(type)) { |
149 | debug('Update settings', type, data, this.all); | 150 | console.log('Update settings', type, data, this.all); |
150 | localStorage.setItem(type, Object.assign(appSettings[type], data)); | 151 | localStorage.setItem(type, Object.assign(appSettings[type], data)); |
151 | } else { | 152 | } else { |
152 | debug('Update settings on file system', type, data); | 153 | console.log('Update settings on file system', type, data); |
153 | ipcRenderer.send('updateAppSettings', { | 154 | ipcRenderer.send('updateAppSettings', { |
154 | type, | 155 | type, |
155 | data, | 156 | data, |
@@ -200,7 +201,7 @@ export default class SettingsStore extends Store { | |||
200 | }); | 201 | }); |
201 | } | 202 | } |
202 | 203 | ||
203 | debug('Migrated updates settings'); | 204 | console.log('Migrated updates settings'); |
204 | }); | 205 | }); |
205 | 206 | ||
206 | this._ensureMigrationAndMarkDone('5.6.0-beta.6-settings', () => { | 207 | this._ensureMigrationAndMarkDone('5.6.0-beta.6-settings', () => { |
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 787ffbb56..8c413a065 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -10,7 +10,8 @@ import Store from './lib/Store'; | |||
10 | import Request from './lib/Request'; | 10 | import Request from './lib/Request'; |
11 | import CachedRequest from './lib/CachedRequest'; | 11 | import CachedRequest from './lib/CachedRequest'; |
12 | 12 | ||
13 | const debug = require('debug')('Ferdium:UserStore'); | 13 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
14 | // const debug = require('debug')('Ferdium:UserStore'); | ||
14 | 15 | ||
15 | // TODO: split stores into UserStore and AuthStore | 16 | // TODO: split stores into UserStore and AuthStore |
16 | export default class UserStore extends Store { | 17 | export default class UserStore extends Store { |
@@ -394,7 +395,7 @@ export default class UserStore extends Store { | |||
394 | } | 395 | } |
395 | 396 | ||
396 | if (!this.data.locale) { | 397 | if (!this.data.locale) { |
397 | debug('Migrate "locale" to user data'); | 398 | console.log('Migrate "locale" to user data'); |
398 | this.actions.user.update({ | 399 | this.actions.user.update({ |
399 | userData: { | 400 | userData: { |
400 | locale: this.stores.app.locale, | 401 | locale: this.stores.app.locale, |
diff --git a/src/webview/badge.ts b/src/webview/badge.ts index 1b66effb6..0ff1ecaf6 100644 --- a/src/webview/badge.ts +++ b/src/webview/badge.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | 2 | ||
3 | const debug = require('debug')('Ferdium:Plugin:BadgeHandler'); | 3 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
4 | // const debug = require('debug')('Ferdium:Plugin:BadgeHandler'); | ||
4 | 5 | ||
5 | export class BadgeHandler { | 6 | export class BadgeHandler { |
6 | // TODO: Need to extract this into a utility class and reuse outside of the recipes | 7 | // TODO: Need to extract this into a utility class and reuse outside of the recipes |
@@ -26,7 +27,7 @@ export class BadgeHandler { | |||
26 | indirect: this.safeParseInt(indirect), | 27 | indirect: this.safeParseInt(indirect), |
27 | }; | 28 | }; |
28 | 29 | ||
29 | debug('Sending badge count to host: %j', count); | 30 | console.log('Sending badge count to host: %j', count); |
30 | ipcRenderer.sendToHost('message-counts', count); | 31 | ipcRenderer.sendToHost('message-counts', count); |
31 | } | 32 | } |
32 | } | 33 | } |
diff --git a/src/webview/darkmode.ts b/src/webview/darkmode.ts index fbb0edf04..99ee68757 100644 --- a/src/webview/darkmode.ts +++ b/src/webview/darkmode.ts | |||
@@ -1,7 +1,8 @@ | |||
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 | const debug = require('debug')('Ferdium:DarkMode'); | 4 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
5 | // const debug = require('debug')('Ferdium:DarkMode'); | ||
5 | 6 | ||
6 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; | 7 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; |
7 | 8 | ||
@@ -26,7 +27,7 @@ export function injectDarkModeStyle(recipePath: string) { | |||
26 | 27 | ||
27 | document.querySelector('head')?.appendChild(styles); | 28 | document.querySelector('head')?.appendChild(styles); |
28 | 29 | ||
29 | debug('Injected Dark Mode style with ID', ID); | 30 | console.log('Injected Dark Mode style with ID', ID); |
30 | } | 31 | } |
31 | } | 32 | } |
32 | 33 | ||
@@ -36,7 +37,7 @@ export function removeDarkModeStyle() { | |||
36 | if (style) { | 37 | if (style) { |
37 | style.remove(); | 38 | style.remove(); |
38 | 39 | ||
39 | debug('Removed Dark Mode Style with ID', ID); | 40 | console.log('Removed Dark Mode Style with ID', ID); |
40 | } | 41 | } |
41 | } | 42 | } |
42 | 43 | ||
diff --git a/src/webview/dialogTitle.ts b/src/webview/dialogTitle.ts index 393c2499f..a5bcb4c41 100644 --- a/src/webview/dialogTitle.ts +++ b/src/webview/dialogTitle.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | 2 | ||
3 | const debug = require('debug')('Ferdium:Plugin:DialogTitleHandler'); | 3 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
4 | // const debug = require('debug')('Ferdium:Plugin:DialogTitleHandler'); | ||
4 | 5 | ||
5 | export class DialogTitleHandler { | 6 | export class DialogTitleHandler { |
6 | titleCache: { title: string }; | 7 | titleCache: { title: string }; |
@@ -25,7 +26,7 @@ export class DialogTitleHandler { | |||
25 | return; | 26 | return; |
26 | } | 27 | } |
27 | 28 | ||
28 | debug('Sending active dialog title to host %s', newTitle); | 29 | console.log('Sending active dialog title to host %s', newTitle); |
29 | ipcRenderer.sendToHost('active-dialog-title', newTitle); | 30 | ipcRenderer.sendToHost('active-dialog-title', newTitle); |
30 | 31 | ||
31 | this.titleCache.title = newTitle; | 32 | this.titleCache.title = newTitle; |
diff --git a/src/webview/lib/RecipeWebview.ts b/src/webview/lib/RecipeWebview.ts index 568c31255..cf70164ef 100644 --- a/src/webview/lib/RecipeWebview.ts +++ b/src/webview/lib/RecipeWebview.ts | |||
@@ -2,7 +2,8 @@ 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 | const debug = require('debug')('Ferdium:Plugin:RecipeWebview'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:Plugin:RecipeWebview'); | ||
6 | 7 | ||
7 | class RecipeWebview { | 8 | class RecipeWebview { |
8 | badgeHandler: any; | 9 | badgeHandler: any; |
@@ -27,7 +28,7 @@ class RecipeWebview { | |||
27 | ipcRenderer.on('poll', () => { | 28 | ipcRenderer.on('poll', () => { |
28 | this.loopFunc(); | 29 | this.loopFunc(); |
29 | 30 | ||
30 | debug('Poll event'); | 31 | console.log('Poll event'); |
31 | 32 | ||
32 | // This event is for checking if the service recipe is still actively | 33 | // This event is for checking if the service recipe is still actively |
33 | // communicating with the client | 34 | // communicating with the client |
@@ -109,7 +110,7 @@ class RecipeWebview { | |||
109 | 110 | ||
110 | if (head) { | 111 | if (head) { |
111 | head.append(styles); | 112 | head.append(styles); |
112 | debug('Append styles', styles); | 113 | console.log('Append styles', styles); |
113 | } | 114 | } |
114 | } | 115 | } |
115 | }); | 116 | }); |
@@ -121,13 +122,13 @@ class RecipeWebview { | |||
121 | if (existsSync(file)) { | 122 | if (existsSync(file)) { |
122 | return readFileSync(file, 'utf8'); | 123 | return readFileSync(file, 'utf8'); |
123 | } | 124 | } |
124 | debug('Script not found', file); | 125 | console.log('Script not found', file); |
125 | return null; | 126 | return null; |
126 | }), | 127 | }), |
127 | ).then(scripts => { | 128 | ).then(scripts => { |
128 | const scriptsFound = scripts.filter(script => script !== null); | 129 | const scriptsFound = scripts.filter(script => script !== null); |
129 | if (scriptsFound.length > 0) { | 130 | if (scriptsFound.length > 0) { |
130 | debug('Inject scripts to main world', scriptsFound); | 131 | console.log('Inject scripts to main world', scriptsFound); |
131 | ipcRenderer.sendToHost('inject-js-unsafe', ...scriptsFound); | 132 | ipcRenderer.sendToHost('inject-js-unsafe', ...scriptsFound); |
132 | } | 133 | } |
133 | }); | 134 | }); |
diff --git a/src/webview/notifications.ts b/src/webview/notifications.ts index 5ae99424c..ff9c844d0 100644 --- a/src/webview/notifications.ts +++ b/src/webview/notifications.ts | |||
@@ -2,7 +2,8 @@ import { ipcRenderer } from 'electron'; | |||
2 | 2 | ||
3 | import { v1 as uuidV1 } from 'uuid'; | 3 | import { v1 as uuidV1 } from 'uuid'; |
4 | 4 | ||
5 | const debug = require('debug')('Ferdium:Notifications'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:Notifications'); | ||
6 | 7 | ||
7 | export class NotificationsHandler { | 8 | export class NotificationsHandler { |
8 | onNotify = (data: { title: string; options: any; notificationId: string }) => | 9 | onNotify = (data: { title: string; options: any; notificationId: string }) => |
@@ -10,7 +11,7 @@ export class NotificationsHandler { | |||
10 | 11 | ||
11 | displayNotification(title: string, options: any) { | 12 | displayNotification(title: string, options: any) { |
12 | return new Promise(resolve => { | 13 | return new Promise(resolve => { |
13 | debug('New notification', title, options); | 14 | console.log('New notification', title, options); |
14 | 15 | ||
15 | const notificationId = uuidV1(); | 16 | const notificationId = uuidV1(); |
16 | 17 | ||
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 4fcf28363..1f3017ccd 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -50,7 +50,8 @@ import { | |||
50 | 50 | ||
51 | import { DEFAULT_APP_SETTINGS } from '../config'; | 51 | import { DEFAULT_APP_SETTINGS } from '../config'; |
52 | 52 | ||
53 | const debug = require('debug')('Ferdium:Plugin'); | 53 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
54 | // const debug = require('debug')('Ferdium:Plugin'); | ||
54 | 55 | ||
55 | const badgeHandler = new BadgeHandler(); | 56 | const badgeHandler = new BadgeHandler(); |
56 | 57 | ||
@@ -64,7 +65,7 @@ const notificationsHandler = new NotificationsHandler(); | |||
64 | const originalWindowOpen = window.open; | 65 | const originalWindowOpen = window.open; |
65 | 66 | ||
66 | window.open = (url, frameName, features) => { | 67 | window.open = (url, frameName, features) => { |
67 | debug('window.open', url, frameName, features); | 68 | console.log('window.open', url, frameName, features); |
68 | if (!url) { | 69 | if (!url) { |
69 | // The service hasn't yet supplied a URL (as used in Skype). | 70 | // The service hasn't yet supplied a URL (as used in Skype). |
70 | // Return a new dummy window object and wait for the service to change the properties | 71 | // Return a new dummy window object and wait for the service to change the properties |
@@ -170,12 +171,12 @@ class RecipeController { | |||
170 | async initialize() { | 171 | async initialize() { |
171 | for (const channel of Object.keys(this.ipcEvents)) { | 172 | for (const channel of Object.keys(this.ipcEvents)) { |
172 | ipcRenderer.on(channel, (...args) => { | 173 | ipcRenderer.on(channel, (...args) => { |
173 | debug('Received IPC event for channel', channel, 'with', ...args); | 174 | console.log('Received IPC event for channel', channel, 'with', ...args); |
174 | this[this.ipcEvents[channel]](...args); | 175 | this[this.ipcEvents[channel]](...args); |
175 | }); | 176 | }); |
176 | } | 177 | } |
177 | 178 | ||
178 | debug('Send "hello" to host'); | 179 | console.log('Send "hello" to host'); |
179 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); | 180 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); |
180 | 181 | ||
181 | this.spellcheckingProvider = null; | 182 | this.spellcheckingProvider = null; |
@@ -198,9 +199,9 @@ class RecipeController { | |||
198 | } | 199 | } |
199 | 200 | ||
200 | loadRecipeModule(event, config, recipe) { | 201 | loadRecipeModule(event, config, recipe) { |
201 | debug('loadRecipeModule'); | 202 | console.log('loadRecipeModule'); |
202 | const modulePath = join(recipe.path, 'webview.js'); | 203 | const modulePath = join(recipe.path, 'webview.js'); |
203 | debug('module path', modulePath); | 204 | console.log('module path', modulePath); |
204 | // Delete module from cache | 205 | // Delete module from cache |
205 | delete require.cache[require.resolve(modulePath)]; | 206 | delete require.cache[require.resolve(modulePath)]; |
206 | try { | 207 | try { |
@@ -213,7 +214,7 @@ class RecipeController { | |||
213 | if (existsSync(modulePath)) { | 214 | if (existsSync(modulePath)) { |
214 | // eslint-disable-next-line import/no-dynamic-require | 215 | // eslint-disable-next-line import/no-dynamic-require |
215 | require(modulePath)(this.recipe, { ...config, recipe }); | 216 | require(modulePath)(this.recipe, { ...config, recipe }); |
216 | debug('Initialize Recipe', config, recipe); | 217 | console.log('Initialize Recipe', config, recipe); |
217 | } | 218 | } |
218 | 219 | ||
219 | this.settings.service = Object.assign(config, { recipe }); | 220 | this.settings.service = Object.assign(config, { recipe }); |
@@ -265,18 +266,18 @@ class RecipeController { | |||
265 | } | 266 | } |
266 | 267 | ||
267 | update() { | 268 | update() { |
268 | debug('enableSpellchecking', this.settings.app.enableSpellchecking); | 269 | console.log('enableSpellchecking', this.settings.app.enableSpellchecking); |
269 | debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); | 270 | console.log('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); |
270 | debug( | 271 | console.log( |
271 | 'System spellcheckerLanguage', | 272 | 'System spellcheckerLanguage', |
272 | this.settings.app.spellcheckerLanguage, | 273 | this.settings.app.spellcheckerLanguage, |
273 | ); | 274 | ); |
274 | debug( | 275 | console.log( |
275 | 'Service spellcheckerLanguage', | 276 | 'Service spellcheckerLanguage', |
276 | this.settings.service.spellcheckerLanguage, | 277 | this.settings.service.spellcheckerLanguage, |
277 | ); | 278 | ); |
278 | debug('darkReaderSettigs', this.settings.service.darkReaderSettings); | 279 | console.log('darkReaderSettigs', this.settings.service.darkReaderSettings); |
279 | debug('searchEngine', this.settings.app.searchEngine); | 280 | console.log('searchEngine', this.settings.app.searchEngine); |
280 | 281 | ||
281 | if (this.userscript && this.userscript.internal_setSettings) { | 282 | if (this.userscript && this.userscript.internal_setSettings) { |
282 | this.userscript.internal_setSettings(this.settings); | 283 | this.userscript.internal_setSettings(this.settings); |
@@ -284,10 +285,10 @@ class RecipeController { | |||
284 | 285 | ||
285 | if (this.settings.app.enableSpellchecking) { | 286 | if (this.settings.app.enableSpellchecking) { |
286 | let { spellcheckerLanguage } = this; | 287 | let { spellcheckerLanguage } = this; |
287 | debug(`Setting spellchecker language to ${spellcheckerLanguage}`); | 288 | console.log(`Setting spellchecker language to ${spellcheckerLanguage}`); |
288 | if (spellcheckerLanguage.includes('automatic')) { | 289 | if (spellcheckerLanguage.includes('automatic')) { |
289 | this.automaticLanguageDetection(); | 290 | this.automaticLanguageDetection(); |
290 | debug( | 291 | console.log( |
291 | 'Found `automatic` locale, falling back to user locale until detected', | 292 | 'Found `automatic` locale, falling back to user locale until detected', |
292 | this.settings.app.locale, | 293 | this.settings.app.locale, |
293 | ); | 294 | ); |
@@ -295,14 +296,14 @@ class RecipeController { | |||
295 | } | 296 | } |
296 | switchDict(spellcheckerLanguage, this.settings.service.id); | 297 | switchDict(spellcheckerLanguage, this.settings.service.id); |
297 | } else { | 298 | } else { |
298 | debug('Disable spellchecker'); | 299 | console.log('Disable spellchecker'); |
299 | } | 300 | } |
300 | 301 | ||
301 | if (!this.recipe) { | 302 | if (!this.recipe) { |
302 | this.hasUpdatedBeforeRecipeLoaded = true; | 303 | this.hasUpdatedBeforeRecipeLoaded = true; |
303 | } | 304 | } |
304 | 305 | ||
305 | debug( | 306 | console.log( |
306 | 'Darkmode enabled?', | 307 | 'Darkmode enabled?', |
307 | this.settings.service.isDarkModeEnabled, | 308 | this.settings.service.isDarkModeEnabled, |
308 | 'Dark theme active?', | 309 | 'Dark theme active?', |
@@ -322,11 +323,11 @@ class RecipeController { | |||
322 | this.settings.service.isDarkModeEnabled && | 323 | this.settings.service.isDarkModeEnabled && |
323 | this.settings.app.isDarkThemeActive !== false | 324 | this.settings.app.isDarkThemeActive !== false |
324 | ) { | 325 | ) { |
325 | debug('Enable dark mode'); | 326 | console.log('Enable dark mode'); |
326 | 327 | ||
327 | // Check if recipe has a custom dark mode handler | 328 | // Check if recipe has a custom dark mode handler |
328 | if (this.recipe && this.recipe.darkModeHandler) { | 329 | if (this.recipe && this.recipe.darkModeHandler) { |
329 | debug('Using custom dark mode handler'); | 330 | console.log('Using custom dark mode handler'); |
330 | 331 | ||
331 | // Remove other dark mode styles if they were already loaded | 332 | // Remove other dark mode styles if they were already loaded |
332 | if (this.hasUpdatedBeforeRecipeLoaded) { | 333 | if (this.hasUpdatedBeforeRecipeLoaded) { |
@@ -337,7 +338,7 @@ class RecipeController { | |||
337 | 338 | ||
338 | this.recipe.darkModeHandler(true, handlerConfig); | 339 | this.recipe.darkModeHandler(true, handlerConfig); |
339 | } else if (darkModeStyleExists(this.settings.service.recipe.path)) { | 340 | } else if (darkModeStyleExists(this.settings.service.recipe.path)) { |
340 | debug('Injecting darkmode from recipe'); | 341 | console.log('Injecting darkmode from recipe'); |
341 | injectDarkModeStyle(this.settings.service.recipe.path); | 342 | injectDarkModeStyle(this.settings.service.recipe.path); |
342 | 343 | ||
343 | // Make sure universal dark mode is disabled | 344 | // Make sure universal dark mode is disabled |
@@ -347,7 +348,7 @@ class RecipeController { | |||
347 | this.settings.app.universalDarkMode && | 348 | this.settings.app.universalDarkMode && |
348 | !ignoreList.includes(window.location.host) | 349 | !ignoreList.includes(window.location.host) |
349 | ) { | 350 | ) { |
350 | debug('Injecting Dark Reader'); | 351 | console.log('Injecting Dark Reader'); |
351 | 352 | ||
352 | // Use Dark Reader instead | 353 | // Use Dark Reader instead |
353 | const { brightness, contrast, sepia } = | 354 | const { brightness, contrast, sepia } = |
@@ -361,8 +362,8 @@ class RecipeController { | |||
361 | this.universalDarkModeInjected = true; | 362 | this.universalDarkModeInjected = true; |
362 | } | 363 | } |
363 | } else { | 364 | } else { |
364 | debug('Remove dark mode'); | 365 | console.log('Remove dark mode'); |
365 | debug('DarkMode disabled - removing remaining styles'); | 366 | console.log('DarkMode disabled - removing remaining styles'); |
366 | 367 | ||
367 | if (this.recipe && this.recipe.darkModeHandler) { | 368 | if (this.recipe && this.recipe.darkModeHandler) { |
368 | // Remove other dark mode styles if they were already loaded | 369 | // Remove other dark mode styles if they were already loaded |
@@ -374,10 +375,10 @@ class RecipeController { | |||
374 | 375 | ||
375 | this.recipe.darkModeHandler(false, handlerConfig); | 376 | this.recipe.darkModeHandler(false, handlerConfig); |
376 | } else if (isDarkModeStyleInjected()) { | 377 | } else if (isDarkModeStyleInjected()) { |
377 | debug('Removing injected darkmode from recipe'); | 378 | console.log('Removing injected darkmode from recipe'); |
378 | removeDarkModeStyle(); | 379 | removeDarkModeStyle(); |
379 | } else { | 380 | } else { |
380 | debug('Removing Dark Reader'); | 381 | console.log('Removing Dark Reader'); |
381 | 382 | ||
382 | disableDarkMode(); | 383 | disableDarkMode(); |
383 | this.universalDarkModeInjected = false; | 384 | this.universalDarkModeInjected = false; |
@@ -405,7 +406,7 @@ class RecipeController { | |||
405 | } | 406 | } |
406 | 407 | ||
407 | serviceIdEcho(event) { | 408 | serviceIdEcho(event) { |
408 | debug('Received a service echo ping'); | 409 | console.log('Received a service echo ping'); |
409 | event.sender.send('service-id', this.settings.service.id); | 410 | event.sender.send('service-id', this.settings.service.id); |
410 | } | 411 | } |
411 | 412 | ||
@@ -427,7 +428,7 @@ class RecipeController { | |||
427 | // Force a minimum length to get better detection results | 428 | // Force a minimum length to get better detection results |
428 | if (value.length < 25) return; | 429 | if (value.length < 25) return; |
429 | 430 | ||
430 | debug('Detecting language for', value); | 431 | console.log('Detecting language for', value); |
431 | const locale = await ipcRenderer.invoke('detect-language', { | 432 | const locale = await ipcRenderer.invoke('detect-language', { |
432 | sample: value, | 433 | sample: value, |
433 | }); | 434 | }); |
@@ -437,7 +438,7 @@ class RecipeController { | |||
437 | 438 | ||
438 | const spellcheckerLocale = | 439 | const spellcheckerLocale = |
439 | getSpellcheckerLocaleByFuzzyIdentifier(locale); | 440 | getSpellcheckerLocaleByFuzzyIdentifier(locale); |
440 | debug( | 441 | console.log( |
441 | 'Language detected reliably, setting spellchecker language to', | 442 | 'Language detected reliably, setting spellchecker language to', |
442 | spellcheckerLocale, | 443 | spellcheckerLocale, |
443 | ); | 444 | ); |
diff --git a/src/webview/sessionHandler.ts b/src/webview/sessionHandler.ts index e38368a18..a2906113d 100644 --- a/src/webview/sessionHandler.ts +++ b/src/webview/sessionHandler.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | const debug = require('debug')('Ferdium:Plugin:SessionHandler'); | 1 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
2 | // const debug = require('debug')('Ferdium:Plugin:SessionHandler'); | ||
2 | 3 | ||
3 | export class SessionHandler { | 4 | export class SessionHandler { |
4 | async releaseServiceWorkers() { | 5 | async releaseServiceWorkers() { |
@@ -7,10 +8,10 @@ export class SessionHandler { | |||
7 | await window.navigator.serviceWorker.getRegistrations(); | 8 | await window.navigator.serviceWorker.getRegistrations(); |
8 | for (const registration of registrations) { | 9 | for (const registration of registrations) { |
9 | registration.unregister(); | 10 | registration.unregister(); |
10 | debug('ServiceWorker unregistered'); | 11 | console.log('ServiceWorker unregistered'); |
11 | } | 12 | } |
12 | } catch (error) { | 13 | } catch (error) { |
13 | debug(error); | 14 | console.log(error); |
14 | } | 15 | } |
15 | } | 16 | } |
16 | } | 17 | } |
diff --git a/src/webview/spellchecker.ts b/src/webview/spellchecker.ts index bad2bb4ff..8cf16a7ba 100644 --- a/src/webview/spellchecker.ts +++ b/src/webview/spellchecker.ts | |||
@@ -2,7 +2,8 @@ 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 | const debug = require('debug')('Ferdium:spellchecker'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:spellchecker'); | ||
6 | 7 | ||
7 | export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { | 8 | export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { |
8 | const locales = Object.keys(SPELLCHECKER_LOCALES).filter( | 9 | const locales = Object.keys(SPELLCHECKER_LOCALES).filter( |
@@ -16,14 +17,14 @@ export function getSpellcheckerLocaleByFuzzyIdentifier(identifier: string) { | |||
16 | 17 | ||
17 | export function switchDict(fuzzyLocale: string, serviceId: string) { | 18 | export function switchDict(fuzzyLocale: string, serviceId: string) { |
18 | if (isMac) { | 19 | if (isMac) { |
19 | debug('Ignoring dictionary changes on macOS'); | 20 | console.log('Ignoring dictionary changes on macOS'); |
20 | return; | 21 | return; |
21 | } | 22 | } |
22 | 23 | ||
23 | debug(`Setting spellchecker locale from: ${fuzzyLocale}`); | 24 | console.log(`Setting spellchecker locale from: ${fuzzyLocale}`); |
24 | const locale = getSpellcheckerLocaleByFuzzyIdentifier(fuzzyLocale); | 25 | const locale = getSpellcheckerLocaleByFuzzyIdentifier(fuzzyLocale); |
25 | if (locale) { | 26 | if (locale) { |
26 | debug(`Sending spellcheck locales to host: ${locale}`); | 27 | console.log(`Sending spellcheck locales to host: ${locale}`); |
27 | ipcRenderer.send('set-spellchecker-locales', { locale, serviceId }); | 28 | ipcRenderer.send('set-spellchecker-locales', { locale, serviceId }); |
28 | } | 29 | } |
29 | } | 30 | } |