browser-debugger-cli 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/bdg/SKILL.md +268 -0
- package/README.md +148 -74
- package/dist/commands/css.d.ts +13 -0
- package/dist/commands/css.js +53 -0
- package/dist/commands/dom/audit.d.ts +14 -0
- package/dist/commands/dom/audit.js +87 -0
- package/dist/commands/dom/formInteraction.js +36 -6
- package/dist/commands/dom/helpers/keyAttributes.d.ts +3 -2
- package/dist/commands/dom/helpers/keyAttributes.js +6 -4
- package/dist/commands/dom/helpers/screenshot.d.ts +1 -0
- package/dist/commands/dom/helpers/screenshot.js +158 -38
- package/dist/commands/dom/index.js +4 -1
- package/dist/commands/dom/screenshot.js +10 -6
- package/dist/commands/dom/wait.js +5 -3
- package/dist/commands/helpJson.js +1 -1
- package/dist/commands/installSkill.d.ts +20 -0
- package/dist/commands/installSkill.js +87 -0
- package/dist/commands/optionBehaviors.js +21 -6
- package/dist/commands/page.js +7 -4
- package/dist/commands/peek.d.ts +7 -0
- package/dist/commands/peek.js +65 -23
- package/dist/commands/shared/optionTypes.d.ts +5 -1
- package/dist/commands/start.d.ts +13 -0
- package/dist/commands/start.js +19 -2
- package/dist/commands/tail.d.ts +7 -1
- package/dist/commands/tail.js +13 -62
- package/dist/commands.js +5 -0
- package/dist/daemon/session/commandRegistry.js +7 -1
- package/dist/daemon/session/plugins.js +4 -52
- package/dist/daemon.js +7986 -6848
- package/dist/errors/messages.d.ts +50 -4
- package/dist/errors/messages.js +94 -5
- package/dist/index.js +709 -190
- package/dist/ipc/client.d.ts +4 -0
- package/dist/ipc/client.js +8 -0
- package/dist/ipc/protocol/auditTypes.d.ts +129 -0
- package/dist/ipc/protocol/auditTypes.js +6 -0
- package/dist/ipc/protocol/commands.d.ts +23 -0
- package/dist/ipc/protocol/commands.js +2 -0
- package/dist/ipc/protocol/domTypes.d.ts +4 -0
- package/dist/ipc/protocol/inspectTypes.d.ts +71 -8
- package/dist/runtime/css/search.d.ts +39 -0
- package/dist/runtime/css/search.js +122 -0
- package/dist/runtime/dom/actionEffects.d.ts +4 -1
- package/dist/runtime/dom/actionEffects.js +8 -4
- package/dist/runtime/dom/audit.d.ts +19 -0
- package/dist/runtime/dom/audit.js +36 -0
- package/dist/runtime/dom/auditModel.d.ts +45 -0
- package/dist/runtime/dom/auditModel.js +215 -0
- package/dist/runtime/dom/auditScripts.d.ts +107 -0
- package/dist/runtime/dom/auditScripts.js +112 -0
- package/dist/runtime/dom/elementGeometry.d.ts +8 -2
- package/dist/runtime/dom/elementGeometry.js +24 -8
- package/dist/runtime/dom/elementInfo.d.ts +3 -2
- package/dist/runtime/dom/elementInfo.js +8 -2
- package/dist/runtime/dom/formFillHelpers/fill.js +2 -2
- package/dist/runtime/dom/inspect.d.ts +7 -0
- package/dist/runtime/dom/inspect.js +88 -23
- package/dist/runtime/dom/inspectAllStyles.d.ts +16 -4
- package/dist/runtime/dom/inspectAllStyles.js +89 -7
- package/dist/runtime/dom/inspectCascade.d.ts +19 -2
- package/dist/runtime/dom/inspectCascade.js +214 -44
- package/dist/runtime/dom/inspectCascadeModel.d.ts +8 -0
- package/dist/runtime/dom/inspectCascadeModel.js +108 -34
- package/dist/runtime/dom/inspectHints.d.ts +26 -3
- package/dist/runtime/dom/inspectHints.js +125 -9
- package/dist/runtime/dom/inspectModel.d.ts +3 -0
- package/dist/runtime/dom/inspectModel.js +30 -7
- package/dist/runtime/dom/inspectPaintModel.d.ts +48 -22
- package/dist/runtime/dom/inspectPaintModel.js +180 -68
- package/dist/runtime/dom/inspectRules.d.ts +19 -0
- package/dist/runtime/dom/inspectRules.js +21 -5
- package/dist/runtime/dom/inspectScripts.d.ts +85 -12
- package/dist/runtime/dom/inspectScripts.js +314 -28
- package/dist/runtime/dom/inspectTree.js +10 -2
- package/dist/runtime/dom/inspectWhyModel.d.ts +2 -1
- package/dist/runtime/dom/inspectWhyModel.js +52 -10
- package/dist/runtime/dom/layout.js +31 -9
- package/dist/runtime/dom/reactEventHelpers.d.ts +7 -0
- package/dist/runtime/dom/reactEventHelpers.js +27 -9
- package/dist/runtime/page/emulation.d.ts +13 -4
- package/dist/runtime/page/emulation.js +69 -4
- package/dist/runtime/page/userAgent.d.ts +17 -0
- package/dist/runtime/page/userAgent.js +57 -0
- package/dist/types.d.ts +12 -0
- package/dist/ui/formatters/audit.d.ts +19 -0
- package/dist/ui/formatters/audit.js +106 -0
- package/dist/ui/formatters/dom.d.ts +1 -1
- package/dist/ui/formatters/dom.js +6 -3
- package/dist/ui/formatters/inspect.js +42 -15
- package/dist/ui/formatters/installSkill.d.ts +11 -0
- package/dist/ui/formatters/installSkill.js +31 -0
- package/dist/ui/formatters/status.js +1 -1
- package/dist/ui/messages/commands.d.ts +44 -7
- package/dist/ui/messages/commands.js +83 -11
- package/dist/ui/messages/preview.d.ts +6 -0
- package/dist/ui/messages/preview.js +9 -1
- package/dist/utils/cssValues.js +36 -4
- package/dist/utils/decisionTrees.js +0 -5
- package/dist/utils/suggestions.d.ts +4 -2
- package/dist/utils/suggestions.js +7 -5
- package/dist/utils/taskMappings.js +1 -1
- package/package.json +4 -2
|
@@ -4,6 +4,7 @@ import { prepareDOMCollection } from '../../telemetry/dom.js';
|
|
|
4
4
|
import { startNavigationTracking } from '../../telemetry/navigation.js';
|
|
5
5
|
import { startNetworkCollection, startWebSocketCollection } from '../../telemetry/network.js';
|
|
6
6
|
import { getErrorMessage } from '../../utils/errors.js';
|
|
7
|
+
import { hideHeadlessUserAgent } from '../../runtime/page/userAgent.js';
|
|
7
8
|
import { filterDefined } from '../../utils/objects.js';
|
|
8
9
|
/** Delay before reading the title after a same-document navigation */
|
|
9
10
|
const TITLE_REFRESH_DELAY_MS = 300;
|
|
@@ -83,56 +84,6 @@ async function emulatePageFocus(cdp, logger) {
|
|
|
83
84
|
.send('Emulation.setFocusEmulationEnabled', { enabled: true })
|
|
84
85
|
.catch((error) => logger.debug(`No focus emulation: ${getErrorMessage(error)}`));
|
|
85
86
|
}
|
|
86
|
-
/** Reads the client hints Chrome reports, renaming the HeadlessChrome brand */
|
|
87
|
-
const USER_AGENT_METADATA_SCRIPT = `(async () => {
|
|
88
|
-
const data = navigator.userAgentData;
|
|
89
|
-
if (!data) return null;
|
|
90
|
-
const values = await data.getHighEntropyValues(
|
|
91
|
-
['architecture', 'bitness', 'model', 'platformVersion', 'fullVersionList', 'wow64']
|
|
92
|
-
);
|
|
93
|
-
const rename = (list) => (list || []).map((entry) => ({
|
|
94
|
-
brand: entry.brand.replace('HeadlessChrome', 'Google Chrome'),
|
|
95
|
-
version: entry.version,
|
|
96
|
-
}));
|
|
97
|
-
return {
|
|
98
|
-
brands: rename(values.brands),
|
|
99
|
-
fullVersionList: rename(values.fullVersionList),
|
|
100
|
-
platform: values.platform,
|
|
101
|
-
platformVersion: values.platformVersion,
|
|
102
|
-
architecture: values.architecture,
|
|
103
|
-
model: values.model,
|
|
104
|
-
mobile: values.mobile,
|
|
105
|
-
bitness: values.bitness,
|
|
106
|
-
wow64: values.wow64,
|
|
107
|
-
};
|
|
108
|
-
})()`;
|
|
109
|
-
/**
|
|
110
|
-
* Send the user agent and client hints of regular Chrome from headless
|
|
111
|
-
* Chrome: sites serve "HeadlessChrome" a different page (or a bot
|
|
112
|
-
* challenge), so the page would not be the one a user sees.
|
|
113
|
-
*
|
|
114
|
-
* @param cdp - CDP connection
|
|
115
|
-
* @param logger - Logger for failures (the session works without it)
|
|
116
|
-
*/
|
|
117
|
-
async function hideHeadlessUserAgent(cdp, logger) {
|
|
118
|
-
try {
|
|
119
|
-
const { userAgent } = (await cdp.send('Browser.getVersion'));
|
|
120
|
-
if (!userAgent.includes('HeadlessChrome'))
|
|
121
|
-
return;
|
|
122
|
-
const metadata = (await cdp.send('Runtime.evaluate', {
|
|
123
|
-
expression: USER_AGENT_METADATA_SCRIPT,
|
|
124
|
-
awaitPromise: true,
|
|
125
|
-
returnByValue: true,
|
|
126
|
-
}));
|
|
127
|
-
await cdp.send('Emulation.setUserAgentOverride', {
|
|
128
|
-
userAgent: userAgent.replace('HeadlessChrome', 'Chrome'),
|
|
129
|
-
...(metadata.result?.value ? { userAgentMetadata: metadata.result.value } : {}),
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
logger.debug(`User agent left as is: ${getErrorMessage(error)}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
87
|
export function createDefaultTelemetryPlugins() {
|
|
137
88
|
return [
|
|
138
89
|
{
|
|
@@ -145,9 +96,10 @@ export function createDefaultTelemetryPlugins() {
|
|
|
145
96
|
{
|
|
146
97
|
name: 'page-identity',
|
|
147
98
|
runAlways: true,
|
|
148
|
-
async start({ cdp, logger }) {
|
|
99
|
+
async start({ cdp, logger, config }) {
|
|
149
100
|
await emulatePageFocus(cdp, logger);
|
|
150
|
-
|
|
101
|
+
if (!config.viewport?.mobile)
|
|
102
|
+
await hideHeadlessUserAgent(cdp, logger);
|
|
151
103
|
return () => undefined;
|
|
152
104
|
},
|
|
153
105
|
},
|