@jitsi/robotjs 0.6.11 → 0.6.12

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/index.js CHANGED
@@ -4,7 +4,12 @@ module.exports = robotjs;
4
4
 
5
5
  module.exports.screen = {};
6
6
 
7
- function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image)
7
+ function toHex(n)
8
+ {
9
+ return n.toString(16).padStart(2, '0');
10
+ }
11
+
12
+ function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image)
8
13
  {
9
14
  this.width = width;
10
15
  this.height = height;
@@ -15,9 +20,19 @@ function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image)
15
20
 
16
21
  this.colorAt = function(x, y)
17
22
  {
18
- return robotjs.getColor(this, x, y);
19
- };
23
+ if (typeof x !== 'number' || typeof y !== 'number') {
24
+ throw new Error(`Invalid number`);
25
+ }
20
26
 
27
+ const buffer = this.image;
28
+ const startIndex = (y * this.width + x) * this.bytesPerPixel;
29
+
30
+ if (x < 0 || x >= this.width || y < 0 || y >= this.height || typeof buffer[startIndex + 2] === 'undefined') {
31
+ throw new Error(`(${x}, ${y}) are outside the bitmap`);
32
+ }
33
+
34
+ return `${toHex(buffer[startIndex + 2])}${toHex(buffer[startIndex + 1])}${toHex(buffer[startIndex])}`;
35
+ };
21
36
  }
22
37
 
23
38
  module.exports.screen.capture = function(x, y, width, height)
@@ -27,7 +42,7 @@ module.exports.screen.capture = function(x, y, width, height)
27
42
  {
28
43
  b = robotjs.captureScreen(x, y, width, height);
29
44
  }
30
- else
45
+ else
31
46
  {
32
47
  b = robotjs.captureScreen();
33
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsi/robotjs",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "Node.js Desktop Automation.",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
Binary file
Binary file