first commit

This commit is contained in:
Frank John Begornia
2025-12-23 01:51:15 +08:00
commit c926590e1d
4137 changed files with 613038 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/**
* Copyright 2023 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.
*/
import type { BidiCommandParameterParser } from '../bidiMapper/BidiMapper.js';
import type { BrowsingContext, Cdp, Input, Network, Permissions, Script, Session, Storage } from '../protocol/protocol.js';
export declare class BidiParser implements BidiCommandParameterParser {
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters;
parseCaptureScreenshotParams(params: unknown): BrowsingContext.CaptureScreenshotParameters;
parseCloseParams(params: unknown): BrowsingContext.CloseParameters;
parseCreateParams(params: unknown): BrowsingContext.CreateParameters;
parseGetTreeParams(params: unknown): BrowsingContext.GetTreeParameters;
parseHandleUserPromptParams(params: unknown): BrowsingContext.HandleUserPromptParameters;
parseNavigateParams(params: unknown): BrowsingContext.NavigateParameters;
parsePrintParams(params: unknown): BrowsingContext.PrintParameters;
parseReloadParams(params: unknown): BrowsingContext.ReloadParameters;
parseSetViewportParams(params: unknown): BrowsingContext.SetViewportParameters;
parseTraverseHistoryParams(params: unknown): BrowsingContext.TraverseHistoryParameters;
parseGetSessionParams(params: unknown): Cdp.GetSessionParameters;
parseSendCommandParams(params: unknown): Cdp.SendCommandParameters;
parsePerformActionsParams(params: unknown): Input.PerformActionsParameters;
parseReleaseActionsParams(params: unknown): Input.ReleaseActionsParameters;
parseSetFilesParams(params: unknown): Input.SetFilesParameters;
parseAddInterceptParams(params: unknown): Network.AddInterceptParameters;
parseContinueRequestParams(params: unknown): Network.ContinueRequestParameters;
parseContinueResponseParams(params: unknown): Network.ContinueResponseParameters;
parseContinueWithAuthParams(params: unknown): Network.ContinueWithAuthParameters;
parseFailRequestParams(params: unknown): Network.FailRequestParameters;
parseProvideResponseParams(params: unknown): Network.ProvideResponseParameters;
parseRemoveInterceptParams(params: unknown): Network.RemoveInterceptParameters;
parseSetPermissionsParams(params: unknown): Permissions.SetPermissionParameters;
parseAddPreloadScriptParams(params: unknown): Script.AddPreloadScriptParameters;
parseCallFunctionParams(params: unknown): Script.CallFunctionParameters;
parseDisownParams(params: unknown): Script.DisownParameters;
parseEvaluateParams(params: unknown): Script.EvaluateParameters;
parseGetRealmsParams(params: unknown): Script.GetRealmsParameters;
parseRemovePreloadScriptParams(params: unknown): Script.RemovePreloadScriptParameters;
parseSubscribeParams(params: unknown): Session.SubscriptionRequest;
parseDeleteCookiesParams(params: unknown): Storage.DeleteCookiesParameters;
parseGetCookiesParams(params: unknown): Storage.GetCookiesParameters;
parseSetCookieParams(params: unknown): Storage.SetCookieParameters;
}

View File

