Skip to content

Commit

Permalink
Merge pull request #2834 from Bilb/update-electron
Browse files Browse the repository at this point in the history
chore: update node version, electron and deps
  • Loading branch information
Bilb authored Aug 7, 2023
2 parents d2bccd1 + 49955a3 commit 940c3f6
Show file tree
Hide file tree
Showing 17 changed files with 631 additions and 544 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
branches:
- clearnet
- unstable
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
Expand Down Expand Up @@ -50,7 +53,6 @@ jobs:
if: runner.os == 'Windows'
run: |
npm install --global yarn node-gyp@latest
npm config set msvs_version 2022
- name: Install Desktop node_modules
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
branches:
- clearnet
- unstable
- unstable1

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
Expand All @@ -31,7 +36,8 @@ jobs:

- name: Cache Desktop node_modules
id: cache-desktop-modules
uses: actions/cache@v2
uses: actions/cache@v3
if: runner.os != 'Windows'
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
Expand All @@ -45,7 +51,6 @@ jobs:
if: runner.os == 'Windows'
run: |
npm install --global node-gyp@latest
npm config set msvs_version 2022
- name: Install Desktop node_modules
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Cache Desktop node_modules
id: cache-desktop-modules
uses: actions/cache@v2
uses: actions/cache@v3
if: runner.os != 'Windows'
with:
path: node_modules
Expand All @@ -45,7 +45,6 @@ jobs:
if: runner.os == 'Windows'
run: |
npm install --global node-gyp@latest
npm config set msvs_version 2022
- name: Install Desktop node_modules
if: steps.cache-desktop-modules.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13.0
18.15.0
2 changes: 1 addition & 1 deletion INTERNALBUILDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ base64 -i certificate.p12 -o encoded.txt

### Node version

