2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IStringDictionary } from '../../../base/common/collections.js';
7
>
import { onUnexpectedError } from '../../../base/common/errors.js';
8
>
import { ExtensionIdentifier, IExtensionDescription } from '../../extensions/common/extensions.js';
9
>
10
>
export interface IActivationEventsGenerator<T> {
11
>
(contributions: readonly T[]): Iterable<string>;
12
>
}
13
>
14
>
export class ImplicitActivationEventsImpl {
15
>
16
>
private readonly _generators = new Map<string, IActivationEventsGenerator<unknown>>();
17
>
private readonly _cache = new WeakMap<IExtensionDescription, string[]>();
18
>
19
>
public register<T>(extensionPointName: string, generator: IActivationEventsGenerator<T>): void {
20
this._generators.set(extensionPointName, generator as IActivationEventsGenerator<unknown>);
21
}
23
>
/**
24
>
* This can run correctly only on the renderer process because that is the only place
25
>
* where all extension points and all implicit activation events generators are known.
26
>
*/
27
>
public readActivationEvents(extensionDescription: IExtensionDescription): string[] {
28
if (!this._cache.has(extensionDescription)) {
29
this._cache.set(extensionDescription, this._readActivationEvents(extensionDescription));