Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update project:
- update dependencies;
- add eslint configuration;
- add jasmine configuration;
- add script for manual testing;
- update unit tests;
  • Loading branch information
serhiikh-gk committed Dec 15, 2025
commit f27ed5af1eb626e8e1e6c17b000350802d56123d
30 changes: 30 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import js from "@eslint/js";
import globals from "globals";
import { defineConfig } from "eslint/config";
import jasmine from "eslint-plugin-jasmine";
import jquery from "eslint-plugin-jquery";

export default defineConfig([
{ files: ["**/*.{mjs,cjs}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { sourceType: 'module', globals: { ...globals.browser, ...globals.jasmine } } },
{
files: ["**/*.js"],
languageOptions: {
sourceType: "commonjs",
globals: {
...globals.js,
...globals.browser,
...globals.jasmine,
...globals.jquery,
...globals.node
}
},
rules: {
"semi": [ "error", "never" ],
"quotes": [2, "single", { "avoidEscape": true }],
"comma-dangle": ["error", "never"],
"indent": ["error", 2]
},
plugins: { js, jasmine, jquery },
extends: ["js/recommended", "jasmine/recommended"]
},
]);
49 changes: 25 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
var robotjs = require('./build/Release/robotjs.node');
var robotjs = require('./build/Release/robotjs.node')

module.exports = robotjs;
module.exports = robotjs

module.exports.screen = {};
module.exports.screen = {}

function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image)
{
this.width = width;
this.height = height;
this.byteWidth = byteWidth;
this.bitsPerPixel = bitsPerPixel;
this.bytesPerPixel = bytesPerPixel;
this.image = image;
this.width = width
this.height = height
this.byteWidth = byteWidth
this.bitsPerPixel = bitsPerPixel
this.bytesPerPixel = bytesPerPixel
this.image = image

this.colorAt = function(x, y)
{
return robotjs.getColor(this, x, y);
};
this.colorAt = function(x, y)
{
return robotjs.getColor(this, x, y)
}

}

module.exports.screen.capture = function(x, y, width, height)
{
//If coords have been passed, use them.
if (typeof x !== "undefined" && typeof y !== "undefined" && typeof width !== "undefined" && typeof height !== "undefined")
{
b = robotjs.captureScreen(x, y, width, height);
}
else
{
b = robotjs.captureScreen();
}
var b
//If coords have been passed, use them.
if (typeof x !== 'undefined' && typeof y !== 'undefined' && typeof width !== 'undefined' && typeof height !== 'undefined')
{
b = robotjs.captureScreen(x, y, width, height)
}
else
{
b = robotjs.captureScreen()
}

return new bitmap(b.width, b.height, b.byteWidth, b.bitsPerPixel, b.bytesPerPixel, b.image);
};
return new bitmap(b.width, b.height, b.byteWidth, b.bitsPerPixel, b.bytesPerPixel, b.image)
}
23 changes: 23 additions & 0 deletions jasmine.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SpecReporter } from "jasmine-spec-reporter";

jasmine.getEnv().clearReporters() // remove default reporter logs
jasmine.getEnv().addReporter(
new SpecReporter({
// add jasmine-spec-reporter
spec: {
displayPending: true,
},
})
)

export default {
spec_dir: "test/all",
spec_files: [
"**/*.js"
],
env: {
stopSpecOnExpectationFailure: false,
random: true,
forbidDuplicateNames: true
}
}
Loading