testdriverai 4.1.20 → 4.1.22
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/agent.js +2 -2
- package/lib/system.js +15 -12
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -295,7 +295,7 @@ const check = async () => {
|
|
|
295
295
|
log.log("info", chalk.dim("checking..."), "testdriver");
|
|
296
296
|
log.log("info", "");
|
|
297
297
|
|
|
298
|
-
let thisScreenshot = await system.captureScreenBase64();
|
|
298
|
+
let thisScreenshot = await system.captureScreenBase64(1, false, true);
|
|
299
299
|
let images = [lastScreenshot, thisScreenshot];
|
|
300
300
|
let mousePosition = await system.getMousePosition();
|
|
301
301
|
let activeWindow = await system.activeWin();
|
|
@@ -333,7 +333,7 @@ const runCommand = async (command, depth) => {
|
|
|
333
333
|
try {
|
|
334
334
|
let response;
|
|
335
335
|
|
|
336
|
-
if (command.command == "
|
|
336
|
+
if (command.command == "run") {
|
|
337
337
|
response = await embed(command.file, depth);
|
|
338
338
|
} else if (command.command == "if") {
|
|
339
339
|
response = await iffy(
|
package/lib/system.js
CHANGED
|
@@ -32,7 +32,7 @@ const tmpFilename = () => {
|
|
|
32
32
|
return path.join(os.tmpdir(), `${new Date().getTime() + Math.random()}.png`);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const captureAndResize = async (scale = 1, silent = false) => {
|
|
35
|
+
const captureAndResize = async (scale = 1, silent = false, mouse = false) => {
|
|
36
36
|
try {
|
|
37
37
|
const primaryDisplay = await getPrimaryDisplay();
|
|
38
38
|
if (!silent) {
|
|
@@ -55,14 +55,17 @@ const captureAndResize = async (scale = 1, silent = false) => {
|
|
|
55
55
|
const cursorPath = path.join(__dirname, "resources", "cursor.png");
|
|
56
56
|
|
|
57
57
|
// resize to 1:1 px ratio
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const sharpInstance = sharp(step1).resize(
|
|
59
|
+
Math.floor(primaryDisplay.currentResX * scale),
|
|
60
|
+
Math.floor(primaryDisplay.currentResY * scale),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (mouse) {
|
|
63
64
|
// composite the mouse image ontop
|
|
64
|
-
.composite([{ input: cursorPath, left: mousePos.x, top: mousePos.y }])
|
|
65
|
-
|
|
65
|
+
sharpInstance.composite([{ input: cursorPath, left: mousePos.x, top: mousePos.y }]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await sharpInstance.toFile(step2);
|
|
66
69
|
|
|
67
70
|
emitter.emit(events.screenCapture.end, {
|
|
68
71
|
scale,
|
|
@@ -83,13 +86,13 @@ const captureAndResize = async (scale = 1, silent = false) => {
|
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
// our handy screenshot function
|
|
86
|
-
const captureScreenBase64 = async (scale = 1, silent = false) => {
|
|
87
|
-
let step2 = await captureAndResize(scale, silent);
|
|
89
|
+
const captureScreenBase64 = async (scale = 1, silent = false, mouse = false) => {
|
|
90
|
+
let step2 = await captureAndResize(scale, silent, mouse);
|
|
88
91
|
return fs.readFileSync(step2, "base64");
|
|
89
92
|
};
|
|
90
93
|
|
|
91
|
-
const captureScreenPNG = async (scale = 1, silent = false) => {
|
|
92
|
-
return await captureAndResize(scale, silent);
|
|
94
|
+
const captureScreenPNG = async (scale = 1, silent = false, mouse = false) => {
|
|
95
|
+
return await captureAndResize(scale, silent, mouse);
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
const platform = () => {
|