@galda/cli 0.10.39 → 0.10.41

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/engine/shot.mjs CHANGED
@@ -78,7 +78,22 @@ try {
78
78
  }
79
79
  }
80
80
  if (opt.wait) await new Promise((r) => setTimeout(r, opt.wait));
81
- await page.screenshot({ path: out, fullPage: opt.full });
81
+ if (opt.element) {
82
+ // Shoot the element itself rather than cropping a page shot: puppeteer
83
+ // scrolls it into view and uses its real box, so the picture is still right
84
+ // when the layout is not where anyone guessed it would be. A selector that
85
+ // matches nothing is an error, never a full-page shot pretending to be the
86
+ // region that was asked for.
87
+ const el = await page.$(opt.element);
88
+ if (!el) throw new Error(`--element matched nothing: ${opt.element}`);
89
+ const box = await el.boundingBox();
90
+ if (!box || box.width < 1 || box.height < 1) throw new Error(`--element is not visible: ${opt.element}`);
91
+ await el.screenshot({ path: out });
92
+ } else if (opt.clip) {
93
+ await page.screenshot({ path: out, clip: opt.clip });
94
+ } else {
95
+ await page.screenshot({ path: out, fullPage: opt.full });
96
+ }
82
97
  } catch (e) {
83
98
  failure = String(e?.message ?? e).split('\n')[0];
84
99
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galda/cli",
3
- "version": "0.10.39",
3
+ "version": "0.10.41",
4
4
  "type": "module",
5
5
  "description": "Galda - hand off work to Claude Code or Codex, get proof back. Runs on your existing subscription, no extra API cost.",
6
6
  "scripts": {