Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onView activation event generation #13091

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading