Update electron to 17.3.0

This commit is contained in:
Fedor Indutny 2022-03-29 10:06:42 -07:00 committed by GitHub
parent 8b36e37d18
commit f7c3a44056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 87 deletions

View File

@ -264,7 +264,7 @@
"cross-env": "5.2.0",
"css-loader": "3.2.0",
"debug": "4.3.3",
"electron": "17.2.0",
"electron": "17.3.0",
"electron-builder": "23.0.1",
"electron-mocha": "11.0.2",
"electron-notarize": "0.1.1",
@ -412,8 +412,6 @@
"afterPack": "ts/scripts/after-pack.js",
"afterSign": "ts/scripts/after-sign.js",
"asarUnpack": [
"ts/workers/heicConverter.bundle.js",
"ts/sql/mainWorker.bundle.js",
"node_modules/better-sqlite3/build/Release/better_sqlite3.node"
],
"files": [

View File

@ -83,43 +83,3 @@ esbuild.build({
entryPoints: [path.join(ROOT_DIR, 'preload.js')],
outfile: path.join(ROOT_DIR, 'preload.bundle.js'),
});
// HEIC worker
esbuild.build({
...bundleDefaults,
entryPoints: [path.join(ROOT_DIR, 'ts', 'workers', 'heicConverterWorker.ts')],
outfile: path.join(ROOT_DIR, 'ts', 'workers', 'heicConverter.bundle.js'),
});
// SQL worker
const libDir = path.join('..', '..', 'node_modules', 'better-sqlite3');
const bindingFile = path.join(
libDir,
'build',
'Release',
'better_sqlite3.node'
);
esbuild.build({
...nodeDefaults,
bundle: true,
plugins: [
{
name: 'bindings',
setup(build) {
build.onResolve({ filter: /^bindings$/ }, () => ({
path: path.join(ROOT_DIR, 'ts', 'sql', 'mainWorkerBindings.ts'),
}));
build.onResolve({ filter: /^better_sqlite3\.node$/ }, () => ({
path: bindingFile,
external: true,
}));
},
},
],
entryPoints: [path.join(ROOT_DIR, 'ts', 'sql', 'mainWorker.ts')],
outfile: path.join(ROOT_DIR, 'ts', 'sql', 'mainWorker.bundle.js'),
});

View File

@ -4,13 +4,13 @@
import { join } from 'path';
import { Worker } from 'worker_threads';
import { format } from 'util';
import { app } from 'electron';
import { strictAssert } from '../util/assert';
import { explodePromise } from '../util/explodePromise';
import type { LoggerType } from '../types/Logging';
import { isCorruptionError } from './errors';
const ASAR_PATTERN = /app\.asar$/;
const MIN_TRACE_DURATION = 40;
export type InitializeOptions = Readonly<{
@ -85,18 +85,8 @@ export class MainSQL {
private onResponse = new Map<number, PromisePair<any>>();
constructor() {
let appDir = join(__dirname, '..', '..');
let isBundled = false;
if (ASAR_PATTERN.test(appDir)) {
appDir = appDir.replace(ASAR_PATTERN, 'app.asar.unpacked');
isBundled = true;
}
const scriptDir = join(appDir, 'ts', 'sql');
this.worker = new Worker(
join(scriptDir, isBundled ? 'mainWorker.bundle.js' : 'mainWorker.js')
);
const scriptDir = join(app.getAppPath(), 'ts', 'sql', 'mainWorker.js');
this.worker = new Worker(scriptDir);
const { promise: onCorruption, resolve: resolveCorruption } =
explodePromise<Error>();

View File

@ -1,13 +0,0 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
// This is a shim that gets inserted in place of `bindings` npm module when
// building sql worker bundle.
module.exports = (binding: string) => {
if (binding === 'better_sqlite3.node') {
// eslint-disable-next-line global-require, import/no-unresolved
return require('better_sqlite3.node');
}
throw new Error(`Unknown binding ${binding}`);
};

View File

@ -3,6 +3,7 @@
import { join } from 'path';
import { Worker } from 'worker_threads';
import { app } from 'electron';
export type WrappedWorkerRequest = {
readonly uuid: string;
@ -15,25 +16,17 @@ export type WrappedWorkerResponse = {
readonly response?: File;
};
const ASAR_PATTERN = /app\.asar$/;
export function getHeicConverter(): (
uuid: string,
data: Uint8Array
) => Promise<WrappedWorkerResponse> {
let appDir = join(__dirname, '..', '..');
let isBundled = false;
if (ASAR_PATTERN.test(appDir)) {
appDir = appDir.replace(ASAR_PATTERN, 'app.asar.unpacked');
isBundled = true;
}
const scriptDir = join(appDir, 'ts', 'workers');
const worker = new Worker(
join(
scriptDir,
isBundled ? 'heicConverter.bundle.js' : 'heicConverterWorker.js'
)
const scriptDir = join(
app.getAppPath(),
'ts',
'workers',
'heicConverterWorker.js'
);
const worker = new Worker(scriptDir);
const ResponseMap = new Map<
string,

View File

@ -6172,10 +6172,10 @@ electron-window@^0.8.0:
dependencies:
is-electron-renderer "^2.0.0"
electron@17.2.0:
version "17.2.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-17.2.0.tgz#a5c42c16352ea968fcb5d1ce256bec51e7d140fe"
integrity sha512-eNXhPVEUofkgAeqRFvTizzYecoCMyS0Rar08WZHSAw9wjfZXawYMvTpjjjk9GiX9W/+Cjxua4YtGn5bOTabc0A==
electron@17.3.0:
version "17.3.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-17.3.0.tgz#cdcc46a7a3cd0b6f2a1757fbeb807f6b2fce847e"
integrity sha512-KuYHCOw1a+CE9thZlWRqTScf6M81KLd6n5qpdBGb0rl62+50RUuau9CnYpBb3EJxrjsXLaiQCBBSdPsozf/XUg==
dependencies:
"@electron/get" "^1.13.0"
"@types/node" "^14.6.2"