chrome-relay 0.5.17 → 0.5.19

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
@@ -383,10 +383,34 @@ function parseChromeReadPageArgs(input) {
383
383
  }
384
384
  function parseChromeClickArgs(input) {
385
385
  const obj = asObject(input, TOOL_NAMES.CLICK);
386
- return {
387
- selector: requireString(obj, "selector", TOOL_NAMES.CLICK),
388
- ...parseTargetArgs(obj)
389
- };
386
+ const target = parseTargetArgs(obj, TOOL_NAMES.CLICK);
387
+ const x = optNumber(obj, "x", TOOL_NAMES.CLICK);
388
+ const y = optNumber(obj, "y", TOOL_NAMES.CLICK);
389
+ if (x !== void 0 !== (y !== void 0)) {
390
+ throw new RelayError({
391
+ code: "invalid_arguments",
392
+ message: "chrome_click_element: pass BOTH x and y, or neither (selector mode).",
393
+ tool: TOOL_NAMES.CLICK,
394
+ phase: "parse_arguments",
395
+ details: { received: { x: obj.x, y: obj.y } },
396
+ retryable: false
397
+ });
398
+ }
399
+ if (x !== void 0 && y !== void 0) {
400
+ return { ...target, kind: "coords", x, y };
401
+ }
402
+ const selector = optString(obj, "selector", TOOL_NAMES.CLICK);
403
+ if (selector) {
404
+ return { ...target, kind: "selector", selector };
405
+ }
406
+ throw new RelayError({
407
+ code: "invalid_arguments",
408
+ message: "chrome_click_element requires either a selector or x AND y.",
409
+ tool: TOOL_NAMES.CLICK,
410
+ phase: "parse_arguments",
411
+ details: { received: { selector: obj.selector, x: obj.x, y: obj.y } },
412
+ retryable: false
413
+ });
390
414
  }
