Update to Electron 4.x

This commit is contained in:
Scott Nonnenberg 2019-02-21 14:41:17 -08:00
parent 667b2e63f1
commit ae161c6cf6
10 changed files with 74 additions and 60 deletions

View file

@ -706,7 +706,7 @@
"message": "Quit", "message": "Quit",
"description": "Command in the tray icon menu, to quit the application" "description": "Command in the tray icon menu, to quit the application"
}, },
"trayTooltip": { "signalDesktop": {
"message": "Signal Desktop", "message": "Signal Desktop",
"description": "Tooltip for the tray icon" "description": "Tooltip for the tray icon"
}, },

View file

@ -237,6 +237,7 @@ function updateForMac(template, messages, options) {
// Add the OSX-specific Signal Desktop menu at the far left // Add the OSX-specific Signal Desktop menu at the far left
template.unshift({ template.unshift({
label: messages.signalDesktop.message,
submenu: [ submenu: [
{ {
label: messages.aboutSignalDesktop.message, label: messages.aboutSignalDesktop.message,

View file

@ -97,7 +97,7 @@ function createTrayIcon(getMainWindow, messages) {
tray.on('click', tray.showWindow); tray.on('click', tray.showWindow);
tray.setToolTip(messages.trayTooltip.message); tray.setToolTip(messages.signalDesktop.message);
tray.updateContextMenu(); tray.updateContextMenu();
return tray; return tray;

View file

@ -2,7 +2,7 @@
const { isNumber, compact } = require('lodash'); const { isNumber, compact } = require('lodash');
const he = require('he'); const he = require('he');
const punycode = require('punycode'); const nodeUrl = require('url');
const LinkifyIt = require('linkify-it'); const LinkifyIt = require('linkify-it');
const linkify = LinkifyIt(); const linkify = LinkifyIt();
@ -330,8 +330,7 @@ function isLinkSneaky(link) {
const domain = getDomain(link); const domain = getDomain(link);
// This is necesary because getDomain returns domains in punycode form // This is necesary because getDomain returns domains in punycode form
// We'd like to use require('url').domainToUnicode() but it's a no-op in a BrowserWindow const unicodeDomain = nodeUrl.domainToUnicode(domain);
const unicodeDomain = punycode.toUnicode(domain);
const chunks = unicodeDomain.split('.'); const chunks = unicodeDomain.split('.');
for (let i = 0, max = chunks.length; i < max; i += 1) { for (let i = 0, max = chunks.length; i < max; i += 1) {

37
main.js
View file

@ -98,21 +98,22 @@ function showWindow() {
if (!process.mas) { if (!process.mas) {
console.log('making app single instance'); console.log('making app single instance');
const shouldQuit = app.makeSingleInstance(() => { const gotLock = app.requestSingleInstanceLock();
// Someone tried to run a second instance, we should focus our window if (!gotLock) {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
showWindow();
}
return true;
});
if (shouldQuit) {
console.log('quitting; we are the second instance'); console.log('quitting; we are the second instance');
app.exit(); app.exit();
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
showWindow();
}
return true;
});
} }
} }
@ -217,7 +218,7 @@ function createWindow() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
// sandbox: true, contextIsolation: false,
preload: path.join(__dirname, 'preload.js'), preload: path.join(__dirname, 'preload.js'),
nativeWindowOpen: true, nativeWindowOpen: true,
}, },
@ -444,8 +445,8 @@ function showAbout() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'about_preload.js'), preload: path.join(__dirname, 'about_preload.js'),
// sandbox: true,
nativeWindowOpen: true, nativeWindowOpen: true,
}, },
parent: mainWindow, parent: mainWindow,
@ -490,8 +491,8 @@ async function showSettingsWindow() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'settings_preload.js'), preload: path.join(__dirname, 'settings_preload.js'),
// sandbox: true,
nativeWindowOpen: true, nativeWindowOpen: true,
}, },
parent: mainWindow, parent: mainWindow,
@ -535,8 +536,8 @@ async function showDebugLogWindow() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'debug_log_preload.js'), preload: path.join(__dirname, 'debug_log_preload.js'),
// sandbox: true,
nativeWindowOpen: true, nativeWindowOpen: true,
}, },
parent: mainWindow, parent: mainWindow,
@ -583,8 +584,8 @@ async function showPermissionsPopupWindow() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'permissions_popup_preload.js'), preload: path.join(__dirname, 'permissions_popup_preload.js'),
// sandbox: true,
nativeWindowOpen: true, nativeWindowOpen: true,
}, },
parent: mainWindow, parent: mainWindow,

