Node updated. Some todos.
This commit is contained in:
50
Scripts/node_modules/chromium-bidi/lib/cjs/bidiTab/mapperTabPage.js
generated
vendored
50
Scripts/node_modules/chromium-bidi/lib/cjs/bidiTab/mapperTabPage.js
generated
vendored
@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.log = exports.generatePage = void 0;
|
||||
exports.generatePage = generatePage;
|
||||
exports.log = log;
|
||||
/**
|
||||
* Copyright 2022 Google LLC.
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
@ -19,44 +20,16 @@ exports.log = exports.generatePage = void 0;
|
||||
*/
|
||||
const log_js_1 = require("../utils/log.js");
|
||||
/** HTML source code for the user-facing Mapper tab. */
|
||||
const mapperPageSource = '<!DOCTYPE html><title>BiDi-CDP Mapper</title><style>body{font-family: Roboto, serif; font-size: 13px; color: #202124;}.log{padding: 12px; font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; font-size: 11px; line-height: 180%; background: #f1f3f4; border-radius: 4px;}.pre{overflow-wrap: break-word; padding: 10px;}.card{margin: 60px auto; padding: 2px 0; max-width: 900px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15), 0 1px 6px rgba(0, 0, 0, 0.2); border-radius: 8px;}.divider{height: 1px; background: #f0f0f0;}.item{padding: 16px 20px;}</style><div class="card"><div class="item"><h1>BiDi-CDP Mapper is controlling this tab</h1><p>Closing or reloading it will stop the BiDi process. <a target="_blank" title="BiDi-CDP Mapper GitHub Repository" href="https://github.com/GoogleChromeLabs/chromium-bidi">Details.</a></p></div><div class="divider"></div><details id="details"><summary class="item">Debug information</summary></details></div>';
|
||||
/**
|
||||
* The following piece of HTML should be added to the `debug` element:
|
||||
*
|
||||
* <div class="divider"></div>
|
||||
* <div class="item">
|
||||
* <h3>${name}</h3>
|
||||
* <div id="${name}_log" class="log">
|
||||
*/
|
||||
function findOrCreateTypeLogContainer(logPrefix) {
|
||||
const logType = logPrefix.split(':')[0];
|
||||
const containerId = `${logType}_log`;
|
||||
const existingContainer = document.getElementById(containerId);
|
||||
if (existingContainer) {
|
||||
return existingContainer;
|
||||
}
|
||||
const debugElement = document.getElementById('details');
|
||||
const divider = document.createElement('div');
|
||||
divider.className = 'divider';
|
||||
debugElement.appendChild(divider);
|
||||
const htmlItem = document.createElement('div');
|
||||
htmlItem.className = 'item';
|
||||
htmlItem.innerHTML = `<h3>${logType}</h3><div id="${containerId}" class="log"></div>`;
|
||||
debugElement.appendChild(htmlItem);
|
||||
return document.getElementById(containerId);
|
||||
}
|
||||
const mapperPageSource = '<!DOCTYPE html><title>BiDi-CDP Mapper</title><style>body{font-family: Roboto,serif;font-size:13px;color:#202124;}.log{padding: 10px;font-family:Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;font-size:11px;line-height:180%;background: #f1f3f4;border-radius:4px;}.pre{overflow-wrap: break-word; margin:10px;}.card{margin:60px auto;padding:2px 0;max-width:900px;box-shadow:0 1px 4px rgba(0,0,0,0.15),0 1px 6px rgba(0,0,0,0.2);border-radius:8px;}.divider{height:1px;background:#f0f0f0;}.item{padding:16px 20px;}</style><div class="card"><div class="item"><h1>BiDi-CDP Mapper is controlling this tab</h1><p>Closing or reloading it will stop the BiDi process. <a target="_blank" title="BiDi-CDP Mapper GitHub Repository" href="https://github.com/GoogleChromeLabs/chromium-bidi">Details.</a></p></div><div class="item"><div id="logs" class="log"></div></div></div></div>';
|
||||
function generatePage() {
|
||||
// If run not in browser (e.g. unit test), do nothing.
|
||||
if (!globalThis.document.documentElement) {
|
||||
return;
|
||||
}
|
||||
globalThis.document.documentElement.innerHTML = mapperPageSource;
|
||||
// Create main log containers in proper order.
|
||||
findOrCreateTypeLogContainer(log_js_1.LogType.debugInfo);
|
||||
findOrCreateTypeLogContainer(log_js_1.LogType.bidi);
|
||||
findOrCreateTypeLogContainer(log_js_1.LogType.cdp);
|
||||
// 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?';
|
||||
}
|
||||
exports.generatePage = generatePage;
|
||||
function stringify(message) {
|
||||
if (typeof message === 'object') {
|
||||
return JSON.stringify(message, null, 2);
|
||||
@ -71,15 +44,20 @@ function log(logPrefix, ...messages) {
|
||||
// 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.
|
||||
global.window?.sendDebugMessage?.(JSON.stringify({ logType: logPrefix, messages }));
|
||||
globalThis.window?.sendDebugMessage?.(JSON.stringify({ logType: logPrefix, messages }, null, 2));
|
||||
}
|
||||
const debugContainer = document.getElementById('logs');
|
||||
if (!debugContainer) {
|
||||
return;
|
||||
}
|
||||
const typeLogContainer = findOrCreateTypeLogContainer(logPrefix);
|
||||
// This piece of HTML should be added:
|
||||
// <div class="pre">...log message...</div>
|
||||
const lineElement = document.createElement('div');
|
||||
lineElement.className = 'pre';
|
||||
lineElement.textContent = [logPrefix, ...messages].map(stringify).join(' ');
|
||||
typeLogContainer.appendChild(lineElement);
|
||||
debugContainer.appendChild(lineElement);
|
||||
if (debugContainer.childNodes.length > 400) {
|
||||
debugContainer.removeChild(debugContainer.childNodes[0]);
|
||||
}
|
||||
}
|
||||
exports.log = log;
|
||||
//# sourceMappingURL=mapperTabPage.js.map
|
||||
Reference in New Issue
Block a user