Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove usage of @electron/remote #125

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/webcomponents/bisweb_cpmelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CPMElement extends HTMLElement {
bis_webutil.createMenuItem(topmenu, ''); // separator
bis_webutil.createMenuItem(topmenu, 'Show JavaScript Console',
function () {
window.BISELECTRON.remote.getCurrentWindow().toggleDevTools();
window.BISELECTRON.toggleDevTools();
});
} else {
bis_webfileutil.createFileSourceSelector(topmenu);
Expand Down
2 changes: 1 addition & 1 deletion js/webcomponents/bisweb_mainviewerapplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ class ViewerApplicationElement extends HTMLElement {
webutil.createMenuItem(hmenu, ''); // separator
webutil.createMenuItem(hmenu, 'Show JavaScript Console',
function () {
window.BISELECTRON.remote.getCurrentWindow().toggleDevTools();
window.BISELECTRON.toggleDevTools();
});
userPreferences.safeGetItem('electonzoom').then( (v) => {
let z=v || 1.0;
Expand Down
2 changes: 1 addition & 1 deletion js/webtest/bisweb_regressiontestelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ var run_tests=async function(testlist,firsttest=0,lasttest=-1,testname='All',use
oldTestDataRootDirectory=testDataRootDirectory;

if (webutil.inElectronApp()) {
window.BISELECTRON.remote.getCurrentWindow().openDevTools();
window.BISELECTRON.toggleDevTools();
}
let url=window.document.URL;
let index=url.indexOf('.html');
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"author": "Yale BioImageSuite Web Team",
"license": "Apache",
"dependencies": {
"@electron/remote": "1.0.2",
"amazon-cognito-auth-js": "1.3.2",
"atob": "2.1.2",
"bootbox": "4.4.0",
Expand Down
14 changes: 12 additions & 2 deletions web/biselectron.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ let getTime = function() {
// -------------------------------------------------------------------------------

const electron = require('electron');
require('@electron/remote/main').initialize();
require('electron-debug')({showDevTools: false,
enabled : true});

Expand All @@ -57,6 +56,18 @@ const ipcMain = electron.ipcMain;
const shell=electron.shell;
const toolfile=require('./images/tools.json');

ipcMain.on('TOGGLE_DEV_TOOLS', (e) => {
e.sender.toggleDevTools();
})

ipcMain.handle('SHOW_SAVE_DIALOG', (e, opts) => {
return electron.dialog.showSaveDialog(null, opts)
})

ipcMain.handle('SHOW_OPEN_DIALOG', (e, opts) => {
return electron.dialog.showOpenDialog(null, opts)
})

const state = {
winlist : [null],
screensize : {
Expand Down Expand Up @@ -273,7 +284,6 @@ const createWindow=function(index,fullURL) {
nodeIntegration: false,
preload: preload,
contextIsolation: false,
enableRemoteModule : true,
},
autoHideMenuBar : true,
icon: __dirname+'/images/favicon.ico'});
Expand Down
14 changes: 11 additions & 3 deletions web/bispreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"use strict";

const electron= require('electron');
const remote = require('@electron/remote');

window.BISELECTRON = {
// ----------------------------------------------------
Expand All @@ -37,8 +36,17 @@ window.BISELECTRON = {
child_process : require('child_process'),
colors : require('colors/safe'),
ipc : electron.ipcRenderer,
dialog : remote.dialog,
remote : remote,
dialog : {
showSaveDialog: (_unused, options) => {
return electron.ipcRenderer.invoke('SHOW_SAVE_DIALOG', options)
},
showOpenDialog: (_unused, options) => {
return electron.ipcRenderer.invoke('SHOW_OPEN_DIALOG', options)
}
},
toggleDevTools: () => {
electron.ipcRenderer.send('TOGGLE_DEV_TOOLS')
},
Buffer : Buffer,
electron : electron,
};
Expand Down
2 changes: 1 addition & 1 deletion web/exportexample.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const fn = function(viewer,img) {
window.onload = function() {

if (bisweb.getEnvironment() === "electron") {
window.BISELECTRON.remote.getCurrentWindow().toggleDevTools();
window.BISELECTRON.toggleDevTools();
$('.navbar-fixed-bottom').remove();
}

Expand Down
1 change: 0 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"description": "The Electron version of BioImageSuite Web",
"main": "biselectron.js",
"dependencies": {
"@electron/remote": "1.0.2",
"commander": "2.16.0",
"colors": "1.1.2",
"electron-debug": "1.5.0",
Expand Down
2 changes: 1 addition & 1 deletion web/tfjsexample.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let run_tf_module=async function(img) {
window.onload = function() {

if (bisweb.getEnvironment() === "electron") {
window.BISELECTRON.remote.getCurrentWindow().toggleDevTools();
window.BISELECTRON.toggleDevTools();
$('.navbar-fixed-bottom').remove();
}

Expand Down
2 changes: 1 addition & 1 deletion web/tfjsexample2.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let run_tf_module=async function(img) {
window.onload = function() {

if (bisweb.getEnvironment() === "electron") {
window.BISELECTRON.remote.getCurrentWindow().toggleDevTools();
window.BISELECTRON.toggleDevTools();
$('.navbar-fixed-bottom').remove();
}

Expand Down