pp-robot-module 0.2.14
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/README.md +34 -0
- package/dist/MR/Ai.d.ts +8 -0
- package/dist/MR/Ai.js +24 -0
- package/dist/MR/Clipboard.d.ts +20 -0
- package/dist/MR/Clipboard.js +60 -0
- package/dist/MR/Csv.d.ts +20 -0
- package/dist/MR/Csv.js +56 -0
- package/dist/MR/Date.d.ts +60 -0
- package/dist/MR/Date.js +94 -0
- package/dist/MR/DbClient.d.ts +97 -0
- package/dist/MR/DbClient.js +269 -0
- package/dist/MR/Dialog.d.ts +0 -0
- package/dist/MR/Dialog.js +40 -0
- package/dist/MR/Excel.d.ts +110 -0
- package/dist/MR/Excel.js +316 -0
- package/dist/MR/File.d.ts +162 -0
- package/dist/MR/File.js +399 -0
- package/dist/MR/Hash.d.ts +12 -0
- package/dist/MR/Hash.js +21 -0
- package/dist/MR/Html.d.ts +38 -0
- package/dist/MR/Html.js +163 -0
- package/dist/MR/Http.d.ts +33 -0
- package/dist/MR/Http.js +121 -0
- package/dist/MR/Imap.d.ts +15 -0
- package/dist/MR/Imap.js +52 -0
- package/dist/MR/Ini.d.ts +31 -0
- package/dist/MR/Ini.js +55 -0
- package/dist/MR/Keyboard.d.ts +59 -0
- package/dist/MR/Keyboard.js +515 -0
- package/dist/MR/Log.d.ts +7 -0
- package/dist/MR/Log.js +52 -0
- package/dist/MR/Mouse.d.ts +51 -0
- package/dist/MR/Mouse.js +152 -0
- package/dist/MR/Net.d.ts +17 -0
- package/dist/MR/Net.js +74 -0
- package/dist/MR/Pdf.d.ts +113 -0
- package/dist/MR/Pdf.js +197 -0
- package/dist/MR/Process.d.ts +46 -0
- package/dist/MR/Process.js +106 -0
- package/dist/MR/QRcode.d.ts +13 -0
- package/dist/MR/QRcode.js +37 -0
- package/dist/MR/RedisClient.d.ts +40 -0
- package/dist/MR/RedisClient.js +183 -0
- package/dist/MR/Regex.d.ts +16 -0
- package/dist/MR/Regex.js +20 -0
- package/dist/MR/Robot.d.ts +19 -0
- package/dist/MR/Robot.js +31 -0
- package/dist/MR/Screen.d.ts +20 -0
- package/dist/MR/Screen.js +79 -0
- package/dist/MR/Smtp.d.ts +21 -0
- package/dist/MR/Smtp.js +83 -0
- package/dist/MR/String.d.ts +104 -0
- package/dist/MR/String.js +166 -0
- package/dist/MR/System.d.ts +31 -0
- package/dist/MR/System.js +201 -0
- package/dist/MR/Validator.d.ts +30 -0
- package/dist/MR/Validator.js +104 -0
- package/dist/MR/WebBrowser.d.ts +210 -0
- package/dist/MR/WebBrowser.js +484 -0
- package/dist/MR/WebBrowser2.d.ts +0 -0
- package/dist/MR/WebBrowser2.js +504 -0
- package/dist/MR/WebElement.d.ts +123 -0
- package/dist/MR/WebElement.js +172 -0
- package/dist/MR/WebKeyboard.d.ts +21 -0
- package/dist/MR/WebKeyboard.js +48 -0
- package/dist/MR/WebMouse.d.ts +46 -0
- package/dist/MR/WebMouse.js +79 -0
- package/dist/MR/Window.d.ts +8 -0
- package/dist/MR/Window.js +34 -0
- package/dist/MR/Word.d.ts +56 -0
- package/dist/MR/Word.js +220 -0
- package/dist/MR/Zip.d.ts +25 -0
- package/dist/MR/Zip.js +89 -0
- package/dist/bin/inputting-method.exe +0 -0
- package/dist/bin/keyboard-password.exe +0 -0
- package/dist/bin/lock-window.exe +0 -0
- package/dist/bin/printer-pdf.exe +0 -0
- package/dist/dotenv.d.ts +0 -0
- package/dist/dotenv.js +2 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +63 -0
- package/dist/util.d.ts +17 -0
- package/dist/util.js +41 -0
- package/package.json +120 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.MR = void 0;
|
13
|
+
var shell = require('shelljs');
|
14
|
+
const fkill = require('fkill');
|
15
|
+
const nut_js_1 = require("@nut-tree/nut-js");
|
16
|
+
const lodash_1 = require("lodash");
|
17
|
+
const Log_1 = require("./Log");
|
18
|
+
var MR;
|
19
|
+
(function (MR) {
|
20
|
+
class Process {
|
21
|
+
constructor() { }
|
22
|
+
static envs(params = { _type: 'Object' }) {
|
23
|
+
Log_1.default.debug("Process.envs");
|
24
|
+
if (params._type === 'Array')
|
25
|
+
return Object.entries(process.env).map(([key, value]) => ({ name: key, value }));
|
26
|
+
return process.env;
|
27
|
+
}
|
28
|
+
static env(params) {
|
29
|
+
Log_1.default.debug("Process.env", params);
|
30
|
+
return process.env[params._key];
|
31
|
+
}
|
32
|
+
static cwd() {
|
33
|
+
Log_1.default.debug("Process.cwd");
|
34
|
+
return process.cwd();
|
35
|
+
}
|
36
|
+
static echo(params) {
|
37
|
+
Log_1.default.debug("Process.echo", params);
|
38
|
+
if (!params._newline) {
|
39
|
+
return shell.echo(params._content);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return shell.echo('-n', params._content);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
static exec(params) {
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
Log_1.default.debug("Process.exec", params);
|
48
|
+
if (params._silent) {
|
49
|
+
return new Promise((resolve, reject) => {
|
50
|
+
const data = shell.exec(params._cmd, { silent: true }).stdout;
|
51
|
+
resolve(data);
|
52
|
+
});
|
53
|
+
}
|
54
|
+
return new Promise((resolve, reject) => {
|
55
|
+
const child = shell.exec(params._cmd, { async: true });
|
56
|
+
child.stdout.on('data', function (data) {
|
57
|
+
resolve(data);
|
58
|
+
});
|
59
|
+
});
|
60
|
+
});
|
61
|
+
}
|
62
|
+
static kill(params) {
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
64
|
+
Log_1.default.debug("Process.kill", params);
|
65
|
+
if (params._pid)
|
66
|
+
yield fkill(params._pid);
|
67
|
+
if (params._name)
|
68
|
+
yield fkill(params._name);
|
69
|
+
if (params._port)
|
70
|
+
yield fkill(':' + params._port);
|
71
|
+
});
|
72
|
+
}
|
73
|
+
static capture(params = { _filePath: '.', _fileName: (0, lodash_1.uniqueId)(), _fileType: 'PNG' }) {
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
75
|
+
Log_1.default.debug("Process.capture", params);
|
76
|
+
if (params._fileType === 'PNG')
|
77
|
+
return yield nut_js_1.screen.capture(params._fileName, nut_js_1.FileType.PNG, params._filePath);
|
78
|
+
else
|
79
|
+
return yield nut_js_1.screen.capture(params._fileName, nut_js_1.FileType.JPG, params._filePath);
|
80
|
+
});
|
81
|
+
}
|
82
|
+
static captureRegion(params = { _x: 0, _y: 0, _width: 100, _height: 100, _filePath: '.', _fileName: (0, lodash_1.uniqueId)(), _fileType: 'PNG' }) {
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
84
|
+
Log_1.default.debug("Process.captureRegion", params);
|
85
|
+
const region = new nut_js_1.Region(params._x, params._x, params._width, params._height);
|
86
|
+
if (params._fileType === 'PNG')
|
87
|
+
return yield nut_js_1.screen.captureRegion(params._fileName, region, nut_js_1.FileType.PNG, params._filePath);
|
88
|
+
else
|
89
|
+
return yield nut_js_1.screen.captureRegion(params._fileName, region, nut_js_1.FileType.JPG, params._filePath);
|
90
|
+
});
|
91
|
+
}
|
92
|
+
static test1() {
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
94
|
+
if (!shell.which('git')) {
|
95
|
+
shell.echo('Sorry, this script requires git');
|
96
|
+
shell.exit(1);
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
shell.echo('oh,git is full');
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
MR.Process = Process;
|
105
|
+
})(MR = exports.MR || (exports.MR = {}));
|
106
|
+
exports.default = MR.Process;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class QRCode {
|
3
|
+
private constructor();
|
4
|
+
static generate(params: {
|
5
|
+
_text: string;
|
6
|
+
}): Promise<any>;
|
7
|
+
static identify(params: {
|
8
|
+
_filename: string;
|
9
|
+
}): void;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
declare const _default: typeof MR.QRCode;
|
13
|
+
export default _default;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.MR = void 0;
|
13
|
+
const Log_1 = require("./Log");
|
14
|
+
const _qrcode = require('qrcode');
|
15
|
+
var MR;
|
16
|
+
(function (MR) {
|
17
|
+
class QRCode {
|
18
|
+
constructor() { }
|
19
|
+
static generate(params) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
Log_1.default.debug("QRCode.generate", params);
|
22
|
+
try {
|
23
|
+
const qrCodeDataURL = yield _qrcode.toDataURL(params._text);
|
24
|
+
return qrCodeDataURL;
|
25
|
+
}
|
26
|
+
catch (err) {
|
27
|
+
console.error(err);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
static identify(params) {
|
32
|
+
Log_1.default.debug("QRCode.identify", params);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
MR.QRCode = QRCode;
|
36
|
+
})(MR = exports.MR || (exports.MR = {}));
|
37
|
+
exports.default = MR.QRCode;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import Redis from "ioredis";
|
3
|
+
export declare namespace MR {
|
4
|
+
class MyRedis {
|
5
|
+
private static myRedis;
|
6
|
+
client: Redis;
|
7
|
+
private static _host;
|
8
|
+
private static _port;
|
9
|
+
private static _password;
|
10
|
+
private static _username;
|
11
|
+
private static _db;
|
12
|
+
private constructor();
|
13
|
+
static get instance(): MyRedis;
|
14
|
+
static create(params: {
|
15
|
+
_host: string;
|
16
|
+
_port: number;
|
17
|
+
_db?: number;
|
18
|
+
_password?: string;
|
19
|
+
}): Redis;
|
20
|
+
config(): Promise<void>;
|
21
|
+
do(params: any): Promise<void>;
|
22
|
+
set(_key: string, _value: string, _ex?: number): Promise<"OK">;
|
23
|
+
get(_key: string): Promise<string>;
|
24
|
+
del(_key: string): Promise<number>;
|
25
|
+
exists(_key: string): Promise<number>;
|
26
|
+
incrby(_key: string): Promise<number>;
|
27
|
+
hmset(_key: string, _value: any): Promise<"OK">;
|
28
|
+
hget(_key: string, _hkey: string): Promise<"OK">;
|
29
|
+
hdel(_key: string, _hkey: string): Promise<number>;
|
30
|
+
hexists(_key: string, _hkey: string): Promise<number>;
|
31
|
+
hincrby(_key: string, _hkey: string): Promise<number>;
|
32
|
+
lpush(_key: string, elements: (string | number | Buffer)[]): Promise<void>;
|
33
|
+
lpop(_key: string): Promise<string>;
|
34
|
+
sadd(_key: string, elements: (string | number | Buffer)[]): Promise<number>;
|
35
|
+
scard(_key: string): Promise<number>;
|
36
|
+
sismember(_key: string, _member: string | Buffer | number): Promise<number>;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
declare const _default: MR.MyRedis;
|
40
|
+
export default _default;
|
@@ -0,0 +1,183 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.MR = void 0;
|
13
|
+
const ioredis_1 = require("ioredis");
|
14
|
+
const Log_1 = require("./Log");
|
15
|
+
var MR;
|
16
|
+
(function (MR) {
|
17
|
+
class MyRedis {
|
18
|
+
constructor() {
|
19
|
+
const redisConfig = {
|
20
|
+
host: MyRedis._host,
|
21
|
+
port: MyRedis._port,
|
22
|
+
password: MyRedis._password,
|
23
|
+
username: MyRedis._username,
|
24
|
+
db: MyRedis._db,
|
25
|
+
lazyConnect: true,
|
26
|
+
retryStrategy: function (times) {
|
27
|
+
return Math.min(times * 50, 5000);
|
28
|
+
},
|
29
|
+
// enableOfflineQueue: false
|
30
|
+
};
|
31
|
+
this.client = new ioredis_1.default(redisConfig);
|
32
|
+
}
|
33
|
+
static get instance() {
|
34
|
+
try {
|
35
|
+
if (!this.myRedis) {
|
36
|
+
this.myRedis = new MyRedis();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
catch (e) {
|
40
|
+
console.log('----------');
|
41
|
+
console.log(e);
|
42
|
+
Log_1.default.error(e.toString());
|
43
|
+
}
|
44
|
+
return this.myRedis;
|
45
|
+
}
|
46
|
+
static create(params) {
|
47
|
+
const redisConfig = {
|
48
|
+
host: params._host,
|
49
|
+
port: params._port,
|
50
|
+
password: params._password,
|
51
|
+
db: params._db,
|
52
|
+
retryStrategy: function (times) {
|
53
|
+
return Math.min(times * 50, 5000);
|
54
|
+
},
|
55
|
+
// enableOfflineQueue: false
|
56
|
+
};
|
57
|
+
const _ = new ioredis_1.default(redisConfig);
|
58
|
+
// this.client = _;
|
59
|
+
return _;
|
60
|
+
}
|
61
|
+
/* public async rawCall(params: {
|
62
|
+
_cmd: string, _key: string, _value: any
|
63
|
+
}) {
|
64
|
+
|
65
|
+
if (!params._value || !Array.isArray(params._value)) {
|
66
|
+
throw new Error('_value argument to rawCall() must be an Array');
|
67
|
+
}
|
68
|
+
switch (params._cmd.toLowerCase()) {
|
69
|
+
case 'set':
|
70
|
+
//redis.set("key_with_ttl", "hey", "EX", 1000);
|
71
|
+
// this.set(params._value);
|
72
|
+
case 'get':
|
73
|
+
this.get(params._key);
|
74
|
+
}
|
75
|
+
|
76
|
+
}
|
77
|
+
*/
|
78
|
+
/* rawCallAsync(args) {
|
79
|
+
return new Promise((resolve, reject) => {
|
80
|
+
this.rawCall(args, (err, resp) => {
|
81
|
+
if (err) return reject(err);
|
82
|
+
resolve(resp);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
} */
|
86
|
+
//nothing
|
87
|
+
config() {
|
88
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
89
|
+
}
|
90
|
+
//nothing
|
91
|
+
do(params) {
|
92
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
93
|
+
}
|
94
|
+
set(_key, _value, _ex) {
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
96
|
+
if (!_ex) {
|
97
|
+
return yield this.client.set(_key, _value);
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
return yield this.client.set(_key, _value, "EX", _ex);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
}
|
104
|
+
get(_key) {
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
106
|
+
return yield this.client.get(_key);
|
107
|
+
});
|
108
|
+
}
|
109
|
+
del(_key) {
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
111
|
+
return yield this.client.del(_key);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
exists(_key) {
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
116
|
+
return yield this.client.exists(_key);
|
117
|
+
});
|
118
|
+
}
|
119
|
+
incrby(_key) {
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
121
|
+
return yield this.client.incrby(_key, 1);
|
122
|
+
});
|
123
|
+
}
|
124
|
+
hmset(_key, _value) {
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
126
|
+
return yield this.client.hmset(_key, _value);
|
127
|
+
});
|
128
|
+
}
|
129
|
+
hget(_key, _hkey) {
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
131
|
+
return yield this.client.hmset(_key, _hkey);
|
132
|
+
});
|
133
|
+
}
|
134
|
+
hdel(_key, _hkey) {
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
136
|
+
return yield this.client.hdel(_key, _hkey);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
hexists(_key, _hkey) {
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
141
|
+
return yield this.client.hexists(_key, _hkey);
|
142
|
+
});
|
143
|
+
}
|
144
|
+
hincrby(_key, _hkey) {
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
146
|
+
return yield this.client.hincrby(_key, _hkey, 1);
|
147
|
+
});
|
148
|
+
}
|
149
|
+
lpush(_key, elements) {
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
151
|
+
//return await this.client.lpush(_key, elements, null);
|
152
|
+
});
|
153
|
+
}
|
154
|
+
lpop(_key) {
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
156
|
+
return yield this.client.lpop(_key);
|
157
|
+
});
|
158
|
+
}
|
159
|
+
sadd(_key, elements) {
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
161
|
+
return yield this.client.sadd(_key, elements);
|
162
|
+
});
|
163
|
+
}
|
164
|
+
scard(_key) {
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
166
|
+
return yield this.client.scard(_key);
|
167
|
+
});
|
168
|
+
}
|
169
|
+
sismember(_key, _member) {
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
171
|
+
return yield this.client.sismember(_key, _member);
|
172
|
+
});
|
173
|
+
}
|
174
|
+
}
|
175
|
+
MyRedis._host = process.env.REDIS_HOST;
|
176
|
+
MyRedis._port = Number(process.env.REDIS_PORT);
|
177
|
+
MyRedis._password = process.env.REDIS_PASSWORD;
|
178
|
+
//redis 6>
|
179
|
+
MyRedis._username = process.env.REDIS_USERNAME;
|
180
|
+
MyRedis._db = Number(process.env.REDIS_DB);
|
181
|
+
MR.MyRedis = MyRedis;
|
182
|
+
})(MR = exports.MR || (exports.MR = {}));
|
183
|
+
exports.default = MR.MyRedis.instance;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class Regex {
|
3
|
+
private constructor();
|
4
|
+
static match(params: {
|
5
|
+
_exp: string;
|
6
|
+
_msg: string;
|
7
|
+
}): RegExpMatchArray;
|
8
|
+
static replace(params: {
|
9
|
+
_exp: string;
|
10
|
+
_msg: string;
|
11
|
+
_text: string;
|
12
|
+
}): string;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
declare const _default: typeof MR.Regex;
|
16
|
+
export default _default;
|
package/dist/MR/Regex.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MR = void 0;
|
4
|
+
const Log_1 = require("./Log");
|
5
|
+
var MR;
|
6
|
+
(function (MR) {
|
7
|
+
class Regex {
|
8
|
+
constructor() { }
|
9
|
+
static match(params) {
|
10
|
+
Log_1.default.debug("Regex.match", params);
|
11
|
+
return params._msg.match(params._exp);
|
12
|
+
}
|
13
|
+
static replace(params) {
|
14
|
+
Log_1.default.debug("Regex.replace", params);
|
15
|
+
return params._msg.replace(params._exp, params._text);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
MR.Regex = Regex;
|
19
|
+
})(MR = exports.MR || (exports.MR = {}));
|
20
|
+
exports.default = MR.Regex;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class Robot {
|
3
|
+
private robotName;
|
4
|
+
private robotDesc;
|
5
|
+
private beanName;
|
6
|
+
private robotTrail;
|
7
|
+
private robotResData;
|
8
|
+
private dataMap;
|
9
|
+
private constructor();
|
10
|
+
addTrail(args: any): void;
|
11
|
+
static create(params?: {
|
12
|
+
_name: string;
|
13
|
+
_desc: string;
|
14
|
+
_beanName: string;
|
15
|
+
}): Robot;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
declare const _default: typeof MR.Robot;
|
19
|
+
export default _default;
|
package/dist/MR/Robot.js
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MR = void 0;
|
4
|
+
const Log_1 = require("./Log");
|
5
|
+
var MR;
|
6
|
+
(function (MR) {
|
7
|
+
class Robot {
|
8
|
+
constructor() {
|
9
|
+
this.robotTrail = [];
|
10
|
+
this.robotResData = [];
|
11
|
+
this.dataMap = {};
|
12
|
+
}
|
13
|
+
addTrail(args) {
|
14
|
+
this.robotTrail.push(args);
|
15
|
+
}
|
16
|
+
static create(params = {
|
17
|
+
_name: 'test',
|
18
|
+
_desc: 'no desc',
|
19
|
+
_beanName: '',
|
20
|
+
}) {
|
21
|
+
Log_1.default.debug("Robot.create", params);
|
22
|
+
const robot = new Robot();
|
23
|
+
robot.robotName = params._name;
|
24
|
+
robot.robotDesc = params._desc;
|
25
|
+
robot.beanName = params._beanName;
|
26
|
+
return robot;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
MR.Robot = Robot;
|
30
|
+
})(MR = exports.MR || (exports.MR = {}));
|
31
|
+
exports.default = MR.Robot;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Region } from "@nut-tree/nut-js";
|
2
|
+
export declare namespace MR {
|
3
|
+
class Screen {
|
4
|
+
private constructor();
|
5
|
+
static highlight(left: number, top: number, width: number, height: number): Promise<Region>;
|
6
|
+
static getSize(): Promise<{
|
7
|
+
width: number;
|
8
|
+
height: number;
|
9
|
+
}>;
|
10
|
+
static width(): Promise<number>;
|
11
|
+
static height(): Promise<number>;
|
12
|
+
static capture(filePath: string, fileName: string): Promise<string>;
|
13
|
+
static colorAt(x: number, y: number): Promise<import("@nut-tree/nut-js").RGBA>;
|
14
|
+
static findImage(path: string, imageFile: string): Promise<Region>;
|
15
|
+
static findImageAndHover(path: string, imageFile: string, timeout: number): Promise<import("@nut-tree/nut-js").MouseClass>;
|
16
|
+
static waitImage(path: string, imageFile: string, timeout: number): Promise<Region>;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
declare const _default: typeof MR.Screen;
|
20
|
+
export default _default;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.MR = void 0;
|
13
|
+
const nut_js_1 = require("@nut-tree/nut-js");
|
14
|
+
var MR;
|
15
|
+
(function (MR) {
|
16
|
+
class Screen {
|
17
|
+
constructor() { }
|
18
|
+
static highlight(left, top, width, height) {
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
20
|
+
return yield nut_js_1.screen.highlight(new nut_js_1.Region(left, top, width, height));
|
21
|
+
});
|
22
|
+
}
|
23
|
+
static getSize() {
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
25
|
+
let h = yield nut_js_1.screen.height();
|
26
|
+
let w = yield nut_js_1.screen.width();
|
27
|
+
return { "width": w, "height": h };
|
28
|
+
});
|
29
|
+
}
|
30
|
+
static width() {
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
32
|
+
return yield nut_js_1.screen.width();
|
33
|
+
});
|
34
|
+
}
|
35
|
+
static height() {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
return yield nut_js_1.screen.height();
|
38
|
+
});
|
39
|
+
}
|
40
|
+
static capture(filePath, fileName) {
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
42
|
+
return yield nut_js_1.screen.capture(fileName, nut_js_1.FileType.PNG, filePath);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
/* public static async captureRegion (filePath: string,fileName: string, left: number, top: number, width: number, height: number) {
|
46
|
+
const region = new Region(left, top, width, height)
|
47
|
+
return await screen.capture (fileName,FileType.PNG,region,filePath);
|
48
|
+
} */
|
49
|
+
static colorAt(x, y) {
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
51
|
+
return yield nut_js_1.screen.colorAt(new nut_js_1.Point(x, y));
|
52
|
+
});
|
53
|
+
}
|
54
|
+
static findImage(path, imageFile) {
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
56
|
+
nut_js_1.screen.config.resourceDirectory = path;
|
57
|
+
return yield nut_js_1.screen.find((0, nut_js_1.imageResource)(imageFile));
|
58
|
+
});
|
59
|
+
}
|
60
|
+
static findImageAndHover(path, imageFile, timeout) {
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
62
|
+
nut_js_1.screen.config.resourceDirectory = path;
|
63
|
+
return yield nut_js_1.mouse.move((0, nut_js_1.straightTo)((0, nut_js_1.centerOf)(yield nut_js_1.screen.waitFor((0, nut_js_1.imageResource)(imageFile), timeout))));
|
64
|
+
});
|
65
|
+
}
|
66
|
+
/* public static async findImageAndClick(path:string,imageFile:string,timeout:number) {
|
67
|
+
Screen.findImageAndHover(path,imageFile,timeout)
|
68
|
+
mouse.click()
|
69
|
+
} */
|
70
|
+
static waitImage(path, imageFile, timeout) {
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
72
|
+
nut_js_1.screen.config.resourceDirectory = path;
|
73
|
+
return yield nut_js_1.screen.waitFor((0, nut_js_1.imageResource)(imageFile), timeout);
|
74
|
+
});
|
75
|
+
}
|
76
|
+
}
|
77
|
+
MR.Screen = Screen;
|
78
|
+
})(MR = exports.MR || (exports.MR = {}));
|
79
|
+
exports.default = MR.Screen;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class SmtpClass {
|
3
|
+
private constructor();
|
4
|
+
private static _host;
|
5
|
+
private static _port;
|
6
|
+
private static _username;
|
7
|
+
private static _password;
|
8
|
+
private static _netType;
|
9
|
+
private static _service;
|
10
|
+
private static _secure;
|
11
|
+
static send(params: {
|
12
|
+
_from: string;
|
13
|
+
_to: string;
|
14
|
+
_subject: string;
|
15
|
+
_text: string;
|
16
|
+
_filenames?: string | string[];
|
17
|
+
}): Promise<any>;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
declare const _default: typeof MR.SmtpClass;
|
21
|
+
export default _default;
|
package/dist/MR/Smtp.js
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.MR = void 0;
|
13
|
+
const nodemailer = require('nodemailer');
|
14
|
+
const path = require('path');
|
15
|
+
const Log_1 = require("./Log");
|
16
|
+
// 使用内置传输发送邮件 查看支持列表:https://nodemailer.com/smtp/well-known/
|
17
|
+
var MR;
|
18
|
+
(function (MR) {
|
19
|
+
class SmtpClass {
|
20
|
+
constructor() { }
|
21
|
+
static send(params) {
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
23
|
+
Log_1.default.debug("SmtpClass.send", params);
|
24
|
+
let transporter = nodemailer.createTransport({
|
25
|
+
service: SmtpClass._service,
|
26
|
+
port: SmtpClass._port,
|
27
|
+
secureConnection: SmtpClass._secure,
|
28
|
+
auth: {
|
29
|
+
user: SmtpClass._username,
|
30
|
+
pass: SmtpClass._password,
|
31
|
+
}
|
32
|
+
});
|
33
|
+
let mailOptions = {
|
34
|
+
from: params._from,
|
35
|
+
to: params._to,
|
36
|
+
subject: params._subject,
|
37
|
+
text: params._text
|
38
|
+
};
|
39
|
+
if (params._filenames) {
|
40
|
+
let attachments = [];
|
41
|
+
if (Array.isArray(params._filenames)) {
|
42
|
+
params._filenames.forEach(v => {
|
43
|
+
const fileName = path.basename(v);
|
44
|
+
attachments.push({
|
45
|
+
filename: fileName,
|
46
|
+
path: v
|
47
|
+
});
|
48
|
+
});
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
const fileName = path.basename(params._filenames);
|
52
|
+
attachments = [
|
53
|
+
{
|
54
|
+
filename: fileName,
|
55
|
+
path: params._filenames
|
56
|
+
}
|
57
|
+
];
|
58
|
+
}
|
59
|
+
mailOptions['attachments'] = attachments;
|
60
|
+
}
|
61
|
+
return new Promise((resolve, reject) => {
|
62
|
+
transporter.sendMail(mailOptions, (error, info) => {
|
63
|
+
if (error) {
|
64
|
+
reject(error);
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
resolve(info);
|
68
|
+
}
|
69
|
+
});
|
70
|
+
});
|
71
|
+
});
|
72
|
+
}
|
73
|
+
}
|
74
|
+
SmtpClass._host = process.env.SMTP_HOST;
|
75
|
+
SmtpClass._port = Number(process.env.SMTP_PORT);
|
76
|
+
SmtpClass._username = process.env.SMTP_USERNAME;
|
77
|
+
SmtpClass._password = process.env.SMTP_PASSWORD;
|
78
|
+
SmtpClass._netType = process.env.SMTP_NETTYPE;
|
79
|
+
SmtpClass._service = process.env.SMTP_SERVICE;
|
80
|
+
SmtpClass._secure = Boolean(process.env.SMTP_SECURE);
|
81
|
+
MR.SmtpClass = SmtpClass;
|
82
|
+
})(MR = exports.MR || (exports.MR = {}));
|
83
|
+
exports.default = MR.SmtpClass;
|