"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const path_1 = require("@opensumi/ide-utils/lib/path");
const util_1 = require("./api/vscode/language/util");
const worker_host_1 = require("./worker.host");
(0, util_1.setPerformance)(self.performance);
// make sure Worker cors
if (self.Worker) {
    const _Worker = self.Worker;
    // eslint-disable-next-line no-global-assign
    Worker = function (stringUrl, options) {
        const js = `importScripts('${stringUrl}');`;
        options = options || {};
        options.name = options.name || (0, path_1.basename)(stringUrl.toString());
        const blob = new Blob([js], { type: 'application/javascript' });
        return new _Worker(URL.createObjectURL(blob));
    };
}
(() => {
    const protocol = (0, worker_host_1.initRPCProtocol)();
    const extWorkerInjector = new di_1.Injector();
    extWorkerInjector.addProviders({
        token: ide_core_common_1.IReporter,
        useValue: new ide_core_common_1.DefaultReporter(),
    });
    new worker_host_1.ExtensionWorkerHost(protocol, extWorkerInjector);
})();
//# sourceMappingURL=worker.host-preload.js.map