You will need node `16.13.0`.
You will need node `18.15.0`.
This can be done by using [nvm](https://github.com/nvm-sh/nvm) and running `nvm use` or you can install it manually.
Once nvm is installed, just run `nvm install` to install the version from the `.nvmrc` file and then `nvm use` to use it.

Expand Down
2 changes: 1 addition & 1 deletion build/notarize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { notarize } = require('electron-notarize');
const { notarize } = require('@electron/notarize');

/*
Pre-requisites: https://github.com/electron/electron-notarize#prerequisites
Expand Down
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"lodash": "^4.17.20",
"ini": "^1.3.6",
"ejs": "^3.1.7",
"electron": "^17.2.0",
"react": "17.0.2",
"@types/react": "17.0.2",
"glob-parent": "^6.0.1",
Expand Down Expand Up @@ -75,11 +74,11 @@
"@emoji-mart/data": "^1.0.6",
"@emoji-mart/react": "^1.0.1",
"@reduxjs/toolkit": "1.8.5",
"@signalapp/better-sqlite3": "^8.4.3",
"@types/react-mentions": "^4.1.8",
"abort-controller": "3.0.0",
"auto-bind": "^4.0.0",
"backbone": "1.3.3",
"better-sqlite3": "https://github.com/oxen-io/session-better-sqlite3#af47530acea25800d22b5e1ae834b709d2bfca40",
"blob-util": "2.0.2",
"blueimp-canvas-to-blob": "^3.29.0",
"blueimp-load-image": "5.14.0",
Expand All @@ -92,7 +91,6 @@
"country-code-lookup": "^0.0.19",
"curve25519-js": "https://github.com/oxen-io/curve25519-js",
"dompurify": "^2.0.7",
"electron-is-dev": "^1.1.0",
"electron-localshortcut": "^3.2.1",
"electron-updater": "^4.2.2",
"emoji-mart": "^5.2.2",
Expand All @@ -102,7 +100,7 @@
"glob": "7.1.2",
"image-type": "^4.1.0",
"ip2country": "1.0.1",
"libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.2.2/libsession_util_nodejs-v0.2.2.tar.gz",
"libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.2.5/libsession_util_nodejs-v0.2.5.tar.gz",
"libsodium-wrappers-sumo": "^0.7.9",
"linkify-it": "^4.0.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -142,9 +140,9 @@
"uuid": "8.3.2"
},
"devDependencies": {
"@electron/notarize": "^2.1.0",
"@playwright/test": "1.16.3",
"@types/backbone": "1.4.2",
"@types/better-sqlite3": "7.4.0",
"@types/blueimp-load-image": "5.14.4",
"@types/buffer-crc32": "^0.2.0",
"@types/bunyan": "^1.8.8",
Expand Down Expand Up @@ -190,15 +188,14 @@
"cross-env": "^6.0.3",
"css-loader": "^6.7.2",
"dmg-builder": "23.6.0",
"electron": "^17.2.0",
"electron-builder": "22.8.0",
"electron-notarize": "^0.2.0",
"electron": "25.3.0",
"electron-builder": "23.0.8",
"esbuild": "^0.14.29",
"eslint": "^8.15.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^10.0.4",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-more": "^1.0.5",
"events": "^3.3.0",
"jsdom": "^19.0.0",
Expand Down Expand Up @@ -230,7 +227,7 @@
"webpack-cli": "^5.0.1"
},
"engines": {
"node": "16.13.0"
"node": "18.15.0"
},
"build": {
"appId": "com.loki-project.messenger-desktop",
Expand Down Expand Up @@ -285,7 +282,7 @@
"icon": "build/icon-linux.icns"
},
"asarUnpack": [
"node_modules/better-sqlite3/build/Release/better_sqlite3.node",
"node_modules/@signalapp/better-sqlite3/build/Release/better_sqlite3.node",
"node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node",
"ts/webworker/workers/node/libsession/*.node",
"ts/mains/main_node.js"
Expand Down
12 changes: 7 additions & 5 deletions ts/mains/main_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function prepareURL(pathSegments: Array<string>, moreKeys?: { theme: any }) {
}

function handleUrl(event: any, target: string) {
event.preventDefault();
event?.preventDefault();
const { protocol } = url.parse(target);
// tslint:disable-next-line: no-http-string
if (protocol === 'http:' || protocol === 'https:') {
Expand All @@ -203,7 +203,11 @@ function handleUrl(event: any, target: string) {

function captureClicks(window: BrowserWindow) {
window.webContents.on('will-navigate', handleUrl);
window.webContents.on('new-window', handleUrl);

window.webContents.setWindowOpenHandler(({ url: urlToOpen }) => {
handleUrl(undefined, urlToOpen);
return { action: 'deny' };
});
}

function getDefaultWindowSize() {
Expand Down Expand Up @@ -909,9 +913,7 @@ app.on('web-contents-created', (_createEvent, contents) => {
contents.on('will-attach-webview', attachEvent => {
attachEvent.preventDefault();
});
contents.on('new-window', newEvent => {
newEvent.preventDefault();
});
contents.setWindowOpenHandler(() => ({ action: 'deny' }));
});

// Ingested in preload.js via a sendSync call
Expand Down
18 changes: 8 additions & 10 deletions ts/node/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import path from 'path';

import electronIsDev from 'electron-is-dev';
import { app } from 'electron';
// tslint:disable: no-console

let environment;
const isPackaged = app.isPackaged;

// In production mode, NODE_ENV cannot be customized by the user
if (electronIsDev) {
environment = process.env.NODE_ENV || 'development';
} else {
if (isPackaged) {
environment = 'production';
// We could be running against production but still be in dev mode, we need to handle that
process.env.NODE_APP_INSTANCE = '';
} else {
environment = process.env.NODE_ENV || 'development';
}

// Set environment vars to configure node-config before requiring it
Expand All @@ -19,15 +22,10 @@ process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', '..', 'config');
if (environment === 'production') {
// harden production config against the local env
process.env.NODE_CONFIG = '';
process.env.NODE_CONFIG_STRICT_MODE = `${!electronIsDev}`;
process.env.NODE_CONFIG_STRICT_MODE = `${isPackaged ? 1 : 0}`; // we want to force strict mode when we are packaged
process.env.HOSTNAME = '';
process.env.ALLOW_CONFIG_MUTATIONS = '';
process.env.SUPPRESS_NO_CONFIG_WARNING = '';

// We could be running against production but still be in dev mode, we need to handle that
if (!electronIsDev) {
process.env.NODE_APP_INSTANCE = '';
}
}

// We load config after we've made our modifications to NODE_ENV
Expand Down
2 changes: 1 addition & 1 deletion ts/node/database_utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CONVERSATION_PRIORITIES,
} from '../models/conversationAttributes';

import * as BetterSqlite3 from 'better-sqlite3';
import * as BetterSqlite3 from '@signalapp/better-sqlite3';

export const CONVERSATIONS_TABLE = 'conversations';
export const MESSAGES_TABLE = 'messages';
Expand Down
6 changes: 3 additions & 3 deletions ts/node/migration/sessionMigrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BetterSqlite3 from 'better-sqlite3';
import * as BetterSqlite3 from '@signalapp/better-sqlite3';
import {
ContactsConfigWrapperNode,
ConvoInfoVolatileWrapperNode,
Expand Down Expand Up @@ -497,8 +497,8 @@ function updateToSessionSchemaVersion15(currentVersion: number, db: BetterSqlite
db.transaction(() => {
db.exec(`
DROP TABLE pairingAuthorisations;
DROP TRIGGER messages_on_delete;
DROP TRIGGER messages_on_update;
DROP TRIGGER IF EXISTS messages_on_delete;
DROP TRIGGER IF EXISTS messages_on_update;
`);

writeSessionSchemaVersion(targetVersion, db);
Expand Down
5 changes: 3 additions & 2 deletions ts/node/migration/signalMigrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BetterSqlite3 from 'better-sqlite3';
import * as BetterSqlite3 from '@signalapp/better-sqlite3';
import { isNumber } from 'lodash';
import path from 'path';

Expand All @@ -23,6 +23,7 @@ const openDbOptions = {
nativeBinding: path.join(
getAppRootPath(),
'node_modules',
'@signalapp',
'better-sqlite3',
'build',
'Release',
Expand Down Expand Up @@ -343,7 +344,7 @@ function updateToSchemaVersion7(currentVersion: number, db: BetterSqlite3.Databa
number
) WHERE number IS NOT NULL;
INSERT INTO sessions(id, number, json)
SELECT "+" || id, number, json FROM sessions_old;
SELECT id, number, json FROM sessions_old;
DROP TABLE sessions_old;
`);

Expand Down
2 changes: 1 addition & 1 deletion ts/node/sql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BetterSqlite3 from 'better-sqlite3';
import * as BetterSqlite3 from '@signalapp/better-sqlite3';
import { app, clipboard, dialog, Notification } from 'electron';
import fs from 'fs';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion ts/node/sqlInstance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as BetterSqlite3 from 'better-sqlite3';
import * as BetterSqlite3 from '@signalapp/better-sqlite3';

let globalInstance: BetterSqlite3.Database | null = null;

Expand Down
2 changes: 1 addition & 1 deletion ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const handleMessagesResponseV4 = async (
}
}
} catch (e) {
window?.log?.warn('handleNewMessages failed:', e);
window?.log?.warn('handleNewMessages failed:', e.message);
}
};

Expand Down
6 changes: 3 additions & 3 deletions ts/updater/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function showDownloadUpdateDialog(
const DOWNLOAD_BUTTON = 0;
const LATER_BUTTON = 1;
const options = {
type: 'info',
type: 'info' as const,
buttons: [messages.autoUpdateDownloadButtonLabel, messages.autoUpdateLaterButtonLabel],
title: messages.autoUpdateNewVersionTitle,
message: messages.autoUpdateNewVersionMessage,
Expand All @@ -43,7 +43,7 @@ export async function showUpdateDialog(
const RESTART_BUTTON = 0;
const LATER_BUTTON = 1;
const options = {
type: 'info',
type: 'info' as const,
buttons: [messages.autoUpdateRestartButtonLabel, messages.autoUpdateLaterButtonLabel],
title: messages.autoUpdateNewVersionTitle,
message: messages.autoUpdateDownloadedMessage,
Expand All @@ -58,7 +58,7 @@ export async function showUpdateDialog(

export async function showCannotUpdateDialog(mainWindow: BrowserWindow, messages: MessagesType) {
const options = {
type: 'error',
type: 'error' as const,
buttons: [messages.ok],
title: messages.cannotUpdate,
message: messages.cannotUpdateDetail,
Expand Down
Loading

0 comments on commit 940c3f6

Please sign in to comment.