@@ -0,0 +1,156 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BidiParser = void 0;
const Parser = __importStar(require("../protocol-parser/protocol-parser.js"));
class BidiParser {
// Browsing Context domain
// keep-sorted start block=yes
parseActivateParams(params) {
return Parser.BrowsingContext.parseActivateParams(params);
}
parseCaptureScreenshotParams(params) {
return Parser.BrowsingContext.parseCaptureScreenshotParams(params);
}
parseCloseParams(params) {
return Parser.BrowsingContext.parseCloseParams(params);
}
parseCreateParams(params) {
return Parser.BrowsingContext.parseCreateParams(params);
}
parseGetTreeParams(params) {
return Parser.BrowsingContext.parseGetTreeParams(params);
}
parseHandleUserPromptParams(params) {
return Parser.BrowsingContext.parseHandleUserPromptParameters(params);
}
parseNavigateParams(params) {
return Parser.BrowsingContext.parseNavigateParams(params);
}
parsePrintParams(params) {
return Parser.BrowsingContext.parsePrintParams(params);
}
parseReloadParams(params) {
return Parser.BrowsingContext.parseReloadParams(params);
}
parseSetViewportParams(params) {
return Parser.BrowsingContext.parseSetViewportParams(params);
}
parseTraverseHistoryParams(params) {
return Parser.BrowsingContext.parseTraverseHistoryParams(params);
}
// keep-sorted end
// CDP domain
// keep-sorted start block=yes
parseGetSessionParams(params) {
return Parser.Cdp.parseGetSessionRequest(params);
}
parseSendCommandParams(params) {
return Parser.Cdp.parseSendCommandRequest(params);
}
// keep-sorted end
// Input domain
// keep-sorted start block=yes
parsePerformActionsParams(params) {
return Parser.Input.parsePerformActionsParams(params);
}
parseReleaseActionsParams(params) {
return Parser.Input.parseReleaseActionsParams(params);
}
parseSetFilesParams(params) {
return Parser.Input.parseSetFilesParams(params);
}
// keep-sorted end
// Network domain
// keep-sorted start block=yes
parseAddInterceptParams(params) {
return Parser.Network.parseAddInterceptParameters(params);
}
parseContinueRequestParams(params) {
return Parser.Network.parseContinueRequestParameters(params);
}
parseContinueResponseParams(params) {
return Parser.Network.parseContinueResponseParameters(params);
}
parseContinueWithAuthParams(params) {
return Parser.Network.parseContinueWithAuthParameters(params);
}
parseFailRequestParams(params) {
return Parser.Network.parseFailRequestParameters(params);
}
parseProvideResponseParams(params) {
return Parser.Network.parseProvideResponseParameters(params);
}
parseRemoveInterceptParams(params) {
return Parser.Network.parseRemoveInterceptParameters(params);
}
// keep-sorted end
// Permissions domain
// keep-sorted start block=yes
parseSetPermissionsParams(params) {
return Parser.Permissions.parseSetPermissionsParams(params);
}
// keep-sorted end
// Script domain
// keep-sorted start block=yes
parseAddPreloadScriptParams(params) {
return Parser.Script.parseAddPreloadScriptParams(params);
}
parseCallFunctionParams(params) {
return Parser.Script.parseCallFunctionParams(params);
}
parseDisownParams(params) {
return Parser.Script.parseDisownParams(params);
}
parseEvaluateParams(params) {
return Parser.Script.parseEvaluateParams(params);
}
parseGetRealmsParams(params) {
return Parser.Script.parseGetRealmsParams(params);
}
parseRemovePreloadScriptParams(params) {
return Parser.Script.parseRemovePreloadScriptParams(params);
}
// keep-sorted end
// Session domain
// keep-sorted start block=yes
parseSubscribeParams(params) {
return Parser.Session.parseSubscribeParams(params);
}
// keep-sorted end
// Storage domain
// keep-sorted start block=yes
parseDeleteCookiesParams(params) {
return Parser.Storage.parseDeleteCookiesParams(params);
}
parseGetCookiesParams(params) {
return Parser.Storage.parseGetCookiesParams(params);
}
parseSetCookieParams(params) {
return Parser.Storage.parseSetCookieParams(params);
}
}
exports.BidiParser = BidiParser;
//# sourceMappingURL=BidiParser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BidiParser.js","sourceRoot":"","sources":["../../../src/bidiTab/BidiParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,8EAAgE;AAEhE,MAAa,UAAU;IACrB,0BAA0B;IAC1B,8BAA8B;IAC9B,mBAAmB,CAAC,MAAe;QACjC,OAAO,MAAM,CAAC,eAAe,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,4BAA4B,CAC1B,MAAe;QAEf,OAAO,MAAM,CAAC,eAAe,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;IACD,gBAAgB,CAAC,MAAe;Q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AAhKD,gCAgKC"}

