Skip to content

Commit

Permalink
Fix onView activation event generation (#13091)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Dec 21, 2023
1 parent 118e514 commit 0055c8c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/plugin-ext/src/hosted/node/plugin-activation-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
PluginPackage,
PluginPackageAuthenticationProvider,
PluginPackageCommand,
PluginPackageContribution,
PluginPackageCustomEditor,
PluginPackageLanguageContribution,
PluginPackageNotebook,
Expand All @@ -31,7 +32,7 @@ import {
* This function will update the manifest based on the plugin contributions.
*/
export function updateActivationEvents(manifest: PluginPackage): void {
if (!isObject(manifest) || !isObject(manifest.contributes) || !manifest.contributes) {
if (!isObject<PluginPackage>(manifest) || !isObject<PluginPackageContribution>(manifest.contributes) || !manifest.contributes) {
return;
}

Expand All @@ -42,8 +43,8 @@ export function updateActivationEvents(manifest: PluginPackage): void {
const commands = Array.isArray(value) ? value : [value];
updateCommandsContributions(commands, activationEvents);
}
if (Array.isArray(manifest.contributes.views)) {
const views = flatten(Object.values(manifest.contributes.views)) as PluginPackageView[];
if (isObject(manifest.contributes.views)) {
const views = flatten(Object.values(manifest.contributes.views));
updateViewsContribution(views, activationEvents);
}
if (Array.isArray(manifest.contributes.customEditors)) {
Expand All @@ -64,47 +65,47 @@ export function updateActivationEvents(manifest: PluginPackage): void {

function updateViewsContribution(views: PluginPackageView[], activationEvents: Set<string>): void {
for (const view of views) {
if (isObject(view) && typeof view.id === 'string') {
if (isObject<PluginPackageView>(view) && typeof view.id === 'string') {
activationEvents.add(`onView:${view.id}`);
}
}
}

function updateCustomEditorsContribution(customEditors: PluginPackageCustomEditor[], activationEvents: Set<string>): void {
for (const customEditor of customEditors) {
if (isObject(customEditor) && typeof customEditor.viewType === 'string') {
if (isObject<PluginPackageCustomEditor>(customEditor) && typeof customEditor.viewType === 'string') {
activationEvents.add(`onCustomEditor:${customEditor.viewType}`);
}
}
}

function updateCommandsContributions(commands: PluginPackageCommand[], activationEvents: Set<string>): void {
for (const command of commands) {
if (isObject(command) && typeof command.command === 'string') {
if (isObject<PluginPackageCommand>(command) && typeof command.command === 'string') {
activationEvents.add(`onCommand:${command.command}`);
}
}
}

function updateAuthenticationProviderContributions(authProviders: PluginPackageAuthenticationProvider[], activationEvents: Set<string>): void {
for (const authProvider of authProviders) {
if (isObject(authProvider) && typeof authProvider.id === 'string') {
if (isObject<PluginPackageAuthenticationProvider>(authProvider) && typeof authProvider.id === 'string') {
activationEvents.add(`onAuthenticationRequest:${authProvider.id}`);
}
}
}

function updateLanguageContributions(languages: PluginPackageLanguageContribution[], activationEvents: Set<string>): void {
for (const language of languages) {
if (isObject(language) && typeof language.id === 'string') {
if (isObject<PluginPackageLanguageContribution>(language) && typeof language.id === 'string') {
activationEvents.add(`onLanguage:${language.id}`);
}
}
}

function updateNotebookContributions(notebooks: PluginPackageNotebook[], activationEvents: Set<string>): void {
for (const notebook of notebooks) {
if (isObject(notebook) && typeof notebook.type === 'string') {
if (isObject<PluginPackageNotebook>(notebook) && typeof notebook.type === 'string') {
activationEvents.add(`onNotebookSerializer:${notebook.type}`);
}
}
Expand Down

0 comments on commit 0055c8c

Please sign in to comment.