View file

@ -79,7 +79,6 @@
"pify": "3.0.0", "pify": "3.0.0",
"protobufjs": "~6.8.6", "protobufjs": "~6.8.6",
"proxy-agent": "3.0.3", "proxy-agent": "3.0.3",
"punycode": "2.1.1",
"react": "16.2.0", "react": "16.2.0",
"react-contextmenu": "2.9.2", "react-contextmenu": "2.9.2",
"react-dom": "16.2.0", "react-dom": "16.2.0",
@ -113,7 +112,7 @@
"asar": "0.14.0", "asar": "0.14.0",
"bower": "1.8.2", "bower": "1.8.2",
"chai": "4.1.2", "chai": "4.1.2",
"electron": "3.0.14", "electron": "4.0.5",
"electron-builder": "20.13.5", "electron-builder": "20.13.5",
"electron-icon-maker": "0.0.3", "electron-icon-maker": "0.0.3",
"eslint": "4.14.0", "eslint": "4.14.0",

View file

@ -1,5 +1,6 @@
[ [
{ {
"label": "Signal Desktop",
"submenu": [ "submenu": [
{ {
"label": "About Signal Desktop", "label": "About Signal Desktop",

View file

@ -1,5 +1,6 @@
[ [
{ {
"label": "Signal Desktop",
"submenu": [ "submenu": [
{ {
"label": "About Signal Desktop", "label": "About Signal Desktop",

View file

@ -2386,49 +2386,65 @@
"rule": "eval", "rule": "eval",
"path": "node_modules/electron/electron.d.ts", "path": "node_modules/electron/electron.d.ts",
"line": " eval(code: string): void;", "line": " eval(code: string): void;",
"lineNumber": 1834, "lineNumber": 2031,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2018-09-15T00:38:04.183Z" "updated": "2019-02-22T01:08:09.603Z"
}, },
{ {
"rule": "jQuery-append(", "rule": "jQuery-append(",
"path": "node_modules/electron/electron.d.ts", "path": "node_modules/electron/electron.d.ts",
"line": " append(menuItem: MenuItem): void;", "line": " append(menuItem: MenuItem): void;",
"lineNumber": 3232, "lineNumber": 3431,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2018-09-19T18:13:29.628Z" "updated": "2019-02-22T01:08:09.603Z"
}, },
{ {
"rule": "jQuery-wrap(", "rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts", "path": "node_modules/electron/node_modules/@types/node/globals.d.ts",
"line": " wrap(oldStream: ReadableStream): this;", "line": " wrap(oldStream: ReadableStream): this;",
"lineNumber": 437, "lineNumber": 573,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2018-09-20T21:02:15.849Z" "updated": "2019-02-22T01:08:09.603Z"
}, },
{ {
"rule": "jQuery-wrap(", "rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts", "path": "node_modules/electron/node_modules/@types/node/globals.d.ts",
"line": " static wrap(code: string): string;", "line": " static wrap(code: string): string;",
"lineNumber": 792, "lineNumber": 976,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2018-09-20T20:45:24.002Z" "updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "eval",
"path": "node_modules/electron/node_modules/@types/node/repl.d.ts",
"line": " * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can",
"lineNumber": 31,
"reasonCategory": "falseMatch",
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "eval",
"path": "node_modules/electron/node_modules/@types/node/repl.d.ts",
"line": " * for the JavaScript `eval()` function.",
"lineNumber": 180,
"reasonCategory": "falseMatch",
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/stream.d.ts",
"line": " wrap(oldStream: NodeJS.ReadableStream): this;",
"lineNumber": 32,
"reasonCategory": "falseMatch",
"updated": "2019-02-22T01:08:09.603Z"
}, },
{ {
"rule": "jQuery-append(", "rule": "jQuery-append(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts", "path": "node_modules/electron/node_modules/@types/node/url.d.ts",
"line": " append(name: string, value: string): void;", "line": " append(name: string, value: string): void;",
"lineNumber": 2355, "lineNumber": 90,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2018-09-20T21:02:15.849Z" "updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts",
"line": " wrap(oldStream: NodeJS.ReadableStream): this;",
"lineNumber": 5277,
"reasonCategory": "falseMatch",
"updated": "2018-09-20T20:45:24.002Z"
}, },
{ {
"rule": "jQuery-$(", "rule": "jQuery-$(",
@ -6040,4 +6056,4 @@
"updated": "2018-09-17T20:50:40.689Z", "updated": "2018-09-17T20:50:40.689Z",
"reasonDetail": "Hard-coded value" "reasonDetail": "Hard-coded value"
} }
] ]

View file

@ -139,9 +139,10 @@
version "10.10.1" version "10.10.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6"
"@types/node@^8.0.24": "@types/node@^10.12.18":
version "8.9.4" version "10.12.26"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.4.tgz#dfd327582a06c114eb6e0441fa3d6fab35edad48" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.26.tgz#2dec19f1f7981c95cb54bab8f618ecb5dc983d0e"
integrity sha512-nMRqS+mL1TOnIJrL6LKJcNZPB8V3eTfRo9FQA2b5gDvrHurC8XbSA86KNe0dShlEL7ReWJv/OU9NL7Z0dnqWTg==
"@types/qs@6.5.1": "@types/qs@6.5.1":
version "6.5.1" version "6.5.1"
@ -2517,12 +2518,12 @@ electron-updater@2.21.10:
semver "^5.5.0" semver "^5.5.0"
source-map-support "^0.5.5" source-map-support "^0.5.5"
electron@3.0.14: electron@4.0.5:
version "3.0.14" version "4.0.5"
resolved "https://registry.yarnpkg.com/electron/-/electron-3.0.14.tgz#d54c51de3651c0fe48a6a6e9aef1ca98e5ea5796" resolved "https://registry.yarnpkg.com/electron/-/electron-4.0.5.tgz#d8e7d8a581a3e31071b2226129b26b6110c1d877"
integrity sha512-1fG9bE0LzL5QXeEq2MC0dHdVO0pbZOnNlVAIyOyJaCFAu/TjLhxQfWj38bFUEojzuVlaR87tZz0iy2qlVZj3sw== integrity sha512-UWFH6SrzNtzfvusGUFYxXDrgsUEbtBXkH/66hpDWxjA2Ckt7ozcYIujZpshbr7LPy8kV3ZRxIvoyCMdaS5DkVQ==
dependencies: dependencies:
"@types/node" "^8.0.24" "@types/node" "^10.12.18"
electron-download "^4.1.0" electron-download "^4.1.0"
extract-zip "^1.0.3" extract-zip "^1.0.3"
@ -6896,11 +6897,6 @@ punycode@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d"
punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
q-i@^2.0.1: q-i@^2.0.1:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/q-i/-/q-i-2.0.1.tgz#fec7e3f0e713f3467358bb5ac80bcc4c115187d6" resolved "https://registry.yarnpkg.com/q-i/-/q-i-2.0.1.tgz#fec7e3f0e713f3467358bb5ac80bcc4c115187d6"