first commit
This commit is contained in:
9
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.d.ts
generated
vendored
Normal file
9
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { type LoggerFn } from '../../../utils/log.js';
|
||||
import type { CdpTarget } from '../context/CdpTarget.js';
|
||||
import type { RealmStorage } from '../script/RealmStorage.js';
|
||||
import type { EventManager } from '../session/EventManager.js';
|
||||
export declare class LogManager {
|
||||
#private;
|
||||
private constructor();
|
||||
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, eventManager: EventManager, logger?: LoggerFn): LogManager;
|
||||
}
|
||||
132
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.js
generated
vendored
Normal file
132
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LogManager = void 0;
|
||||
const protocol_js_1 = require("../../../protocol/protocol.js");
|
||||
const log_js_1 = require("../../../utils/log.js");
|
||||
const logHelper_js_1 = require("./logHelper.js");
|
||||
/** Converts CDP StackTrace object to BiDi StackTrace object. */
|
||||
function getBidiStackTrace(cdpStackTrace) {
|
||||
const stackFrames = cdpStackTrace?.callFrames.map((callFrame) => {
|
||||
return {
|
||||
columnNumber: callFrame.columnNumber,
|
||||
functionName: callFrame.functionName,
|
||||
lineNumber: callFrame.lineNumber,
|
||||
url: callFrame.url,
|
||||
};
|
||||
});
|
||||
return stackFrames ? { callFrames: stackFrames } : undefined;
|
||||
}
|
||||
function getLogLevel(consoleApiType) {
|
||||
if (["error" /* Log.Level.Error */, 'assert'].includes(consoleApiType)) {
|
||||
return "error" /* Log.Level.Error */;
|
||||
}
|
||||
if (["debug" /* Log.Level.Debug */, 'trace'].includes(consoleApiType)) {
|
||||
return "debug" /* Log.Level.Debug */;
|
||||
}
|
||||
if (["warn" /* Log.Level.Warn */, 'warning'].includes(consoleApiType)) {
|
||||
return "warn" /* Log.Level.Warn */;
|
||||
}
|
||||
return "info" /* Log.Level.Info */;
|
||||
}
|
||||
class LogManager {
|
||||
#eventManager;
|
||||
#realmStorage;
|
||||
#cdpTarget;
|
||||
#logger;
|
||||
constructor(cdpTarget, realmStorage, eventManager, logger) {
|
||||
this.#cdpTarget = cdpTarget;
|
||||
this.#realmStorage = realmStorage;
|
||||
this.#eventManager = eventManager;
|
||||
this.#logger = logger;
|
||||
}
|
||||
static create(cdpTarget, realmStorage, eventManager, logger) {
|
||||
const logManager = new LogManager(cdpTarget, realmStorage, eventManager, logger);
|
||||
logManager.#initializeEntryAddedEventListener();
|
||||
return logManager;
|
||||
}
|
||||
#initializeEntryAddedEventListener() {
|
||||
this.#cdpTarget.cdpClient.on('Runtime.consoleAPICalled', (params) => {
|
||||
// Try to find realm by `cdpSessionId` and `executionContextId`,
|
||||
// if provided.
|
||||
const realm = this.#realmStorage.findRealm({
|
||||
cdpSessionId: this.#cdpTarget.cdpSessionId,
|
||||
executionContextId: params.executionContextId,
|
||||
});
|
||||
if (realm === undefined) {
|
||||
// Ignore exceptions not attached to any realm.
|
||||
this.#logger?.(log_js_1.LogType.cdp, params);
|
||||
return;
|
||||
}
|
||||
const argsPromise = realm === undefined
|
||||
? Promise.resolve(params.args)
|
||||
: // Properly serialize arguments if possible.
|
||||
Promise.all(params.args.map((arg) => {
|
||||
return realm.serializeCdpObject(arg, "none" /* Script.ResultOwnership.None */);
|
||||
}));
|
||||
for (const browsingContext of realm.associatedBrowsingContexts) {
|
||||
this.#eventManager.registerPromiseEvent(argsPromise.then((args) => ({
|
||||
kind: 'success',
|
||||
value: {
|
||||
type: 'event',
|
||||
method: protocol_js_1.ChromiumBidi.Log.EventNames.LogEntryAdded,
|
||||
params: {
|
||||
level: getLogLevel(params.type),
|
||||
source: realm.source,
|
||||
text: (0, logHelper_js_1.getRemoteValuesText)(args, true),
|
||||
timestamp: Math.round(params.timestamp),
|
||||
stackTrace: getBidiStackTrace(params.stackTrace),
|
||||
type: 'console',
|
||||
// Console method is `warn`, not `warning`.
|
||||
method: params.type === 'warning' ? 'warn' : params.type,
|
||||
args,
|
||||
},
|
||||
},
|
||||
})), browsingContext.id, protocol_js_1.ChromiumBidi.Log.EventNames.LogEntryAdded);
|
||||
}
|
||||
});
|
||||
this.#cdpTarget.cdpClient.on('Runtime.exceptionThrown', (params) => {
|
||||
// Try to find realm by `cdpSessionId` and `executionContextId`,
|
||||
// if provided.
|
||||
const realm = this.#realmStorage.findRealm({
|
||||
cdpSessionId: this.#cdpTarget.cdpSessionId,
|
||||
executionContextId: params.exceptionDetails.executionContextId,
|
||||
});
|
||||
if (realm === undefined) {
|
||||
// Ignore exceptions not attached to any realm.
|
||||
this.#logger?.(log_js_1.LogType.cdp, params);
|
||||
return;
|
||||
}
|
||||
for (const browsingContext of realm.associatedBrowsingContexts) {
|
||||
this.#eventManager.registerPromiseEvent(LogManager.#getExceptionText(params, realm).then((text) => ({
|
||||
kind: 'success',
|
||||
value: {
|
||||
type: 'event',
|
||||
method: protocol_js_1.ChromiumBidi.Log.EventNames.LogEntryAdded,
|
||||
params: {
|
||||
level: "error" /* Log.Level.Error */,
|
||||
source: realm.source,
|
||||
text,
|
||||
timestamp: Math.round(params.timestamp),
|
||||
stackTrace: getBidiStackTrace(params.exceptionDetails.stackTrace),
|
||||
type: 'javascript',
|
||||
},
|
||||
},
|
||||
})), browsingContext.id, protocol_js_1.ChromiumBidi.Log.EventNames.LogEntryAdded);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Try the best to get the exception text.
|
||||
*/
|
||||
static async #getExceptionText(params, realm) {
|
||||
if (!params.exceptionDetails.exception) {
|
||||
return params.exceptionDetails.text;
|
||||
}
|
||||
if (realm === undefined) {
|
||||
return JSON.stringify(params.exceptionDetails.exception);
|
||||
}
|
||||
return await realm.stringifyObject(params.exceptionDetails.exception);
|
||||
}
|
||||
}
|
||||
exports.LogManager = LogManager;
|
||||
//# sourceMappingURL=LogManager.js.map
|
||||
1
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.js.map
generated
vendored
Normal file
1
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/LogManager.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LogManager.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/log/LogManager.ts"],"names":[],"mappings":";;;AAkBA,+DAAwE;AACxE,kDAA6D;AAM7D,iDAAmD;AAEnD,gEAAgE;AAChE,SAAS,iBAAiB,CACxB,aAAsD;IAEtD,MAAM,WAAW,GAAG,aAAa,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC9D,OAAO;YACL,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,GAAG,EAAE,SAAS,CAAC,GAAG;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC;AAED,SAAS,WAAW,CAAC,cAAsB;IACzC,IAAI,gCAAkB,QAAQ,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACzD,qCAAuB;IACzB,CAAC;IACD,IAAI,gCAAkB,OAAO,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACxD,qCAAuB;IACzB,CAAC;IACD,IAAI,8BAAiB,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACzD,mCAAsB;IACxB,CAAC;IACD,mCAAsB;AACxB,CAAC;AAED,MAAa,UAAU;IACZ,aAAa,CAAe;IAC5B,aAAa,CAAe;IAC5B,UAAU,CAAY;IACt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AAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACxE,CAAC;CACF;AApJD,gCAoJC"}
|
||||
23
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.d.ts
generated
vendored
Normal file
23
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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 { Script } from '../../../protocol/protocol.js';
|
||||
/**
|
||||
* @param args input remote values to be format printed
|
||||
* @return parsed text of the remote values in specific format
|
||||
*/
|
||||
export declare function logMessageFormatter(args: Script.RemoteValue[]): string;
|
||||
export declare function getRemoteValuesText(args: Script.RemoteValue[], formatText: boolean): string;
|
||||
174
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.js
generated
vendored
Normal file
174
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getRemoteValuesText = exports.logMessageFormatter = void 0;
|
||||
const assert_js_1 = require("../../../utils/assert.js");
|
||||
const specifiers = ['%s', '%d', '%i', '%f', '%o', '%O', '%c'];
|
||||
function isFormatSpecifier(str) {
|
||||
return specifiers.some((spec) => str.includes(spec));
|
||||
}
|
||||
/**
|
||||
* @param args input remote values to be format printed
|
||||
* @return parsed text of the remote values in specific format
|
||||
*/
|
||||
function logMessageFormatter(args) {
|
||||
let output = '';
|
||||
const argFormat = args[0].value.toString();
|
||||
const argValues = args.slice(1, undefined);
|
||||
const tokens = argFormat.split(new RegExp(specifiers.map((spec) => `(${spec})`).join('|'), 'g'));
|
||||
for (const token of tokens) {
|
||||
if (token === undefined || token === '') {
|
||||
continue;
|
||||
}
|
||||
if (isFormatSpecifier(token)) {
|
||||
const arg = argValues.shift();
|
||||
// raise an exception when less value is provided
|
||||
(0, assert_js_1.assert)(arg, `Less value is provided: "${getRemoteValuesText(args, false)}"`);
|
||||
if (token === '%s') {
|
||||
output += stringFromArg(arg);
|
||||
}
|
||||
else if (token === '%d' || token === '%i') {
|
||||
if (arg.type === 'bigint' ||
|
||||
arg.type === 'number' ||
|
||||
arg.type === 'string') {
|
||||
output += parseInt(arg.value.toString(), 10);
|
||||
}
|
||||
else {
|
||||
output += 'NaN';
|
||||
}
|
||||
}
|
||||
else if (token === '%f') {
|
||||
if (arg.type === 'bigint' ||
|
||||
arg.type === 'number' ||
|
||||
arg.type === 'string') {
|
||||
output += parseFloat(arg.value.toString());
|
||||
}
|
||||
else {
|
||||
output += 'NaN';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// %o, %O, %c
|
||||
output += toJson(arg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
output += token;
|
||||
}
|
||||
}
|
||||
// raise an exception when more value is provided
|
||||
if (argValues.length > 0) {
|
||||
throw new Error(`More value is provided: "${getRemoteValuesText(args, false)}"`);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.logMessageFormatter = logMessageFormatter;
|
||||
/**
|
||||
* @param arg input remote value to be parsed
|
||||
* @return parsed text of the remote value
|
||||
*
|
||||
* input: {"type": "number", "value": 1}
|
||||
* output: 1
|
||||
*
|
||||
* input: {"type": "string", "value": "abc"}
|
||||
* output: "abc"
|
||||
*
|
||||
* input: {"type": "object", "value": [["id", {"type": "number", "value": 1}]]}
|
||||
* output: '{"id": 1}'
|
||||
*
|
||||
* input: {"type": "object", "value": [["font-size", {"type": "string", "value": "20px"}]]}
|
||||
* output: '{"font-size": "20px"}'
|
||||
*/
|
||||
function toJson(arg) {
|
||||
// arg type validation
|
||||
if (arg.type !== 'array' &&
|
||||
arg.type !== 'bigint' &&
|
||||
arg.type !== 'date' &&
|
||||
arg.type !== 'number' &&
|
||||
arg.type !== 'object' &&
|
||||
arg.type !== 'string') {
|
||||
return stringFromArg(arg);
|
||||
}
|
||||
if (arg.type === 'bigint') {
|
||||
return `${arg.value.toString()}n`;
|
||||
}
|
||||
if (arg.type === 'number') {
|
||||
return arg.value.toString();
|
||||
}
|
||||
if (['date', 'string'].includes(arg.type)) {
|
||||
return JSON.stringify(arg.value);
|
||||
}
|
||||
if (arg.type === 'object') {
|
||||
return `{${arg.value
|
||||
.map((pair) => {
|
||||
return `${JSON.stringify(pair[0])}:${toJson(pair[1])}`;
|
||||
})
|
||||
.join(',')}}`;
|
||||
}
|
||||
if (arg.type === 'array') {
|
||||
return `[${arg.value?.map((val) => toJson(val)).join(',') ?? ''}]`;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
||||
throw Error(`Invalid value type: ${arg}`);
|
||||
}
|
||||
function stringFromArg(arg) {
|
||||
if (!Object.hasOwn(arg, 'value')) {
|
||||
return arg.type;
|
||||
}
|
||||
switch (arg.type) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'boolean':
|
||||
case 'bigint':
|
||||
return String(arg.value);
|
||||
case 'regexp':
|
||||
return `/${arg.value.pattern}/${arg.value.flags ?? ''}`;
|
||||
case 'date':
|
||||
return new Date(arg.value).toString();
|
||||
case 'object':
|
||||
return `Object(${arg.value?.length ?? ''})`;
|
||||
case 'array':
|
||||
return `Array(${arg.value?.length ?? ''})`;
|
||||
case 'map':
|
||||
return `Map(${arg.value?.length})`;
|
||||
case 'set':
|
||||
return `Set(${arg.value?.length})`;
|
||||
default:
|
||||
return arg.type;
|
||||
}
|
||||
}
|
||||
function getRemoteValuesText(args, formatText) {
|
||||
const arg = args[0];
|
||||
if (!arg) {
|
||||
return '';
|
||||
}
|
||||
// if args[0] is a format specifier, format the args as output
|
||||
if (arg.type === 'string' &&
|
||||
isFormatSpecifier(arg.value.toString()) &&
|
||||
formatText) {
|
||||
return logMessageFormatter(args);
|
||||
}
|
||||
// if args[0] is not a format specifier, just join the args with \u0020 (unicode 'SPACE')
|
||||
return args
|
||||
.map((arg) => {
|
||||
return stringFromArg(arg);
|
||||
})
|
||||
.join('\u0020');
|
||||
}
|
||||
exports.getRemoteValuesText = getRemoteValuesText;
|
||||
//# sourceMappingURL=logHelper.js.map
|
||||
1
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.js.map
generated
vendored
Normal file
1
node_modules/chromium-bidi/lib/cjs/bidiMapper/domains/log/logHelper.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"logHelper.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/log/logHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,wDAAgD;AAEhD,MAAM,U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