"use strict"; /** * Copyright 2021 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @license */ Object.defineProperty(exports, "__esModule", { value: true }); const bidiMapper_js_1 = require("../bidiMapper/bidiMapper.js"); const CdpConnection_js_1 = require("../cdp/CdpConnection.js"); const log_js_1 = require("../utils/log.js"); const BidiParser_js_1 = require("./BidiParser.js"); const Transport_js_1 = require("./Transport.js"); const mapperTabPage_js_1 = require("./mapperTabPage.js"); // Initiate `setSelfTargetId` as soon as possible to prevent race condition. const waitSelfTargetIdPromise = waitSelfTargetId(); void (async () => { (0, mapperTabPage_js_1.generatePage)(); // Needed to filter out info related to BiDi target. const selfTargetId = await waitSelfTargetIdPromise; const bidiServer = await bidiMapper_js_1.BidiServer.createAndStart(new Transport_js_1.WindowBidiTransport(), /** * A CdpTransport implementation that uses the window.cdp bindings * injected by Target.exposeDevToolsProtocol. */ new CdpConnection_js_1.CdpConnection(new Transport_js_1.WindowCdpTransport(), mapperTabPage_js_1.log), selfTargetId, new BidiParser_js_1.BidiParser(), mapperTabPage_js_1.log); (0, mapperTabPage_js_1.log)(log_js_1.LogType.debugInfo, 'Launched'); bidiServer.emitOutgoingMessage(bidiMapper_js_1.OutgoingMessage.createResolved({ launched: true, }), 'launched'); })(); // Needed to filter out info related to BiDi target. async function waitSelfTargetId() { return new Promise((resolve) => { window.setSelfTargetId = (targetId) => { (0, mapperTabPage_js_1.log)(log_js_1.LogType.debugInfo, 'Current target ID:', targetId); resolve(targetId); }; }); } //# sourceMappingURL=bidiTab.js.map