Skip to content

Commit

Permalink
chore: update electron@19.0.17 (microsoft#161027)
Browse files Browse the repository at this point in the history
* chore: update electron@19.0.17

* chore: update API typings

* fix: compilation errors

* build: add libcups dependency
  • Loading branch information
deepak1556 authored Sep 16, 2022
1 parent 816b3e2 commit 22cbb8e
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
disturl "https://electronjs.org/headers"
target "19.0.12"
target "19.0.17"
runtime "electron"
build_from_source "true"
3 changes: 3 additions & 0 deletions build/linux/debian/dep-lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports.referenceGeneratedDepsByArch = {
'libc6 (>= 2.17)',
'libc6 (>= 2.2.5)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.5.12)',
'libdrm2 (>= 2.4.38)',
Expand Down Expand Up @@ -67,6 +68,7 @@ exports.referenceGeneratedDepsByArch = {
'libc6 (>= 2.4)',
'libc6 (>= 2.9)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.5.12)',
'libdrm2 (>= 2.4.38)',
Expand Down Expand Up @@ -105,6 +107,7 @@ exports.referenceGeneratedDepsByArch = {
'libatspi2.0-0 (>= 2.9.90)',
'libc6 (>= 2.17)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.0.2)',
'libdrm2 (>= 2.4.38)',
Expand Down
3 changes: 3 additions & 0 deletions build/linux/debian/dep-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const referenceGeneratedDepsByArch = {
'libc6 (>= 2.17)',
'libc6 (>= 2.2.5)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.5.12)',
'libdrm2 (>= 2.4.38)',
Expand Down Expand Up @@ -67,6 +68,7 @@ export const referenceGeneratedDepsByArch = {
'libc6 (>= 2.4)',
'libc6 (>= 2.9)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.5.12)',
'libdrm2 (>= 2.4.38)',
Expand Down Expand Up @@ -105,6 +107,7 @@ export const referenceGeneratedDepsByArch = {
'libatspi2.0-0 (>= 2.9.90)',
'libc6 (>= 2.17)',
'libcairo2 (>= 1.6.0)',
'libcups2 (>= 1.6.0)',
'libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3',
'libdbus-1-3 (>= 1.0.2)',
'libdrm2 (>= 2.4.38)',
Expand Down
3 changes: 3 additions & 0 deletions build/linux/rpm/dep-lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ exports.referenceGeneratedDepsByArch = {
'libc.so.6(GLIBC_2.8)(64bit)',
'libc.so.6(GLIBC_2.9)(64bit)',
'libcairo.so.2()(64bit)',
'libcups.so.2()(64bit)',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3()(64bit)',
'libdl.so.2()(64bit)',
Expand Down Expand Up @@ -133,6 +134,7 @@ exports.referenceGeneratedDepsByArch = {
'libc.so.6(GLIBC_2.8)',
'libc.so.6(GLIBC_2.9)',
'libcairo.so.2',
'libcups.so.2',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3',
'libdl.so.2',
Expand Down Expand Up @@ -221,6 +223,7 @@ exports.referenceGeneratedDepsByArch = {
'libc.so.6()(64bit)',
'libc.so.6(GLIBC_2.17)(64bit)',
'libcairo.so.2()(64bit)',
'libcups.so.2()(64bit)',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3()(64bit)',
'libdbus-1.so.3(LIBDBUS_1_3)(64bit)',
Expand Down
3 changes: 3 additions & 0 deletions build/linux/rpm/dep-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const referenceGeneratedDepsByArch = {
'libc.so.6(GLIBC_2.8)(64bit)',
'libc.so.6(GLIBC_2.9)(64bit)',
'libcairo.so.2()(64bit)',
'libcups.so.2()(64bit)',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3()(64bit)',
'libdl.so.2()(64bit)',
Expand Down Expand Up @@ -132,6 +133,7 @@ export const referenceGeneratedDepsByArch = {
'libc.so.6(GLIBC_2.8)',
'libc.so.6(GLIBC_2.9)',
'libcairo.so.2',
'libcups.so.2',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3',
'libdl.so.2',
Expand Down Expand Up @@ -220,6 +222,7 @@ export const referenceGeneratedDepsByArch = {
'libc.so.6()(64bit)',
'libc.so.6(GLIBC_2.17)(64bit)',
'libcairo.so.2()(64bit)',
'libcups.so.2()(64bit)',
'libcurl.so.4()(64bit)',
'libdbus-1.so.3()(64bit)',
'libdbus-1.so.3(LIBDBUS_1_3)(64bit)',
Expand Down
4 changes: 2 additions & 2 deletions cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@
"git": {
"name": "electron",
"repositoryUrl": "https://github.com/electron/electron",
"commitHash": "b05ccd812e3bb3de5b1546a313e298961653e942"
"commitHash": "0e6da36264d52656d5cd36a4c15937a6a6ca778e"
}
},
"isOnlyProductionDependency": true,
"license": "MIT",
"version": "19.0.12"
"version": "19.0.17"
},
{
"component": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"cssnano": "^4.1.11",
"debounce": "^1.0.0",
"deemon": "^1.4.0",
"electron": "19.0.12",
"electron": "19.0.17",
"eslint": "8.7.0",
"eslint-plugin-header": "3.1.1",
"eslint-plugin-jsdoc": "^39.3.2",
Expand Down
18 changes: 11 additions & 7 deletions src/bootstrap-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,17 @@ function listenForMessagePort() {
// We need to listen for the 'port' event as soon as possible,
// otherwise we might miss the event. But we should also be
// prepared in case the event arrives late.
process.on('port', (e) => {
if (global.vscodePortsCallback) {
global.vscodePortsCallback(e.ports);
} else {
global.vscodePorts = e.ports;
}
});
// @ts-ignore
if (process.parentPort) {
// @ts-ignore
process.parentPort.on('message', (e) => {
if (global.vscodePortsCallback) {
global.vscodePortsCallback(e.ports);
} else {
global.vscodePorts = e.ports;
}
});
}
}

//#endregion
165 changes: 130 additions & 35 deletions src/vs/platform/extensions/electron-main/extensionHostStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { canceled, SerializedError, transformErrorForSerialization } from 'vs/base/common/errors';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IExtensionHostProcessOptions, IExtensionHostStarter } from 'vs/platform/extensions/common/extensionHostStarter';
import { Emitter, Event } from 'vs/base/common/event';
import { ILogService } from 'vs/platform/log/common/log';
Expand All @@ -22,18 +22,113 @@ import * as electron from 'electron';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';

declare namespace UtilityProcessProposedApi {
interface UtilityProcessOptions {
serviceName?: string | undefined;
execArgv?: string[] | undefined;
env?: NodeJS.ProcessEnv | undefined;
interface UtilityProcessConstructorOptions {
/**
* Environment key-value pairs. Default is `process.env`.
*/
env?: NodeJS.ProcessEnv;
/**
* List of string arguments passed to the executable. Default is
* `process.execArgv`.
*/
execArgv?: string[];
/**
* Child's stdout and stderr configuration. Default is `pipe`. String value can be
* one of `pipe`, `ignore`, `inherit`, for more details on these values you can
* refer to stdio documentation from Node.js. Currently this option does not allow
* configuring stdin and is always set to `ignore`. For example, the supported
* values will be processed as following:
*/
stdio?: (Array<'pipe' | 'ignore' | 'inherit'>) | (string);
/**
* Name of the process that will appear in `name` property of `child-process-gone`
* event of `app`. Default is `node.mojom.NodeService`.
*/
serviceName?: string;
/**
* With this flag, the utility process will be launched via the `Electron Helper
* (Plugin).app` helper executable on macOS, which can be codesigned with
* `com.apple.security.cs.disable-library-validation` and
* `com.apple.security.cs.allow-unsigned-executable-memory` entitlements. This will
* allow the utility process to load unsigned libraries. Unless you specifically
* need this capability, it is best to leave this disabled. Default is `false`.
*
* @platform darwin
*/
allowLoadingUnsignedLibraries?: boolean;
}
export class UtilityProcess extends EventEmitter {
readonly pid?: number | undefined;
constructor(modulePath: string, args?: string[] | undefined, options?: UtilityProcessOptions);
postMessage(channel: string, message: any, transfer?: Electron.MessagePortMain[]): void;
kill(signal?: number | string): boolean;
on(event: 'exit', listener: (event: Electron.Event, code: number) => void): this;
on(event: 'spawn', listener: () => void): this;
class UtilityProcess extends EventEmitter {

// Docs: https://electronjs.org/docs/api/utility-process

/**
* Emitted after the child process ends. `code` contains the exit code for the
* process obtained from waitpid on posix, or GetExitCodeProcess on windows.
*/
on(event: 'exit', listener: (event: Electron.Event,
code: number) => void): this;
once(event: 'exit', listener: (event: Electron.Event,
code: number) => void): this;
addListener(event: 'exit', listener: (event: Electron.Event,
code: number) => void): this;
removeListener(event: 'exit', listener: (event: Electron.Event,
code: number) => void): this;
/**
* Emitted when the child process sends a message using
* `process.parentPort.postMessage()`.
*/
on(event: 'message', listener: (event: Electron.Event,
message: any) => void): this;
once(event: 'message', listener: (event: Electron.Event,
message: any) => void): this;
addListener(event: 'message', listener: (event: Electron.Event,
message: any) => void): this;
removeListener(event: 'message', listener: (event: Electron.Event,
message: any) => void): this;
/**
* Emitted once the child process has spawned successfully.
*/
on(event: 'spawn', listener: Function): this;
once(event: 'spawn', listener: Function): this;
addListener(event: 'spawn', listener: Function): this;
removeListener(event: 'spawn', listener: Function): this;
/**
* UtilityProcess
*/
constructor(modulePath: string, args?: string[], options?: UtilityProcessConstructorOptions);
/**
* Terminates the process gracefully. On POSIX, it uses SIGTERM but will ensure to
* reap the process on exit. This function returns true if kill succeeds, and false
* otherwise.
*/
kill(): boolean;
/**
* Send a message to the child process, optionally transferring ownership of zero
* or more [`MessagePortMain`][] objects.
*
* For example:
*/
postMessage(message: any, transfer?: Electron.MessagePortMain[]): void;
/**
* A `Integer | undefined` representing the process identifier (PID) of the child
* process. If the child process fails to spawn due to errors, then the value is
* `undefined`.
*/
pid: (number) | (undefined);
/**
* A `NodeJS.ReadableStream | null | undefined` that represents the child process's
* stderr. If the child was spawned with options.stdio[2] set to anything other
* than 'pipe', then this will be `null`. The property will be `undefined` if the
* child process could not be successfully spawned.
*/
stderr: (NodeJS.ReadableStream) | (null) | (undefined);
/**
* A `NodeJS.ReadableStream | null | undefined` that represents the child process's
* stdout. If the child was spawned with options.stdio[1] set to anything other
* than 'pipe', then this will be `null`. The property will be `undefined` if the
* child process could not be successfully spawned.
*/
stdout: (NodeJS.ReadableStream) | (null) | (undefined);
}
}
const UtilityProcess = <typeof UtilityProcessProposedApi.UtilityProcess>((electron as any).UtilityProcess);
Expand Down Expand Up @@ -286,10 +381,14 @@ class ExtensionHostProcess extends Disposable {

class UtilityExtensionHostProcess extends Disposable {

readonly onStdout = Event.None;
readonly onStderr = Event.None;
readonly onError = Event.None;

readonly _onStdout = this._register(new Emitter<string>());
readonly onStdout = this._onStdout.event;

readonly _onStderr = this._register(new Emitter<string>());
readonly onStderr = this._onStderr.event;

readonly _onMessage = this._register(new Emitter<any>());
readonly onMessage = this._onMessage.event;

Expand Down Expand Up @@ -335,6 +434,22 @@ class UtilityExtensionHostProcess extends Disposable {

this._process = new UtilityProcess(modulePath, args, { serviceName, env, execArgv });

const stdoutDecoder = new StringDecoder('utf-8');
this._process.stdout?.on('data', (chunk) => {
const strChunk = typeof chunk === 'string' ? chunk : stdoutDecoder.write(chunk);
this._onStdout.fire(strChunk);
});

const stderrDecoder = new StringDecoder('utf-8');
this._process.stderr?.on('data', (chunk) => {
const strChunk = typeof chunk === 'string' ? chunk : stderrDecoder.write(chunk);
this._onStderr.fire(strChunk);
});

this._process.on('message', msg => {
this._onMessage.fire(msg);
});

this._register(Event.fromNodeEventEmitter<void>(this._process, 'spawn')(() => {
this._logService.info(`UtilityProcess<${this.id}>: received spawn event.`);
}));
Expand All @@ -344,26 +459,10 @@ class UtilityExtensionHostProcess extends Disposable {
this._hasExited = true;
this._onExit.fire({ pid: this._process!.pid!, code, signal: '' });
}));
const listener = (event: electron.Event, details: electron.Details) => {
if (details.type !== 'Utility') {
return;
}
// Despite the fact that we pass the argument `seviceName`,
// the details have a field called `name` where this value appears
if (details.name === serviceName) {
this._logService.info(`UtilityProcess<${this.id}>: terminated unexpectedly with code ${details.exitCode}.`);
this._hasExited = true;
this._onExit.fire({ pid: this._process!.pid!, code: details.exitCode, signal: '' });
}
};
electron.app.on('child-process-gone', listener);
this._register(toDisposable(() => {
electron.app.off('child-process-gone', listener);
}));

const { port1, port2 } = new electron.MessageChannelMain();

this._process.postMessage('port', null, [port2]);
this._process.postMessage('null', [port2]);
responseWindow.webContents.postMessage(opts.responseChannel, opts.responseNonce, [port1]);
}

Expand All @@ -382,10 +481,6 @@ class UtilityExtensionHostProcess extends Disposable {
// use (undocumented) _debugProcess feature of node
(<ProcessExt>process)._debugProcess!(this._process.pid!);
return true;
} else if (!platform.isWindows) {
// use KILL USR1 on non-windows platforms (fallback)
this._process.kill('SIGUSR1');
return true;
} else {
// not supported...
return false;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3932,10 +3932,10 @@ electron-to-chromium@^1.4.202:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.207.tgz#9c3310ebace2952903d05dcaba8abe3a4ed44c01"
integrity sha512-piH7MJDJp4rJCduWbVvmUd59AUne1AFBJ8JaRQvk0KzNTSUnZrVXHCZc+eg+CGE4OujkcLJznhGKD6tuAshj5Q==

electron@19.0.12:
version "19.0.12"
resolved "https://registry.yarnpkg.com/electron/-/electron-19.0.12.tgz#73d11cc2a3e4dbcd61fdc1c39561e7a7911046e9"
integrity sha512-GOvG0t2NCeJYIfmC3g/dnEAQ71k3nQDbRVqQhpi2YbsYMury0asGJwqnVAv2uZQEwCwSx4XOwOQARTFEG/msWw==
electron@19.0.17:
version "19.0.17"
resolved "https://registry.yarnpkg.com/electron/-/electron-19.0.17.tgz#850d806e88b1ef141b88b491dc41661778691c27"
integrity sha512-3Offu61K+d19EZIc76MhKRsSCqfe3jDiqtD0p8jXr6p/TW7+7/jOQp407ZaZu0nQN6/xDIEi2sP4XQBom6GjTQ==
dependencies:
"@electron/get" "^1.14.1"
"@types/node" "^16.11.26"
Expand Down

0 comments on commit 22cbb8e

Please sign in to comment.