Skip to content

Commit

Permalink
Merge TS context isolation branch onto Typescript master branch (#598)
Browse files Browse the repository at this point in the history
* Typescript 🎉

* Typescript 🎉 (logger, get-guid, string-format and throttle)

* Refactor typescript code

* consolidate all the utility functions to one file

* refactor protocol handler feature

* Typescript:

Add code documentation
Add pre-commit hooks

* Typescript: Fix logger formatting

* Typescript: Add support for react

* Typescript: Completed about app

* Typescript: Completed about app

* Typescript: Completed about app

* Typescript - Fix issues with about-app and add login to convert less to css

* Typescript - Fix loading screen

* Typescript - Add custom title bar

* Typescript - Add method to get locale

* Typescript - Add logic to clean up old logs

* Typescript - Add set badge count api

* Typescript - Complete application menu

* Typescript - Add logic to translate menu items

* Typescript - freeze window.ssf api

* Typescript - Handle popup menu on alt key press

* Typescript - Completed activity detection

* Typescript - Completed screen snippet

* Typescript - Add login to close screen snippet

* Typescript - Completed window actions & snackbar, Updated i18n module

* Typescript - Completed native crypto implementation & fixed bugs

* Typescript - Completed Desktop capturer & screen picker implementation

* Typescript - Optimize window actions

* Typescript - Add support for child window

* Typescript - fix pop url validation issue & browserify preload

* Typescript - Completed context menu implementation and fixed screen snippet

* Typescript - Completed screen sharing indicator and fixed i18n usage issue

* Typescript - Fix i18n locale setting issue

* Typescript - Completed download manager

* Typescript - Completed Basic auth

* Typescript - Network connectivity dialog

* Typescript - Handle certificate error

* Typescript - Add translation for certificate error dialog buttons

* Typescript - Add gulp tasks to compile less, typescript and copy files

* Typescript - Fix some issues with custom title bar, loading screen & screen snippet

* Typescript - Remove ES2015 lib

* :typescript: - Do not inject custom title bar for mac

* :typescript: - Fix screen sharing indicator text and format string

* Typescript - Fix esc to full screen

* Typescript - handle multiple/single instance of the client and add safety checks

* Typescript - Refactor code base

* Typescript - Optimize window validation and fix screen picker issue

* Typescript - Optimize protocol handler

* typescript: logger unit test

* typescript: activityDetection unit test (#560)

* ELECTRON-1022 - Create app bridge that communicates between renderer and preload via postMessage

* ELECTRON-1024 - Add support for screen share and screen sharing indicator

* config unit test (#566)

* ELECTRON-1024 - Fix screen sharing indicator close issue

* ELECTRON-1022 - Bump Symphony version to 5.0.0 (1.55)

* fixing jest coverage output report (#575)

* protocol handle unit test (#576)

* Typescript - Remove unwanted checks in protocol handler and add test cases

* added more tests to increase coverage to 100 for protocol handler

* Typescript download manager unit test (#579)

* adding enzyme

* download manager unit test

* Typescript - Completed notification workflow

* about app unit test

* Typescript - Fix notification styles

* fixing Compiler error: Generic type ReactElement<P, T> (#583)

* fix app path on windows (#580)

* basic auth unit test (#582)

* screen picker unit test (#587)

* screen picker unit test

* screen sharing indicator unit test

* loading screen unit test (#588)

* improving snapshot using snapshotSerializers to remove unnecessary things (#596)

* Typescript - Enforce braces for if/for/do/while statements.

* Typescript - Fix Lint issues and Unit test

* Typescript - Enable eofline (Ensure the file ends with a newline.)

* Typescript - Update logger logic and format

* Typescript - Provide option for user to set custom log path

* Typescript - Fix eofline in css files

* Typescript - ignore spec from compiling and remove unwanted rebuild command
  • Loading branch information
KiranNiranjan committed Apr 2, 2019
1 parent e3f4830 commit 13e82ba
Show file tree
Hide file tree
Showing 49 changed files with 1,578 additions and 253 deletions.
25 changes: 8 additions & 17 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ <h1>Symphony Electron API Demo</h1>

num++;

var notf = new ssf.Notification(title, {
var notf = {
id: num,
title,
body: (body + ' num=' + num + ' tag=' + tag),
image: imageUrl,
flash: shouldFlash,
Expand All @@ -142,24 +144,11 @@ <h1>Symphony Electron API Demo</h1>
hello: 'hello word'
},
tag: tag,
company: company
});

notf.addEventListener('click', onclick);
function onclick(event) {
event.target.close();
alert('notification clicked: ' + event.target.data.hello);
}

notf.addEventListener('close', onclose);
function onclose() {
alert('notification closed');
company: company,
method: 'notification',
};

notf.addEventListener('error', onerror);
function onerror(event) {
alert('error=' + event.result);
};
window.postMessage({ method: 'notification', data: notf }, '*');
});

var badgeCount = 0;
Expand Down Expand Up @@ -292,5 +281,7 @@ <h1>Symphony Electron API Demo</h1>
document.location.reload();
});

window.addEventListener('message', (event) => console.log(event));

</script>
</html>
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gulp.task('clean', function() {
});

gulp.task('compile', function() {
return gulp.src(['src/**/*.ts'])
return gulp.src(['src/**/*.ts', 'src/**/*.tsx'])
.pipe(tsc({ project: './tsconfig.json' }))
.pipe(gulp.dest('lib/'))
});
Expand All @@ -35,4 +35,4 @@ gulp.task('copy', function () {
}).pipe(gulp.dest('lib/src'))
});

gulp.task('build', gulp.series('clean', 'compile', 'less', 'copy'));
gulp.task('build', gulp.series('clean', 'compile', 'less', 'copy'));
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "Symphony",
"productName": "Symphony",
"version": "4.5.0",
"clientVersion": "1.55.0",
"version": "5.0.0",
"clientVersion": "1.55",
"buildNumber": "0",
"description": "Symphony desktop app (Foundation ODP)",
"author": "Symphony",
Expand All @@ -16,7 +16,7 @@
"browserify-preload": "browserify -o lib/src/renderer/_preload-main.js -x electron --insert-global-vars=__filename,__dirname lib/src/renderer/preload-main.js",
"rebuild": "electron-rebuild -f",
"dev": "npm run prebuild && cross-env ELECTRON_DEV=true electron .",
"test": "npm run lint && npm rebuild --build-from-source && cross-env ELECTRON_QA=true jest --config jest.unit.config.json --runInBand && npm run rebuild",
"test": "npm run lint && cross-env ELECTRON_QA=true jest --config jest.unit.config.json --runInBand",
"demo-win": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/index.html",
"demo-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/index.html",
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir",
Expand Down
2 changes: 2 additions & 0 deletions spec/screenSharingIndicator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ describe('screen sharing indicator', () => {
const closeIpcRendererMock = {
cmd: 'close-window',
windowType: 'screen-sharing-indicator',
winKey: 'id-123',
};
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const wrapper = shallow(React.createElement(ScreenSharingIndicator));
wrapper.setState({ streamId: 'id-123' });
wrapper.find(customSelector).simulate('click');
expect(spy).lastCalledWith(symphonyAPIEventLabel, closeIpcRendererMock);
});
Expand Down
6 changes: 4 additions & 2 deletions src/app/activity-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class ActivityDetection {
const idleTimeInMillis = idleTime * 1000;
if (idleTimeInMillis < this.idleThreshold) {
this.sendActivity(idleTimeInMillis);
if (this.timer) clearInterval(this.timer);
if (this.timer) {
clearInterval(this.timer);
}
this.timer = undefined;
logger.info(`activity-detection: activity occurred`);
return;
Expand Down Expand Up @@ -78,4 +80,4 @@ class ActivityDetection {

const activityDetection = new ActivityDetection();

export { activityDetection };
export { activityDetection };
2 changes: 1 addition & 1 deletion src/app/app-cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const cleanUpAppCache = async (): Promise<void> => {
*/
export const createAppCacheFile = (): void => {
fs.writeFileSync(cacheCheckFilePath, '');
};
};
2 changes: 1 addition & 1 deletion src/app/auto-launch-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ const autoLaunchInstance = new AutoLaunchController(props);

export {
autoLaunchInstance,
};
};
14 changes: 10 additions & 4 deletions src/app/child-window-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ const getParsedUrl = (configURL: string): Url => {
export const handleChildWindow = (webContents: WebContents): void => {
const childWindow = (event, newWinUrl, frameName, disposition, newWinOptions): void => {
const mainWindow = windowHandler.getMainWindow();
if (!mainWindow || mainWindow.isDestroyed()) return;
if (!windowHandler.url) return;
if (!mainWindow || mainWindow.isDestroyed()) {
return;
}
if (!windowHandler.url) {
return;
}

if (!newWinOptions.webPreferences) {
newWinOptions.webPreferences = {};
Expand Down Expand Up @@ -104,7 +108,9 @@ export const handleChildWindow = (webContents: WebContents): void => {

childWebContents.once('did-finish-load', async () => {
const browserWin: ICustomBrowserWindow = BrowserWindow.fromWebContents(childWebContents) as ICustomBrowserWindow;
if (!browserWin) return;
if (!browserWin) {
return;
}
windowHandler.addWindow(newWinKey, browserWin);
browserWin.webContents.send('page-load', { isWindowsOS });
// Inserts css on to the window
Expand All @@ -129,4 +135,4 @@ export const handleChildWindow = (webContents: WebContents): void => {
}
};
webContents.on('new-window', childWindow);
};
};
2 changes: 1 addition & 1 deletion src/app/chrome-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ export const setChromeFlags = () => {
}
}
}
};
};
2 changes: 1 addition & 1 deletion src/app/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ const config = new Config();

export {
config,
};
};
4 changes: 2 additions & 2 deletions src/app/crypto-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { logger } from '../common/logger';
const TAG_LENGTH = 16;
const arch = process.arch === 'ia32';
const winLibraryPath = isDevEnv ? path.join(__dirname, '..', '..', 'library') : path.join(execPath, 'library');
const macLibraryPath = isDevEnv ? path.join(__dirname, '..', '..', 'library') : path.join(execPath, '..', 'library');
const macLibraryPath = isDevEnv ? path.join(__dirname, '..', '..', '..', 'library') : path.join(execPath, '..', 'library');

const cryptoLibPath = isMac ?
path.join(macLibraryPath, 'cryptoLib.dylib') :
Expand Down Expand Up @@ -133,4 +133,4 @@ class CryptoLibrary implements ICryptoLib {

const cryptoLibrary = new CryptoLibrary();

export { cryptoLibrary };
export { cryptoLibrary };
10 changes: 7 additions & 3 deletions src/app/dialog-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ electron.app.on('certificate-error', (event, webContents, url, error, _certifica
*/
export const showLoadFailure = (browserWindow: Electron.BrowserWindow, url: string, errorDesc: string, errorCode: number, retryCallback: () => void, showDialog: boolean): void => {
let message = url ? `${i18n.t('Error loading URL')()}:\n${url}` : i18n.t('Error loading window')();
if (errorDesc) message += `\n\n${errorDesc}`;
if (errorCode) message += `\n\nError Code: ${errorCode}`;
if (errorDesc) {
message += `\n\n${errorDesc}`;
}
if (errorCode) {
message += `\n\nError Code: ${errorCode}`;
}

// async handle of user input
const response = (buttonId: number): void => {
Expand Down Expand Up @@ -132,4 +136,4 @@ export const showLoadFailure = (browserWindow: Electron.BrowserWindow, url: stri
export const showNetworkConnectivityError = (browserWindow: Electron.BrowserWindow, url: string = '', retryCallback: () => void): void => {
const errorDesc = i18n.t('Network connectivity has been lost. Check your internet connection.')();
showLoadFailure(browserWindow, url, errorDesc, 0, retryCallback, true);
};
};
27 changes: 7 additions & 20 deletions src/app/main-api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.Event, arg: IApiArgs) => {
// validates the user bring to front config and activates the wrapper
if (typeof arg.reason === 'string' && arg.reason === 'notification') {
const shouldBringToFront = config.getConfigFields([ 'bringToFront' ]);
if (shouldBringToFront) activate(arg.windowName, false);
if (shouldBringToFront) {
activate(arg.windowName, false);
}
}
break;
case apiCmds.openScreenPickerWindow:
Expand All @@ -95,21 +97,6 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.Event, arg: IApiArgs) => {
}
break;
}
/*case ApiCmds.optimizeMemoryConsumption:
if (typeof arg.memory === 'object'
&& typeof arg.cpuUsage === 'object'
&& typeof arg.memory.workingSetSize === 'number') {
setPreloadMemoryInfo(arg.memory, arg.cpuUsage);
}
break;
case ApiCmds.optimizeMemoryRegister:
setPreloadWindow(event.sender);
break;
case ApiCmds.setIsInMeeting:
if (typeof arg.isInMeeting === 'boolean') {
setIsInMeeting(arg.isInMeeting);
}
break;*/
case apiCmds.setLocale:
if (typeof arg.locale === 'string') {
updateLocale(arg.locale as LocaleType);
Expand All @@ -124,12 +111,12 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.Event, arg: IApiArgs) => {
screenSnippet.capture(event.sender);
break;
case apiCmds.closeWindow:
windowHandler.closeWindow(arg.windowType);
windowHandler.closeWindow(arg.windowType, arg.winKey);
break;
case apiCmds.openScreenSharingIndicator:
const { displayId, id } = arg;
if (typeof displayId === 'string' && typeof id === 'number') {
windowHandler.createScreenSharingIndicatorWindow(event.sender, displayId, id);
const { displayId, id, streamId } = arg;
if (typeof displayId === 'string' && typeof id === 'number' && typeof streamId === 'string') {
windowHandler.createScreenSharingIndicatorWindow(event.sender, displayId, id, streamId);
}
break;
case apiCmds.downloadManagerAction:
Expand Down
6 changes: 4 additions & 2 deletions src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ if (!allowMultiInstance) {
// Someone tried to run a second instance, we should focus our window.
const mainWindow = windowHandler.getMainWindow();
if (mainWindow && !mainWindow.isDestroyed()) {
if (isMac) return mainWindow.show();
if (isMac) {
return mainWindow.show();
}
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
Expand Down Expand Up @@ -117,4 +119,4 @@ app.on('activate', () => {
*
* This event is emitted only on macOS at this moment
*/
app.on('open-url', (_event, url) => protocolHandler.sendProtocol(url));
app.on('open-url', (_event, url) => protocolHandler.sendProtocol(url));
2 changes: 1 addition & 1 deletion src/app/protocol-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ class ProtocolHandler {

const protocolHandler = new ProtocolHandler();

export { protocolHandler };
export { protocolHandler };
2 changes: 1 addition & 1 deletion src/app/reports-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ export const exportCrashDumps = (): void => {
});
}
});
};
};
10 changes: 7 additions & 3 deletions src/app/screen-snippet-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class ScreenSnippet {
updateAlwaysOnTop(false, false);
}
// only allow one screen capture at a time.
if (this.child) this.child.kill();
if (this.child) {
this.child.kill();
}
try {
await this.execCmd(this.captureUtil, this.captureUtilArgs);
const { message, data, type }: IScreenSnippet = await this.convertFileToData();
Expand Down Expand Up @@ -86,7 +88,9 @@ class ScreenSnippet {
private execCmd(captureUtil: string, captureUtilArgs: ReadonlyArray<string>): Promise<ChildProcess> {
return new Promise<ChildProcess>((resolve, reject) => {
return this.child = execFile(captureUtil, captureUtilArgs, (error: ExecException | null) => {
if (this.isAlwaysOnTop) updateAlwaysOnTop(true, false);
if (this.isAlwaysOnTop) {
updateAlwaysOnTop(true, false);
}
if (error && error.killed) {
// processs was killed, just resolve with no data.
return reject(error);
Expand Down Expand Up @@ -140,4 +144,4 @@ class ScreenSnippet {

const screenSnippet = new ScreenSnippet();

export { screenSnippet };
export { screenSnippet };
2 changes: 1 addition & 1 deletion src/app/spell-check-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ export class SpellChecker {
}
return menu;
}
}
}
Loading

0 comments on commit 13e82ba

Please sign in to comment.