UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

63 lines • 2.56 kB
// ***************************************************************************** // Copyright (C) 2025 EclipseSource GmbH and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at // http://www.eclipse.org/legal/epl-2.0. // // This Source Code may also be made available under the following Secondary // Licenses when the conditions for such availability set forth in the Eclipse // Public License v. 2.0 are satisfied: GNU General Public License, version 2 // with the GNU Classpath Exception which is available at // https://www.gnu.org/software/classpath/license.html. // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** import { __decorate } from "tslib"; import { inject, injectable } from 'inversify'; import { ViewContainer } from '../view-container.js'; import { TabBarDecorator } from '../shell/tab-bar-decorator.js'; import { BadgeService } from './badge-service.js'; let TabBarBadgeDecorator = class TabBarBadgeDecorator { constructor() { this.id = 'theia-plugin-view-container-badge-decorator'; } onDidChangeDecorations(...[cb, thisArg, disposable]) { return this.badgeService.onDidChangeBadges(() => cb(), thisArg, disposable); } decorate({ owner }) { let total = 0; const result = []; const aggregate = (badge) => { if (badge?.value) { total += badge.value; } if (badge?.tooltip) { result.push({ tooltip: badge.tooltip }); } }; if (owner instanceof ViewContainer) { for (const { wrapped } of owner.getParts()) { aggregate(this.badgeService.getBadge(wrapped)); } } else { aggregate(this.badgeService.getBadge(owner)); } if (total !== 0) { result.push({ badge: total }); } return result; } }; __decorate([ inject(BadgeService) ], TabBarBadgeDecorator.prototype, "badgeService", void 0); TabBarBadgeDecorator = __decorate([ injectable() ], TabBarBadgeDecorator); export { TabBarBadgeDecorator }; export function bindBadgeDecoration(bind) { bind(BadgeService).toSelf().inSingletonScope(); bind(TabBarBadgeDecorator).toSelf().inSingletonScope(); bind(TabBarDecorator).toService(TabBarBadgeDecorator); } //# sourceMappingURL=tabbar-badge-decorator.js.map