"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KTWorkerExtension = exports.KTExtension = exports.Extension = void 0;
class Extension {
    constructor(metadata, extensionService, mainThreadExtensionService, exportsData) {
        this.metadata = metadata;
        this.extensionService = extensionService;
        this.mainThreadExtensionService = mainThreadExtensionService;
        const { packageJSON, path, id, extendConfig } = this.metadata;
        this.id = id;
        this.extensionPath = path;
        this.packageJSON = packageJSON;
        this.extensionKind = packageJSON.extensionKind || undefined;
        this.l10n = packageJSON.l10n;
        this.extendConfig = extendConfig || undefined;
        this.extensionUri = metadata.extensionLocation;
        if (exportsData) {
            this._exports = exportsData;
        }
    }
    get isActive() {
        return this.extensionService.isActivated(this.id);
    }
    get exports() {
        return this._exports || this.extensionService.getExtensionExports(this.id);
    }
    /**
     * Activates this extension and returns its public API.
     *
     * @return A promise that will resolve when this extension has been activated.
     */
    async activate() {
        try {
            if (!this.isActive) {
                await this.mainThreadExtensionService.$activateExtension(this.extensionPath);
            }
            return this.exports;
        }
        catch (e) { }
    }
}
exports.Extension = Extension;
class KTExtension extends Extension {
    constructor(metadata, extensionService, mainThreadExtensionService, exportsData, extendExportsData) {
        super(metadata, extensionService, mainThreadExtensionService, exportsData);
        if (extendExportsData) {
            this._extendExportsData = extendExportsData;
        }
    }
    get extendExports() {
        return this._extendExportsData || this.extensionService.getExtendExports(this.id);
    }
}
exports.KTExtension = KTExtension;
/**
 * 与 VSCExtension 的区别是，没有 extendExports
 * 对于纯 worker 的插件来说，其导出的 API 应该是与 VS Code 保持一致的，即只需要 `extension.exports` 即可
 */
class KTWorkerExtension extends Extension {
    constructor(metadata, extensionService, mainThreadExtensionService, exportsData) {
        super(metadata, extensionService, mainThreadExtensionService, exportsData);
        if (metadata.workerScriptPath) {
            this.workerScriptPath = metadata.workerScriptPath;
        }
    }
}
exports.KTWorkerExtension = KTWorkerExtension;
//# sourceMappingURL=vscode.extension.js.map