UNPKG

@senx/discovery-widgets

Version:

Discovery Widgets Elements

52 lines (51 loc) 1.92 kB
/* * Copyright 2022 SenX S.A.S. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // noinspection JSUnusedGlobalSymbols import { Logger } from "./logger"; import { CHART_TYPES } from "../model/types"; export class PluginManager { constructor() { this.LOG = new Logger(PluginManager); if (!window) { return; } const win = window; win.DiscoveryPluginRegistry = Object.assign({}, (win.DiscoveryPluginRegistry || {})); this.registry = win.DiscoveryPluginRegistry; } static getInstance() { if (!PluginManager.instance) { PluginManager.instance = new PluginManager(); } return PluginManager.instance; } register(plugin) { var _a, _b; this.registry[plugin.type] = plugin; CHART_TYPES.push(plugin.type); (_a = this.LOG) === null || _a === void 0 ? void 0 : _a.info(['Registration', plugin.name], `${plugin.toString()}`); (_b = this.LOG) === null || _b === void 0 ? void 0 : _b.debug(['Registration of', plugin.name], this.registry); } get(type) { var _a; (_a = this.LOG) === null || _a === void 0 ? void 0 : _a.debug(['getPlugin'], this.registry, type); return this.registry[type]; } has(type) { return this.registry[type] !== undefined; } } //# sourceMappingURL=PluginManager.js.map