diff --git a/package-lock.json b/package-lock.json index 3b3bef5b..881ad6c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5936,9 +5936,9 @@ } }, "electron": { - "version": "14.1.1", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-14.1.1.tgz", - "integrity": "sha1-ZDcm/h/UrXf7s6dbIRAF7QE1dIU=", + "version": "14.2.1", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-14.2.1.tgz", + "integrity": "sha1-7ouc+owErU2UVtqlu6xWLCwlF6E=", "dev": true, "requires": { "@electron/get": "^1.0.1", @@ -5947,9 +5947,9 @@ }, "dependencies": { "@types/node": { - "version": "14.17.19", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-14.17.19.tgz", - "integrity": "sha1-c0HprBtddI16PdwEM27VNqb5HDE=", + "version": "14.17.33", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/@types/node/-/node-14.17.33.tgz", + "integrity": "sha1-AR7ijjjceu4b4DLOrfYzKgqxWxI=", "dev": true } } @@ -15158,8 +15158,8 @@ } }, "screen-snippet": { - "version": "git+ssh://git@github.com/symphonyoss/ScreenSnippet2.git#889aedbd3ecf16320a387967aaee0e7ca992d717", - "from": "screen-snippet@git+https://github.com/symphonyoss/ScreenSnippet2.git#v2.4.0", + "version": "git+https://github.com/symphonyoss/ScreenSnippet2.git#63071f24d6539598cef436daadf659c6d3fa3661", + "from": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2", "optional": true }, "semver": { diff --git a/package.json b/package.json index 0a57d23c..ac4bb416 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "compile:project": "gulp build", "compile:spec": "tsc -p tsconfig.spec.json", "compile:robot": "npm rebuild --build-from-source robotjs", - "dev": "npm run prebuild && cross-env ELECTRON_DEV=true electron .", + "dev": "gulp build && npm run browserify && cross-env ELECTRON_DEV=true electron .", "demo": "run-os", "demo:win32": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///src/demo/index.html", "demo:darwin": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/src/demo/index.html", @@ -126,7 +126,7 @@ "browserify": "16.5.1", "cross-env": "5.2.0", "del": "3.0.0", - "electron": "14.1.1", + "electron": "14.2.1", "electron-builder": "22.7.0", "electron-builder-squirrel-windows": "20.38.3", "electron-icon-maker": "0.0.4", diff --git a/src/app/activity-detection.ts b/src/app/activity-detection.ts index 61c1a2c8..b7200d22 100644 --- a/src/app/activity-detection.ts +++ b/src/app/activity-detection.ts @@ -1,4 +1,4 @@ -import { app, powerMonitor } from 'electron'; +import { app, powerMonitor, WebContents } from 'electron'; import Timer = NodeJS.Timer; import { logger } from '../common/logger'; @@ -6,7 +6,7 @@ import { windowHandler } from './window-handler'; class ActivityDetection { private idleThreshold: number; - private window: Electron.WebContents | null; + private window: WebContents | null; private timer: Timer | undefined; private queryInterval: NodeJS.Timer | undefined; @@ -22,7 +22,7 @@ class ActivityDetection { * @param idleThreshold {number} */ public setWindowAndThreshold( - window: Electron.WebContents, + window: WebContents, idleThreshold: number, ): void { this.window = window; diff --git a/src/app/analytics-handler.ts b/src/app/analytics-handler.ts index 827b5fa6..37328dd3 100644 --- a/src/app/analytics-handler.ts +++ b/src/app/analytics-handler.ts @@ -1,6 +1,11 @@ +import { WebContents } from 'electron'; + export interface IAnalyticsData { element: AnalyticsElements; - action_type?: MenuActionTypes | ScreenSnippetActionTypes | ToastNotificationActionTypes; + action_type?: + | MenuActionTypes + | ScreenSnippetActionTypes + | ToastNotificationActionTypes; action_result?: AnalyticsActions; extra_data?: object; } @@ -56,15 +61,15 @@ const MAX_EVENT_QUEUE_LENGTH = 50; const analyticsCallback = 'analytics-callback'; class Analytics { - private preloadWindow: Electron.webContents | undefined; + private preloadWindow: WebContents | undefined; private analyticsEventQueue: IAnalyticsData[] = []; /** * Stores the reference to the preload window * - * @param webContents {Electron.webContents} + * @param webContents {WeContents} */ - public registerPreloadWindow(webContents: Electron.webContents): void { + public registerPreloadWindow(webContents: WebContents): void { this.preloadWindow = webContents; if (!(this.preloadWindow && !this.preloadWindow.isDestroyed())) { diff --git a/src/app/crash-handler.ts b/src/app/crash-handler.ts index 021d5f2f..008aa999 100644 --- a/src/app/crash-handler.ts +++ b/src/app/crash-handler.ts @@ -110,6 +110,7 @@ class CrashHandler { `crash-handler: Renderer process crash event processed with data ${JSON.stringify( eventData, )}`, + details, ); break; default: diff --git a/src/app/download-handler.ts b/src/app/download-handler.ts index cfad9e32..d6814453 100644 --- a/src/app/download-handler.ts +++ b/src/app/download-handler.ts @@ -1,4 +1,4 @@ -import { BrowserWindow, dialog, shell } from 'electron'; +import { BrowserWindow, dialog, shell, WebContents } from 'electron'; import * as fs from 'fs'; import { i18n } from '../common/i18n'; import { logger } from '../common/logger'; @@ -35,14 +35,14 @@ class DownloadHandler { }); } - private window!: Electron.WebContents | null; + private window!: WebContents | null; private items: IDownloadItem[] = []; /** * Sets the window for the download handler * @param window Window object */ - public setWindow(window: Electron.WebContents): void { + public setWindow(window: WebContents): void { this.window = window; logger.info(`download-handler: Initialized download handler`); } diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index 4d83a2ea..d8983c2d 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -83,10 +83,7 @@ ipcMain.on( ); return; } - logger.info( - `main-api-handler: API call received - ${arg.cmd} - Properties:`, - arg, - ); + logApiCallParams(arg); switch (arg.cmd) { case apiCmds.isOnline: if (typeof arg.isOnline === 'boolean') { @@ -440,3 +437,82 @@ ipcMain.handle( return; }, ); + +/** + * Log API call parameters. + */ +const logApiCallParams = (arg: any) => { + const apiCmd = arg.cmd; + switch (apiCmd) { + case apiCmds.showNotification: + const title = 'hidden'; + const body = 'hidden'; + const notificationDetails: INotificationData = { + ...arg.notificationOpts, + title, + body, + }; + logger.info( + `main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify( + notificationDetails, + null, + 2, + )}`, + ); + break; + case apiCmds.badgeDataUrl: + const dataUrl = 'hidden'; + const badgeDataUrlDetails = { + ...arg, + dataUrl, + }; + logger.info( + `main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify( + badgeDataUrlDetails, + null, + 2, + )}`, + ); + break; + case apiCmds.openScreenPickerWindow: + const sources = arg.sources.map((source: any) => { + return { + name: source.name, + id: source.id, + thumbnail: 'hidden', + display_id: source.display_id, + appIcon: source.appIcon, + }; + }); + const openScreenPickerDetails = { + ...arg, + sources, + }; + logger.info( + `main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify( + openScreenPickerDetails, + null, + 2, + )}`, + ); + break; + case apiCmds.isMisspelled: + logger.verbose( + `main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify( + arg, + null, + 2, + )}`, + ); + break; + default: + logger.info( + `main-api-handler: - ${apiCmd} - Properties: ${JSON.stringify( + arg, + null, + 2, + )}`, + ); + break; + } +}; diff --git a/src/app/main-event-handler.ts b/src/app/main-event-handler.ts index affad702..b3a6f980 100644 --- a/src/app/main-event-handler.ts +++ b/src/app/main-event-handler.ts @@ -3,7 +3,7 @@ import { WebContents } from 'electron'; export class MainProcessEvents { private registeredWebContents: Map> = new Map< string, - Set + Set >(); /** diff --git a/src/app/protocol-handler.ts b/src/app/protocol-handler.ts index 83fa2be6..1dbf2456 100644 --- a/src/app/protocol-handler.ts +++ b/src/app/protocol-handler.ts @@ -1,3 +1,4 @@ +import { WebContents } from 'electron'; import { apiName } from '../common/api-interface'; import { isMac } from '../common/env'; import { logger } from '../common/logger'; @@ -12,7 +13,7 @@ class ProtocolHandler { private static isValidProtocolUri = (uri: string): boolean => !!(uri && uri.startsWith(protocol.SymphonyProtocol)); - private preloadWebContents: Electron.WebContents | null = null; + private preloadWebContents: WebContents | null = null; private protocolUri: string | null = null; constructor() { @@ -22,9 +23,9 @@ class ProtocolHandler { /** * Stores the web contents of the preload * - * @param webContents {Electron.WebContents} + * @param webContents {WeContents} */ - public setPreloadWebContents(webContents: Electron.WebContents): void { + public setPreloadWebContents(webContents: WebContents): void { this.preloadWebContents = webContents; logger.info( `protocol handler: SFE is active and we have a valid protocol window with web contents!`, diff --git a/src/app/reports-handler.ts b/src/app/reports-handler.ts index 81d5547f..aedd1928 100644 --- a/src/app/reports-handler.ts +++ b/src/app/reports-handler.ts @@ -1,5 +1,5 @@ import * as archiver from 'archiver'; -import { app, BrowserWindow, dialog, shell } from 'electron'; +import { app, BrowserWindow, dialog, shell, WebContents } from 'electron'; import * as fs from 'fs'; import * as path from 'path'; @@ -83,12 +83,12 @@ const generateArchiveForDirectory = ( }); }; -let logWebContents: Electron.WebContents; +let logWebContents: WebContents; const logTypes: string[] = []; const receivedLogs: ILogs[] = []; export const registerLogRetriever = ( - sender: Electron.WebContents, + sender: WebContents, logName: string, ): void => { logWebContents = sender; diff --git a/src/app/screen-snippet-handler.ts b/src/app/screen-snippet-handler.ts index 98a806ab..efdea051 100644 --- a/src/app/screen-snippet-handler.ts +++ b/src/app/screen-snippet-handler.ts @@ -1,4 +1,10 @@ -import { app, BrowserWindow, ipcMain, nativeImage } from 'electron'; +import { + app, + BrowserWindow, + ipcMain, + nativeImage, + WebContents, +} from 'electron'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; @@ -69,9 +75,9 @@ class ScreenSnippet { * Captures a user selected portion of the monitor and returns jpeg image * encoded in base64 format. * - * @param webContents {Electron.webContents} + * @param webContents {WeContents} */ - public async capture(webContents: Electron.webContents) { + public async capture(webContents: WebContents) { const mainWindow = windowHandler.getMainWindow(); if (mainWindow && windowExists(mainWindow) && isWindowsOS) { this.shouldUpdateAlwaysOnTop = mainWindow.isAlwaysOnTop(); @@ -308,7 +314,7 @@ class ScreenSnippet { * Uploads a screen snippet * @param webContents A browser window's web contents object */ - private uploadSnippet(webContents: Electron.webContents) { + private uploadSnippet(webContents: WebContents) { ipcMain.once( 'upload-snippet', async ( diff --git a/src/app/spell-check-handler.ts b/src/app/spell-check-handler.ts index 6bfc7969..e7f914cc 100644 --- a/src/app/spell-check-handler.ts +++ b/src/app/spell-check-handler.ts @@ -1,4 +1,4 @@ -import { app, MenuItem } from 'electron'; +import { app, MenuItem, WebContents } from 'electron'; import * as path from 'path'; import { @@ -47,9 +47,9 @@ export class SpellChecker { /** * Attaches context-menu event for every webContents * - * @param webContents {Electron.WebContents} + * @param webContents {WeContents} */ - public attachToWebContents(webContents: Electron.WebContents): void { + public attachToWebContents(webContents: WebContents): void { const contextMenuBuilder = new ContextMenuBuilder( this.spellCheckHandler, webContents, diff --git a/src/app/window-actions.ts b/src/app/window-actions.ts index af8e0236..18a03fe4 100644 --- a/src/app/window-actions.ts +++ b/src/app/window-actions.ts @@ -3,6 +3,7 @@ import { dialog, PermissionRequestHandlerHandlerDetails, systemPreferences, + WebContents, } from 'electron'; import { apiName, IBoundsChange, KeyCodes } from '../common/api-interface'; @@ -447,11 +448,9 @@ const handleMediaPermissions = async ( /** * Sets permission requests for the window * - * @param webContents {Electron.webContents} + * @param webContents {WeContents} */ -export const handlePermissionRequests = ( - webContents: Electron.webContents, -): void => { +export const handlePermissionRequests = (webContents: WebContents): void => { if (!webContents || !webContents.session) { return; } diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 400b8272..38878c11 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -962,9 +962,9 @@ export class WindowHandler { /** * Checks if the window and a key has a window * - * @param webContents {Electron.webContents} + * @param webContents {WeContents} */ - public hasView(webContents: Electron.webContents): boolean { + public hasView(webContents: WebContents): boolean { return ( webContents === this.mainView?.webContents || webContents === this.titleBarView?.webContents @@ -1370,7 +1370,7 @@ export class WindowHandler { * @param id */ public createScreenPickerWindow( - window: Electron.WebContents, + window: WebContents, sources: DesktopCapturerSource[], id: number, ): void { @@ -1612,13 +1612,13 @@ export class WindowHandler { * Creates a screen sharing indicator whenever uses start * sharing the screen * - * @param screenSharingWebContents {Electron.webContents} + * @param screenSharingWebContents {WeContents} * @param displayId {string} - current display id * @param id {number} - postMessage request id * @param streamId {string} - MediaStream id */ public createScreenSharingIndicatorWindow( - screenSharingWebContents: Electron.webContents, + screenSharingWebContents: WebContents, displayId: string, id: number, streamId: string, diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index 2732d7a6..ae8fa4d1 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -322,7 +322,7 @@ export const isValidWindow = ( * @return {Boolean} returns true if exists otherwise false * @param webContents */ -export const isValidView = (webContents: Electron.webContents): boolean => { +export const isValidView = (webContents: WebContents): boolean => { if (!checkValidWindow) { return true; } @@ -526,12 +526,12 @@ export const downloadManagerAction = async (type, filePath): Promise => { * * @param _event * @param item {Electron.DownloadItem} - * @param webContents {Electron.WebContents} + * @param webContents {WeContents} */ export const handleDownloadManager = ( _event, item: Electron.DownloadItem, - webContents: Electron.WebContents, + webContents: WebContents, ) => { // Send file path when download is complete item.once('done', (_e, state) => { diff --git a/src/common/logger.ts b/src/common/logger.ts index 87d251d0..566e3603 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -1,4 +1,4 @@ -import { app } from 'electron'; +import { app, WebContents } from 'electron'; import electronLog, { LogLevel, transports } from 'electron-log'; import * as fs from 'fs'; import * as path from 'path'; @@ -37,7 +37,7 @@ class Logger { private readonly desiredLogLevel?: LogLevel; private readonly logQueue: ILogMsg[]; private readonly logPath: string; - private loggerWindow: Electron.WebContents | null; + private loggerWindow: WebContents | null; constructor() { this.loggerWindow = null; @@ -158,7 +158,7 @@ class Logger { * * @param window {WebContents} - renderer window */ - public setLoggerWindow(window: Electron.WebContents): void { + public setLoggerWindow(window: WebContents): void { this.loggerWindow = window; if (this.loggerWindow) { diff --git a/tsconfig.json b/tsconfig.json index f488abc7..ab77e33b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,10 +7,7 @@ "jsx": "react", "outDir": "lib", "rootDir": ".", - "lib": [ - "es2016", - "dom" - ], + "lib": ["es2016", "dom"], "moduleResolution": "node", "strict": true, "removeComments": false, @@ -24,14 +21,8 @@ "noUnusedLocals": true, "noImplicitThis": true, "noUnusedParameters": true, - "typeRoots": [ - "node_modules/@types" - ] + "typeRoots": ["node_modules/@types"] }, - "exclude": [ - "node_modules", - "lib", - "tests", - "spec" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "lib", "tests", "spec"] }