unsleep 1.1.0
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/LICENCE +21 -0
- package/README.md +13 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +39 -0
- package/package.json +72 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Maxime Golfier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const robotjs_1 = __importDefault(require("robotjs"));
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
+
commander_1.program
|
|
10
|
+
.name('unsleep')
|
|
11
|
+
.description('Prevent your computer from sleeping')
|
|
12
|
+
.version(package_json_1.default.version)
|
|
13
|
+
.option('-a,--autoclick', 'Enable auto clicker')
|
|
14
|
+
.option('-ad,--autoclick-delay <value>', 'Delay between auto clicks')
|
|
15
|
+
.option('-m --mouse', 'Enable mouse movement')
|
|
16
|
+
.option('-md, --mouse-delay <value>', 'Delay between mouse movements in ms (default: 5000)')
|
|
17
|
+
.parse(process.argv);
|
|
18
|
+
const options = commander_1.program.opts();
|
|
19
|
+
const hasMouseOption = options.mouse;
|
|
20
|
+
const hasAutoClickOption = options.autoclick;
|
|
21
|
+
const autoClickDelay = options.autoclickDelay;
|
|
22
|
+
const mouseDelay = options.mouseDelay;
|
|
23
|
+
const generateDelay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
24
|
+
const randomIntFromInterval = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
|
|
25
|
+
const screenSize = robotjs_1.default.getScreenSize();
|
|
26
|
+
const MOUSE_DELAY_MS = mouseDelay ? parseInt(mouseDelay) : 5000;
|
|
27
|
+
const AUTOCLICK_DELAY_MS = autoClickDelay ? parseInt(autoClickDelay) : 5000;
|
|
28
|
+
(async function () {
|
|
29
|
+
while (true) {
|
|
30
|
+
if (hasMouseOption) {
|
|
31
|
+
await generateDelay(MOUSE_DELAY_MS);
|
|
32
|
+
robotjs_1.default.moveMouse(randomIntFromInterval(0, screenSize.height), randomIntFromInterval(0, screenSize.width));
|
|
33
|
+
}
|
|
34
|
+
if (hasAutoClickOption) {
|
|
35
|
+
await generateDelay(AUTOCLICK_DELAY_MS);
|
|
36
|
+
robotjs_1.default.mouseClick();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unsleep",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"author": "maxgfr",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Tool to move your mouse to prevent your computer from sleeping",
|
|
7
|
+
"main": "./build/index.js",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/maxgfr/unsleep.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/maxgfr/unsleep/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/maxgfr/unsleep#readme",
|
|
16
|
+
"files": [
|
|
17
|
+
"build"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"unsleep"
|
|
21
|
+
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"unsleep": "./build/index.js"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"start": "node build/index.js",
|
|
27
|
+
"dev": "nodemon",
|
|
28
|
+
"develop": "node -r @swc-node/register ./src/index.ts",
|
|
29
|
+
"test": "jest --passWithNoTests",
|
|
30
|
+
"test:watch": "jest --watch",
|
|
31
|
+
"clean": "rimraf build",
|
|
32
|
+
"build": "tsc -p tsconfig.build.json",
|
|
33
|
+
"build:watch": "tsc -w -p tsconfig.build.json",
|
|
34
|
+
"build:swc": "swc ./src -d build",
|
|
35
|
+
"build:swc:watch": "swc ./src -d build -w",
|
|
36
|
+
"build:pkg": "pkg ./build/index.js --out-path dist/",
|
|
37
|
+
"lint": "eslint ./src --ext .ts",
|
|
38
|
+
"prettier": "prettier --write './src/**/*.{ts,js,json}'",
|
|
39
|
+
"release": "semantic-release"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"robotjs": "^0.6.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@semantic-release/changelog": "^6.0.2",
|
|
47
|
+
"@semantic-release/commit-analyzer": "^11.0.0",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
49
|
+
"@semantic-release/github": "^9.0.0",
|
|
50
|
+
"@semantic-release/npm": "^9.0.1",
|
|
51
|
+
"@semantic-release/release-notes-generator": "^12.0.0",
|
|
52
|
+
"@swc-node/register": "1.10.10",
|
|
53
|
+
"@swc/cli": "0.6.0",
|
|
54
|
+
"@swc/core": "1.11.16",
|
|
55
|
+
"@swc/jest": "0.2.37",
|
|
56
|
+
"@types/commander": "^2.12.2",
|
|
57
|
+
"@types/jest": "29.5.14",
|
|
58
|
+
"@types/node": "20.17.30",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
60
|
+
"@typescript-eslint/parser": "6.21.0",
|
|
61
|
+
"@yao-pkg/pkg": "^5.12.1",
|
|
62
|
+
"eslint": "8.57.1",
|
|
63
|
+
"eslint-config-prettier": "9.1.0",
|
|
64
|
+
"eslint-plugin-jest": "27.9.0",
|
|
65
|
+
"jest": "29.7.0",
|
|
66
|
+
"nodemon": "3.1.9",
|
|
67
|
+
"prettier": "3.5.3",
|
|
68
|
+
"rimraf": "5.0.10",
|
|
69
|
+
"semantic-release": "22.0.12",
|
|
70
|
+
"typescript": "5.8.2"
|
|
71
|
+
}
|
|
72
|
+
}
|