browserclaw 0.9.4 → 0.9.6

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
@@ -1716,7 +1716,13 @@ function appendCdpPath2(cdpUrl, cdpPath) {
1716
1716
  }
1717
1717
  }
1718
1718
  async function withPlaywrightPageCdpSession(page, fn) {
1719
- const session = await page.context().newCDPSession(page);
1719
+ const CDP_SESSION_TIMEOUT_MS = 1e4;
1720
+ const session = await Promise.race([
1721
+ page.context().newCDPSession(page),
1722
+ new Promise(
1723
+ (_, reject) => setTimeout(() => reject(new Error("newCDPSession timed out after 10s")), CDP_SESSION_TIMEOUT_MS)
1724
+ )
1725
+ ]);
1720
1726
  try {
1721
1727
  return await fn(session);
1722
1728
  } finally {
@@ -3081,9 +3087,17 @@ async function pressAndHoldViaCdp(opts) {
3081
3087
  targetId: opts.targetId,
3082
3088
  fn: async (send) => {
3083
3089
  await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...pos });
3090
+ await send("Input.dispatchTouchEvent", {
3091
+ type: "touchStart",
3092
+ touchPoints: [{ x: pos.x, y: pos.y, id: 1 }]
3093
+ });
3084
3094
  await send("Input.dispatchMouseEvent", { type: "mousePressed", ...pos, ...btn });
3085
3095
  await new Promise((r) => setTimeout(r, holdMs));
3086
3096
  await send("Input.dispatchMouseEvent", { type: "mouseReleased", ...pos, ...btn });
3097
+ await send("Input.dispatchTouchEvent", {
3098
+ type: "touchEnd",
3099
+ touchPoints: [{ x: pos.x, y: pos.y, id: 1 }]
3100
+ });
3087
3101
  }
3088
3102
  });
3089
3103
  }