From a02c823fae9339251b8e4f5b39bfd6d1b7600017 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Thu, 18 Jan 2024 13:06:13 +0000 Subject: [PATCH 1/2] Fix `vscode.env.appRoot` path --- .../browser-only/frontend-only-application-module.ts | 1 + packages/core/src/common/application-protocol.ts | 1 + packages/core/src/node/application-server.ts | 9 ++++++++- packages/plugin-ext/src/common/plugin-api-rpc.ts | 3 ++- .../plugin-ext/src/hosted/browser/hosted-plugin.ts | 12 ++++++++++-- .../src/hosted/browser/worker/worker-env-ext.ts | 2 +- packages/plugin-ext/src/plugin/env.ts | 9 ++++++++- packages/plugin-ext/src/plugin/node/env-node-ext.ts | 7 ------- 8 files changed, 31 insertions(+), 13 deletions(-) diff --git a/packages/core/src/browser-only/frontend-only-application-module.ts b/packages/core/src/browser-only/frontend-only-application-module.ts index 680e7d227c83a..1820adde62504 100644 --- a/packages/core/src/browser-only/frontend-only-application-module.ts +++ b/packages/core/src/browser-only/frontend-only-application-module.ts @@ -55,6 +55,7 @@ export const frontendOnlyApplicationModule = new ContainerModule((bind, unbind, const mockedApplicationServer: ApplicationServer = { getExtensionsInfos: async (): Promise => [], getApplicationInfo: async (): Promise => undefined, + getApplicationRoot: async (): Promise => '', getBackendOS: async (): Promise => OS.Type.Linux }; if (isBound(ApplicationServer)) { diff --git a/packages/core/src/common/application-protocol.ts b/packages/core/src/common/application-protocol.ts index d84822c908d0a..d4b4a848d961f 100644 --- a/packages/core/src/common/application-protocol.ts +++ b/packages/core/src/common/application-protocol.ts @@ -23,6 +23,7 @@ export const ApplicationServer = Symbol('ApplicationServer'); export interface ApplicationServer { getExtensionsInfos(): Promise; getApplicationInfo(): Promise; + getApplicationRoot(): Promise; /** * @deprecated since 1.25.0. Use `OS.backend.type()` instead. */ diff --git a/packages/core/src/node/application-server.ts b/packages/core/src/node/application-server.ts index 011f90db35e60..e80212248293d 100644 --- a/packages/core/src/node/application-server.ts +++ b/packages/core/src/node/application-server.ts @@ -37,11 +37,18 @@ export class ApplicationServerImpl implements ApplicationServer { const name = pck.name; const version = pck.version; - return Promise.resolve({ name, version }); + return Promise.resolve({ + name, + version + }); } return Promise.resolve(undefined); } + getApplicationRoot(): Promise { + return Promise.resolve(this.applicationPackage.projectPath); + } + async getBackendOS(): Promise { return OS.type(); } diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 32140ec1c0625..0364b384cf4a0 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -163,9 +163,10 @@ export interface EnvInit { queryParams: QueryParameters; language: string; shell: string; - uiKind: UIKind, + uiKind: UIKind; appName: string; appHost: string; + appRoot: string; } export interface PluginAPI { diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index d9e957a986af5..c2016725f7aa0 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -66,6 +66,7 @@ import { LanguageService } from '@theia/monaco-editor-core/esm/vs/editor/common/ import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '@theia/core/lib/common/message-rpc/uint8-array-message-buffer'; import { BasicChannel } from '@theia/core/lib/common/message-rpc/channel'; import { NotebookTypeRegistry, NotebookService, NotebookRendererMessagingService } from '@theia/notebook/lib/browser'; +import { ApplicationServer } from '@theia/core/lib/common/application-protocol'; import { AbstractHostedPluginSupport, PluginContributions, PluginHost, ALL_ACTIVATION_EVENT, isConnectionScopedBackendPlugin @@ -174,6 +175,9 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport supportedActivationEvents.push(event)); } @@ -317,7 +324,8 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport { return this.proxy.$getClientOperatingSystem(); } @@ -92,7 +97,9 @@ export abstract class EnvExtImpl { return this.applicationName; } - abstract get appRoot(): string; + get appRoot(): string { + return this.applicationRoot; + } abstract get isNewAppInstall(): boolean; diff --git a/packages/plugin-ext/src/plugin/node/env-node-ext.ts b/packages/plugin-ext/src/plugin/node/env-node-ext.ts index 2ad86064f13cf..18ac72b3038d0 100644 --- a/packages/plugin-ext/src/plugin/node/env-node-ext.ts +++ b/packages/plugin-ext/src/plugin/node/env-node-ext.ts @@ -51,13 +51,6 @@ export class EnvNodeExtImpl extends EnvExtImpl { return this.macMachineId; } - /** - * Provides application root. - */ - get appRoot(): string { - return __dirname; - } - get isNewAppInstall(): boolean { return this._isNewAppInstall; } From ee6168de08739632a422865c5e9266d9022d2dda Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Wed, 24 Jan 2024 11:37:58 +0000 Subject: [PATCH 2/2] Fix appRoot init --- packages/plugin-ext/src/plugin/plugin-manager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-ext/src/plugin/plugin-manager.ts b/packages/plugin-ext/src/plugin/plugin-manager.ts index 66e1809848db4..bffd73d1de30a 100644 --- a/packages/plugin-ext/src/plugin/plugin-manager.ts +++ b/packages/plugin-ext/src/plugin/plugin-manager.ts @@ -467,6 +467,7 @@ export class PluginManagerExtImpl extends AbstractPluginManagerExtImpl