Skip to content

Commit

Permalink
Update packages electron remote module (#773)
Browse files Browse the repository at this point in the history
* deprecated electron remote statements replaces

Co-authored-by: Karl Drejing <[email protected]>
  • Loading branch information
e9gille and KarlTD committed Sep 25, 2021
1 parent 15142ca commit 6bad06c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const esc = s => s.replace(/[<>&'"]/g, x => ESC[x]);

const ipc = require('node-ipc');
const el = require('electron').remote;
const el = require('@electron/remote');
const bw = el.getCurrentWindow();
const [width] = bw.getSize();
const qp = require('querystring').parse(window.location.search.slice(1));
Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const rq = require;
const fs = rq('fs');
const ps = process;
const el = rq('electron');
require('@electron/remote/main').initialize();
const D = {};

// Detect platform: https://nodejs.org/api/process.html#process_process_platform
Expand Down
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"repository": ".",
"dependencies": {
"@electron/remote": "^2.0.1",
"jquery": "^3.6.0",
"monaco-editor": "^0.27.0",
"node-ipc": "^9.2.1",
Expand Down
6 changes: 3 additions & 3 deletions src/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@
&& !/Interrupt$|TreeList|Reply|FormatCode|GetAutocomplete|SaveChanges|CloseWindow|Exit/.test(x)) return;
sendEach([JSON.stringify([x, y])]);
};
const a = rq('electron').remote.process.argv;
const a = rq('@electron/remote').process.argv;
const { env } = D.el.process;
const h = { // h:args by name
c: env.RIDE_CONNECT,
Expand All @@ -1026,7 +1026,7 @@
log: env.RIDE_LOG,
};
if (D.mac && env.DYALOG_SPAWN) {
const app = rq('electron').remote.app.getAppPath();
const app = rq('@electron/remote').app.getAppPath();
h.s = `${app}${env.DYALOG_SPAWN}`;
}
for (let i = 1; i < a.length; i++) if (a[i][0] === '-') { h[a[i].slice(1)] = a[i + 1]; i += 1; }
Expand Down Expand Up @@ -1055,7 +1055,7 @@
exe: h.s,
log: h.log,
};
const openfile = rq('electron').remote.getGlobal('open_file');
const openfile = rq('@electron/remote').getGlobal('open_file');
if (openfile && /(dws|dcfg)$/i.test(openfile)) {
const qt = /\s/.test(openfile) ? '"' : '';
cnf.args = `LOAD=${qt}${openfile}${qt}`;
Expand Down
4 changes: 2 additions & 2 deletions src/pre_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const J = {};
D.zoom2fs = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 22, 24, 26, 28, 32, 36, 42, 48];
if (typeof nodeRequire !== 'undefined') {
D.el = nodeRequire('electron').remote;
D.el = nodeRequire('@electron/remote');
D.elw = D.el.getGlobal('elw');
D.ipc = nodeRequire('node-ipc');
D.ipc.config.logInColor = false;
D = $.extend(D, nodeRequire('electron').remote.getGlobal('D'));
D = $.extend(D, nodeRequire('@electron/remote').getGlobal('D'));
const plt = process.platform;
D.win = /^win/i.test(plt);
D.mac = plt === 'darwin';
Expand Down
2 changes: 1 addition & 1 deletion src/prf.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ D.prf = {};
D.db = !nodeRequire ? localStorage : (function DB() {
const rq = nodeRequire;
const fs = rq('fs');
const el = rq('electron').remote;
const el = rq('@electron/remote');
// file-backed storage with API similar to that of localStorage
const k = []; // keys
const v = []; // values
Expand Down
2 changes: 1 addition & 1 deletion src/prf_col.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
});
monaco.editor.setTheme(name);
if (D.el) {
nodeRequire('electron').remote.getGlobal('winstate').theme = schema.theme;
nodeRequire('@electron/remote').getGlobal('winstate').theme = schema.theme;
}
}
function updStl() { // update global style from what's in prefs.json
Expand Down
2 changes: 1 addition & 1 deletion utils/style-picker/index-init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fs=require('fs'),remote=require('electron').remote,dialog=remote.dialog;
const fs=require('fs'),remote=require('@electron/remote'),dialog=remote.dialog;
window.global={};

(function(global){
Expand Down

0 comments on commit 6bad06c

Please sign in to comment.