Skip to content

Commit

Permalink
#219: Upgrade electron to v12, migrate to @electron/remote, and set c…
Browse files Browse the repository at this point in the history
…ontextIsolation to false
  • Loading branch information
bstein committed Aug 15, 2022
1 parent 716f366 commit 3e2f582
Show file tree
Hide file tree
Showing 19 changed files with 1,467 additions and 54 deletions.
3 changes: 1 addition & 2 deletions app/app/analysis/analysisController.js
Expand Up @@ -26,10 +26,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import jetpack from 'fs-jetpack';
import {remote} from 'electron';
import { dialog } from '@electron/remote';
import {shell} from 'electron';
import path from 'path';
const {dialog} = remote;

export class AnalysisController {

Expand Down
4 changes: 1 addition & 3 deletions app/app/bcl/modalBclController.js
Expand Up @@ -26,9 +26,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import jetpack from 'fs-jetpack';
//const {shell} = require('electron');
import {remote} from 'electron';
const {shell} = remote;
import { shell } from '@electron/remote';

export class ModalBclController {

Expand Down
7 changes: 3 additions & 4 deletions app/app/index.run.js
Expand Up @@ -27,17 +27,16 @@
**********************************************************************************************************************/
/*global bootlint*/

import {remote} from 'electron';
const {app, Menu, shell} = remote;
import { app, getGlobal, Menu, shell } from '@electron/remote';

export function runBlock($rootScope, $state, $window, $document, $translate, toastr, MeasureManager, DependencyManager, Project, BCL, OsServer, SetProject, OpenProject, $log, Message) {
'ngInject';

let exitReady = false;

$window.onbeforeunload = e => {
console.log('EXIT BUTTON CLICKED?: ', remote.getGlobal('exitClicked'));
if (!exitReady && remote.getGlobal('exitClicked')) {
console.log('EXIT BUTTON CLICKED?: ', getGlobal('exitClicked'));
if (!exitReady && getGlobal('exitClicked')) {
try {
// only if project is set
if (Project.getProjectDir() != null) {
Expand Down
3 changes: 1 addition & 2 deletions app/app/main/dependencyManagerService.js
Expand Up @@ -25,8 +25,7 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';
const {app} = remote;
import { app } from '@electron/remote';
import jetpack from 'fs-jetpack';
import AdmZip from 'adm-zip';
import https from 'https';
Expand Down
2 changes: 0 additions & 2 deletions app/app/main/measureManagerService.js
Expand Up @@ -25,9 +25,7 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';
import openport from 'openport';
const {app} = remote;

export class MeasureManager {
constructor($log, $http, $q, DependencyManager, Message) {
Expand Down
4 changes: 1 addition & 3 deletions app/app/project/modalOpenProjectController.js
Expand Up @@ -25,9 +25,7 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';

const {app} = remote;
import { app } from '@electron/remote';

export class ModalOpenProjectController {

Expand Down
3 changes: 1 addition & 2 deletions app/app/project/modalSetMeasuresDirController.js
Expand Up @@ -25,8 +25,7 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';
const {dialog} = remote;
import { dialog } from '@electron/remote';

export class ModalSetMeasuresDirController {

Expand Down
4 changes: 1 addition & 3 deletions app/app/project/openProjectService.js
Expand Up @@ -25,9 +25,7 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';

const {dialog} = remote;
import { dialog } from '@electron/remote';

export class OpenProject {
constructor($q, $log, $uibModal, Message) {
Expand Down
3 changes: 1 addition & 2 deletions app/app/project/osServerService.js
Expand Up @@ -26,8 +26,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import jetpack from 'fs-jetpack';
import {remote} from 'electron';
const {app} = remote;
import { app } from '@electron/remote';
import path from 'path';
import os from 'os';
import AdmZip from 'adm-zip';
Expand Down
4 changes: 1 addition & 3 deletions app/app/project/projectService.js
Expand Up @@ -28,13 +28,11 @@
import jetpack from 'fs-jetpack';
//import os from 'os';
import path from 'path';
import {remote} from 'electron';
import { app, dialog } from '@electron/remote';
import jsZip from 'jszip';
import fs from 'fs';
import archiver from 'archiver';

const {app, dialog} = remote;

export class Project {
constructor($q, $log, $http, $uibModal, MeasureManager, $sce, Message, toastr, $translate) {
'ngInject';
Expand Down
4 changes: 1 addition & 3 deletions app/app/project/setProjectService.js
Expand Up @@ -26,12 +26,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import jetpack from 'fs-jetpack';
import {remote} from 'electron';
import { dialog } from '@electron/remote';
import fs from 'fs';
import path from 'path';

const {dialog} = remote;

export class SetProject {
constructor($q, $log, $state, $uibModal, Project, OsServer, BCL, $translate, toastr, Message) {
'ngInject';
Expand Down
4 changes: 1 addition & 3 deletions app/app/reports/reportsController.js
Expand Up @@ -28,10 +28,8 @@
import jetpack from 'fs-jetpack';
import os from 'os';
import path from 'path';
import {remote} from 'electron';
import { app } from '@electron/remote';
import { getEnv } from '../../env';

const {app} = remote;
export class ReportsController {

constructor($log, Project, $scope, Message) {
Expand Down
3 changes: 3 additions & 0 deletions app/background.js
Expand Up @@ -34,6 +34,8 @@ import { app } from 'electron';
import createWindow from './electron/window';
import { getEnv } from './env';

require('@electron/remote/main').initialize();

app.on('ready', () => {

const mainWindow = createWindow('main', {
Expand All @@ -42,6 +44,7 @@ app.on('ready', () => {
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false,
webviewTag: true,
webSecurity: false // Disable the same-origin policy when using http
}
Expand Down
7 changes: 3 additions & 4 deletions app/electron/context_menu.js
Expand Up @@ -25,9 +25,8 @@
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
import {remote} from 'electron';
import { app, getCurrentWindow, Menu, MenuItem } from '@electron/remote';
import jetpack from 'fs-jetpack';
const {app, Menu, MenuItem} = remote;

const env = jetpack.cwd(app.getAppPath()).read('env.json', 'json');

Expand Down Expand Up @@ -73,14 +72,14 @@ const env = jetpack.cwd(app.getAppPath()).read('env.json', 'json');
e.preventDefault();
if (env.name == 'development') {
rightClickPosition = {x: e.x, y: e.y};
remote.getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y);
getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y);
}

// Set the default context menu (cut, copy, paste) in all input textarea fields elements
switch (e.target.nodeName) {
case 'TEXTAREA':
case 'INPUT':
textMenu.popup(remote.getCurrentWindow());
textMenu.popup(getCurrentWindow());
break;
}
}, false);
Expand Down

0 comments on commit 3e2f582

Please sign in to comment.