mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge vscode source through 1.62 release (#19981)
* Build breaks 1 * Build breaks * Build breaks * Build breaks * More build breaks * Build breaks (#2512) * Runtime breaks * Build breaks * Fix dialog location break * Update typescript * Fix ASAR break issue * Unit test breaks * Update distro * Fix breaks in ADO builds (#2513) * Bump to node 16 * Fix hygiene errors * Bump distro * Remove reference to node type * Delete vscode specific extension * Bump to node 16 in CI yaml * Skip integration tests in CI builds (while fixing) * yarn.lock update * Bump moment dependency in remote yarn * Fix drop-down chevron style * Bump to node 16 * Remove playwrite from ci.yaml * Skip building build scripts in hygine check
This commit is contained in:
35
src/vs/platform/extensions/common/extensionHostStarter.ts
Normal file
35
src/vs/platform/extensions/common/extensionHostStarter.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SerializedError } from 'vs/base/common/errors';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IExtensionHostStarter = createDecorator<IExtensionHostStarter>('extensionHostStarter');
|
||||
|
||||
export const ipcExtensionHostStarterChannelName = 'extensionHostStarter';
|
||||
|
||||
export interface IExtensionHostProcessOptions {
|
||||
env: { [key: string]: string | undefined; };
|
||||
detached: boolean;
|
||||
execArgv: string[] | undefined;
|
||||
silent: boolean;
|
||||
}
|
||||
|
||||
export interface IExtensionHostStarter {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
onDynamicStdout(id: string): Event<string>;
|
||||
onDynamicStderr(id: string): Event<string>;
|
||||
onDynamicMessage(id: string): Event<any>;
|
||||
onDynamicError(id: string): Event<{ error: SerializedError; }>;
|
||||
onDynamicExit(id: string): Event<{ code: number; signal: string }>;
|
||||
|
||||
createExtensionHost(): Promise<{ id: string; }>;
|
||||
start(id: string, opts: IExtensionHostProcessOptions): Promise<{ pid: number; }>;
|
||||
enableInspectPort(id: string): Promise<boolean>;
|
||||
kill(id: string): Promise<void>;
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import * as strings from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILocalization } from 'vs/platform/localizations/common/localizations';
|
||||
import { getRemoteName } from 'vs/platform/remote/common/remoteHosts';
|
||||
|
||||
export const MANIFEST_CACHE_FOLDER = 'CachedExtensions';
|
||||
export const USER_MANIFEST_CACHE_FILE = 'user';
|
||||
@@ -32,6 +33,9 @@ export interface IConfigurationProperty {
|
||||
}
|
||||
|
||||
export interface IConfiguration {
|
||||
id?: string,
|
||||
order?: number,
|
||||
title?: string,
|
||||
properties: { [key: string]: IConfigurationProperty; };
|
||||
}
|
||||
|
||||
@@ -125,8 +129,9 @@ export interface IWalkthroughStep {
|
||||
readonly title: string;
|
||||
readonly description: string | undefined;
|
||||
readonly media:
|
||||
| { image: string | { dark: string, light: string, hc: string }, altText: string, markdown?: never }
|
||||
| { markdown: string, image?: never }
|
||||
| { image: string | { dark: string, light: string, hc: string }, altText: string, markdown?: never, svg?: never }
|
||||
| { markdown: string, image?: never, svg?: never }
|
||||
| { svg: string, altText: string, markdown?: never, image?: never }
|
||||
readonly completionEvents?: string[];
|
||||
/** @deprecated use `completionEvents: 'onCommand:...'` */
|
||||
readonly doneOn?: { command: string };
|
||||
@@ -350,10 +355,18 @@ export function isLanguagePackExtension(manifest: IExtensionManifest): boolean {
|
||||
return manifest.contributes && manifest.contributes.localizations ? manifest.contributes.localizations.length > 0 : false;
|
||||
}
|
||||
|
||||
export function isAuthenticaionProviderExtension(manifest: IExtensionManifest): boolean {
|
||||
export function isAuthenticationProviderExtension(manifest: IExtensionManifest): boolean {
|
||||
return manifest.contributes && manifest.contributes.authentication ? manifest.contributes.authentication.length > 0 : false;
|
||||
}
|
||||
|
||||
export function isResolverExtension(manifest: IExtensionManifest, remoteAuthority: string | undefined): boolean {
|
||||
if (remoteAuthority && manifest.enableProposedApi) {
|
||||
const activationEvent = `onResolveRemoteAuthority:${getRemoteName(remoteAuthority)}`;
|
||||
return manifest.activationEvents?.indexOf(activationEvent) !== -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const IBuiltinExtensionsScannerService = createDecorator<IBuiltinExtensionsScannerService>('IBuiltinExtensionsScannerService');
|
||||
export interface IBuiltinExtensionsScannerService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
201
src/vs/platform/extensions/node/extensionHostStarter.ts
Normal file
201
src/vs/platform/extensions/node/extensionHostStarter.ts
Normal file
@@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SerializedError, transformErrorForSerialization } from 'vs/base/common/errors';
|
||||
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 { ChildProcess, fork } from 'child_process';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
import { StringDecoder } from 'string_decoder';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { cwd } from 'vs/base/common/process';
|
||||
|
||||
class ExtensionHostProcess extends Disposable {
|
||||
|
||||
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;
|
||||
|
||||
readonly _onError = this._register(new Emitter<{ error: SerializedError; }>());
|
||||
readonly onError = this._onError.event;
|
||||
|
||||
readonly _onExit = this._register(new Emitter<{ pid: number; code: number; signal: string }>());
|
||||
readonly onExit = this._onExit.event;
|
||||
|
||||
private _process: ChildProcess | null = null;
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
@ILogService private readonly _logService: ILogService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
register(disposable: IDisposable) {
|
||||
this._register(disposable);
|
||||
}
|
||||
|
||||
start(opts: IExtensionHostProcessOptions): { pid: number; } {
|
||||
this._process = fork(
|
||||
FileAccess.asFileUri('bootstrap-fork', require).fsPath,
|
||||
['--type=extensionHost', '--skipWorkspaceStorageLock'],
|
||||
mixin({ cwd: cwd() }, opts),
|
||||
);
|
||||
const pid = this._process.pid;
|
||||
|
||||
this._logService.info(`Starting extension host with pid ${pid}.`);
|
||||
|
||||
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._process.on('error', (err) => {
|
||||
this._onError.fire({ error: transformErrorForSerialization(err) });
|
||||
});
|
||||
|
||||
this._process.on('exit', (code: number, signal: string) => {
|
||||
this._onExit.fire({ pid, code, signal });
|
||||
});
|
||||
|
||||
return { pid };
|
||||
}
|
||||
|
||||
enableInspectPort(): boolean {
|
||||
if (!this._process) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this._logService.info(`Enabling inspect port on extension host with pid ${this._process.pid}.`);
|
||||
|
||||
interface ProcessExt {
|
||||
_debugProcess?(n: number): any;
|
||||
}
|
||||
|
||||
if (typeof (<ProcessExt>process)._debugProcess === 'function') {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
kill(): void {
|
||||
if (!this._process) {
|
||||
return;
|
||||
}
|
||||
this._logService.info(`Killing extension host with pid ${this._process.pid}.`);
|
||||
this._process.kill();
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtensionHostStarter implements IDisposable, IExtensionHostStarter {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private static _lastId: number = 0;
|
||||
|
||||
private readonly _extHosts: Map<string, ExtensionHostProcess>;
|
||||
|
||||
constructor(
|
||||
@ILogService private readonly _logService: ILogService
|
||||
) {
|
||||
this._extHosts = new Map<string, ExtensionHostProcess>();
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
// Intentionally not killing the extension host processes
|
||||
}
|
||||
|
||||
private _getExtHost(id: string): ExtensionHostProcess {
|
||||
const extHostProcess = this._extHosts.get(id);
|
||||
if (!extHostProcess) {
|
||||
throw new Error(`Unknown extension host!`);
|
||||
}
|
||||
return extHostProcess;
|
||||
}
|
||||
|
||||
onDynamicStdout(id: string): Event<string> {
|
||||
return this._getExtHost(id).onStdout;
|
||||
}
|
||||
|
||||
onDynamicStderr(id: string): Event<string> {
|
||||
return this._getExtHost(id).onStderr;
|
||||
}
|
||||
|
||||
onDynamicMessage(id: string): Event<any> {
|
||||
return this._getExtHost(id).onMessage;
|
||||
}
|
||||
|
||||
onDynamicError(id: string): Event<{ error: SerializedError; }> {
|
||||
return this._getExtHost(id).onError;
|
||||
}
|
||||
|
||||
onDynamicExit(id: string): Event<{ code: number; signal: string; }> {
|
||||
return this._getExtHost(id).onExit;
|
||||
}
|
||||
|
||||
async createExtensionHost(): Promise<{ id: string; }> {
|
||||
const id = String(++ExtensionHostStarter._lastId);
|
||||
const extHost = new ExtensionHostProcess(id, this._logService);
|
||||
this._extHosts.set(id, extHost);
|
||||
extHost.onExit(({ pid, code, signal }) => {
|
||||
this._logService.info(`Extension host with pid ${pid} exited with code: ${code}, signal: ${signal}.`);
|
||||
setTimeout(() => {
|
||||
extHost.dispose();
|
||||
this._extHosts.delete(id);
|
||||
});
|
||||
});
|
||||
return { id };
|
||||
}
|
||||
|
||||
async start(id: string, opts: IExtensionHostProcessOptions): Promise<{ pid: number; }> {
|
||||
return this._getExtHost(id).start(opts);
|
||||
}
|
||||
|
||||
async enableInspectPort(id: string): Promise<boolean> {
|
||||
const extHostProcess = this._extHosts.get(id);
|
||||
if (!extHostProcess) {
|
||||
return false;
|
||||
}
|
||||
return extHostProcess.enableInspectPort();
|
||||
}
|
||||
|
||||
async kill(id: string): Promise<void> {
|
||||
const extHostProcess = this._extHosts.get(id);
|
||||
if (!extHostProcess) {
|
||||
// already gone!
|
||||
return;
|
||||
}
|
||||
extHostProcess.kill();
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IExtensionHostStarter, ExtensionHostStarter, true);
|
||||
Reference in New Issue
Block a user