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/index.js CHANGED
@@ -5,7 +5,7 @@ import os from "node:os";
5
5
  import path from "node:path";
6
6
 
7
7
  // ../protocol/dist/constants.js
8
- var BROWSERPILOT_VERSION = "1.2.1";
8
+ var BROWSERPILOT_VERSION = "1.2.2";
9
9
  var DEFAULT_DAEMON_HOST = "127.0.0.1";
10
10
  var DEFAULT_DAEMON_PORT = 19888;
11
11
  var NATIVE_HOST_NAME = "com.browserpilot.bridge";
@@ -806,16 +806,19 @@ async function waitForPageLoad(session, options = {}) {
806
806
  await sleep(Math.min(minWaitMs, timeoutMs));
807
807
  }
808
808
  while (Date.now() - start < timeoutMs) {
809
+ let href = "";
809
810
  try {
810
811
  const res = await session.send("Runtime.evaluate", {
811
- expression: "document.readyState",
812
+ expression: "({ readyState: document.readyState, href: location.href })",
812
813
  returnByValue: true
813
814
  });
814
- readyState = res.result?.value ?? "loading";
815
+ readyState = res.result?.value?.readyState ?? "loading";
816
+ href = res.result?.value?.href ?? "";
815
817
  } catch {
816
818
  readyState = "loading";
817
819
  }
818
- if ((readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
820
+ const stillOnBlank = Boolean(options.ignoreAboutBlank) && (!href || href === "about:blank");
821
+ if (!stillOnBlank && (readyState === "complete" || readyState === "interactive") && inflight.size === 0) {
819
822
  if (idleSince === null)
820
823
  idleSince = Date.now();
821
824
  if (Date.now() - idleSince >= idleMs || readyState === "complete") {
@@ -2464,6 +2467,7 @@ var ROLE_COLORS = {
2464
2467
  };
2465
2468
  async function captureLabeledScreenshot(page, options = {}) {
2466
2469
  const maxLabels = options.maxLabels ?? 120;
2470
+ await page.session.enableDomain("DOM");
2467
2471
  const snapshot = await page.snapshotEngine.capture(page.session, { showDiffSinceLastCall: false });
2468
2472
  const viewport = await page.evaluate("({ width: window.innerWidth, height: window.innerHeight })");
2469
2473
  const labels = [];
@@ -2993,9 +2997,12 @@ var StylesInspector = class {
2993
2997
  const extractDecls = (props) => {
2994
2998
  if (!props)
2995
2999
  return [];
3000
+ const hasAuthoredRanges = props.some((p) => Boolean(p.range || p.text));
2996
3001
  const out = [];
2997
3002
  for (const p of props) {
2998
- if (p.disabled || !p.name || p.name.startsWith("-webkit-") || !p.value)
3003
+ if (p.disabled || p.implicit || !p.name || p.name.startsWith("-webkit-") || !p.value)
3004
+ continue;
3005
+ if (hasAuthoredRanges && !p.range && !p.text)
2999
3006
  continue;
3000
3007
  const overridden = seenProps.has(p.name);
3001
3008
  seenProps.add(p.name);
@@ -5761,7 +5768,7 @@ async function executeTool(ctx, name, args = {}) {
5761
5768
  });
5762
5769
  if (sessionId) manager.getOrCreateSession(sessionId).activeTabId = tab.tabId;
5763
5770
  if (/^https?:\/\//i.test(targetUrl)) {
5764
- await waitForPageLoad(tab.session, { timeoutMs: 6e3, idleMs: 200 }).catch(() => {
5771
+ await waitForPageLoad(tab.session, { timeoutMs: 1e4, idleMs: 250, ignoreAboutBlank: true }).catch(() => {
5765
5772
  });
5766
5773
  }
5767
5774
  const meta = await tab.page.getUrlAndTitle().catch(() => ({ url: targetUrl, title: "" }));