From b02748e6076bd9f3802b7a4af1532d7e663381f5 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 13 Jul 2020 09:58:49 -0700 Subject: [PATCH] build: ensure that electron/lib/browser can only use browser or common imports (#24512) * build: ensure that electron/lib/browser can only use browser or common imports * chore: fix linting --- build/webpack/webpack.config.base.js | 7 +++- lib/browser/.eslintrc.json | 21 ++++++++++++ lib/browser/api/app.ts | 2 +- .../api/auto-updater/auto-updater-win.ts | 4 +-- lib/browser/api/base-window.ts | 2 +- lib/browser/api/browser-window.ts | 4 +-- lib/browser/api/crash-reporter.ts | 2 +- lib/browser/api/dialog.ts | 4 +-- lib/browser/api/menu-item-roles.ts | 2 +- lib/browser/api/menu-item.ts | 4 +-- lib/browser/api/menu.ts | 4 +-- lib/browser/api/net-log.ts | 2 +- lib/browser/api/net.ts | 4 +-- lib/browser/api/power-monitor.ts | 2 +- lib/browser/api/protocol.ts | 2 +- lib/browser/api/screen.ts | 2 +- lib/browser/api/system-preferences.ts | 2 +- lib/browser/api/views/image-view.ts | 2 +- lib/browser/api/web-contents-view.ts | 2 +- lib/browser/api/web-contents.ts | 28 ++++++++-------- lib/browser/chrome-extension-shim.ts | 2 +- lib/browser/default-menu.ts | 3 +- lib/browser/devtools.ts | 2 +- lib/browser/ipc-main-impl.ts | 2 +- lib/browser/navigation-controller.ts | 2 +- lib/browser/remote/objects-registry.ts | 2 +- lib/browser/remote/server.ts | 10 +++--- lib/browser/rpc-server.ts | 32 +++++++++---------- 28 files changed, 92 insertions(+), 65 deletions(-) create mode 100644 lib/browser/.eslintrc.json diff --git a/build/webpack/webpack.config.base.js b/build/webpack/webpack.config.base.js index 4ab16f9470..c9e51db6c3 100644 --- a/build/webpack/webpack.config.base.js +++ b/build/webpack/webpack.config.base.js @@ -76,6 +76,8 @@ module.exports = ({ entry = path.resolve(electronRoot, 'lib', target, 'init.js'); } + const electronAPIFile = path.resolve(electronRoot, 'lib', loadElectronFromAlternateTarget || target, 'api', 'exports', 'electron.ts'); + return ({ mode: 'development', devtool: false, @@ -88,7 +90,10 @@ module.exports = ({ resolve: { alias: { '@electron/internal': path.resolve(electronRoot, 'lib'), - electron: path.resolve(electronRoot, 'lib', loadElectronFromAlternateTarget || target, 'api', 'exports', 'electron.ts'), + electron$: electronAPIFile, + 'electron/main$': electronAPIFile, + 'electron/renderer$': electronAPIFile, + 'electron/common$': electronAPIFile, // Force timers to resolve to our dependency that doesn't use window.postMessage timers: path.resolve(electronRoot, 'node_modules', 'timers-browserify', 'main.js') }, diff --git a/lib/browser/.eslintrc.json b/lib/browser/.eslintrc.json new file mode 100644 index 0000000000..27d223a509 --- /dev/null +++ b/lib/browser/.eslintrc.json @@ -0,0 +1,21 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/renderer" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/isolated_renderer/*", + "@electron/internal/renderer/*", + "@electron/internal/sandboxed_worker/*", + "@electron/internal/worker/*" + ] + } + ] + } +} \ No newline at end of file diff --git a/lib/browser/api/app.ts b/lib/browser/api/app.ts index 507a36d1b0..db25a34b7d 100644 --- a/lib/browser/api/app.ts +++ b/lib/browser/api/app.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { deprecate, Menu } from 'electron'; +import { deprecate, Menu } from 'electron/main'; import { EventEmitter } from 'events'; const bindings = process._linkedBinding('electron_browser_app'); diff --git a/lib/browser/api/auto-updater/auto-updater-win.ts b/lib/browser/api/auto-updater/auto-updater-win.ts index 3719274606..9758107019 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.ts +++ b/lib/browser/api/auto-updater/auto-updater-win.ts @@ -1,6 +1,6 @@ -import { app } from 'electron'; +import { app } from 'electron/main'; import { EventEmitter } from 'events'; -import * as squirrelUpdate from './squirrel-update-win'; +import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win'; class AutoUpdater extends EventEmitter { updateAvailable: boolean = false; diff --git a/lib/browser/api/base-window.ts b/lib/browser/api/base-window.ts index ea9a4d0bc3..bad6837c5f 100644 --- a/lib/browser/api/base-window.ts +++ b/lib/browser/api/base-window.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import type { BaseWindow as TLWT } from 'electron'; +import type { BaseWindow as TLWT } from 'electron/main'; const { BaseWindow } = process._linkedBinding('electron_browser_base_window') as { BaseWindow: typeof TLWT }; Object.setPrototypeOf(BaseWindow.prototype, EventEmitter.prototype); diff --git a/lib/browser/api/browser-window.ts b/lib/browser/api/browser-window.ts index ee3fd194cb..fe0c8f6ac0 100644 --- a/lib/browser/api/browser-window.ts +++ b/lib/browser/api/browser-window.ts @@ -1,5 +1,5 @@ -import { BaseWindow, WebContents, Event, BrowserView, TouchBar } from 'electron'; -import type { BrowserWindow as BWT } from 'electron'; +import { BaseWindow, WebContents, Event, BrowserView, TouchBar } from 'electron/main'; +import type { BrowserWindow as BWT } from 'electron/main'; const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT }; Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype); diff --git a/lib/browser/api/crash-reporter.ts b/lib/browser/api/crash-reporter.ts index 34d7001135..4cbe0dd766 100644 --- a/lib/browser/api/crash-reporter.ts +++ b/lib/browser/api/crash-reporter.ts @@ -1,4 +1,4 @@ -import { app, deprecate } from 'electron'; +import { app, deprecate } from 'electron/main'; const binding = process._linkedBinding('electron_browser_crash_reporter'); diff --git a/lib/browser/api/dialog.ts b/lib/browser/api/dialog.ts index 37bd7177c1..a0d3a03c9b 100644 --- a/lib/browser/api/dialog.ts +++ b/lib/browser/api/dialog.ts @@ -1,5 +1,5 @@ -import { app, BrowserWindow } from 'electron'; -import { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main'; +import { app, BrowserWindow } from 'electron/main'; +import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main'; const dialogBinding = process._linkedBinding('electron_browser_dialog'); const DialogType = { diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts index 189a728b75..1170c4a1e9 100644 --- a/lib/browser/api/menu-item-roles.ts +++ b/lib/browser/api/menu-item-roles.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, WebContents, MenuItemConstructorOptions } from 'electron'; +import { app, BrowserWindow, WebContents, MenuItemConstructorOptions } from 'electron/main'; const isMac = process.platform === 'darwin'; const isWindows = process.platform === 'win32'; diff --git a/lib/browser/api/menu-item.ts b/lib/browser/api/menu-item.ts index 123cb79cca..cd5562fb16 100644 --- a/lib/browser/api/menu-item.ts +++ b/lib/browser/api/menu-item.ts @@ -1,5 +1,5 @@ -import * as roles from './menu-item-roles'; -import { Menu, Event, BrowserWindow, WebContents } from 'electron'; +import * as roles from '@electron/internal/browser/api/menu-item-roles'; +import { Menu, Event, BrowserWindow, WebContents } from 'electron/main'; let nextCommandId = 0; diff --git a/lib/browser/api/menu.ts b/lib/browser/api/menu.ts index adf2f75701..725396fb82 100644 --- a/lib/browser/api/menu.ts +++ b/lib/browser/api/menu.ts @@ -1,5 +1,5 @@ -import { BaseWindow, MenuItem, webContents, Menu as MenuType, BrowserWindow, MenuItemConstructorOptions } from 'electron'; -import { sortMenuItems } from './menu-utils'; +import { BaseWindow, MenuItem, webContents, Menu as MenuType, BrowserWindow, MenuItemConstructorOptions } from 'electron/main'; +import { sortMenuItems } from '@electron/internal/browser/api/menu-utils'; const v8Util = process._linkedBinding('electron_common_v8_util'); const bindings = process._linkedBinding('electron_browser_menu'); diff --git a/lib/browser/api/net-log.ts b/lib/browser/api/net-log.ts index 81a9e51524..031fec6f51 100644 --- a/lib/browser/api/net-log.ts +++ b/lib/browser/api/net-log.ts @@ -1,6 +1,6 @@ // TODO(deepak1556): Deprecate and remove standalone netLog module, // it is now a property of session module. -import { app, session } from 'electron'; +import { app, session } from 'electron/main'; const startLogging: typeof session.defaultSession.netLog.startLogging = async (path, options) => { if (!app.isReady()) return; diff --git a/lib/browser/api/net.ts b/lib/browser/api/net.ts index 6bbc177a44..c8d1681007 100644 --- a/lib/browser/api/net.ts +++ b/lib/browser/api/net.ts @@ -1,7 +1,7 @@ import * as url from 'url'; import { Readable, Writable } from 'stream'; -import { app } from 'electron'; -import { ClientRequestConstructorOptions, UploadProgress } from 'electron/main'; +import { app } from 'electron/main'; +import type { ClientRequestConstructorOptions, UploadProgress } from 'electron/main'; const { isValidHeaderName, isValidHeaderValue, diff --git a/lib/browser/api/power-monitor.ts b/lib/browser/api/power-monitor.ts index 219494a8eb..d07e773f32 100644 --- a/lib/browser/api/power-monitor.ts +++ b/lib/browser/api/power-monitor.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import { app } from 'electron'; +import { app } from 'electron/main'; const { createPowerMonitor, diff --git a/lib/browser/api/protocol.ts b/lib/browser/api/protocol.ts index 96c443e1d2..0ee726ee6d 100644 --- a/lib/browser/api/protocol.ts +++ b/lib/browser/api/protocol.ts @@ -1,4 +1,4 @@ -import { app, session } from 'electron'; +import { app, session } from 'electron/main'; // Global protocol APIs. const protocol = process._linkedBinding('electron_browser_protocol'); diff --git a/lib/browser/api/screen.ts b/lib/browser/api/screen.ts index 63cfb44f0a..b212276287 100644 --- a/lib/browser/api/screen.ts +++ b/lib/browser/api/screen.ts @@ -1,6 +1,6 @@ 'use strict'; -import { createLazyInstance } from '../utils'; +import { createLazyInstance } from '@electron/internal/browser/utils'; const { EventEmitter } = require('events'); const { Screen, createScreen } = process._linkedBinding('electron_common_screen'); diff --git a/lib/browser/api/system-preferences.ts b/lib/browser/api/system-preferences.ts index bc305df130..9d39f4f2b7 100644 --- a/lib/browser/api/system-preferences.ts +++ b/lib/browser/api/system-preferences.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import { deprecate } from 'electron'; +import { deprecate } from 'electron/main'; const { systemPreferences, SystemPreferences } = process._linkedBinding('electron_browser_system_preferences'); // SystemPreferences is an EventEmitter. diff --git a/lib/browser/api/views/image-view.ts b/lib/browser/api/views/image-view.ts index fe358205d0..5599240fcb 100644 --- a/lib/browser/api/views/image-view.ts +++ b/lib/browser/api/views/image-view.ts @@ -1,4 +1,4 @@ -import { View } from 'electron'; +import { View } from 'electron/main'; const { ImageView } = process._linkedBinding('electron_browser_image_view'); diff --git a/lib/browser/api/web-contents-view.ts b/lib/browser/api/web-contents-view.ts index 936c229a91..63650ef926 100644 --- a/lib/browser/api/web-contents-view.ts +++ b/lib/browser/api/web-contents-view.ts @@ -1,4 +1,4 @@ -import { View } from 'electron'; +import { View } from 'electron/main'; const { WebContentsView } = process._linkedBinding('electron_browser_web_contents_view'); diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 48b2ed05bb..57a0990ccb 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -1,14 +1,14 @@ -import { app, ipcMain, session, deprecate } from 'electron'; -import type { MenuItem, MenuItemConstructorOptions, WebContentsInternal } from 'electron'; +import { app, ipcMain, session, deprecate } from 'electron/main'; +import type { MenuItem, MenuItemConstructorOptions } from 'electron/main'; import * as url from 'url'; import * as path from 'path'; -import { internalWindowOpen } from '../guest-window-manager'; -import { NavigationController } from '../navigation-controller'; -import { ipcMainInternal } from '../ipc-main-internal'; -import * as ipcMainUtils from '../ipc-main-internal-utils'; -import { parseFeatures } from '../../common/parse-features-string'; -import { MessagePortMain } from '../message-port-main'; +import { internalWindowOpen } from '@electron/internal/browser/guest-window-manager'; +import { NavigationController } from '@electron/internal/browser/navigation-controller'; +import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; +import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; +import { parseFeatures } from '@electron/internal/common/parse-features-string'; +import { MessagePortMain } from '@electron/internal/browser/message-port-main'; import { EventEmitter } from 'events'; // session is not used here, the purpose is to make sure session is initalized @@ -122,7 +122,7 @@ const defaultPrintingSetting = { // JavaScript implementations of WebContents. const binding = process._linkedBinding('electron_browser_web_contents'); -const { WebContents } = binding as { WebContents: { prototype: WebContentsInternal } }; +const { WebContents } = binding as { WebContents: { prototype: Electron.WebContentsInternal } }; Object.setPrototypeOf(WebContents.prototype, EventEmitter.prototype); @@ -203,7 +203,7 @@ for (const method of webFrameMethods) { }; } -const waitTillCanExecuteJavaScript = async (webContents: WebContentsInternal) => { +const waitTillCanExecuteJavaScript = async (webContents: Electron.WebContentsInternal) => { if (webContents.getURL() && !webContents.isLoadingMainFrame()) return; return new Promise((resolve) => { @@ -483,7 +483,7 @@ WebContents.prototype._init = function () { this.setMaxListeners(0); // Dispatch IPC messages to the ipc module. - this.on('-ipc-message' as any, function (this: WebContentsInternal, event: any, internal: boolean, channel: string, args: any[]) { + this.on('-ipc-message' as any, function (this: Electron.WebContentsInternal, event: any, internal: boolean, channel: string, args: any[]) { if (internal) { addReplyInternalToEvent(event); ipcMainInternal.emit(channel, event, ...args); @@ -508,7 +508,7 @@ WebContents.prototype._init = function () { } }); - this.on('-ipc-message-sync' as any, function (this: WebContentsInternal, event: any, internal: boolean, channel: string, args: any[]) { + this.on('-ipc-message-sync' as any, function (this: Electron.WebContentsInternal, event: any, internal: boolean, channel: string, args: any[]) { addReturnValueToEvent(event); if (internal) { addReplyInternalToEvent(event); @@ -546,7 +546,7 @@ WebContents.prototype._init = function () { }); // The devtools requests the webContents to reload. - this.on('devtools-reload-page', function (this: WebContentsInternal) { + this.on('devtools-reload-page', function (this: Electron.WebContentsInternal) { this.reload(); }); @@ -569,7 +569,7 @@ WebContents.prototype._init = function () { // Create a new browser window for the native implementation of // "window.open", used in sandbox and nativeWindowOpen mode. - this.on('-add-new-contents' as any, (event: any, webContents: WebContentsInternal, disposition: string, + this.on('-add-new-contents' as any, (event: any, webContents: Electron.WebContentsInternal, disposition: string, userGesture: boolean, left: number, top: number, width: number, height: number, url: string, frameName: string, referrer: string, rawFeatures: string, postData: string) => { if ((disposition !== 'foreground-tab' && disposition !== 'new-window' && diff --git a/lib/browser/chrome-extension-shim.ts b/lib/browser/chrome-extension-shim.ts index 0d782fded3..9bf6732939 100644 --- a/lib/browser/chrome-extension-shim.ts +++ b/lib/browser/chrome-extension-shim.ts @@ -2,7 +2,7 @@ // BrowserWindow-based extensions stuff to the new native-backed extensions // API. -import { app, session, BrowserWindow, deprecate } from 'electron'; +import { app, session, BrowserWindow, deprecate } from 'electron/main'; app.whenReady().then(function () { const addExtension = function (srcDirectory: string) { diff --git a/lib/browser/default-menu.ts b/lib/browser/default-menu.ts index f470d64fd6..b4703da62c 100644 --- a/lib/browser/default-menu.ts +++ b/lib/browser/default-menu.ts @@ -1,4 +1,5 @@ -import { shell, Menu } from 'electron'; +import { Menu } from 'electron/main'; +import { shell } from 'electron/common'; const v8Util = process._linkedBinding('electron_common_v8_util'); diff --git a/lib/browser/devtools.ts b/lib/browser/devtools.ts index 2e13497949..32476bf3a5 100644 --- a/lib/browser/devtools.ts +++ b/lib/browser/devtools.ts @@ -1,4 +1,4 @@ -import { dialog, Menu } from 'electron'; +import { dialog, Menu } from 'electron/main'; import * as fs from 'fs'; import * as url from 'url'; diff --git a/lib/browser/ipc-main-impl.ts b/lib/browser/ipc-main-impl.ts index 8d6c91bbba..fb3ee02c94 100644 --- a/lib/browser/ipc-main-impl.ts +++ b/lib/browser/ipc-main-impl.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'events'; -import { IpcMainInvokeEvent } from 'electron'; +import { IpcMainInvokeEvent } from 'electron/main'; export class IpcMainImpl extends EventEmitter { private _invokeHandlers: Map void> = new Map(); diff --git a/lib/browser/navigation-controller.ts b/lib/browser/navigation-controller.ts index 6632ec9855..4c5ab32b09 100644 --- a/lib/browser/navigation-controller.ts +++ b/lib/browser/navigation-controller.ts @@ -1,4 +1,4 @@ -import { ipcMainInternal } from './ipc-main-internal'; +import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import type { WebContents, LoadURLOptions } from 'electron/main'; import { EventEmitter } from 'events'; diff --git a/lib/browser/remote/objects-registry.ts b/lib/browser/remote/objects-registry.ts index 80e1dc60b5..365936b924 100644 --- a/lib/browser/remote/objects-registry.ts +++ b/lib/browser/remote/objects-registry.ts @@ -1,6 +1,6 @@ 'use strict'; -import { WebContents } from 'electron'; +import { WebContents } from 'electron/main'; const v8Util = process._linkedBinding('electron_common_v8_util'); diff --git a/lib/browser/remote/server.ts b/lib/browser/remote/server.ts index c4e28696a8..41d3c2a9cf 100644 --- a/lib/browser/remote/server.ts +++ b/lib/browser/remote/server.ts @@ -1,9 +1,9 @@ -import * as electron from 'electron'; +import * as electron from 'electron/main'; import { EventEmitter } from 'events'; -import objectsRegistry from './objects-registry'; -import { ipcMainInternal } from '../ipc-main-internal'; -import { isPromise, isSerializableObject, deserialize, serialize } from '../../common/type-utils'; -import type { MetaTypeFromRenderer, ObjectMember, MetaType, ObjProtoDescriptor } from '../../common/remote/types'; +import objectsRegistry from '@electron/internal/browser/remote/objects-registry'; +import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; +import { isPromise, isSerializableObject, deserialize, serialize } from '@electron/internal/common/type-utils'; +import type { MetaTypeFromRenderer, ObjectMember, MetaType, ObjProtoDescriptor } from '@electron/internal/common/remote/types'; const v8Util = process._linkedBinding('electron_common_v8_util'); const eventBinding = process._linkedBinding('electron_browser_event'); diff --git a/lib/browser/rpc-server.ts b/lib/browser/rpc-server.ts index b7cd6a5da8..5bab076d1c 100644 --- a/lib/browser/rpc-server.ts +++ b/lib/browser/rpc-server.ts @@ -1,24 +1,24 @@ -import * as electron from 'electron'; +import { app } from 'electron/main'; +import type { IpcMainInvokeEvent, WebContents } from 'electron/main'; +import { clipboard, crashReporter } from 'electron/common'; import * as fs from 'fs'; -import { ipcMainInternal } from './ipc-main-internal'; -import * as ipcMainUtils from './ipc-main-internal-utils'; -import * as guestViewManager from './guest-view-manager'; -import * as typeUtils from '../common/type-utils'; -import { IpcMainInvokeEvent } from 'electron/main'; +import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; +import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; +import * as guestViewManager from '@electron/internal/browser/guest-view-manager'; +import * as typeUtils from '@electron/internal/common/type-utils'; const eventBinding = process._linkedBinding('electron_browser_event'); -const clipboard = process._linkedBinding('electron_common_clipboard'); -const emitCustomEvent = function (contents: electron.WebContents, eventName: string, ...args: any[]) { +const emitCustomEvent = function (contents: WebContents, eventName: string, ...args: any[]) { const event = eventBinding.createWithSender(contents); - electron.app.emit(eventName, event, contents, ...args); + app.emit(eventName, event, contents, ...args); contents.emit(eventName, event, ...args); return event; }; -const logStack = function (contents: electron.WebContents, code: string, stack: string) { +const logStack = function (contents: WebContents, code: string, stack: string) { if (stack) { console.warn(`WebContents (${contents.id}): ${code}`, stack); } @@ -54,7 +54,7 @@ ipcMainUtils.handleSync('ELECTRON_BROWSER_CLIPBOARD_SYNC', function (event: IpcM throw new Error(`Invalid method: ${method}`); } - return typeUtils.serialize((electron.clipboard as any)[method](...typeUtils.deserialize(args))); + return typeUtils.serialize((clipboard as any)[method](...typeUtils.deserialize(args))); }); if (BUILDFLAG(ENABLE_DESKTOP_CAPTURER)) { @@ -118,21 +118,21 @@ ipcMainInternal.on('ELECTRON_BROWSER_PRELOAD_ERROR', function (event: ElectronIn }); ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_GET_LAST_CRASH_REPORT', () => { - return electron.crashReporter.getLastCrashReport(); + return crashReporter.getLastCrashReport(); }); ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_GET_UPLOADED_REPORTS', () => { - return electron.crashReporter.getUploadedReports(); + return crashReporter.getUploadedReports(); }); ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_GET_UPLOAD_TO_SERVER', () => { - return electron.crashReporter.getUploadToServer(); + return crashReporter.getUploadToServer(); }); ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_SET_UPLOAD_TO_SERVER', (event: IpcMainInvokeEvent, uploadToServer: boolean) => { - return electron.crashReporter.setUploadToServer(uploadToServer); + return crashReporter.setUploadToServer(uploadToServer); }); ipcMainUtils.handleSync('ELECTRON_CRASH_REPORTER_GET_CRASHES_DIRECTORY', () => { - return electron.crashReporter.getCrashesDirectory(); + return crashReporter.getCrashesDirectory(); });