browserpilot-cdp 1.2.1 → 1.2.3

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/dist/cli.js CHANGED
@@ -8,11 +8,12 @@ import path7 from "node:path";
8
8
  import { fileURLToPath as fileURLToPath3 } from "node:url";
9
9
 
10
10
  // ../protocol/dist/constants.js
11
- var BROWSERPILOT_VERSION = "1.2.1";
11
+ var BROWSERPILOT_VERSION = "1.2.3";
12
12
  var DEFAULT_DAEMON_HOST = "127.0.0.1";
13
13
  var DEFAULT_DAEMON_PORT = 19888;
14
14
  var NATIVE_HOST_NAME = "com.browserpilot.bridge";
15
15
  var NATIVE_MESSAGE_MAX_BYTES = 1024 * 1024;
16
+ var NATIVE_INCOMING_MAX_BYTES = 64 * 1024 * 1024;
16
17
  var DEFAULT_CDP_TIMEOUT_MS = 15e3;
17
18
  var MAX_CONSOLE_BUFFER = 5e3;
18
19
  var MAX_NETWORK_BUFFER = 2e3;
@@ -893,16 +894,19 @@ async function waitForPageLoad(session, options = {}) {
893
894
  await sleep(Math.min(minWaitMs, timeoutMs));
894
895
  }
895
896
  while (Date.now() - start < timeoutMs) {
897
+ let href = "";
896
898
  try {
897
899
  const res = await session.send("Runtime.evaluate", {
898
- expression: "document.readyState",
900
+ expression: "({ readyState: document.readyState, href: location.href })",
899
901
  returnByValue: true
900
902
  });
901
- readyState = res.result?.value ?? "loading";
903
+ readyState = res.result?.value?.readyState ?? "loading";
904
+ href = res.result?.value?.href ?? "";
902
905
  } catch {
903
906
  readyState = "loading";
904
907
  }
905
- if ((readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
908
+ const stillOnBlank = Boolean(options.ignoreAboutBlank) && (!href || href === "about:blank");
909
+ if (!stillOnBlank && (readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
906
910
  if (idleSince === null)
907
911
  idleSince = Date.now();
908
912
  if (Date.now() - idleSince >= idleMs || readyState === "complete") {
@@ -1181,7 +1185,16 @@ function filterSnapshotLines(fullText, search, maxMatches = 25) {
1181
1185
  const allLines = fullText.split("\n");
1182
1186
  const header = allLines[0]?.startsWith("URL:") ? allLines[0] : "";
1183
1187
  const body = header ? allLines.slice(1) : allLines;
1184
- const regex = search instanceof RegExp ? search : new RegExp(escapeRegex(search), "i");
1188
+ let regex;
1189
+ if (search instanceof RegExp) {
1190
+ regex = search;
1191
+ } else {
1192
+ try {
1193
+ regex = new RegExp(search, "i");
1194
+ } catch {
1195
+ regex = new RegExp(escapeRegex(search), "i");
1196
+ }
1197
+ }
1185
1198
  const matchedIndices = /* @__PURE__ */ new Set();
1186
1199
  let count = 0;
1187
1200
  for (let i = 0; i < body.length; i++) {
@@ -2551,6 +2564,7 @@ var ROLE_COLORS = {
2551
2564
  };
2552
2565
  async function captureLabeledScreenshot(page, options = {}) {
2553
2566
  const maxLabels = options.maxLabels ?? 120;
2567
+ await page.session.enableDomain("DOM");
2554
2568
  const snapshot = await page.snapshotEngine.capture(page.session, { showDiffSinceLastCall: false });
2555
2569
  const viewport = await page.evaluate("({ width: window.innerWidth, height: window.innerHeight })");
2556
2570
  const labels = [];
@@ -3080,9 +3094,12 @@ var StylesInspector = class {
3080
3094
  const extractDecls = (props) => {
3081
3095
  if (!props)
3082
3096
  return [];
3097
+ const hasAuthoredRanges = props.some((p) => Boolean(p.range || p.text));
3083
3098
  const out = [];
3084
3099
  for (const p of props) {
3085
- if (p.disabled || !p.name || p.name.startsWith("-webkit-") || !p.value)
3100
+ if (p.disabled || p.implicit || !p.name || p.name.startsWith("-webkit-") || !p.value)
3101
+ continue;
3102
+ if (hasAuthoredRanges && !p.range && !p.text)
3086
3103
  continue;
3087
3104
  const overridden = seenProps.has(p.name);
3088
3105
  seenProps.add(p.name);
@@ -5848,7 +5865,7 @@ async function executeTool(ctx, name, args = {}) {
5848
5865
  });
5849
5866
  if (sessionId) manager.getOrCreateSession(sessionId).activeTabId = tab.tabId;
5850
5867
  if (/^https?:\/\//i.test(targetUrl)) {
5851
- await waitForPageLoad(tab.session, { timeoutMs: 6e3, idleMs: 200 }).catch(() => {
5868
+ await waitForPageLoad(tab.session, { timeoutMs: 1e4, idleMs: 250, ignoreAboutBlank: true }).catch(() => {
5852
5869
  });
5853
5870
  }
5854
5871
  const meta = await tab.page.getUrlAndTitle().catch(() => ({ url: targetUrl, title: "" }));
@@ -7570,6 +7587,7 @@ BrowserPilot Setup (v${BROWSERPILOT_VERSION})`);
7570
7587
  const args = [
7571
7588
  "--no-first-run",
7572
7589
  "--no-default-browser-check",
7590
+ "--window-size=1280,800",
7573
7591
  `--remote-debugging-port=${cdpPort}`,
7574
7592
  `--user-data-dir=${profileDir}`
7575
7593
  ];