browserclaw 0.9.0 → 0.9.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.d.cts CHANGED
@@ -717,6 +717,25 @@ declare class CrawlPage {
717
717
  clickCount?: number;
718
718
  delayMs?: number;
719
719
  }): Promise<void>;
720
+ /**
721
+ * Press and hold at page coordinates using raw CDP events.
722
+ *
723
+ * Bypasses Playwright's automation layer by dispatching CDP
724
+ * `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
725
+ * that detect automated clicks.
726
+ *
727
+ * @param x - X coordinate in CSS pixels
728
+ * @param y - Y coordinate in CSS pixels
729
+ * @param opts - Options (holdMs: hold duration, default 1000, max 30000)
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * await page.pressAndHold(400, 300, { holdMs: 5000 });
734
+ * ```
735
+ */
736
+ pressAndHold(x: number, y: number, opts?: {
737
+ holdMs?: number;
738
+ }): Promise<void>;
720
739
  /**
721
740
  * Click an element by its visible text content (no snapshot/ref needed).
722
741
  *
package/dist/index.d.ts CHANGED
@@ -717,6 +717,25 @@ declare class CrawlPage {
717
717
  clickCount?: number;
718
718
  delayMs?: number;
719
719
  }): Promise<void>;
720
+ /**
721
+ * Press and hold at page coordinates using raw CDP events.
722
+ *
723
+ * Bypasses Playwright's automation layer by dispatching CDP
724
+ * `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
725
+ * that detect automated clicks.
726
+ *
727
+ * @param x - X coordinate in CSS pixels
728
+ * @param y - Y coordinate in CSS pixels
729
+ * @param opts - Options (holdMs: hold duration, default 1000, max 30000)
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * await page.pressAndHold(400, 300, { holdMs: 5000 });
734
+ * ```
735
+ */
736
+ pressAndHold(x: number, y: number, opts?: {
737
+ holdMs?: number;
738
+ }): Promise<void>;
720
739
  /**
721
740
  * Click an element by its visible text content (no snapshot/ref needed).
722
741
  *
package/dist/index.js CHANGED
@@ -37,9 +37,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  mod
38
38
  ));
39
39
 
40
- // ../../../node_modules/ipaddr.js/lib/ipaddr.js
40
+ // node_modules/ipaddr.js/lib/ipaddr.js
41
41
  var require_ipaddr = __commonJS({
42
- "../../../node_modules/ipaddr.js/lib/ipaddr.js"(exports$1, module) {
42
+ "node_modules/ipaddr.js/lib/ipaddr.js"(exports$1, module) {
43
43
  (function(root) {
44
44
  const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
45
45
  const ipv4Regexes = {
@@ -1377,6 +1377,7 @@ async function launchChrome(opts = {}) {
1377
1377
  const spawnChrome = () => {
1378
1378
  const args = [
1379
1379
  `--remote-debugging-port=${String(cdpPort)}`,
1380
+ "--remote-debugging-address=127.0.0.1",
1380
1381
  `--user-data-dir=${userDataDir}`,
1381
1382
  "--no-first-run",
1382
1383
  "--no-default-browser-check",
@@ -3067,6 +3068,25 @@ async function mouseClickViaPlaywright(opts) {
3067
3068
  delay: opts.delayMs
3068
3069
  });
3069
3070
  }
3071
+ var MAX_HOLD_MS = 3e4;
3072
+ async function pressAndHoldViaCdp(opts) {
3073
+ const holdMs = resolveBoundedDelayMs(opts.holdMs ?? 1e3, "holdMs", MAX_HOLD_MS);
3074
+ const page = await getPageForTargetId({ cdpUrl: opts.cdpUrl, targetId: opts.targetId });
3075
+ ensurePageState(page);
3076
+ const pos = { x: opts.x, y: opts.y };
3077
+ const btn = { button: "left", clickCount: 1 };
3078
+ await withPageScopedCdpClient({
3079
+ cdpUrl: opts.cdpUrl,
3080
+ page,
3081
+ targetId: opts.targetId,
3082
+ fn: async (send) => {
3083
+ await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...pos });
3084
+ await send("Input.dispatchMouseEvent", { type: "mousePressed", ...pos, ...btn });
3085
+ await new Promise((r) => setTimeout(r, holdMs));
3086
+ await send("Input.dispatchMouseEvent", { type: "mouseReleased", ...pos, ...btn });
3087
+ }
3088
+ });
3089
+ }
3070
3090
  async function clickByTextViaPlaywright(opts) {
3071
3091
  const page = await getRestoredPageForTarget(opts);
3072
3092
  const timeout = resolveInteractionTimeoutMs(opts.timeoutMs);
@@ -4915,6 +4935,31 @@ var CrawlPage = class {
4915
4935
  delayMs: opts?.delayMs
4916
4936
  });
4917
4937
  }
4938
+ /**
4939
+ * Press and hold at page coordinates using raw CDP events.
4940
+ *
4941
+ * Bypasses Playwright's automation layer by dispatching CDP
4942
+ * `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
4943
+ * that detect automated clicks.
4944
+ *
4945
+ * @param x - X coordinate in CSS pixels
4946
+ * @param y - Y coordinate in CSS pixels
4947
+ * @param opts - Options (holdMs: hold duration, default 1000, max 30000)
4948
+ *
4949
+ * @example
4950
+ * ```ts
4951
+ * await page.pressAndHold(400, 300, { holdMs: 5000 });
4952
+ * ```
4953
+ */
4954
+ async pressAndHold(x, y, opts) {
4955
+ return pressAndHoldViaCdp({
4956
+ cdpUrl: this.cdpUrl,
4957
+ targetId: this.targetId,
4958
+ x,
4959
+ y,
4960
+ holdMs: opts?.holdMs
4961
+ });
4962
+ }
4918
4963
  /**
4919
4964
  * Click an element by its visible text content (no snapshot/ref needed).
4920
4965
  *