@maaxyz/maa-node 2.2.2-post.14-ci.12068666732 → 2.3.0-alpha.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/index.js CHANGED
@@ -638,18 +638,21 @@ var ResourceBase = class {
638
638
  import_maa3.default.resource_destroy(this.handle);
639
639
  }
640
640
  set inference_device(id) {
641
- switch (id) {
642
- case "cpu":
643
- id = -2;
644
- break;
645
- case "auto":
646
- id = -1;
647
- break;
641
+ if (typeof id === "string") {
642
+ id = import_maa3.default.InferenceDevice[id];
648
643
  }
649
644
  if (!import_maa3.default.resource_set_option_inference_device(this.handle, id)) {
650
645
  throw "Resource set inference_device failed";
651
646
  }
652
647
  }
648
+ set inference_execution_provider(provider) {
649
+ if (!import_maa3.default.resource_set_option_inference_execution_provider(
650
+ this.handle,
651
+ import_maa3.default.InferenceExecutionProvider[provider]
652
+ )) {
653
+ throw "Resource set inference_execution_provider failed";
654
+ }
655
+ }
653
656
  register_custom_recognizer(name, func) {
654
657
  if (!import_maa3.default.resource_register_custom_recognition(
655
658
  this.handle,
package/dist/maa.d.ts CHANGED
@@ -16,6 +16,8 @@ export type NodeId = Id & { __brand: 'NodeId' }
16
16
 
17
17
  export type Status = number & { __brand: 'Status' }
18
18
  export type LoggingLevel = number & { __brand: 'LoggingLevel' }
19
+ export type InferenceDevice = number & { __brand: 'InferenceDevice' }
20
+ export type InferenceExecutionProvider = number & { __brand: 'InferenceExecutionProvider' }
19
21
 
20
22
  export type ImageData = ArrayBuffer
21
23
 
@@ -195,7 +197,11 @@ export declare function resource_create(
195
197
  export declare function resource_destroy(handle: ResourceHandle): void
196
198
  export declare function resource_set_option_inference_device(
197
199
  handle: ResourceHandle,
198
- id: number
200
+ id: InferenceDevice | number
201
+ ): boolean
202
+ export declare function resource_set_option_inference_execution_provider(
203
+ handle: ResourceHandle,
204
+ provider: InferenceExecutionProvider
199
205
  ): boolean
200
206
  export declare function resource_register_custom_recognition(
201
207
  handle: ResourceHandle,
@@ -363,3 +369,8 @@ export declare const Win32ScreencapMethod: Record<
363
369
  >
364
370
  export declare const Win32InputMethod: Record<'Seize' | 'SendMessage', ScreencapOrInputMethods>
365
371
  export declare const DbgControllerType: Record<'CarouselImage' | 'ReplayRecording', Uint64>
372
+ export declare const InferenceDevice: Record<'CPU' | 'Auto', InferenceDevice>
373
+ export declare const InferenceExecutionProvider: Record<
374
+ 'Auto' | 'CPU' | 'DirectML' | 'CoreML' | 'CUDA',
375
+ InferenceExecutionProvider
376
+ >
@@ -17,7 +17,8 @@ export declare class ResourceBase {
17
17
  set parsed_notify(cb: (msg: ResourceNotify) => maa.MaybePromise<void>);
18
18
  constructor(handle: maa.ResourceHandle);
19
19
  destroy(): void;
20
- set inference_device(id: 'cpu' | 'auto' | number);
20
+ set inference_device(id: keyof typeof maa.InferenceDevice | number);
21
+ set inference_execution_provider(provider: keyof typeof maa.InferenceExecutionProvider);
21
22
  register_custom_recognizer(name: string, func: CustomRecognizerCallback): void;
22
23
  unregister_custom_recognizer(name: string): void;
23
24
  clear_custom_recognizer(): void;
package/package.json CHANGED
@@ -21,13 +21,13 @@
21
21
  "prettier": "^3.3.2",
22
22
  "typescript": "^5.4.5"
23
23
  },
24
- "version": "2.2.2-post.14-ci.12068666732",
24
+ "version": "2.3.0-alpha.2",
25
25
  "optionalDependencies": {
26
- "@maaxyz/maa-node-darwin-arm64": "2.2.2-post.14-ci.12068666732",
27
- "@maaxyz/maa-node-darwin-x64": "2.2.2-post.14-ci.12068666732",
28
- "@maaxyz/maa-node-linux-arm64": "2.2.2-post.14-ci.12068666732",
29
- "@maaxyz/maa-node-linux-x64": "2.2.2-post.14-ci.12068666732",
30
- "@maaxyz/maa-node-win32-arm64": "2.2.2-post.14-ci.12068666732",
31
- "@maaxyz/maa-node-win32-x64": "2.2.2-post.14-ci.12068666732"
26
+ "@maaxyz/maa-node-darwin-arm64": "2.3.0-alpha.2",
27
+ "@maaxyz/maa-node-darwin-x64": "2.3.0-alpha.2",
28
+ "@maaxyz/maa-node-linux-arm64": "2.3.0-alpha.2",
29
+ "@maaxyz/maa-node-linux-x64": "2.3.0-alpha.2",
30
+ "@maaxyz/maa-node-win32-arm64": "2.3.0-alpha.2",
31
+ "@maaxyz/maa-node-win32-x64": "2.3.0-alpha.2"
32
32
  }
33
33
  }
package/src/maa.d.ts CHANGED
@@ -16,6 +16,8 @@ export type NodeId = Id & { __brand: 'NodeId' }
16
16
 
17
17
  export type Status = number & { __brand: 'Status' }
18
18
  export type LoggingLevel = number & { __brand: 'LoggingLevel' }
19
+ export type InferenceDevice = number & { __brand: 'InferenceDevice' }
20
+ export type InferenceExecutionProvider = number & { __brand: 'InferenceExecutionProvider' }
19
21
 
20
22
  export type ImageData = ArrayBuffer
21
23
 
@@ -195,7 +197,11 @@ export declare function resource_create(
195
197
  export declare function resource_destroy(handle: ResourceHandle): void
196
198
  export declare function resource_set_option_inference_device(
197
199
  handle: ResourceHandle,
198
- id: number
200
+ id: InferenceDevice | number
201
+ ): boolean
202
+ export declare function resource_set_option_inference_execution_provider(
203
+ handle: ResourceHandle,
204
+ provider: InferenceExecutionProvider
199
205
  ): boolean
200
206
  export declare function resource_register_custom_recognition(
201
207
  handle: ResourceHandle,
@@ -363,3 +369,8 @@ export declare const Win32ScreencapMethod: Record<
363
369
  >
364
370
  export declare const Win32InputMethod: Record<'Seize' | 'SendMessage', ScreencapOrInputMethods>
365
371
  export declare const DbgControllerType: Record<'CarouselImage' | 'ReplayRecording', Uint64>
372
+ export declare const InferenceDevice: Record<'CPU' | 'Auto', InferenceDevice>
373
+ export declare const InferenceExecutionProvider: Record<
374
+ 'Auto' | 'CPU' | 'DirectML' | 'CoreML' | 'CUDA',
375
+ InferenceExecutionProvider
376
+ >
package/src/resource.ts CHANGED
@@ -45,20 +45,26 @@ export class ResourceBase {
45
45
  maa.resource_destroy(this.handle)
46
46
  }
47
47
 
48
- set inference_device(id: 'cpu' | 'auto' | number) {
49
- switch (id) {
50
- case 'cpu':
51
- id = -2
52
- break
53
- case 'auto':
54
- id = -1
55
- break
48
+ set inference_device(id: keyof typeof maa.InferenceDevice | number) {
49
+ if (typeof id === 'string') {
50
+ id = maa.InferenceDevice[id]
56
51
  }
57
52
  if (!maa.resource_set_option_inference_device(this.handle, id)) {
58
53
  throw 'Resource set inference_device failed'
59
54
  }
60
55
  }
61
56
 
57
+ set inference_execution_provider(provider: keyof typeof maa.InferenceExecutionProvider) {
58
+ if (
59
+ !maa.resource_set_option_inference_execution_provider(
60
+ this.handle,
61
+ maa.InferenceExecutionProvider[provider]
62
+ )
63
+ ) {
64
+ throw 'Resource set inference_execution_provider failed'
65
+ }
66
+ }
67
+
62
68
  register_custom_recognizer(name: string, func: CustomRecognizerCallback) {
63
69
  if (
64
70
  !maa.resource_register_custom_recognition(