From 0c150745bc90daad2bd00b884bd933181d0d6ae5 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Thu, 12 Mar 2020 10:01:18 +0000 Subject: [PATCH] [plugin] expose frontend API to access loaded plugins' metadata Signed-off-by: Anton Kosyakov --- packages/plugin-ext-vscode/src/node/scanner-vscode.ts | 7 +++++-- packages/plugin-ext/src/common/plugin-protocol.ts | 4 ++++ packages/plugin-ext/src/hosted/browser/hosted-plugin.ts | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/plugin-ext-vscode/src/node/scanner-vscode.ts b/packages/plugin-ext-vscode/src/node/scanner-vscode.ts index a71ffafe33a65..06edb22316391 100644 --- a/packages/plugin-ext-vscode/src/node/scanner-vscode.ts +++ b/packages/plugin-ext-vscode/src/node/scanner-vscode.ts @@ -43,7 +43,10 @@ export class VsCodePluginScanner extends TheiaPluginScanner implements PluginSca }, entryPoint: { backend: plugin.main - } + }, + iconUrl: plugin.icon && PluginPackage.toPluginUrl(plugin, plugin.icon), + readmeUrl: PluginPackage.toPluginUrl(plugin, './README.md'), + licenseUrl: PluginPackage.toPluginUrl(plugin, './LICENSE') }; return result; } @@ -65,7 +68,7 @@ export class VsCodePluginScanner extends TheiaPluginScanner implements PluginSca } } // Return the map of dependencies if present, else `undefined`. - return dependencies.size > 0 ? dependencies : undefined ; + return dependencies.size > 0 ? dependencies : undefined; } getLifecycle(plugin: PluginPackage): PluginLifecycle { diff --git a/packages/plugin-ext/src/common/plugin-protocol.ts b/packages/plugin-ext/src/common/plugin-protocol.ts index 079474a52f18d..a43af8403a4e4 100644 --- a/packages/plugin-ext/src/common/plugin-protocol.ts +++ b/packages/plugin-ext/src/common/plugin-protocol.ts @@ -55,6 +55,7 @@ export interface PluginPackage { activationEvents?: string[]; extensionDependencies?: string[]; extensionPack?: string[]; + icon?: string; } export namespace PluginPackage { export function toPluginUrl(pck: PluginPackage, relativePath: string): string { @@ -442,6 +443,9 @@ export interface PluginModel { }; entryPoint: PluginEntryPoint; packagePath: string; + iconUrl?: string; + readmeUrl?: string; + licenseUrl?: string; } export interface PluginEntryPoint { diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index 645340e7fecbf..900e501c250fe 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -202,6 +202,11 @@ export class HostedPluginSupport { return plugins; } + getPlugin(id: string): DeployedPlugin | undefined { + const contributions = this.contributions.get(id); + return contributions && contributions.plugin; + } + /** do not call it, except from the plugin frontend contribution */ onStart(container: interfaces.Container): void { this.container = container;