View File

@@ -0,0 +1,35 @@
/**
* Copyright 2023 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. *
*/
import type { BidiTransport } from '../bidiMapper/BidiMapper.js';
import { type ChromiumBidi } from '../protocol/protocol.js';
import type { Transport } from '../utils/transport.js';
export declare class WindowBidiTransport implements BidiTransport {
#private;
static readonly LOGGER_PREFIX_RECV: "bidi:RECV ◂";
static readonly LOGGER_PREFIX_SEND: "bidi:SEND ▸";
constructor();
setOnMessage(onMessage: Parameters<BidiTransport['setOnMessage']>[0]): void;
sendMessage(message: ChromiumBidi.Message): void;
close(): void;
}
export declare class WindowCdpTransport implements Transport {
#private;
constructor();
setOnMessage(onMessage: Parameters<Transport['setOnMessage']>[0]): void;
sendMessage(message: string): void;
close(): void;
}

138
node_modules/chromium-bidi/lib/cjs/bidiTab/Transport.js generated vendored Normal file
View File

@@ -0,0 +1,138 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WindowCdpTransport = exports.WindowBidiTransport = void 0;
const log_js_1 = require("../utils/log.js");
const mapperTabPage_js_1 = require("./mapperTabPage.js");
class WindowBidiTransport {
static LOGGER_PREFIX_RECV = `${log_js_1.LogType.bidi}:RECV ◂`;
static LOGGER_PREFIX_SEND = `${log_js_1.LogType.bidi}:SEND ▸`;
#onMessage = null;
constructor() {
window.onBidiMessage = (message) => {
(0, mapperTabPage_js_1.log)(WindowBidiTransport.LOGGER_PREFIX_RECV, message);
try {
const command = WindowBidiTransport.#parseBidiMessage(message);
this.#onMessage?.call(null, command);
}
catch (e) {
const error = e instanceof Error ? e : new Error(e);
// Transport-level error does not provide channel.
this.#respondWithError(message, "invalid argument" /* ErrorCode.InvalidArgument */, error, null);
}
};
}
setOnMessage(onMessage) {
this.#onMessage = onMessage;
}
sendMessage(message) {
(0, mapperTabPage_js_1.log)(WindowBidiTransport.LOGGER_PREFIX_SEND, message);
const json = JSON.stringify(message);
window.sendBidiResponse(json);
}
close() {
this.#onMessage = null;
window.onBidiMessage = null;
}
#respondWithError(plainCommandData, errorCode, error, channel) {
const errorResponse = WindowBidiTransport.#getErrorResponse(plainCommandData, errorCode, error);
if (channel) {
this.sendMessage({
...errorResponse,
channel,
});
}
else {
this.sendMessage(errorResponse);
}
}
static #getJsonType(value) {
if (value === null) {
return 'null';
}
if (Array.isArray(value)) {
return 'array';
}
return typeof value;
}
static #getErrorResponse(message, errorCode, error) {
// XXX: this is bizarre per spec. We reparse the payload and
// extract the ID, regardless of what kind of value it was.
let messageId;
try {
const command = JSON.parse(message);
if (WindowBidiTransport.#getJsonType(command) === 'object' &&
'id' in command) {
messageId = command.id;
}
}
catch { }
return {
type: 'error',
id: messageId,
error: errorCode,
message: error.message,
};
}
static #parseBidiMessage(message) {
let command;
try {
command = JSON.parse(message);
}
catch {
throw new Error('Cannot parse data as JSON');
}
const type = WindowBidiTransport.#getJsonType(command);
if (type !== 'object') {
throw new Error(`Expected JSON object but got ${type}`);
}
// Extract and validate id, method and params.
const { id, method, params } = command;
const idType = WindowBidiTransport.#getJsonType(id);
if (idType !== 'number' || !Number.isInteger(id) || id < 0) {
// TODO: should uint64_t be the upper limit?
// https://tools.ietf.org/html/rfc7049#section-2.1
throw new Error(`Expected unsigned integer but got ${idType}`);
}
const methodType = WindowBidiTransport.#getJsonType(method);
if (methodType !== 'string') {
throw new Error(`Expected string method but got ${methodType}`);
}
const paramsType = WindowBidiTransport.#getJsonType(params);
if (paramsType !== 'object') {
throw new Error(`Expected object params but got ${paramsType}`);
}
let channel = command.channel;
if (channel !== undefined) {
const channelType = WindowBidiTransport.#getJsonType(channel);
if (channelType !== 'string') {
throw new Error(`Expected string channel but got ${channelType}`);
}
// Empty string channel is considered as no channel provided.
if (channel === '') {
channel = undefined;
}
}
return { id, method, params, channel };
}
}
exports.WindowBidiTransport = WindowBidiTransport;
class WindowCdpTransport {
#onMessage = null;
constructor() {
window.cdp.onmessage = (message) => {
this.#onMessage?.call(null, message);
};
}
setOnMessage(onMessage) {
this.#onMessage = onMessage;
}
sendMessage(message) {
window.cdp.send(message);
}
close() {
this.#onMessage = null;
window.cdp.onmessage = null;
}
}
exports.WindowCdpTransport = WindowCdpTransport;
//# sourceMappingURL=Transport.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../../src/bidiTab/Transport.ts"],"names":[],"mappings":";;;AAuBA,4CAAwC;AAGxC,yDAAuC;AAEvC,MAAa,mBAAmB;IAC9B,MAAM,CAAU,kBAAkB,GAAG,GAAG,gBAAO,CAAC,IAAI,SAAkB,CAAC;IACvE,MAAM,CAAU,kBAAkB,GAAG,GAAG,gBAAO,CAAC,IAAI,SAAkB,CAAC;IAEvE,UAAU,GAAqD,IAAI,CAAC;IAEpE;QACE,MAAM,CAAC,aAAa,GAAG,CAAC,OAAe,EAAE,EAAE;YACzC,IAAA,sBAAG,EAAC,mBAAmB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAC/D,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,CAAU,EAAE,CAAC;gBACpB,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAW,CAAC,CAAC;gBAC9D,kDAAkD;gBAClD,IAAI,CAAC,iBAAiB,CAAC,OAAO,sDAA6B,KAAK,EAAE,IAAI,CAA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CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF;AArBD,gDAqBC"}

