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
package/dist/MR/Http.js
ADDED
@@ -0,0 +1,121 @@
|
|
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 node_fetch_1 = require("node-fetch");
|
14
|
+
const fs = require("fs");
|
15
|
+
const Log_1 = require("./Log");
|
16
|
+
const userAgents = require('top-user-agents');
|
17
|
+
const { URLSearchParams } = require('url');
|
18
|
+
var MR;
|
19
|
+
(function (MR) {
|
20
|
+
class Http {
|
21
|
+
constructor() { }
|
22
|
+
static addContentType(headers) {
|
23
|
+
let ct = true;
|
24
|
+
if (headers) {
|
25
|
+
var keys = Object.keys(headers);
|
26
|
+
if (keys.includes("Content-Type")) {
|
27
|
+
ct = false;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (ct) {
|
31
|
+
headers['Content-Type'] = 'application/json';
|
32
|
+
}
|
33
|
+
return headers;
|
34
|
+
}
|
35
|
+
static getUserAgent() {
|
36
|
+
return userAgents;
|
37
|
+
}
|
38
|
+
static addUserAgent(headers) {
|
39
|
+
let ua = true;
|
40
|
+
if (headers) {
|
41
|
+
var keys = Object.keys(headers);
|
42
|
+
if (keys.includes("User-Agent")) {
|
43
|
+
ua = false;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
if (ua) {
|
47
|
+
const userAgent = userAgents[0];
|
48
|
+
headers['User-Agent'] = userAgent.toString();
|
49
|
+
}
|
50
|
+
return headers;
|
51
|
+
}
|
52
|
+
static get(params) {
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
54
|
+
Log_1.default.debug("Http.get", params);
|
55
|
+
const response = yield (0, node_fetch_1.default)(params._url, {
|
56
|
+
method: 'get',
|
57
|
+
headers: Http.addUserAgent(params._headers)
|
58
|
+
});
|
59
|
+
return yield response.text();
|
60
|
+
});
|
61
|
+
}
|
62
|
+
static post(params) {
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
64
|
+
Log_1.default.debug("Http.post", params);
|
65
|
+
let headers = Http.addContentType(params._headers);
|
66
|
+
const response = yield (0, node_fetch_1.default)(params._url, {
|
67
|
+
method: 'post',
|
68
|
+
body: JSON.stringify(params._body),
|
69
|
+
headers: Http.addUserAgent(headers)
|
70
|
+
});
|
71
|
+
const data = yield response.text();
|
72
|
+
return data;
|
73
|
+
});
|
74
|
+
}
|
75
|
+
static form(params) {
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
77
|
+
Log_1.default.debug("Http.form", params);
|
78
|
+
const param = new URLSearchParams();
|
79
|
+
Object.keys(params._body).forEach((key) => {
|
80
|
+
param.append(key, params._body[key]);
|
81
|
+
});
|
82
|
+
const response = yield (0, node_fetch_1.default)(params._url, {
|
83
|
+
method: params._method || 'POST',
|
84
|
+
body: param,
|
85
|
+
headers: Http.addUserAgent(params._headers)
|
86
|
+
});
|
87
|
+
const data = yield response.text();
|
88
|
+
return data;
|
89
|
+
});
|
90
|
+
}
|
91
|
+
static parseCookies(params) {
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
93
|
+
Log_1.default.debug("Http.parseCookies", params);
|
94
|
+
const raw = params._response.headers.raw()['set-cookie'];
|
95
|
+
return raw.map((entry) => {
|
96
|
+
const parts = entry.split(';');
|
97
|
+
const cookiePart = parts[0];
|
98
|
+
return cookiePart;
|
99
|
+
}).join(';');
|
100
|
+
});
|
101
|
+
}
|
102
|
+
static download(params) {
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
104
|
+
Log_1.default.debug("Http.download", params);
|
105
|
+
const res = yield (0, node_fetch_1.default)(params._url);
|
106
|
+
const fileStream = fs.createWriteStream(params._filename);
|
107
|
+
return new Promise((resolve, reject) => {
|
108
|
+
res.body.pipe(fileStream);
|
109
|
+
res.body.on("error", (err) => {
|
110
|
+
reject(err);
|
111
|
+
});
|
112
|
+
fileStream.on("finish", () => {
|
113
|
+
resolve();
|
114
|
+
});
|
115
|
+
});
|
116
|
+
});
|
117
|
+
}
|
118
|
+
}
|
119
|
+
MR.Http = Http;
|
120
|
+
})(MR = exports.MR || (exports.MR = {}));
|
121
|
+
exports.default = MR.Http;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class ImapClass {
|
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 receive(): Promise<any>;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
declare const _default: typeof MR.ImapClass;
|
15
|
+
export default _default;
|
package/dist/MR/Imap.js
ADDED
@@ -0,0 +1,52 @@
|
|
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 MailListener = require('mail-listener2');
|
14
|
+
const Log_1 = require("./Log");
|
15
|
+
var MR;
|
16
|
+
(function (MR) {
|
17
|
+
class ImapClass {
|
18
|
+
constructor() { }
|
19
|
+
static receive() {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const config = {
|
22
|
+
username: ImapClass._username,
|
23
|
+
password: ImapClass._password,
|
24
|
+
host: ImapClass._host,
|
25
|
+
port: ImapClass._port,
|
26
|
+
tls: ImapClass._secure
|
27
|
+
};
|
28
|
+
Log_1.default.debug("ImapClass.receive", config);
|
29
|
+
const mailListener = new MailListener(config);
|
30
|
+
// 启动邮件监听器并返回 Promise
|
31
|
+
return new Promise((resolve, reject) => {
|
32
|
+
mailListener.on('mail', (mail, seqno, attributes) => {
|
33
|
+
resolve(mail);
|
34
|
+
});
|
35
|
+
mailListener.on('error', (err) => {
|
36
|
+
reject(err);
|
37
|
+
});
|
38
|
+
mailListener.start();
|
39
|
+
});
|
40
|
+
});
|
41
|
+
}
|
42
|
+
}
|
43
|
+
ImapClass._host = process.env.IMAP_HOST;
|
44
|
+
ImapClass._port = Number(process.env.IMAP_PORT);
|
45
|
+
ImapClass._username = process.env.IMAP_USERNAME;
|
46
|
+
ImapClass._password = process.env.IMAP_PASSWORD;
|
47
|
+
ImapClass._netType = process.env.IMAP_NETTYPE;
|
48
|
+
ImapClass._service = process.env.IMAP_SERVICE;
|
49
|
+
ImapClass._secure = Boolean(process.env.IMAP_SECURE);
|
50
|
+
MR.ImapClass = ImapClass;
|
51
|
+
})(MR = exports.MR || (exports.MR = {}));
|
52
|
+
exports.default = MR.ImapClass;
|
package/dist/MR/Ini.d.ts
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class Ini {
|
3
|
+
private constructor();
|
4
|
+
static readFile(params: {
|
5
|
+
_filename: string;
|
6
|
+
}): any;
|
7
|
+
static writeFile(params: {
|
8
|
+
_iniobj: any;
|
9
|
+
_filename: string;
|
10
|
+
_section?: string;
|
11
|
+
}): void;
|
12
|
+
static getValue(params: {
|
13
|
+
_config: any;
|
14
|
+
_key: string;
|
15
|
+
_section?: string;
|
16
|
+
}): any;
|
17
|
+
static setValue(params: {
|
18
|
+
_config: any;
|
19
|
+
_key: string;
|
20
|
+
_value: string;
|
21
|
+
_section?: string;
|
22
|
+
}): void;
|
23
|
+
static delete(params: {
|
24
|
+
_config: any;
|
25
|
+
_key: string;
|
26
|
+
_section?: string;
|
27
|
+
}): void;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
declare const _default: typeof MR.Ini;
|
31
|
+
export default _default;
|
package/dist/MR/Ini.js
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MR = void 0;
|
4
|
+
const fs = require("fs");
|
5
|
+
const Log_1 = require("./Log");
|
6
|
+
const _ini = require('ini');
|
7
|
+
var MR;
|
8
|
+
(function (MR) {
|
9
|
+
class Ini {
|
10
|
+
constructor() { }
|
11
|
+
static readFile(params) {
|
12
|
+
Log_1.default.debug("Ini.readFile", params);
|
13
|
+
const config = _ini.parse(fs.readFileSync(params._filename, 'utf-8'));
|
14
|
+
return config;
|
15
|
+
}
|
16
|
+
static writeFile(params) {
|
17
|
+
Log_1.default.debug("Ini.writeFile", params);
|
18
|
+
fs.writeFileSync(params._filename, _ini.stringify(params._iniobj, { section: params._section }));
|
19
|
+
}
|
20
|
+
static getValue(params) {
|
21
|
+
Log_1.default.debug("Ini.getValue", params);
|
22
|
+
const __key = params._key;
|
23
|
+
if (params._section !== undefined) {
|
24
|
+
const __section = params._section;
|
25
|
+
return (params._config).__section.__key;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
return (params._config).__key;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
static setValue(params) {
|
32
|
+
Log_1.default.debug("Ini.setValue", params);
|
33
|
+
const __key = params._key;
|
34
|
+
if (params._section !== undefined) {
|
35
|
+
(params._config).params.section.__key = params._value;
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
(params._config).__key = params._value;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
static delete(params) {
|
42
|
+
Log_1.default.debug("Ini.delete", params);
|
43
|
+
const __key = params._key;
|
44
|
+
if (params._section !== undefined) {
|
45
|
+
const __section = params._section;
|
46
|
+
delete (params._config).__section.__key;
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
delete (params._config).__key;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
MR.Ini = Ini;
|
54
|
+
})(MR = exports.MR || (exports.MR = {}));
|
55
|
+
exports.default = MR.Ini;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
export declare namespace MR {
|
2
|
+
class Keyboard {
|
3
|
+
private constructor();
|
4
|
+
static get(): Promise<import("@nut-tree/nut-js").KeyboardClass>;
|
5
|
+
private static isFileExist;
|
6
|
+
private static copyFile;
|
7
|
+
static password(params: {
|
8
|
+
_msg: string;
|
9
|
+
_debug?: boolean;
|
10
|
+
}): Promise<void>;
|
11
|
+
static str(params: {
|
12
|
+
_msg: string;
|
13
|
+
}): Promise<import("@nut-tree/nut-js").KeyboardClass>;
|
14
|
+
private static convert;
|
15
|
+
static press(params: {
|
16
|
+
_key: string;
|
17
|
+
}): Promise<void>;
|
18
|
+
static hotkey(params: {
|
19
|
+
_keys: string[];
|
20
|
+
}): Promise<void>;
|
21
|
+
static Win_D(): Promise<void>;
|
22
|
+
static Alt_F4(): Promise<void>;
|
23
|
+
static Ctrl_C(): Promise<void>;
|
24
|
+
static Ctrl_V(): Promise<void>;
|
25
|
+
static Ctrl_Shift(): Promise<void>;
|
26
|
+
static Home(): Promise<void>;
|
27
|
+
static End(): Promise<void>;
|
28
|
+
static Down(): Promise<void>;
|
29
|
+
static Left(): Promise<void>;
|
30
|
+
static Up(): Promise<void>;
|
31
|
+
static Right(): Promise<void>;
|
32
|
+
static CapsLock(): Promise<void>;
|
33
|
+
static Shift(): Promise<void>;
|
34
|
+
static Ctrl(): Promise<void>;
|
35
|
+
static Alt(): Promise<void>;
|
36
|
+
static Tab(): Promise<void>;
|
37
|
+
static Space(): Promise<void>;
|
38
|
+
static Backspace(): Promise<void>;
|
39
|
+
static Delete(): Promise<void>;
|
40
|
+
static Enter(): Promise<void>;
|
41
|
+
static Escape(): Promise<void>;
|
42
|
+
static F1(): Promise<void>;
|
43
|
+
static F2(): Promise<void>;
|
44
|
+
static F3(): Promise<void>;
|
45
|
+
static F4(): Promise<void>;
|
46
|
+
static F5(): Promise<void>;
|
47
|
+
static F6(): Promise<void>;
|
48
|
+
static F7(): Promise<void>;
|
49
|
+
static F8(): Promise<void>;
|
50
|
+
static F9(): Promise<void>;
|
51
|
+
static F10(): Promise<void>;
|
52
|
+
static F11(): Promise<void>;
|
53
|
+
static F12(): Promise<void>;
|
54
|
+
private static getKeyEnum;
|
55
|
+
private static InnerKeyEnums;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
declare const _default: typeof MR.Keyboard;
|
59
|
+
export default _default;
|