chrome-relay 0.5.18 → 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.18" : "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,12 @@ 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
+ ],
1323
1353
  "0.5.18": [
1324
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.",
1325
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).",
@@ -1607,9 +1637,26 @@ Use "chrome-relay switch ${url}" to activate that tab, or "chrome-relay navigate
1607
1637
  function registerInput(ctx) {
1608
1638
  const { program, withBase, run } = ctx;
1609
1639
  tabOpt(
1610
- 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
+ )
1611
1654
  ).action(async (selector, opts) => {
1612
- 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));
1613
1660
  });
1614
1661
  tabOpt(
1615
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.18" : "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.18" : "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.18",
3
+ "version": "0.5.19",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",