browserpilot-cdp 1.2.1 → 1.2.2

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,7 +8,7 @@ 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.2";
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";
@@ -893,16 +893,19 @@ async function waitForPageLoad(session, options = {}) {
893
893
  await sleep(Math.min(minWaitMs, timeoutMs));
894
894
  }
895
895
  while (Date.now() - start < timeoutMs) {
896
+ let href = "";
896
897
  try {
897
898
  const res = await session.send("Runtime.evaluate", {
898
- expression: "document.readyState",
899
+ expression: "({ readyState: document.readyState, href: location.href })",
899
900
  returnByValue: true
900
901
  });
901
- readyState = res.result?.value ?? "loading";
902
+ readyState = res.result?.value?.readyState ?? "loading";
903
+ href = res.result?.value?.href ?? "";
902
904
  } catch {
903
905
  readyState = "loading";
904
906
  }
905
- if ((readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
907
+ const stillOnBlank = Boolean(options.ignoreAboutBlank) && (!href || href === "about:blank");
908
+ if (!stillOnBlank && (readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
906
909
  if (idleSince === null)
907
910
  idleSince = Date.now();
908
911
  if (Date.now() - idleSince >= idleMs || readyState === "complete") {
@@ -2551,6 +2554,7 @@ var ROLE_COLORS = {
2551
2554
  };
2552
2555
  async function captureLabeledScreenshot(page, options = {}) {
2553
2556
  const maxLabels = options.maxLabels ?? 120;
2557
+ await page.session.enableDomain("DOM");
2554
2558
  const snapshot = await page.snapshotEngine.capture(page.session, { showDiffSinceLastCall: false });
2555
2559
  const viewport = await page.evaluate("({ width: window.innerWidth, height: window.innerHeight })");
2556
2560
  const labels = [];
@@ -3080,9 +3084,12 @@ var StylesInspector = class {
3080
3084
  const extractDecls = (props) => {
3081
3085
  if (!props)
3082
3086
  return [];
3087
+ const hasAuthoredRanges = props.some((p) => Boolean(p.range || p.text));
3083
3088
  const out = [];
3084
3089
  for (const p of props) {
3085
- if (p.disabled || !p.name || p.name.startsWith("-webkit-") || !p.value)
3090
+ if (p.disabled || p.implicit || !p.name || p.name.startsWith("-webkit-") || !p.value)
3091
+ continue;
3092
+ if (hasAuthoredRanges && !p.range && !p.text)
3086
3093
  continue;
3087
3094
  const overridden = seenProps.has(p.name);
3088
3095
  seenProps.add(p.name);
@@ -5848,7 +5855,7 @@ async function executeTool(ctx, name, args = {}) {
5848
5855
  });
5849
5856
  if (sessionId) manager.getOrCreateSession(sessionId).activeTabId = tab.tabId;
5850
5857
  if (/^https?:\/\//i.test(targetUrl)) {
5851
- await waitForPageLoad(tab.session, { timeoutMs: 6e3, idleMs: 200 }).catch(() => {
5858
+ await waitForPageLoad(tab.session, { timeoutMs: 1e4, idleMs: 250, ignoreAboutBlank: true }).catch(() => {
5852
5859
  });
5853
5860
  }
5854
5861
  const meta = await tab.page.getUrlAndTitle().catch(() => ({ url: targetUrl, title: "" }));
@@ -7570,6 +7577,7 @@ BrowserPilot Setup (v${BROWSERPILOT_VERSION})`);
7570
7577
  const args = [
7571
7578
  "--no-first-run",
7572
7579
  "--no-default-browser-check",
7580
+ "--window-size=1280,800",
7573
7581
  `--remote-debugging-port=${cdpPort}`,
7574
7582
  `--user-data-dir=${profileDir}`
7575
7583
  ];