import { __awaiter, __generator } from "tslib";
import { success } from '@dash4/log/build/browser';
var win = window;
win.dash4 = win.dash4 || {};
win.dash4.plugins = win.dash4.plugins || {};
export function registerPlugin(name, PluginComponent) {
    success(name, 'registered');
    win.dash4.plugins[name] = PluginComponent;
}
export function getArePluginsRegistered() {
    return __awaiter(this, void 0, void 0, function () {
        function check(resolve) {
            if (pluginsAvailable()) {
                resolve(true);
            }
            setTimeout(function () { return check(resolve); }, 10);
        }
        var pluginsAvailable;
        return __generator(this, function (_a) {
            pluginsAvailable = function () { return win.dash4 && win.dash4.plugins && Object.keys(win.dash4.plugins).length > 0; };
            return [2 /*return*/, new Promise(function (resolve) {
                    check(resolve);
                })];
        });
    });
}
//# sourceMappingURL=register-plugin.js.map