"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequireInterceptorService = exports.RequireInterceptorContribution = exports.IRequireInterceptorService = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
exports.IRequireInterceptorService = Symbol('IRequireInterceptorService');
exports.RequireInterceptorContribution = Symbol('RequireInterceptorContribution');
let RequireInterceptorService = class RequireInterceptorService {
    constructor() {
        this.registry = new Map();
    }
    registerRequireInterceptor(interceptor) {
        if (this.registry.has(interceptor.moduleName)) {
            this.logger.warn(`module ${interceptor.moduleName} already register`);
            return ide_core_common_1.Disposable.NULL;
        }
        this.registry.set(interceptor.moduleName, interceptor);
        return ide_core_common_1.Disposable.create(() => {
            this.registry.delete(interceptor.moduleName);
        });
    }
    getRequireInterceptor(moduleName) {
        return this.registry.get(moduleName);
    }
};
exports.RequireInterceptorService = RequireInterceptorService;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.ILogger),
    tslib_1.__metadata("design:type", Object)
], RequireInterceptorService.prototype, "logger", void 0);
exports.RequireInterceptorService = RequireInterceptorService = tslib_1.__decorate([
    (0, di_1.Injectable)()
], RequireInterceptorService);
//# sourceMappingURL=require-interceptor.js.map