mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -51,7 +51,7 @@ export class WebWorkerExtensionHostStarter implements IExtensionHostStarter {
|
||||
const emitter = new Emitter<VSBuffer>();
|
||||
|
||||
const url = getWorkerBootstrapUrl(require.toUrl('../worker/extensionHostWorkerMain.js'), 'WorkerExtensionHost');
|
||||
const worker = new Worker(url);
|
||||
const worker = new Worker(url, { name: 'WorkerExtensionHost' });
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
const { data } = event;
|
||||
|
||||
@@ -30,7 +30,7 @@ const NO_OP_VOID_PROMISE = Promise.resolve<void>(undefined);
|
||||
|
||||
export abstract class AbstractExtensionService extends Disposable implements IExtensionService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
protected readonly _onDidRegisterExtensions: Emitter<void> = this._register(new Emitter<void>());
|
||||
public readonly onDidRegisterExtensions = this._onDidRegisterExtensions.event;
|
||||
@@ -443,7 +443,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
|
||||
|
||||
class ProposedApiController {
|
||||
|
||||
private readonly enableProposedApiFor: string | string[];
|
||||
private readonly enableProposedApiFor: string[];
|
||||
private readonly enableProposedApiForAll: boolean;
|
||||
private readonly productAllowProposedApi: Set<string>;
|
||||
|
||||
@@ -451,15 +451,8 @@ class ProposedApiController {
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
@IProductService productService: IProductService
|
||||
) {
|
||||
this.enableProposedApiFor = environmentService.args['enable-proposed-api'] || [];
|
||||
if (this.enableProposedApiFor.length) {
|
||||
// Make enabled proposed API be lowercase for case insensitive comparison
|
||||
if (Array.isArray(this.enableProposedApiFor)) {
|
||||
this.enableProposedApiFor = this.enableProposedApiFor.map(id => id.toLowerCase());
|
||||
} else {
|
||||
this.enableProposedApiFor = this.enableProposedApiFor.toLowerCase();
|
||||
}
|
||||
}
|
||||
// Make enabled proposed API be lowercase for case insensitive comparison
|
||||
this.enableProposedApiFor = (environmentService.args['enable-proposed-api'] || []).map(id => id.toLowerCase());
|
||||
|
||||
this.enableProposedApiForAll = !environmentService.isBuilt ||
|
||||
(!!environmentService.extensionDevelopmentLocationURI && productService.nameLong !== 'Visual Studio Code') ||
|
||||
|
||||
@@ -28,22 +28,21 @@ const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
const THIRTY_SECONDS = 30 * 1000;
|
||||
const URL_TO_HANDLE = 'extensionUrlHandler.urlToHandle';
|
||||
const CONFIRMED_EXTENSIONS_CONFIGURATION_KEY = 'extensions.confirmedUriHandlerExtensionIds';
|
||||
const CONFIRMED_EXTENSIONS_STORAGE_KEY = 'extensionUrlHandler.confirmedExtensions';
|
||||
|
||||
function isExtensionId(value: string): boolean {
|
||||
return /^[a-z0-9][a-z0-9\-]*\.[a-z0-9][a-z0-9\-]*$/i.test(value);
|
||||
}
|
||||
|
||||
export const IExtensionUrlHandler = createDecorator<IExtensionUrlHandler>('inactiveExtensionUrlHandler');
|
||||
export const IExtensionUrlHandler = createDecorator<IExtensionUrlHandler>('extensionUrlHandler');
|
||||
|
||||
export interface IExtensionUrlHandler {
|
||||
readonly _serviceBrand: any;
|
||||
readonly _serviceBrand: undefined;
|
||||
registerExtensionHandler(extensionId: ExtensionIdentifier, handler: IURLHandler): void;
|
||||
unregisterExtensionHandler(extensionId: ExtensionIdentifier): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class handles URLs which are directed towards inactive extensions.
|
||||
* This class handles URLs which are directed towards extensions.
|
||||
* If a URL is directed towards an inactive extension, it buffers it,
|
||||
* activates the extension and re-opens the URL once the extension registers
|
||||
* a URL handler. If the extension never registers a URL handler, the urls
|
||||
@@ -53,7 +52,7 @@ export interface IExtensionUrlHandler {
|
||||
*/
|
||||
class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
|
||||
readonly _serviceBrand: any;
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
private extensionHandlers = new Map<string, IURLHandler>();
|
||||
private uriBuffer = new Map<string, { timestamp: number, uri: URI }[]>();
|
||||
@@ -114,11 +113,11 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
}
|
||||
|
||||
const result = await this.dialogService.confirm({
|
||||
message: localize('confirmUrl', "Allow an extension to open this URL?", extensionId),
|
||||
message: localize('confirmUrl', "Allow an extension to open this URI?", extensionId),
|
||||
checkbox: {
|
||||
label: localize('rememberConfirmUrl', "Don't ask again for this extension."),
|
||||
},
|
||||
detail: `${extension.displayName || extension.name} (${extensionId}) wants to open a URL:\n\n${uriString}`,
|
||||
detail: `${extension.displayName || extension.name} (${extensionId}) wants to open a URI:\n\n${uriString}`,
|
||||
primaryButton: localize('open', "&&Open"),
|
||||
type: 'question'
|
||||
});
|
||||
@@ -128,7 +127,7 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
}
|
||||
|
||||
if (result.checkboxChecked) {
|
||||
this.addConfirmedExtensionIdToStorage(extensionId);
|
||||
await this.addConfirmedExtensionIdToStorage(extensionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,10 +289,8 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
}
|
||||
|
||||
private getConfirmedExtensionIds(): Set<string> {
|
||||
const ids = [
|
||||
...this.getConfirmedExtensionIdsFromStorage(),
|
||||
...this.getConfirmedExtensionIdsFromConfiguration(),
|
||||
].map(extensionId => ExtensionIdentifier.toKey(extensionId));
|
||||
const ids = this.getConfirmedExtensionIdsFromConfiguration()
|
||||
.map(extensionId => ExtensionIdentifier.toKey(extensionId));
|
||||
|
||||
return new Set(ids);
|
||||
}
|
||||
@@ -308,26 +305,12 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler {
|
||||
return confirmedExtensionIds;
|
||||
}
|
||||
|
||||
private getConfirmedExtensionIdsFromStorage(): Array<string> {
|
||||
const confirmedExtensionIdsJson = this.storageService.get(CONFIRMED_EXTENSIONS_STORAGE_KEY, StorageScope.GLOBAL, '[]');
|
||||
private async addConfirmedExtensionIdToStorage(extensionId: string): Promise<void> {
|
||||
const confirmedExtensionIds = this.configurationService.getValue<Array<string>>(CONFIRMED_EXTENSIONS_CONFIGURATION_KEY);
|
||||
const set = new Set(confirmedExtensionIds);
|
||||
set.add(extensionId);
|
||||
|
||||
try {
|
||||
return JSON.parse(confirmedExtensionIdsJson);
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private addConfirmedExtensionIdToStorage(extensionId: string): void {
|
||||
const existingConfirmedExtensionIds = this.getConfirmedExtensionIdsFromStorage();
|
||||
this.storageService.store(
|
||||
CONFIRMED_EXTENSIONS_STORAGE_KEY,
|
||||
JSON.stringify([
|
||||
...existingConfirmedExtensionIds,
|
||||
ExtensionIdentifier.toKey(extensionId),
|
||||
]),
|
||||
StorageScope.GLOBAL,
|
||||
);
|
||||
await this.configurationService.updateValue(CONFIRMED_EXTENSIONS_CONFIGURATION_KEY, [...set.values()]);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -130,7 +130,7 @@ export interface IResponsiveStateChangeEvent {
|
||||
}
|
||||
|
||||
export interface IExtensionService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* An event emitted when extensions are registered after their extension points got handled.
|
||||
@@ -258,7 +258,7 @@ export function toExtension(extensionDescription: IExtensionDescription): IExten
|
||||
|
||||
|
||||
export class NullExtensionService implements IExtensionService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
onDidRegisterExtensions: Event<void> = Event.None;
|
||||
onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]> = Event.None;
|
||||
onDidChangeExtensions: Event<void> = Event.None;
|
||||
|
||||
@@ -12,13 +12,13 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
export const IStaticExtensionsService = createDecorator<IStaticExtensionsService>('IStaticExtensionsService');
|
||||
|
||||
export interface IStaticExtensionsService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
getExtensions(): Promise<IExtensionDescription[]>;
|
||||
}
|
||||
|
||||
export class StaticExtensionsService implements IStaticExtensionsService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _descriptions: IExtensionDescription[] = [];
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagemen
|
||||
|
||||
export class RemoteExtensionManagementChannelClient extends ExtensionManagementChannelClient {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
channel: IChannel,
|
||||
|
||||
@@ -49,8 +49,9 @@ class ExtensionManifestParser extends ExtensionManifestHandler {
|
||||
|
||||
public parse(): Promise<IExtensionDescription> {
|
||||
return pfs.readFile(this._absoluteManifestPath).then((manifestContents) => {
|
||||
try {
|
||||
const manifest = JSON.parse(manifestContents.toString());
|
||||
const errors: json.ParseError[] = [];
|
||||
const manifest = json.parse(manifestContents.toString(), errors);
|
||||
if (errors.length === 0) {
|
||||
if (manifest.__metadata) {
|
||||
manifest.uuid = manifest.__metadata.id;
|
||||
}
|
||||
@@ -60,8 +61,10 @@ class ExtensionManifestParser extends ExtensionManifestHandler {
|
||||
}
|
||||
delete manifest.__metadata;
|
||||
return manifest;
|
||||
} catch (e) {
|
||||
this._log.error(this._absoluteFolderPath, nls.localize('jsonParseFail', "Failed to parse {0}: {1}.", this._absoluteManifestPath, getParseErrorMessage(e.message)));
|
||||
} else {
|
||||
errors.forEach(e => {
|
||||
this._log.error(this._absoluteFolderPath, nls.localize('jsonParseFail', "Failed to parse {0}: [{1}, {2}] {3}.", this._absoluteManifestPath, e.offset, e.length, getParseErrorMessage(e.error)));
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}, (err) => {
|
||||
|
||||
@@ -469,26 +469,24 @@ async function readCaCertificates() {
|
||||
}
|
||||
|
||||
async function readWindowsCaCertificates() {
|
||||
// Not using await to work around minifier bug (https://github.com/microsoft/vscode/issues/79044).
|
||||
return import('vscode-windows-ca-certs')
|
||||
.then(winCA => {
|
||||
let ders: any[] = [];
|
||||
const store = winCA();
|
||||
try {
|
||||
let der: any;
|
||||
while (der = store.next()) {
|
||||
ders.push(der);
|
||||
}
|
||||
} finally {
|
||||
store.done();
|
||||
}
|
||||
const winCA = await import('vscode-windows-ca-certs');
|
||||
|
||||
const certs = new Set(ders.map(derToPem));
|
||||
return {
|
||||
certs: Array.from(certs),
|
||||
append: true
|
||||
};
|
||||
});
|
||||
let ders: any[] = [];
|
||||
const store = winCA();
|
||||
try {
|
||||
let der: any;
|
||||
while (der = store.next()) {
|
||||
ders.push(der);
|
||||
}
|
||||
} finally {
|
||||
store.done();
|
||||
}
|
||||
|
||||
const certs = new Set(ders.map(derToPem));
|
||||
return {
|
||||
certs: Array.from(certs),
|
||||
append: true
|
||||
};
|
||||
}
|
||||
|
||||
async function readMacCaCertificates() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IExtHostDecorations, ExtHostDecorations } from 'vs/workbench/api/common
|
||||
import { IExtHostConfiguration, ExtHostConfiguration } from 'vs/workbench/api/common/extHostConfiguration';
|
||||
import { IExtHostCommands, ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { IExtHostDocumentsAndEditors, ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { IExtHostTerminalService } from 'vs/workbench/api/common/extHostTerminalService';
|
||||
import { IExtHostTerminalService, WorkerExtHostTerminalService } from 'vs/workbench/api/common/extHostTerminalService';
|
||||
import { IExtHostTask } from 'vs/workbench/api/common/extHostTask';
|
||||
import { IExtHostDebugService } from 'vs/workbench/api/common/extHostDebugService';
|
||||
import { IExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
|
||||
@@ -48,7 +48,7 @@ function NotImplementedProxy<T>(name: ServiceIdentifier<T>): { new(): T } {
|
||||
}
|
||||
};
|
||||
}
|
||||
registerSingleton(IExtHostTerminalService, class extends NotImplementedProxy(IExtHostTerminalService) { });
|
||||
registerSingleton(IExtHostTerminalService, WorkerExtHostTerminalService);
|
||||
registerSingleton(IExtHostTask, class extends NotImplementedProxy(IExtHostTask) { });
|
||||
registerSingleton(IExtHostDebugService, class extends NotImplementedProxy(IExtHostDebugService) { });
|
||||
registerSingleton(IExtHostSearch, class extends NotImplementedProxy(IExtHostSearch) { });
|
||||
|
||||
@@ -15,6 +15,9 @@ import 'vs/workbench/services/extensions/worker/extHost.services';
|
||||
//#region --- Define, capture, and override some globals
|
||||
//todo@joh do not allow extensions to call postMessage and other globals...
|
||||
|
||||
// declare WorkerSelf#postMessage
|
||||
declare function postMessage(data: any, transferables?: Transferable[]): void;
|
||||
|
||||
declare namespace self {
|
||||
let close: any;
|
||||
let postMessage: any;
|
||||
@@ -38,7 +41,7 @@ self.caches.open = () => console.trace(`'indexedDB.caches' has been blocked`);
|
||||
//#endregion ---
|
||||
|
||||
const hostUtil = new class implements IHostUtils {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
exit(_code?: number | undefined): void {
|
||||
nativeClose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user