UNPKG

@sussudio/platform

Version:

Internal APIs for VS Code's service injection the base services.

38 lines (37 loc) 1.45 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { onUnexpectedError } from '@sussudio/base/common/errors.mjs'; export class ImplicitActivationEventsImpl { _generators = new Map(); register(extensionPointName, generator) { this._generators.set(extensionPointName, generator); } updateManifest(manifest) { if (typeof manifest.main === 'undefined' && typeof manifest.browser === 'undefined') { return; } if (manifest.activationEvents === undefined) { Object.assign(manifest, { activationEvents: [] }); } if (!Array.isArray(manifest.activationEvents) || !manifest.contributes) { return; } for (const extPointName in manifest.contributes) { const generator = this._generators.get(extPointName); if (!generator) { // There's no generator for this extension point continue; } const contrib = manifest.contributes[extPointName]; const contribArr = Array.isArray(contrib) ? contrib : [contrib]; try { generator(contribArr, manifest.activationEvents); } catch (err) { onUnexpectedError(err); } } } } export const ImplicitActivationEvents = new ImplicitActivationEventsImpl();