View File

@@ -0,0 +1,31 @@
/**
* 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
*/
declare global {
interface Window {
runMapperInstance: ((...args: any) => Promise<void>) | null;
cdp: {
send: (message: string) => void;
onmessage: ((message: string) => void) | null;
};
sendBidiResponse: (response: string) => void;
onBidiMessage: ((message: string) => void) | null;
sendDebugMessage?: ((message: string) => void) | null;
}
}
export {};

58
node_modules/chromium-bidi/lib/cjs/bidiTab/bidiTab.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"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 mapperTabPage_js_1 = require("./mapperTabPage.js");
const Transport_js_1 = require("./Transport.js");
(0, mapperTabPage_js_1.generatePage)();
const mapperTabToServerTransport = new Transport_js_1.WindowBidiTransport();
const cdpTransport = new Transport_js_1.WindowCdpTransport();
/**
* A CdpTransport implementation that uses the window.cdp bindings
* injected by Target.exposeDevToolsProtocol.
*/
const cdpConnection = new CdpConnection_js_1.MapperCdpConnection(cdpTransport, mapperTabPage_js_1.log);
/**
* Launches the BiDi mapper instance.
* @param {string} selfTargetId
* @param options Mapper options. E.g. `acceptInsecureCerts`.
*/
async function runMapperInstance(selfTargetId, options) {
// eslint-disable-next-line no-console
console.log('Launching Mapper instance with selfTargetId:', selfTargetId);
const bidiServer = await BidiMapper_js_1.BidiServer.createAndStart(mapperTabToServerTransport, cdpConnection,
/**
* Create a Browser CDP Session per Mapper instance.
*/
await cdpConnection.createBrowserSession(), selfTargetId, options, new BidiParser_js_1.BidiParser(), mapperTabPage_js_1.log);
(0, mapperTabPage_js_1.log)(log_js_1.LogType.debugInfo, 'Mapper instance has been launched');
return bidiServer;
}
/**
* Set `window.runMapper` to a function which launches the BiDi mapper instance.
* @param selfTargetId Needed to filter out info related to BiDi target.
* @param options Mapper options. E.g. `acceptInsecureCerts`. */
window.runMapperInstance = async (selfTargetId, options) => {
await runMapperInstance(selfTargetId, options);
};
//# sourceMappingURL=bidiTab.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bidiTab.js","sourceRoot":"","sources":["../../../src/bidiTab/bidiTab.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AAEvD,8DAA4D;AAC5D,4CAAwC;AAExC,mDAA2C;AAC3C,yDAAqD;AACrD,iDAAuE;AA2BvE,IAAA,+BAAY,GAAE,CAAC;AACf,MAAM,0BAA0B,GAAG,IAAI,kCAAmB,EAAE,CAAC;AAC7D,MAAM,YAAY,GAAG,IAAI,iCAAkB,EAAE,CAAC;AAC9C;;;GAGG;AACH,MAAM,aAAa,GAAG,IAAI,sCAAmB,CAAC,YAAY,EAAE,sBAAG,CAAC,CAAC;AAEjE;;;;GAIG;AACH,KAAK,UAAU,iBAAiB,CAC9B,YAAoB,EACpB,OAAuB;IAEvB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,8CAA8C,EAAE,YAAY,CAAC,CAAC;IAE1E,MAAM,UAAU,GAAG,MAAM,0BAAU,CAAC,cAAc,CAChD,0BAA0B,EAC1B,aAAa;IACb;;OAEG;IACH,MAAM,aAAa,CAAC,oBAAoB,EAAE,EAC1C,YAAY,EACZ,OAAO,EACP,IAAI,0BAAU,EAAE,EAChB,sBAAG,CACJ,CAAC;IAEF,IAAA,sBAAG,EAAC,gBAAO,CAAC,SAAS,EAAE,mCAAmC,CAAC,CAAC;IAE5D,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;gEAGgE;AAChE,MAAM,CAAC,iBAAiB,GAAG,KAAK,EAAE,YAAY,EAAE,OAAuB,EAAE,EAAE;IACzE,MAAM,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC"}

View File

@@ -0,0 +1,19 @@
/**
* 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.
*/
import { type LogPrefix } from '../utils/log.js';
export declare function generatePage(): void;
export declare function log(logPrefix: LogPrefix, ...messages: unknown[]): void;

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = exports.generatePage = void 0;
/**
* 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 = '<!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);
}
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);
}
exports.generatePage = generatePage;
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.
global.window?.sendDebugMessage?.(JSON.stringify({ logType: logPrefix, messages }));
}
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);
}
exports.log = log;
//# sourceMappingURL=mapperTabPage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mapperTabPage.js","sourceRoot":"","sources":["../../../src/bidiTab/mapperTabPage.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,4CAAwD;AAExD,uDAAuD;AACvD,MAAM,gBAAgB,GACpB,w8BAAw8B,CAAC;AAE38B;;;;;;;GAOG;AACH,SAAS,4BAA4B,CAAC,SAAoB;IACxD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,GAAG,OAAO,MAAM,CAAC;IAErC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAE,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