Path: blob/main/src/vs/workbench/services/extensions/common/extensionsRegistry.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as nls from '../../../../nls.js';6import { onUnexpectedError } from '../../../../base/common/errors.js';7import { IJSONSchema } from '../../../../base/common/jsonSchema.js';8import Severity from '../../../../base/common/severity.js';9import { EXTENSION_IDENTIFIER_PATTERN } from '../../../../platform/extensionManagement/common/extensionManagement.js';10import { Extensions, IJSONContributionRegistry } from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';11import { Registry } from '../../../../platform/registry/common/platform.js';12import { IMessage } from './extensions.js';13import { IExtensionDescription, EXTENSION_CATEGORIES, ExtensionIdentifierSet } from '../../../../platform/extensions/common/extensions.js';14import { ExtensionKind } from '../../../../platform/environment/common/environment.js';15import { productSchemaId } from '../../../../platform/product/common/productService.js';16import { ImplicitActivationEvents, IActivationEventsGenerator } from '../../../../platform/extensionManagement/common/implicitActivationEvents.js';17import { IDisposable } from '../../../../base/common/lifecycle.js';18import { allApiProposals } from '../../../../platform/extensions/common/extensionsApiProposals.js';1920const schemaRegistry = Registry.as<IJSONContributionRegistry>(Extensions.JSONContribution);2122export class ExtensionMessageCollector {2324private readonly _messageHandler: (msg: IMessage) => void;25private readonly _extension: IExtensionDescription;26private readonly _extensionPointId: string;2728constructor(29messageHandler: (msg: IMessage) => void,30extension: IExtensionDescription,31extensionPointId: string32) {33this._messageHandler = messageHandler;34this._extension = extension;35this._extensionPointId = extensionPointId;36}3738private _msg(type: Severity, message: string): void {39this._messageHandler({40type: type,41message: message,42extensionId: this._extension.identifier,43extensionPointId: this._extensionPointId44});45}4647public error(message: string): void {48this._msg(Severity.Error, message);49}5051public warn(message: string): void {52this._msg(Severity.Warning, message);53}5455public info(message: string): void {56this._msg(Severity.Info, message);57}58}5960export interface IExtensionPointUser<T> {61description: IExtensionDescription;62value: T;63collector: ExtensionMessageCollector;64}6566export type IExtensionPointHandler<T> = (extensions: readonly IExtensionPointUser<T>[], delta: ExtensionPointUserDelta<T>) => void;6768export interface IExtensionPoint<T> {69readonly name: string;70setHandler(handler: IExtensionPointHandler<T>): IDisposable;71readonly defaultExtensionKind: ExtensionKind[] | undefined;72readonly canHandleResolver?: boolean;73}7475export class ExtensionPointUserDelta<T> {7677private static _toSet<T>(arr: readonly IExtensionPointUser<T>[]): ExtensionIdentifierSet {78const result = new ExtensionIdentifierSet();79for (let i = 0, len = arr.length; i < len; i++) {80result.add(arr[i].description.identifier);81}82return result;83}8485public static compute<T>(previous: readonly IExtensionPointUser<T>[] | null, current: readonly IExtensionPointUser<T>[]): ExtensionPointUserDelta<T> {86if (!previous || !previous.length) {87return new ExtensionPointUserDelta<T>(current, []);88}89if (!current || !current.length) {90return new ExtensionPointUserDelta<T>([], previous);91}9293const previousSet = this._toSet(previous);94const currentSet = this._toSet(current);9596const added = current.filter(user => !previousSet.has(user.description.identifier));97const removed = previous.filter(user => !currentSet.has(user.description.identifier));9899return new ExtensionPointUserDelta<T>(added, removed);100}101102constructor(103public readonly added: readonly IExtensionPointUser<T>[],104public readonly removed: readonly IExtensionPointUser<T>[],105) { }106}107108export class ExtensionPoint<T> implements IExtensionPoint<T> {109110public readonly name: string;111public readonly defaultExtensionKind: ExtensionKind[] | undefined;112public readonly canHandleResolver?: boolean;113114private _handler: IExtensionPointHandler<T> | null;115private _users: IExtensionPointUser<T>[] | null;116private _delta: ExtensionPointUserDelta<T> | null;117118constructor(name: string, defaultExtensionKind: ExtensionKind[] | undefined, canHandleResolver?: boolean) {119this.name = name;120this.defaultExtensionKind = defaultExtensionKind;121this.canHandleResolver = canHandleResolver;122this._handler = null;123this._users = null;124this._delta = null;125}126127setHandler(handler: IExtensionPointHandler<T>): IDisposable {128if (this._handler !== null) {129throw new Error('Handler already set!');130}131this._handler = handler;132this._handle();133134return {135dispose: () => {136this._handler = null;137}138};139}140141acceptUsers(users: IExtensionPointUser<T>[]): void {142this._delta = ExtensionPointUserDelta.compute(this._users, users);143this._users = users;144this._handle();145}146147private _handle(): void {148if (this._handler === null || this._users === null || this._delta === null) {149return;150}151152try {153this._handler(this._users, this._delta);154} catch (err) {155onUnexpectedError(err);156}157}158}159160const extensionKindSchema: IJSONSchema = {161type: 'string',162enum: [163'ui',164'workspace'165],166enumDescriptions: [167nls.localize('ui', "UI extension kind. In a remote window, such extensions are enabled only when available on the local machine."),168nls.localize('workspace', "Workspace extension kind. In a remote window, such extensions are enabled only when available on the remote."),169],170};171172const schemaId = 'vscode://schemas/vscode-extensions';173export const schema: IJSONSchema = {174properties: {175engines: {176type: 'object',177description: nls.localize('vscode.extension.engines', "Engine compatibility."),178properties: {179'vscode': {180type: 'string',181description: nls.localize('vscode.extension.engines.vscode', 'For VS Code extensions, specifies the VS Code version that the extension is compatible with. Cannot be *. For example: ^0.10.5 indicates compatibility with a minimum VS Code version of 0.10.5.'),182default: '^1.22.0',183}184}185},186publisher: {187description: nls.localize('vscode.extension.publisher', 'The publisher of the VS Code extension.'),188type: 'string'189},190displayName: {191description: nls.localize('vscode.extension.displayName', 'The display name for the extension used in the VS Code gallery.'),192type: 'string'193},194categories: {195description: nls.localize('vscode.extension.categories', 'The categories used by the VS Code gallery to categorize the extension.'),196type: 'array',197uniqueItems: true,198items: {199oneOf: [{200type: 'string',201enum: EXTENSION_CATEGORIES,202},203{204type: 'string',205const: 'Languages',206deprecationMessage: nls.localize('vscode.extension.category.languages.deprecated', 'Use \'Programming Languages\' instead'),207}]208}209},210galleryBanner: {211type: 'object',212description: nls.localize('vscode.extension.galleryBanner', 'Banner used in the VS Code marketplace.'),213properties: {214color: {215description: nls.localize('vscode.extension.galleryBanner.color', 'The banner color on the VS Code marketplace page header.'),216type: 'string'217},218theme: {219description: nls.localize('vscode.extension.galleryBanner.theme', 'The color theme for the font used in the banner.'),220type: 'string',221enum: ['dark', 'light']222}223}224},225contributes: {226description: nls.localize('vscode.extension.contributes', 'All contributions of the VS Code extension represented by this package.'),227type: 'object',228properties: {229// extensions will fill in230} as any as { [key: string]: any },231default: {}232},233preview: {234type: 'boolean',235description: nls.localize('vscode.extension.preview', 'Sets the extension to be flagged as a Preview in the Marketplace.'),236},237enableProposedApi: {238type: 'boolean',239deprecationMessage: nls.localize('vscode.extension.enableProposedApi.deprecated', 'Use `enabledApiProposals` instead.'),240},241enabledApiProposals: {242markdownDescription: nls.localize('vscode.extension.enabledApiProposals', 'Enable API proposals to try them out. Only valid **during development**. Extensions **cannot be published** with this property. For more details visit: https://code.visualstudio.com/api/advanced-topics/using-proposed-api'),243type: 'array',244uniqueItems: true,245items: {246type: 'string',247enum: Object.keys(allApiProposals).map(proposalName => proposalName),248markdownEnumDescriptions: Object.values(allApiProposals).map(value => value.proposal)249}250},251api: {252markdownDescription: nls.localize('vscode.extension.api', 'Describe the API provided by this extension. For more details visit: https://code.visualstudio.com/api/advanced-topics/remote-extensions#handling-dependencies-with-remote-extensions'),253type: 'string',254enum: ['none'],255enumDescriptions: [256nls.localize('vscode.extension.api.none', "Give up entirely the ability to export any APIs. This allows other extensions that depend on this extension to run in a separate extension host process or in a remote machine.")257]258},259activationEvents: {260description: nls.localize('vscode.extension.activationEvents', 'Activation events for the VS Code extension.'),261type: 'array',262items: {263type: 'string',264defaultSnippets: [265{266label: 'onWebviewPanel',267description: nls.localize('vscode.extension.activationEvents.onWebviewPanel', 'An activation event emmited when a webview is loaded of a certain viewType'),268body: 'onWebviewPanel:viewType'269},270{271label: 'onLanguage',272description: nls.localize('vscode.extension.activationEvents.onLanguage', 'An activation event emitted whenever a file that resolves to the specified language gets opened.'),273body: 'onLanguage:${1:languageId}'274},275{276label: 'onCommand',277description: nls.localize('vscode.extension.activationEvents.onCommand', 'An activation event emitted whenever the specified command gets invoked.'),278body: 'onCommand:${2:commandId}'279},280{281label: 'onDebug',282description: nls.localize('vscode.extension.activationEvents.onDebug', 'An activation event emitted whenever a user is about to start debugging or about to setup debug configurations.'),283body: 'onDebug'284},285{286label: 'onDebugInitialConfigurations',287description: nls.localize('vscode.extension.activationEvents.onDebugInitialConfigurations', 'An activation event emitted whenever a "launch.json" needs to be created (and all provideDebugConfigurations methods need to be called).'),288body: 'onDebugInitialConfigurations'289},290{291label: 'onDebugDynamicConfigurations',292description: nls.localize('vscode.extension.activationEvents.onDebugDynamicConfigurations', 'An activation event emitted whenever a list of all debug configurations needs to be created (and all provideDebugConfigurations methods for the "dynamic" scope need to be called).'),293body: 'onDebugDynamicConfigurations'294},295{296label: 'onDebugResolve',297description: nls.localize('vscode.extension.activationEvents.onDebugResolve', 'An activation event emitted whenever a debug session with the specific type is about to be launched (and a corresponding resolveDebugConfiguration method needs to be called).'),298body: 'onDebugResolve:${6:type}'299},300{301label: 'onDebugAdapterProtocolTracker',302description: nls.localize('vscode.extension.activationEvents.onDebugAdapterProtocolTracker', 'An activation event emitted whenever a debug session with the specific type is about to be launched and a debug protocol tracker might be needed.'),303body: 'onDebugAdapterProtocolTracker:${6:type}'304},305{306label: 'workspaceContains',307description: nls.localize('vscode.extension.activationEvents.workspaceContains', 'An activation event emitted whenever a folder is opened that contains at least a file matching the specified glob pattern.'),308body: 'workspaceContains:${4:filePattern}'309},310{311label: 'onStartupFinished',312description: nls.localize('vscode.extension.activationEvents.onStartupFinished', 'An activation event emitted after the start-up finished (after all `*` activated extensions have finished activating).'),313body: 'onStartupFinished'314},315{316label: 'onTaskType',317description: nls.localize('vscode.extension.activationEvents.onTaskType', 'An activation event emitted whenever tasks of a certain type need to be listed or resolved.'),318body: 'onTaskType:${1:taskType}'319},320{321label: 'onFileSystem',322description: nls.localize('vscode.extension.activationEvents.onFileSystem', 'An activation event emitted whenever a file or folder is accessed with the given scheme.'),323body: 'onFileSystem:${1:scheme}'324},325{326label: 'onEditSession',327description: nls.localize('vscode.extension.activationEvents.onEditSession', 'An activation event emitted whenever an edit session is accessed with the given scheme.'),328body: 'onEditSession:${1:scheme}'329},330{331label: 'onSearch',332description: nls.localize('vscode.extension.activationEvents.onSearch', 'An activation event emitted whenever a search is started in the folder with the given scheme.'),333body: 'onSearch:${7:scheme}'334},335{336label: 'onView',337body: 'onView:${5:viewId}',338description: nls.localize('vscode.extension.activationEvents.onView', 'An activation event emitted whenever the specified view is expanded.'),339},340{341label: 'onUri',342body: 'onUri',343description: nls.localize('vscode.extension.activationEvents.onUri', 'An activation event emitted whenever a system-wide Uri directed towards this extension is open.'),344},345{346label: 'onOpenExternalUri',347body: 'onOpenExternalUri',348description: nls.localize('vscode.extension.activationEvents.onOpenExternalUri', 'An activation event emitted whenever a external uri (such as an http or https link) is being opened.'),349},350{351label: 'onCustomEditor',352body: 'onCustomEditor:${9:viewType}',353description: nls.localize('vscode.extension.activationEvents.onCustomEditor', 'An activation event emitted whenever the specified custom editor becomes visible.'),354},355{356label: 'onNotebook',357body: 'onNotebook:${1:type}',358description: nls.localize('vscode.extension.activationEvents.onNotebook', 'An activation event emitted whenever the specified notebook document is opened.'),359},360{361label: 'onAuthenticationRequest',362body: 'onAuthenticationRequest:${11:authenticationProviderId}',363description: nls.localize('vscode.extension.activationEvents.onAuthenticationRequest', 'An activation event emitted whenever sessions are requested from the specified authentication provider.')364},365{366label: 'onRenderer',367description: nls.localize('vscode.extension.activationEvents.onRenderer', 'An activation event emitted whenever a notebook output renderer is used.'),368body: 'onRenderer:${11:rendererId}'369},370{371label: 'onTerminalProfile',372body: 'onTerminalProfile:${1:terminalId}',373description: nls.localize('vscode.extension.activationEvents.onTerminalProfile', 'An activation event emitted when a specific terminal profile is launched.'),374},375{376label: 'onTerminalQuickFixRequest',377body: 'onTerminalQuickFixRequest:${1:quickFixId}',378description: nls.localize('vscode.extension.activationEvents.onTerminalQuickFixRequest', 'An activation event emitted when a command matches the selector associated with this ID'),379},380{381label: 'onWalkthrough',382body: 'onWalkthrough:${1:walkthroughID}',383description: nls.localize('vscode.extension.activationEvents.onWalkthrough', 'An activation event emitted when a specified walkthrough is opened.'),384},385{386label: 'onIssueReporterOpened',387body: 'onIssueReporterOpened',388description: nls.localize('vscode.extension.activationEvents.onIssueReporterOpened', 'An activation event emitted when the issue reporter is opened.'),389},390{391label: 'onChatParticipant',392body: 'onChatParticipant:${1:participantId}',393description: nls.localize('vscode.extension.activationEvents.onChatParticipant', 'An activation event emitted when the specified chat participant is invoked.'),394},395{396label: 'onLanguageModelChatProvider',397body: 'onLanguageModelChatProvider:${1:vendor}',398description: nls.localize('vscode.extension.activationEvents.onLanguageModelChatProvider', 'An activation event emitted when a chat model provider for the given vendor is requested.'),399},400{401label: 'onLanguageModelTool',402body: 'onLanguageModelTool:${1:toolId}',403description: nls.localize('vscode.extension.activationEvents.onLanguageModelTool', 'An activation event emitted when the specified language model tool is invoked.'),404},405{406label: 'onTerminal',407body: 'onTerminal:{1:shellType}',408description: nls.localize('vscode.extension.activationEvents.onTerminal', 'An activation event emitted when a terminal of the given shell type is opened.'),409},410{411label: 'onTerminalCompletionsRequested',412body: 'onTerminalCompletionsRequested',413description: nls.localize('vscode.extension.activationEvents.onTerminalCompletionsRequested', 'An activation event emitted when terminal completions are requested.'),414},415{416label: 'onTerminalShellIntegration',417body: 'onTerminalShellIntegration:${1:shellType}',418description: nls.localize('vscode.extension.activationEvents.onTerminalShellIntegration', 'An activation event emitted when terminal shell integration is activated for the given shell type.'),419},420{421label: 'onMcpCollection',422description: nls.localize('vscode.extension.activationEvents.onMcpCollection', 'An activation event emitted whenver a tool from the MCP server is requested.'),423body: 'onMcpCollection:${2:collectionId}',424},425{426label: '*',427description: nls.localize('vscode.extension.activationEvents.star', 'An activation event emitted on VS Code startup. To ensure a great end user experience, please use this activation event in your extension only when no other activation events combination works in your use-case.'),428body: '*'429}430],431}432},433badges: {434type: 'array',435description: nls.localize('vscode.extension.badges', 'Array of badges to display in the sidebar of the Marketplace\'s extension page.'),436items: {437type: 'object',438required: ['url', 'href', 'description'],439properties: {440url: {441type: 'string',442description: nls.localize('vscode.extension.badges.url', 'Badge image URL.')443},444href: {445type: 'string',446description: nls.localize('vscode.extension.badges.href', 'Badge link.')447},448description: {449type: 'string',450description: nls.localize('vscode.extension.badges.description', 'Badge description.')451}452}453}454},455markdown: {456type: 'string',457description: nls.localize('vscode.extension.markdown', "Controls the Markdown rendering engine used in the Marketplace. Either github (default) or standard."),458enum: ['github', 'standard'],459default: 'github'460},461qna: {462default: 'marketplace',463description: nls.localize('vscode.extension.qna', "Controls the Q&A link in the Marketplace. Set to marketplace to enable the default Marketplace Q & A site. Set to a string to provide the URL of a custom Q & A site. Set to false to disable Q & A altogether."),464anyOf: [465{466type: ['string', 'boolean'],467enum: ['marketplace', false]468},469{470type: 'string'471}472]473},474extensionDependencies: {475description: nls.localize('vscode.extension.extensionDependencies', 'Dependencies to other extensions. The identifier of an extension is always ${publisher}.${name}. For example: vscode.csharp.'),476type: 'array',477uniqueItems: true,478items: {479type: 'string',480pattern: EXTENSION_IDENTIFIER_PATTERN481}482},483extensionPack: {484description: nls.localize('vscode.extension.contributes.extensionPack', "A set of extensions that can be installed together. The identifier of an extension is always ${publisher}.${name}. For example: vscode.csharp."),485type: 'array',486uniqueItems: true,487items: {488type: 'string',489pattern: EXTENSION_IDENTIFIER_PATTERN490}491},492extensionKind: {493description: nls.localize('extensionKind', "Define the kind of an extension. `ui` extensions are installed and run on the local machine while `workspace` extensions run on the remote."),494type: 'array',495items: extensionKindSchema,496default: ['workspace'],497defaultSnippets: [498{499body: ['ui'],500description: nls.localize('extensionKind.ui', "Define an extension which can run only on the local machine when connected to remote window.")501},502{503body: ['workspace'],504description: nls.localize('extensionKind.workspace', "Define an extension which can run only on the remote machine when connected remote window.")505},506{507body: ['ui', 'workspace'],508description: nls.localize('extensionKind.ui-workspace', "Define an extension which can run on either side, with a preference towards running on the local machine.")509},510{511body: ['workspace', 'ui'],512description: nls.localize('extensionKind.workspace-ui', "Define an extension which can run on either side, with a preference towards running on the remote machine.")513},514{515body: [],516description: nls.localize('extensionKind.empty', "Define an extension which cannot run in a remote context, neither on the local, nor on the remote machine.")517}518]519},520capabilities: {521description: nls.localize('vscode.extension.capabilities', "Declare the set of supported capabilities by the extension."),522type: 'object',523properties: {524virtualWorkspaces: {525description: nls.localize('vscode.extension.capabilities.virtualWorkspaces', "Declares whether the extension should be enabled in virtual workspaces. A virtual workspace is a workspace which is not backed by any on-disk resources. When false, this extension will be automatically disabled in virtual workspaces. Default is true."),526type: ['boolean', 'object'],527defaultSnippets: [528{ label: 'limited', body: { supported: '${1:limited}', description: '${2}' } },529{ label: 'false', body: { supported: false, description: '${2}' } },530],531default: true.valueOf,532properties: {533supported: {534markdownDescription: nls.localize('vscode.extension.capabilities.virtualWorkspaces.supported', "Declares the level of support for virtual workspaces by the extension."),535type: ['string', 'boolean'],536enum: ['limited', true, false],537enumDescriptions: [538nls.localize('vscode.extension.capabilities.virtualWorkspaces.supported.limited', "The extension will be enabled in virtual workspaces with some functionality disabled."),539nls.localize('vscode.extension.capabilities.virtualWorkspaces.supported.true', "The extension will be enabled in virtual workspaces with all functionality enabled."),540nls.localize('vscode.extension.capabilities.virtualWorkspaces.supported.false', "The extension will not be enabled in virtual workspaces."),541]542},543description: {544type: 'string',545markdownDescription: nls.localize('vscode.extension.capabilities.virtualWorkspaces.description', "A description of how virtual workspaces affects the extensions behavior and why it is needed. This only applies when `supported` is not `true`."),546}547}548},549untrustedWorkspaces: {550description: nls.localize('vscode.extension.capabilities.untrustedWorkspaces', 'Declares how the extension should be handled in untrusted workspaces.'),551type: 'object',552required: ['supported'],553defaultSnippets: [554{ body: { supported: '${1:limited}', description: '${2}' } },555],556properties: {557supported: {558markdownDescription: nls.localize('vscode.extension.capabilities.untrustedWorkspaces.supported', "Declares the level of support for untrusted workspaces by the extension."),559type: ['string', 'boolean'],560enum: ['limited', true, false],561enumDescriptions: [562nls.localize('vscode.extension.capabilities.untrustedWorkspaces.supported.limited', "The extension will be enabled in untrusted workspaces with some functionality disabled."),563nls.localize('vscode.extension.capabilities.untrustedWorkspaces.supported.true', "The extension will be enabled in untrusted workspaces with all functionality enabled."),564nls.localize('vscode.extension.capabilities.untrustedWorkspaces.supported.false', "The extension will not be enabled in untrusted workspaces."),565]566},567restrictedConfigurations: {568description: nls.localize('vscode.extension.capabilities.untrustedWorkspaces.restrictedConfigurations', "A list of configuration keys contributed by the extension that should not use workspace values in untrusted workspaces."),569type: 'array',570items: {571type: 'string'572}573},574description: {575type: 'string',576markdownDescription: nls.localize('vscode.extension.capabilities.untrustedWorkspaces.description', "A description of how workspace trust affects the extensions behavior and why it is needed. This only applies when `supported` is not `true`."),577}578}579}580}581},582sponsor: {583description: nls.localize('vscode.extension.contributes.sponsor', "Specify the location from where users can sponsor your extension."),584type: 'object',585defaultSnippets: [586{ body: { url: '${1:https:}' } },587],588properties: {589'url': {590description: nls.localize('vscode.extension.contributes.sponsor.url', "URL from where users can sponsor your extension. It must be a valid URL with a HTTP or HTTPS protocol. Example value: https://github.com/sponsors/nvaccess"),591type: 'string',592}593}594},595scripts: {596type: 'object',597properties: {598'vscode:prepublish': {599description: nls.localize('vscode.extension.scripts.prepublish', 'Script executed before the package is published as a VS Code extension.'),600type: 'string'601},602'vscode:uninstall': {603description: nls.localize('vscode.extension.scripts.uninstall', 'Uninstall hook for VS Code extension. Script that gets executed when the extension is completely uninstalled from VS Code which is when VS Code is restarted (shutdown and start) after the extension is uninstalled. Only Node scripts are supported.'),604type: 'string'605}606}607},608icon: {609type: 'string',610description: nls.localize('vscode.extension.icon', 'The path to a 128x128 pixel icon.')611},612l10n: {613type: 'string',614description: nls.localize({615key: 'vscode.extension.l10n',616comment: [617'{Locked="bundle.l10n._locale_.json"}',618'{Locked="vscode.l10n API"}'619]620}, 'The relative path to a folder containing localization (bundle.l10n.*.json) files. Must be specified if you are using the vscode.l10n API.')621},622pricing: {623type: 'string',624markdownDescription: nls.localize('vscode.extension.pricing', 'The pricing information for the extension. Can be Free (default) or Trial. For more details visit: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#extension-pricing-label'),625enum: ['Free', 'Trial'],626default: 'Free'627}628}629};630631export type removeArray<T> = T extends Array<infer X> ? X : T;632633export interface IExtensionPointDescriptor<T> {634extensionPoint: string;635deps?: IExtensionPoint<any>[];636jsonSchema: IJSONSchema;637defaultExtensionKind?: ExtensionKind[];638canHandleResolver?: boolean;639/**640* A function which runs before the extension point has been validated and which641* should collect automatic activation events from the contribution.642*/643activationEventsGenerator?: IActivationEventsGenerator<removeArray<T>>;644}645646export class ExtensionsRegistryImpl {647648private readonly _extensionPoints = new Map<string, ExtensionPoint<any>>();649650public registerExtensionPoint<T>(desc: IExtensionPointDescriptor<T>): IExtensionPoint<T> {651if (this._extensionPoints.has(desc.extensionPoint)) {652throw new Error('Duplicate extension point: ' + desc.extensionPoint);653}654const result = new ExtensionPoint<T>(desc.extensionPoint, desc.defaultExtensionKind, desc.canHandleResolver);655this._extensionPoints.set(desc.extensionPoint, result);656if (desc.activationEventsGenerator) {657ImplicitActivationEvents.register(desc.extensionPoint, desc.activationEventsGenerator);658}659660schema.properties!['contributes'].properties![desc.extensionPoint] = desc.jsonSchema;661schemaRegistry.registerSchema(schemaId, schema);662663return result;664}665666public getExtensionPoints(): ExtensionPoint<any>[] {667return Array.from(this._extensionPoints.values());668}669}670671const PRExtensions = {672ExtensionsRegistry: 'ExtensionsRegistry'673};674Registry.add(PRExtensions.ExtensionsRegistry, new ExtensionsRegistryImpl());675export const ExtensionsRegistry: ExtensionsRegistryImpl = Registry.as(PRExtensions.ExtensionsRegistry);676677schemaRegistry.registerSchema(schemaId, schema);678679680schemaRegistry.registerSchema(productSchemaId, {681properties: {682extensionEnabledApiProposals: {683description: nls.localize('product.extensionEnabledApiProposals', "API proposals that the respective extensions can freely use."),684type: 'object',685properties: {},686additionalProperties: {687anyOf: [{688type: 'array',689uniqueItems: true,690items: {691type: 'string',692enum: Object.keys(allApiProposals),693markdownEnumDescriptions: Object.values(allApiProposals).map(value => value.proposal)694}695}]696}697}698}699});700701702