@houwert/conductor 0.19.0 → 0.19.1
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/commands/screenshot.js +17 -7
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -68,9 +68,14 @@ async function screenshot(outputPath, opts = {}, sessionName = 'default', fullPa
|
|
|
68
68
|
let hierarchyW;
|
|
69
69
|
let hierarchyH;
|
|
70
70
|
if (driver instanceof ios_js_1.IOSDriver) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
// The root axElement returned by the driver is a synthetic wrapper
|
|
72
|
+
// around the foreground app + status bars and has frame=.zero, so
|
|
73
|
+
// reading scale from it would always collapse to 1× and crop the
|
|
74
|
+
// wrong region on retina/4K screens. Use deviceInfo, which reports
|
|
75
|
+
// both points (AX space) and pixels (screenshot space).
|
|
76
|
+
const info = await driver.deviceInfo();
|
|
77
|
+
hierarchyW = info.widthPoints;
|
|
78
|
+
hierarchyH = info.heightPoints;
|
|
74
79
|
el = await (0, wait_js_1.waitForIOSElement)((o) => driver.viewHierarchy(false, [], { cache: o?.cached }).then((x) => x.axElement), sel, undefined, undefined, (0, direct_ios_selector_js_1.makeIOSDirectResolver)(driver, sel));
|
|
75
80
|
}
|
|
76
81
|
else if (driver instanceof web_js_1.WebDriver) {
|
|
@@ -93,10 +98,15 @@ async function screenshot(outputPath, opts = {}, sessionName = 'default', fullPa
|
|
|
93
98
|
const { width: pngW, height: pngH } = (0, png_crop_js_1.readPngDimensions)(buf);
|
|
94
99
|
const scaleX = hierarchyW > 0 ? pngW / hierarchyW : 1;
|
|
95
100
|
const scaleY = hierarchyH > 0 ? pngH / hierarchyH : 1;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
101
|
+
// Margin is in the same logical units as the bounds (points on iOS,
|
|
102
|
+
// pixels on Android/Web — same units the `inspect` command prints),
|
|
103
|
+
// so scale it into screenshot pixels alongside the bounds.
|
|
104
|
+
const marginX = margin * scaleX;
|
|
105
|
+
const marginY = margin * scaleY;
|
|
106
|
+
const rectX = Math.round(el.bounds.x * scaleX - marginX);
|
|
107
|
+
const rectY = Math.round(el.bounds.y * scaleY - marginY);
|
|
108
|
+
const rectW = Math.round(el.bounds.width * scaleX + marginX * 2);
|
|
109
|
+
const rectH = Math.round(el.bounds.height * scaleY + marginY * 2);
|
|
100
110
|
if (rectX + rectW <= 0 || rectY + rectH <= 0 || rectX >= pngW || rectY >= pngH) {
|
|
101
111
|
throw new Error(`element ${label} bounds [${rectX},${rectY} ${rectW}x${rectH}] are outside the screenshot (${pngW}x${pngH})`);
|
|
102
112
|
}
|
package/dist/index.js
CHANGED
|
@@ -222,7 +222,7 @@ async function main() {
|
|
|
222
222
|
'user-agent',
|
|
223
223
|
'color-scheme',
|
|
224
224
|
],
|
|
225
|
-
alias: { h: 'help', v: 'verbose', V: 'version' },
|
|
225
|
+
alias: { h: 'help', v: 'verbose', V: 'version', o: 'output' },
|
|
226
226
|
});
|
|
227
227
|
if (argv['verbose'])
|
|
228
228
|
(0, verbose_js_1.setVerbose)(true);
|