@maaxyz/maa-node 4.0.0-alpha.2 → 4.0.0-beta.2
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/dist/client.d.ts +11 -0
- package/dist/context.d.ts +0 -1
- package/dist/global.d.ts +2 -1
- package/dist/{index.d.ts → index-client.d.ts} +2 -0
- package/dist/{index.js → index-client.js} +73 -24
- package/dist/index-server.d.ts +11 -0
- package/dist/index-server.js +1079 -0
- package/dist/maa.d.ts +33 -3
- package/dist/server.d.ts +7 -0
- package/package.json +16 -12
- package/scripts/build.mjs +1 -1
- package/src/client.ts +44 -0
- package/src/context.ts +1 -5
- package/src/{index.ts → index-client.ts} +4 -0
- package/src/index-server.ts +13 -0
- package/src/maa-client.js +24 -0
- package/src/maa-server.js +24 -0
- package/src/maa.d.ts +33 -3
- package/src/maa.js +0 -26
- package/src/pi.ts +15 -11
- package/src/server.ts +56 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as maa from './maa';
|
|
2
|
+
import { Resource } from './resource';
|
|
3
|
+
export declare class AgentClient {
|
|
4
|
+
handle: maa.AgentClientHandle;
|
|
5
|
+
constructor();
|
|
6
|
+
destroy(): void;
|
|
7
|
+
bind_resource(resource: Resource): void;
|
|
8
|
+
create_socket(identifier: string | null): string;
|
|
9
|
+
connect(): void;
|
|
10
|
+
disconnect(): void;
|
|
11
|
+
}
|
package/dist/context.d.ts
CHANGED
package/dist/global.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as maa from './maa';
|
|
1
2
|
export declare const Global: {
|
|
2
3
|
readonly version: string;
|
|
3
4
|
log_dir: string;
|
|
4
5
|
save_draw: boolean;
|
|
5
6
|
recording: boolean;
|
|
6
|
-
stdout_level:
|
|
7
|
+
stdout_level: keyof typeof maa.LoggingLevel;
|
|
7
8
|
show_hit_draw: boolean;
|
|
8
9
|
debug_mode: boolean;
|
|
9
10
|
config_init_option(user_path: string, default_json?: string): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import './maa-client.js';
|
|
1
2
|
export * as api from './maa';
|
|
2
3
|
export * from './controller';
|
|
3
4
|
export * from './resource';
|
|
@@ -7,3 +8,4 @@ export * from './global';
|
|
|
7
8
|
export * from './pi';
|
|
8
9
|
export * from './types';
|
|
9
10
|
export * from './pipeline';
|
|
11
|
+
export * from './client';
|
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/maa.js
|
|
34
|
-
var
|
|
35
|
-
"src/maa.js"(exports2, module2) {
|
|
33
|
+
// src/maa-client.js
|
|
34
|
+
var require_maa_client = __commonJS({
|
|
35
|
+
"src/maa-client.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
37
|
if (!globalThis.MaaAPI) {
|
|
38
38
|
switch (`${process.platform}-${process.arch}`) {
|
|
@@ -60,10 +60,19 @@ var require_maa = __commonJS({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
// src/
|
|
64
|
-
var
|
|
65
|
-
|
|
63
|
+
// src/maa.js
|
|
64
|
+
var require_maa = __commonJS({
|
|
65
|
+
"src/maa.js"(exports2, module2) {
|
|
66
|
+
"use strict";
|
|
67
|
+
module2.exports = globalThis.MaaAPI;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/index-client.ts
|
|
72
|
+
var index_client_exports = {};
|
|
73
|
+
__export(index_client_exports, {
|
|
66
74
|
AdbController: () => AdbController,
|
|
75
|
+
AgentClient: () => AgentClient,
|
|
67
76
|
Context: () => Context,
|
|
68
77
|
ControllerBase: () => ControllerBase,
|
|
69
78
|
CustomController: () => CustomController,
|
|
@@ -80,7 +89,8 @@ __export(src_exports, {
|
|
|
80
89
|
api: () => api,
|
|
81
90
|
pp: () => pp
|
|
82
91
|
});
|
|
83
|
-
module.exports = __toCommonJS(
|
|
92
|
+
module.exports = __toCommonJS(index_client_exports);
|
|
93
|
+
var import_maa_client = __toESM(require_maa_client());
|
|
84
94
|
var api = __toESM(require_maa());
|
|
85
95
|
|
|
86
96
|
// src/controller.ts
|
|
@@ -557,11 +567,7 @@ var Context = class _Context {
|
|
|
557
567
|
this.#tasker = new TaskerBase(maa4.context_get_tasker(this.handle));
|
|
558
568
|
}
|
|
559
569
|
async run_task(entry, pipeline_override = {}) {
|
|
560
|
-
const id = await maa4.context_run_task(
|
|
561
|
-
this.handle,
|
|
562
|
-
entry,
|
|
563
|
-
JSON.stringify(pipeline_override)
|
|
564
|
-
);
|
|
570
|
+
const id = await maa4.context_run_task(this.handle, entry, JSON.stringify(pipeline_override));
|
|
565
571
|
return this.#tasker.task_detail(id);
|
|
566
572
|
}
|
|
567
573
|
async run_recognition(entry, image, pipeline_override = {}) {
|
|
@@ -790,18 +796,22 @@ var Pi = {
|
|
|
790
796
|
notify(message, details_json) {
|
|
791
797
|
},
|
|
792
798
|
register_custom_recognizer(id, name, func) {
|
|
793
|
-
maa7.pi_register_custom_recognizer(
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
799
|
+
maa7.pi_register_custom_recognizer(
|
|
800
|
+
id,
|
|
801
|
+
name,
|
|
802
|
+
(context, id2, task, name2, param, image, roi) => {
|
|
803
|
+
const self = {
|
|
804
|
+
context: new Context(context),
|
|
805
|
+
id: id2,
|
|
806
|
+
task,
|
|
807
|
+
name: name2,
|
|
808
|
+
param: JSON.parse(param),
|
|
809
|
+
image,
|
|
810
|
+
roi
|
|
811
|
+
};
|
|
812
|
+
return func.apply(self, [self]);
|
|
813
|
+
}
|
|
814
|
+
);
|
|
805
815
|
},
|
|
806
816
|
register_custom_action(id, name, func) {
|
|
807
817
|
maa7.pi_register_custom_action(id, name, (context, id2, task, name2, param, recoId, box) => {
|
|
@@ -1000,9 +1010,48 @@ function pp() {
|
|
|
1000
1010
|
);
|
|
1001
1011
|
return self;
|
|
1002
1012
|
}
|
|
1013
|
+
|
|
1014
|
+
// src/client.ts
|
|
1015
|
+
var maa8 = __toESM(require_maa());
|
|
1016
|
+
var AgentClient = class {
|
|
1017
|
+
handle;
|
|
1018
|
+
constructor() {
|
|
1019
|
+
const h = maa8.agent_client_create();
|
|
1020
|
+
if (!h) {
|
|
1021
|
+
throw "AgentClient create failed";
|
|
1022
|
+
}
|
|
1023
|
+
this.handle = h;
|
|
1024
|
+
}
|
|
1025
|
+
destroy() {
|
|
1026
|
+
maa8.agent_client_destroy(this.handle);
|
|
1027
|
+
}
|
|
1028
|
+
bind_resource(resource) {
|
|
1029
|
+
if (!maa8.agent_client_bind_resource(this.handle, resource.handle)) {
|
|
1030
|
+
throw "AgentClient bind resource failed";
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
create_socket(identifier) {
|
|
1034
|
+
const rid = maa8.agent_client_create_socket(this.handle, identifier);
|
|
1035
|
+
if (rid === null) {
|
|
1036
|
+
throw "AgentClient create socket failed";
|
|
1037
|
+
}
|
|
1038
|
+
return rid;
|
|
1039
|
+
}
|
|
1040
|
+
connect() {
|
|
1041
|
+
if (!maa8.agent_client_connect(this.handle)) {
|
|
1042
|
+
throw "AgentClient connect failed";
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
disconnect() {
|
|
1046
|
+
if (!maa8.agent_client_disconnect(this.handle)) {
|
|
1047
|
+
throw "AgentClient disconnect failed";
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1003
1051
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1004
1052
|
0 && (module.exports = {
|
|
1005
1053
|
AdbController,
|
|
1054
|
+
AgentClient,
|
|
1006
1055
|
Context,
|
|
1007
1056
|
ControllerBase,
|
|
1008
1057
|
CustomController,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './maa-server.js';
|
|
2
|
+
export * as api from './maa';
|
|
3
|
+
export * from './controller';
|
|
4
|
+
export * from './resource';
|
|
5
|
+
export * from './tasker';
|
|
6
|
+
export * from './context';
|
|
7
|
+
export * from './global';
|
|
8
|
+
export * from './pi';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export * from './pipeline';
|
|
11
|
+
export * from './server';
|