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.cjs CHANGED
@@ -1727,7 +1727,13 @@ function appendCdpPath2(cdpUrl, cdpPath) {
1727
1727
  }
1728
1728
  }
1729
1729
  async function withPlaywrightPageCdpSession(page, fn) {
1730
- const session = await page.context().newCDPSession(page);
1730
+ const CDP_SESSION_TIMEOUT_MS = 1e4;
1731
+ const session = await Promise.race([
1732
+ page.context().newCDPSession(page),
1733
+ new Promise(
1734
+ (_, reject) => setTimeout(() => reject(new Error("newCDPSession timed out after 10s")), CDP_SESSION_TIMEOUT_MS)
1735
+ )
1736
+ ]);
1731
1737
  try {
1732
1738
  return await fn(session);
1733
1739
  } finally {
@@ -3092,9 +3098,17 @@ async function pressAndHoldViaCdp(opts) {
3092
3098
  targetId: opts.targetId,
3093
3099
  fn: async (send) => {
3094
3100
  await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...pos });
3101
+ await send("Input.dispatchTouchEvent", {
3102
+ type: "touchStart",
3103
+ touchPoints: [{ x: pos.x, y: pos.y, id: 1 }]
3104
+ });
3095
3105
  await send("Input.dispatchMouseEvent", { type: "mousePressed", ...pos, ...btn });
3096
3106
  await new Promise((r) => setTimeout(r, holdMs));
3097
3107
  await send("Input.dispatchMouseEvent", { type: "mouseReleased", ...pos, ...btn });
3108
+ await send("Input.dispatchTouchEvent", {
3109
+ type: "touchEnd",
3110
+ touchPoints: [{ x: pos.x, y: pos.y, id: 1 }]
3111
+ });
3098
3112
  }
3099
3113
  });
3100
3114
  }