Skip to content

Commit

Permalink
[plugin] expose frontend API to access loaded plugins' metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Mar 19, 2020
1 parent 011f733 commit 0c15074
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/plugin-ext-vscode/src/node/scanner-vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -442,6 +443,9 @@ export interface PluginModel {
};
entryPoint: PluginEntryPoint;
packagePath: string;
iconUrl?: string;
readmeUrl?: string;
licenseUrl?: string;
}

export interface PluginEntryPoint {
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0c15074

Please sign in to comment.