From e47a286153ffd82c81de26053d79eab246098083 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 15 May 2023 11:18:57 -0700 Subject: [PATCH] resolvers: add appQuality and appCommit (#182532) Currently remote extensions use a hack to read the product.json, but this can't be done on web. Instead expose proper API to get the appQuality and appCommit. --- src/vs/workbench/api/common/extHost.api.impl.ts | 10 +++++++++- .../extensions/browser/webWorkerExtensionHost.ts | 1 + .../extensions/common/extensionHostProtocol.ts | 1 + .../services/extensions/common/remoteExtensionHost.ts | 1 + .../electron-sandbox/localProcessExtensionHost.ts | 1 + src/vscode-dts/vscode.proposed.resolvers.d.ts | 7 +++++++ 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 1536555f0e3..f4770a51dec 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -397,7 +397,15 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I registerIssueUriRequestHandler(handler: vscode.IssueUriRequestHandler) { checkProposedApiEnabled(extension, 'handleIssueUri'); return extHostIssueReporter.registerIssueUriRequestHandler(extension, handler); - } + }, + get appQuality(): string | undefined { + checkProposedApiEnabled(extension, 'resolvers'); + return initData.quality; + }, + get appCommit(): string | undefined { + checkProposedApiEnabled(extension, 'resolvers'); + return initData.commit; + }, }; if (!initData.environment.extensionTestsLocationURI) { // allow to patch env-function when running tests diff --git a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts index f8c743176ad..ad66755797e 100644 --- a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts +++ b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts @@ -278,6 +278,7 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost return { commit: this._productService.commit, version: this._productService.version, + quality: this._productService.quality, parentPid: 0, environment: { isExtensionDevelopmentDebug: this._environmentService.debugRenderer, diff --git a/src/vs/workbench/services/extensions/common/extensionHostProtocol.ts b/src/vs/workbench/services/extensions/common/extensionHostProtocol.ts index 26e269fffd5..4472c9b7bdb 100644 --- a/src/vs/workbench/services/extensions/common/extensionHostProtocol.ts +++ b/src/vs/workbench/services/extensions/common/extensionHostProtocol.ts @@ -19,6 +19,7 @@ export interface IExtensionDescriptionDelta { export interface IExtensionHostInitData { version: string; + quality: string | undefined; commit?: string; /** * When set to `0`, no polling for the parent process still running will happen. diff --git a/src/vs/workbench/services/extensions/common/remoteExtensionHost.ts b/src/vs/workbench/services/extensions/common/remoteExtensionHost.ts index 70aa7236fb2..7ac17418689 100644 --- a/src/vs/workbench/services/extensions/common/remoteExtensionHost.ts +++ b/src/vs/workbench/services/extensions/common/remoteExtensionHost.ts @@ -208,6 +208,7 @@ export class RemoteExtensionHost extends Disposable implements IExtensionHost { return { commit: this._productService.commit, version: this._productService.version, + quality: this._productService.quality, parentPid: remoteInitData.pid, environment: { isExtensionDevelopmentDebug, diff --git a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts index 268774b373a..6360149dfce 100644 --- a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts @@ -419,6 +419,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost { return { commit: this._productService.commit, version: this._productService.version, + quality: this._productService.quality, parentPid: 0, environment: { isExtensionDevelopmentDebug: this._isExtensionDevDebug, diff --git a/src/vscode-dts/vscode.proposed.resolvers.d.ts b/src/vscode-dts/vscode.proposed.resolvers.d.ts index d7529dd871f..1eb6e8b6100 100644 --- a/src/vscode-dts/vscode.proposed.resolvers.d.ts +++ b/src/vscode-dts/vscode.proposed.resolvers.d.ts @@ -60,6 +60,13 @@ declare module 'vscode' { label: string; } + export namespace env { + /** Quality of the application. May be undefined if running from sources. */ + export const appQuality: string | undefined; + /** Commit of the application. May be undefined if running from sources. */ + export const appCommit: string | undefined; + } + interface TunnelOptions { remoteAddress: { port: number; host: string }; // The desired local port. If this port can't be used, then another will be chosen.