"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generatePage = generatePage; exports.log = log; /** * Copyright 2022 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. */ const log_js_1 = require("../utils/log.js"); /** HTML source code for the user-facing Mapper tab. */ const mapperPageSource = 'BiDi-CDP Mapper

BiDi-CDP Mapper is controlling this tab

Closing or reloading it will stop the BiDi process. Details.

'; function generatePage() { // If run not in browser (e.g. unit test), do nothing. if (!globalThis.document.documentElement) { return; } globalThis.document.documentElement.innerHTML = mapperPageSource; // Show a confirmation dialog when the user tries to leave the Mapper tab. globalThis.window.onbeforeunload = () => 'Closing or reloading this tab will stop the BiDi process. Are you sure you want to leave?'; } function stringify(message) { if (typeof message === 'object') { return JSON.stringify(message, null, 2); } return message; } function log(logPrefix, ...messages) { // If run not in browser (e.g. unit test), do nothing. if (!globalThis.document.documentElement) { return; } // Skip sending BiDi logs as they are logged once by `bidi:server:*` if (!logPrefix.startsWith(log_js_1.LogType.bidi)) { // If `sendDebugMessage` is defined, send the log message there. globalThis.window?.sendDebugMessage?.(JSON.stringify({ logType: logPrefix, messages }, null, 2)); } const debugContainer = document.getElementById('logs'); if (!debugContainer) { return; } // This piece of HTML should be added: //
...log message...
const lineElement = document.createElement('div'); lineElement.className = 'pre'; lineElement.textContent = [logPrefix, ...messages].map(stringify).join(' '); debugContainer.appendChild(lineElement); if (debugContainer.childNodes.length > 400) { debugContainer.removeChild(debugContainer.childNodes[0]); } } //# sourceMappingURL=mapperTabPage.js.map