"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainThreadLifeCycle = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const electron_1 = require("@opensumi/ide-core-common/lib/electron");
const error_1 = require("@opensumi/ide-core-common/lib/error");
let MainThreadLifeCycle = class MainThreadLifeCycle {
    constructor(injector) {
        this.injector = injector;
    }
    $setExtensionCandidate(candidate) {
        if (this.appConfig.isElectronRenderer) {
            const electronMainLifecycle = this.injector.get(electron_1.IElectronMainLifeCycleService);
            electronMainLifecycle.setExtensionCandidate(candidate, ide_core_browser_1.electronEnv.currentWindowId);
        }
        else {
            (0, error_1.throwNonElectronError)('MainThreadLifeCycle.$setExtensionCandidate');
        }
    }
    $setExtensionDir(dir) {
        if (this.appConfig.isElectronRenderer) {
            const electronMainLifecycle = this.injector.get(electron_1.IElectronMainLifeCycleService);
            electronMainLifecycle.setExtensionDir(dir, ide_core_browser_1.electronEnv.currentWindowId);
        }
        else {
            (0, error_1.throwNonElectronError)('MainThreadLifeCycle.$setExtensionDir');
        }
    }
};
exports.MainThreadLifeCycle = MainThreadLifeCycle;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.AppConfig),
    tslib_1.__metadata("design:type", Object)
], MainThreadLifeCycle.prototype, "appConfig", void 0);
exports.MainThreadLifeCycle = MainThreadLifeCycle = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true }),
    tslib_1.__metadata("design:paramtypes", [di_1.Injector])
], MainThreadLifeCycle);
//# sourceMappingURL=main.thread.lifecycle.js.map