391
415
  function parseChromeFillArgs(input) {
392
416
  const obj = asObject(input, TOOL_NAMES.FILL);
@@ -1077,7 +1101,7 @@ var init_dist = __esm({
1077
1101
  import { Command } from "commander";
1078
1102
 
1079
1103
  // src/index.ts
1080
- var CHROME_RELAY_VERSION = true ? "0.5.17" : "0.0.0-dev";
1104
+ var CHROME_RELAY_VERSION = true ? "0.5.19" : "0.0.0-dev";
1081
1105
 
1082
1106
  // src/commands/shared.ts
1083
1107
  init_dist();
@@ -1320,6 +1344,18 @@ async function runDoctor() {
1320
1344
 
1321
1345
  // src/release-notes.ts
1322
1346
  var RELEASE_NOTES = {
1347
+ "0.5.19": [
1348
+ "Coordinate click. `chrome-relay click --x N --y N --tab N` dispatches a trusted Input.dispatchMouseEvent at the given pixel coordinates \u2014 no selector required. The selector positional became optional; the protocol parser collapses click args into a discriminated union (`kind: 'selector'` | `kind: 'coords'`) and rejects partial coords (`--x` without `--y`) with `invalid_arguments`.",
1349
+ "Intentionally NOT shipping `click-text`. Once coord-click exists, finding text + clicking is fully composable with `js` (TreeWalker \u2192 getBoundingClientRect) \u2192 `click --x/--y`. Per the CLI philosophy, that's a smart wrapper, not a primitive. The two-step recipe lives in docs/clicking-strategies.md as the documented pattern.",
1350
+ "Updated docs: docs/clicking-strategies.md now lists the 4 click verbs (click selector/coords, click-ax, js) and the text-recipe; docs/cli-philosophy.md explains the hide-vs-expose calculus that led to this design.",
1351
+ "Tests: +2 in program.test.ts (coord-click + partial-coords rejection), +1 in args-all.test.ts (discriminated-union parsing). Existing click tests updated to expect the parsed `kind: 'selector'` shape now that CLI-side parseToolArgs runs before send."
1352
+ ],
1353
+ "0.5.18": [
1354
+ "Force-visible on attach \u2014 actually fixes Cloudflare-style SPAs now. 0.5.17 had two bugs: (1) missing `Page.enable` before `Page.addScriptToEvaluateOnNewDocument` (the script registration silently failed, so the shim only applied to the current doc \u2014 page reloads dropped it), (2) the JS shim used one try-block so a deprecated `Object.defineProperty(document, 'webkitVisibilityState')` could throw and skip the `document.hasFocus` patch.",
1355
+ "0.5.18 fixes both: enables Page domain first, then applies each patch in its own try/catch. New patches added: `document.hasFocus` (overridden on both instance and Document.prototype), `Emulation.setFocusEmulationEnabled` via CDP, `document.wasDiscarded`. End result: Cloudflare Web Analytics dashboard now fully renders on backgrounded tabs without focus theft (verified live).",
1356
+ "Reverted the `navigate --new` about:blank trampoline from 0.5.17. It was opening about:blank as a stepping stone to attach before page JS ran; user-visible as a ~200ms flash. Removed \u2014 the addScriptToEvaluateOnNewDocument registration in 0.5.18 is robust enough that subsequent reloads pick up the shim cleanly.",
1357
+ "Honest caveat: shim covers visibility + focus gates. If a page detects automation via other means (chrome.runtime.connect probe, navigator.webdriver, debugger evaluation traces), chrome-relay won't help \u2014 those need stealth-mode workarounds separate from visibility."
1358
+ ],
1323
1359
  "0.5.17": [
1324
1360
  "Force-visible on attach (default-on). Modern SPAs (Cloudflare dashboard, Linear, Notion) gate their JS on `document.visibilityState` and stall on backgrounded tabs \u2014 chrome-relay's whole pitch is operate-without-stealing-focus, and that pitch silently broke whenever the page was visibility-gated. Fix runs three CDP calls on every attach: `Page.setWebLifecycleState({state:'active'})` to stop Chrome's rAF/timer throttling, plus a JS shim (installed via `Page.addScriptToEvaluateOnNewDocument` AND `Runtime.evaluate`) that overrides `document.visibilityState` / `document.hidden` so the page's own checks see 'visible.'",
1325
1361
  "Scoped to debugger-attached tabs only \u2014 other tabs the user has open stay normally throttled. Override clears when chrome-relay detaches. User's viewport never changes.",
@@ -1601,9 +1637,26 @@ Use "chrome-relay switch ${url}" to activate that tab, or "chrome-relay navigate
1601
1637
  function registerInput(ctx) {
1602
1638
  const { program, withBase, run } = ctx;
1603
1639
  tabOpt(
1604
- program.command("click <selector>").description("Click an element by CSS selector.")
1640
+ program.command("click [selector]").description("Click an element. Pass a CSS selector OR --x and --y for a coordinate click.").option("--x <px>", "explicit x coordinate (CSS pixels); requires --y", (v) => Number(v)).option("--y <px>", "explicit y coordinate (CSS pixels); requires --x", (v) => Number(v)).addHelpText(
1641
+ "after",
1642
+ `
1643
+
1644
+ Examples:
1645
+ chrome-relay click 'button[aria-label="Save"]'
1646
+ chrome-relay click --tab 123 --x 1327 --y 771
1647
+
1648
+ Pick selector mode when the element has a stable CSS query. Pick
1649
+ coordinate mode when the page wraps content in unmarked divs (Cloudflare
1650
+ dashboard, Vercel dashboard, etc.) and you got the rect from a prior
1651
+ \`chrome-relay js\` call or a screenshot. See docs/clicking-strategies.md.
1652
+ `
1653
+ )
1605
1654
  ).action(async (selector, opts) => {
1606
- await run("chrome_click_element", withBase(opts, { selector }));
1655
+ const extras = {};
1656
+ if (selector) extras.selector = selector;
1657
+ if (typeof opts.x === "number") extras.x = opts.x;
1658
+ if (typeof opts.y === "number") extras.y = opts.y;
1659
+ await run("chrome_click_element", withBase(opts, extras));
1607
1660
  });
1608
1661
  tabOpt(
1609
1662
  program.command("fill <selector> <value>").description("Fill an input or textarea.")
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- var CHROME_RELAY_VERSION = true ? "0.5.17" : "0.0.0-dev";
2
+ var CHROME_RELAY_VERSION = true ? "0.5.19" : "0.0.0-dev";
3
3
  export {
4
4
  CHROME_RELAY_VERSION
5
5
  };
@@ -56,7 +56,7 @@ function toBridgeError(unknownErr, fallbackTool) {
56
56
  }
57
57
 
58
58
  // src/index.ts
59
- var CHROME_RELAY_VERSION = true ? "0.5.17" : "0.0.0-dev";
59
+ var CHROME_RELAY_VERSION = true ? "0.5.19" : "0.0.0-dev";
60
60
 
61
61
  // src/release-notes.ts
62
62
  function compareSemver(a, b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-relay",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",