MaaFw 4.5.6__py3-none-win_arm64.whl → 5.0.0a2__py3-none-win_arm64.whl

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.

Potentially problematic release.


This version of MaaFw might be problematic. Click here for more details.

maa/tasker.py CHANGED
@@ -7,13 +7,12 @@ from .define import *
7
7
  from .library import Library
8
8
  from .buffer import ImageListBuffer, RectBuffer, StringBuffer, ImageBuffer
9
9
  from .job import Job, JobWithResult
10
- from .notification_handler import NotificationHandler
10
+ from .event_sink import EventSink, NotificationType
11
11
  from .resource import Resource
12
12
  from .controller import Controller
13
13
 
14
14
 
15
15
  class Tasker:
16
- _notification_handler: Optional[NotificationHandler]
17
16
  _handle: MaaTaskerHandle
18
17
  _own: bool
19
18
 
@@ -21,19 +20,21 @@ class Tasker:
21
20
 
22
21
  def __init__(
23
22
  self,
24
- notification_handler: Optional[NotificationHandler] = None,
23
+ notification_handler: None = None,
25
24
  handle: Optional[MaaTaskerHandle] = None,
26
25
  ):
26
+ if notification_handler:
27
+ raise NotImplementedError(
28
+ "NotificationHandler is deprecated, use add_sink, add_context_sink instead."
29
+ )
30
+
27
31
  self._set_api_properties()
28
32
 
29
33
  if handle:
30
34
  self._handle = handle
31
35
  self._own = False
32
36
  else:
33
- self._notification_handler = notification_handler
34
- self._handle = Library.framework().MaaTaskerCreate(
35
- *NotificationHandler._gen_c_param(self._notification_handler)
36
- )
37
+ self._handle = Library.framework().MaaTaskerCreate()
37
38
  self._own = True
38
39
 
39
40
  if not self._handle:
@@ -112,64 +113,55 @@ class Tasker:
112
113
  def clear_cache(self) -> bool:
113
114
  return bool(Library.framework().MaaTaskerClearCache(self._handle))
114
115
 
115
- @staticmethod
116
- def set_log_dir(path: Union[Path, str]) -> bool:
117
- strpath = str(path)
118
- return bool(
119
- Library.framework().MaaSetGlobalOption(
120
- MaaOption(MaaGlobalOptionEnum.LogDir),
121
- strpath.encode(),
122
- len(strpath),
123
- )
124
- )
116
+ _sink_holder: Dict[int, "TaskerEventSink"] = {}
125
117
 
126
- @staticmethod
127
- def set_save_draw(save_draw: bool) -> bool:
128
- cbool = ctypes.c_bool(save_draw)
129
- return bool(
130
- Library.framework().MaaSetGlobalOption(
131
- MaaOption(MaaGlobalOptionEnum.SaveDraw),
132
- ctypes.pointer(cbool),
133
- ctypes.sizeof(ctypes.c_bool),
118
+ def add_sink(self, sink: "TaskerEventSink") -> Optional[int]:
119
+ sink_id = int(
120
+ Library.framework().MaaTaskerAddSink(
121
+ self._handle, *EventSink._gen_c_param(sink)
134
122
  )
135
123
  )
124
+ if sink_id == MaaInvalidId:
125
+ return None
136
126
 
137
- @staticmethod
138
- def set_recording(recording: bool) -> bool:
139
- """
140
- Deprecated
141
- """
142
- return False
127
+ self._sink_holder[sink_id] = sink
128
+ return sink_id
143
129
 
144
- @staticmethod
145
- def set_stdout_level(level: LoggingLevelEnum) -> bool:
146
- clevel = MaaLoggingLevel(level)
147
- return bool(
148
- Library.framework().MaaSetGlobalOption(
149
- MaaOption(MaaGlobalOptionEnum.StdoutLevel),
150
- ctypes.pointer(clevel),
151
- ctypes.sizeof(MaaLoggingLevel),
152
- )
153
- )
130
+ def remove_sink(self, sink_id: int) -> None:
131
+ Library.framework().MaaTaskerRemoveSink(self._handle, sink_id)
132
+ self._sink_holder.pop(sink_id)
154
133
 
155
- @staticmethod
156
- def set_debug_mode(debug_mode: bool) -> bool:
157
- cbool = ctypes.c_bool(debug_mode)
158
- return bool(
159
- Library.framework().MaaSetGlobalOption(
160
- MaaOption(MaaGlobalOptionEnum.DebugMode),
161
- ctypes.pointer(cbool),
162
- ctypes.sizeof(ctypes.c_bool),
134
+ def clear_sinks(self) -> None:
135
+ Library.framework().MaaTaskerClearSinks(self._handle)
136
+
137
+ def add_context_sink(self, sink: "ContextEventSink") -> Optional[int]:
138
+ sink_id = int(
139
+ Library.framework().MaaTaskerAddContextSink(
140
+ self._handle, *EventSink._gen_c_param(sink)
163
141
  )
164
142
  )
143
+ if sink_id == MaaInvalidId:
144
+ return None
145
+
146
+ self._sink_holder[sink_id] = sink
147
+ return sink_id
148
+
149
+ def remove_context_sink(self, sink_id: int) -> None:
150
+ Library.framework().MaaTaskerRemoveContextSink(self._handle, sink_id)
151
+ self._sink_holder.pop(sink_id)
152
+
153
+ def clear_context_sinks(self) -> None:
154
+ Library.framework().MaaTaskerClearContextSinks(self._handle)
165
155
 
166
156
  ### private ###
167
157
 
168
158
  @staticmethod
169
159
  def _gen_post_param(entry: str, pipeline_override: Dict) -> Tuple[bytes, bytes]:
160
+ pipeline_json = json.dumps(pipeline_override, ensure_ascii=False)
161
+
170
162
  return (
171
163
  entry.encode(),
172
- json.dumps(pipeline_override, ensure_ascii=False).encode(),
164
+ pipeline_json.encode(),
173
165
  )
174
166
 
175
167
  def _gen_task_job(self, taskid: MaaTaskId) -> JobWithResult:
@@ -188,7 +180,7 @@ class Tasker:
188
180
 
189
181
  def get_recognition_detail(self, reco_id: int) -> Optional[RecognitionDetail]:
190
182
  name = StringBuffer()
191
- algorithm = StringBuffer()
183
+ algorithm = StringBuffer() # type: ignore
192
184
  hit = MaaBool()
193
185
  box = RectBuffer()
194
186
  detail_json = StringBuffer()
@@ -296,6 +288,66 @@ class Tasker:
296
288
  task_id=task_id, entry=entry.get(), nodes=nodes, status=Status(status)
297
289
  )
298
290
 
291
+ @staticmethod
292
+ def set_log_dir(path: Union[Path, str]) -> bool:
293
+ strpath = str(path)
294
+ return bool(
295
+ Library.framework().MaaGlobalSetOption(
296
+ MaaOption(MaaGlobalOptionEnum.LogDir),
297
+ strpath.encode(),
298
+ len(strpath),
299
+ )
300
+ )
301
+
302
+ @staticmethod
303
+ def set_save_draw(save_draw: bool) -> bool:
304
+ cbool = ctypes.c_bool(save_draw)
305
+ return bool(
306
+ Library.framework().MaaGlobalSetOption(
307
+ MaaOption(MaaGlobalOptionEnum.SaveDraw),
308
+ ctypes.pointer(cbool),
309
+ ctypes.sizeof(ctypes.c_bool),
310
+ )
311
+ )
312
+
313
+ @staticmethod
314
+ def set_recording(recording: bool) -> bool:
315
+ """
316
+ Deprecated
317
+ """
318
+ return False
319
+
320
+ @staticmethod
321
+ def set_stdout_level(level: LoggingLevelEnum) -> bool:
322
+ clevel = MaaLoggingLevel(level)
323
+ return bool(
324
+ Library.framework().MaaGlobalSetOption(
325
+ MaaOption(MaaGlobalOptionEnum.StdoutLevel),
326
+ ctypes.pointer(clevel),
327
+ ctypes.sizeof(MaaLoggingLevel),
328
+ )
329
+ )
330
+
331
+ @staticmethod
332
+ def set_debug_mode(debug_mode: bool) -> bool:
333
+ cbool = ctypes.c_bool(debug_mode)
334
+ return bool(
335
+ Library.framework().MaaGlobalSetOption(
336
+ MaaOption(MaaGlobalOptionEnum.DebugMode),
337
+ ctypes.pointer(cbool),
338
+ ctypes.sizeof(ctypes.c_bool),
339
+ )
340
+ )
341
+
342
+ @staticmethod
343
+ def load_plugin(path: Union[Path, str]) -> bool:
344
+ strpath = str(path)
345
+ return bool(
346
+ Library.framework().MaaGlobalLoadPlugin(
347
+ strpath.encode(),
348
+ )
349
+ )
350
+
299
351
  _api_properties_initialized: bool = False
300
352
 
301
353
  @staticmethod
@@ -330,12 +382,21 @@ class Tasker:
330
382
  return
331
383
  Tasker._api_properties_initialized = True
332
384
 
333
- Library.framework().MaaTaskerCreate.restype = MaaTaskerHandle
334
- Library.framework().MaaTaskerCreate.argtypes = [
335
- MaaNotificationCallback,
336
- ctypes.c_void_p,
385
+ Library.framework().MaaGlobalSetOption.restype = MaaBool
386
+ Library.framework().MaaGlobalSetOption.argtypes = [
387
+ MaaGlobalOption,
388
+ MaaOptionValue,
389
+ MaaOptionValueSize,
390
+ ]
391
+
392
+ Library.framework().MaaGlobalLoadPlugin.restype = MaaBool
393
+ Library.framework().MaaGlobalLoadPlugin.argtypes = [
394
+ ctypes.c_char_p,
337
395
  ]
338
396
 
397
+ Library.framework().MaaTaskerCreate.restype = MaaTaskerHandle
398
+ Library.framework().MaaTaskerCreate.argtypes = []
399
+
339
400
  Library.framework().MaaTaskerDestroy.restype = None
340
401
  Library.framework().MaaTaskerDestroy.argtypes = [MaaTaskerHandle]
341
402
 
@@ -432,9 +493,65 @@ class Tasker:
432
493
  MaaTaskerHandle,
433
494
  ]
434
495
 
435
- Library.framework().MaaSetGlobalOption.restype = MaaBool
436
- Library.framework().MaaSetGlobalOption.argtypes = [
437
- MaaGlobalOption,
438
- MaaOptionValue,
439
- MaaOptionValueSize,
496
+ Library.framework().MaaTaskerAddSink.restype = MaaSinkId
497
+ Library.framework().MaaTaskerAddSink.argtypes = [
498
+ MaaTaskerHandle,
499
+ MaaEventCallback,
500
+ ctypes.c_void_p,
501
+ ]
502
+
503
+ Library.framework().MaaTaskerRemoveSink.restype = None
504
+ Library.framework().MaaTaskerRemoveSink.argtypes = [
505
+ MaaTaskerHandle,
506
+ MaaSinkId,
507
+ ]
508
+
509
+ Library.framework().MaaTaskerClearSinks.restype = None
510
+ Library.framework().MaaTaskerClearSinks.argtypes = [MaaTaskerHandle]
511
+
512
+ Library.framework().MaaTaskerAddContextSink.restype = MaaSinkId
513
+ Library.framework().MaaTaskerAddContextSink.argtypes = [
514
+ MaaTaskerHandle,
515
+ MaaEventCallback,
516
+ ctypes.c_void_p,
440
517
  ]
518
+
519
+ Library.framework().MaaTaskerRemoveContextSink.restype = None
520
+ Library.framework().MaaTaskerRemoveContextSink.argtypes = [
521
+ MaaTaskerHandle,
522
+ MaaSinkId,
523
+ ]
524
+
525
+ Library.framework().MaaTaskerClearContextSinks.restype = None
526
+ Library.framework().MaaTaskerClearContextSinks.argtypes = [MaaTaskerHandle]
527
+
528
+
529
+ class TaskerEventSink(EventSink):
530
+
531
+ @dataclass
532
+ class TaskerTaskDetail:
533
+ task_id: int
534
+ entry: str
535
+ uuid: str
536
+ hash: str
537
+
538
+ def on_tasker_task(
539
+ self, tasker: Tasker, noti_type: NotificationType, detail: TaskerTaskDetail
540
+ ):
541
+ pass
542
+
543
+ def on_raw_notification(self, handle: ctypes.c_void_p, msg: str, details: dict):
544
+
545
+ tasker = Tasker(handle=handle)
546
+ noti_type = EventSink._notification_type(msg)
547
+
548
+ if msg.startswith("Tasker.Task"):
549
+ detail = self.TaskerTaskDetail(
550
+ task_id=details["task_id"],
551
+ entry=details["entry"],
552
+ uuid=details["uuid"],
553
+ hash=details["hash"],
554
+ )
555
+ self.on_tasker_task(tasker, noti_type, detail)
556
+ else:
557
+ self.on_unknown_notification(tasker, msg, details)
maa/toolkit.py CHANGED
@@ -3,11 +3,9 @@ import json
3
3
  from dataclasses import dataclass
4
4
  from pathlib import Path
5
5
  from typing import Dict, List, Union, Optional, Any
6
- from collections import defaultdict
7
6
 
8
7
  from .define import *
9
8
  from .library import Library
10
- from .notification_handler import NotificationHandler
11
9
 
12
10
 
13
11
  @dataclass
@@ -122,66 +120,9 @@ class Toolkit:
122
120
  Library.toolkit().MaaToolkitDesktopWindowListDestroy(list_handle)
123
121
  return windows
124
122
 
125
- @staticmethod
126
- def pi_register_custom_recognition(
127
- name: str, recognition: "CustomRecognition", inst_id: int = 0 # type: ignore
128
- ) -> None:
129
- Toolkit._set_api_properties()
130
-
131
- # avoid gc
132
- Toolkit._pi_custom_recognition_holder[inst_id][name] = recognition
133
-
134
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomRecognition(
135
- ctypes.c_uint64(inst_id),
136
- name.encode(),
137
- recognition.c_handle,
138
- recognition.c_arg,
139
- )
140
-
141
- @staticmethod
142
- def pi_register_custom_action(
143
- name: str, action: "CustomAction", inst_id: int = 0 # type: ignore
144
- ) -> None:
145
- Toolkit._set_api_properties()
146
-
147
- # avoid gc
148
- Toolkit._pi_custom_recognition_holder[inst_id][name] = action
149
-
150
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomAction(
151
- ctypes.c_uint64(inst_id),
152
- name.encode(),
153
- action.c_handle,
154
- action.c_arg,
155
- )
156
-
157
- @staticmethod
158
- def pi_run_cli(
159
- resource_path: Union[str, Path],
160
- user_path: Union[str, Path],
161
- directly: bool = False,
162
- notification_handler: Optional[NotificationHandler] = None,
163
- inst_id: int = 0,
164
- ) -> bool:
165
- Toolkit._set_api_properties()
166
-
167
- Toolkit._pi_notification_handler = notification_handler
168
-
169
- return bool(
170
- Library.toolkit().MaaToolkitProjectInterfaceRunCli(
171
- ctypes.c_uint64(inst_id),
172
- str(resource_path).encode(),
173
- str(user_path).encode(),
174
- directly,
175
- *NotificationHandler._gen_c_param(Toolkit._pi_notification_handler),
176
- )
177
- )
178
-
179
123
  ### private ###
180
124
 
181
125
  _api_properties_initialized: bool = False
182
- _pi_custom_recognition_holder = defaultdict(dict)
183
- _pi_custom_action_holder = defaultdict(dict)
184
- _pi_notification_handler: Optional[NotificationHandler] = None
185
126
 
186
127
  @staticmethod
187
128
  def _set_api_properties():
@@ -301,29 +242,3 @@ class Toolkit:
301
242
  Library.toolkit().MaaToolkitDesktopWindowGetWindowName.argtypes = [
302
243
  MaaToolkitDesktopWindowHandle
303
244
  ]
304
-
305
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomRecognition.restype = None
306
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomRecognition.argtypes = [
307
- ctypes.c_uint64,
308
- ctypes.c_char_p,
309
- MaaCustomRecognitionCallback,
310
- ctypes.c_void_p,
311
- ]
312
-
313
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomAction.restype = None
314
- Library.toolkit().MaaToolkitProjectInterfaceRegisterCustomAction.argtypes = [
315
- ctypes.c_uint64,
316
- ctypes.c_char_p,
317
- MaaCustomActionCallback,
318
- ctypes.c_void_p,
319
- ]
320
-
321
- Library.toolkit().MaaToolkitProjectInterfaceRunCli.restype = MaaBool
322
- Library.toolkit().MaaToolkitProjectInterfaceRunCli.argtypes = [
323
- ctypes.c_uint64,
324
- ctypes.c_char_p,
325
- ctypes.c_char_p,
326
- MaaBool,
327
- MaaNotificationCallback,
328
- ctypes.c_void_p,
329
- ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MaaFw
3
- Version: 4.5.6
3
+ Version: 5.0.0a2
4
4
  Summary: An automation black-box testing framework based on image recognition
5
5
  Project-URL: Homepage, https://github.com/MaaXYZ/MaaFramework
6
6
  Author: MaaXYZ
@@ -35,7 +35,7 @@ _✨ 基于图像识别的自动化黑盒测试框架 ✨_
35
35
  <img alt="activity" src="https://img.shields.io/github/commit-activity/m/MaaXYZ/MaaFramework?color=%23ff69b4">
36
36
  <img alt="stars" src="https://img.shields.io/github/stars/MaaXYZ/MaaFramework?style=social">
37
37
  <br>
38
- <a href="https://pypi.org/project/MaaFw/" target="_blank"><img alt="pypi" src="https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white"></a>
38
+ <a href="https://pypi.org/project/MaaFw/" target="_blank"><img alt="pypi" src="https://img.shields.io/pypi/dm/maafw?logo=pypi&label=PyPI"></a>
39
39
  <a href="https://www.nuget.org/packages/Maa.Framework.Runtimes" target="_blank"><img alt="nuget" src="https://img.shields.io/badge/NuGet-004880?logo=nuget"></a>
40
40
  <a href="https://www.npmjs.com/package/@maaxyz/maa-node" target="_blank"><img alt="npm" src="https://img.shields.io/badge/npm-CB3837?logo=npm"></a>
41
41
  <a href="https://mirrorchyan.com/zh/projects?source=maafw-badge" target="_blank"><img alt="mirrorc" src="https://img.shields.io/badge/Mirror%E9%85%B1-%239af3f6?logo=countingworkspro&logoColor=4f46e5"></a>
@@ -55,6 +55,9 @@ _✨ 基于图像识别的自动化黑盒测试框架 ✨_
55
55
 
56
56
  ## 即刻开始
57
57
 
58
+ > [!TIP]
59
+ > 访问我们的 [官网](https://maafw.xyz/) 以获得更优秀的文档阅读体验。
60
+
58
61
  - [快速开始](docs/zh_cn/1.1-快速开始.md)
59
62
  - [集成文档](docs/zh_cn/2.1-集成文档.md)
60
63
  - [Pipeline 协议](docs/zh_cn/3.1-任务流水线协议.md)
@@ -144,7 +147,9 @@ _✨ 基于图像识别的自动化黑盒测试框架 ✨_
144
147
 
145
148
  - [SLIMEIM_Maa](https://github.com/miaojiuqing/SLIMEIM_Maa) ![Pipeline](https://img.shields.io/badge/Pipeline-%23876f69?logo=paddypower&logoColor=%23FFFFFF) ![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white) ![license](https://img.shields.io/github/license/miaojiuqing/SLIMEIM_Maa) ![activity](https://img.shields.io/github/commit-activity/m/miaojiuqing/SLIMEIM_Maa?color=%23ff69b4) ![stars](https://img.shields.io/github/stars/miaojiuqing/SLIMEIM_Maa?style=social) [![mirrorc](https://img.shields.io/badge/Mirror%E9%85%B1-%239af3f6?logo=countingworkspro&logoColor=4f46e5)](https://mirrorchyan.com/zh/projects?source=maafw-badge&rid=SLIMEIM_Maa)
146
149
  魔王与龙的建国谭小助手。使用图像识别+模拟控制技术,解放双手!由 MaaFramework 强力驱动!
147
-
150
+
151
+ - [Maa_bbb](https://github.com/miaojiuqing/Maa_bbb) ![Pipeline](https://img.shields.io/badge/Pipeline-%23876f69?logo=paddypower&logoColor=%23FFFFFF) ![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white) ![license](https://img.shields.io/github/license/miaojiuqing/Maa_bbb) ![activity](https://img.shields.io/github/commit-activity/m/miaojiuqing/Maa_bbb?color=%23ff69b4) ![stars](https://img.shields.io/github/stars/miaojiuqing/Maa_bbb?style=social) [![mirrorc](https://img.shields.io/badge/Mirror%E9%85%B1-%239af3f6?logo=countingworkspro&logoColor=4f46e5)](https://mirrorchyan.com/zh/projects?rid=Maa_bbb)
152
+ 崩坏三小助手。使用图像识别+模拟控制技术,解放双手!PC端与模拟器端同步支持,由 MaaFramework 强力驱动!
148
153
 
149
154
  ## 生态共建
150
155
 
@@ -0,0 +1,34 @@
1
+ maa/__init__.py,sha256=t2Z9yJWrSZfH16xYN67bKpiPEHDf7iaiw4wi0PjmU8U,250
2
+ maa/agent_client.py,sha256=qx1-3VGp97JB_UMlbkvK-O_GTigbdqD6U4gGKi2yQW4,4049
3
+ maa/buffer.py,sha256=XFr1MnWt-xmZkhQ_2ZzGfiqSJJwmphY4U07EEzMNYQc,16544
4
+ maa/context.py,sha256=KT22q5tnzrIu8RQQSni3zAvUwNNPNB7-ZEyvwSU2Eao,9054
5
+ maa/controller.py,sha256=XstPEuDe2I3ptN1ChcOd9hyh79OjUIKxZvA3WoDbQq8,26428
6
+ maa/custom_action.py,sha256=honGd28UaKWzApYBHO9_Cka8hPfzZUy6HBUfIdfQiaU,2554
7
+ maa/custom_recognition.py,sha256=nfNgPKq9a6t2eoXwKMJRvZMXTh31Jn0JfxUMsfGI33Y,3384
8
+ maa/define.py,sha256=tr_Ecur9tLIJP3MCX2SjiHwECeTfSl2BOOFNPYrj_04,13671
9
+ maa/event_sink.py,sha256=E5QgjQIbqvLfMg4QoelWCPFmLDawaszEsuLZtwb43VI,1925
10
+ maa/job.py,sha256=MUI5T2X9ON9c7Dl6yo_0pp8Ulpn25XOD_uEdGm2k-TA,1231
11
+ maa/library.py,sha256=u6gbEHDV3I0y69-ZoBo1p6-bAtP4jqSQa4FICuzaw3U,3961
12
+ maa/pipeline.py,sha256=ep9RtViltI4J6_8tP1z9geYhV_O2ezP8NXietxAl8nM,8861
13
+ maa/resource.py,sha256=ljULjrCdVOmFxt0cj9HSyUQsU59mPfiJj0AZ4kla50E,14559
14
+ maa/tasker.py,sha256=Dt-tLz8hSiBZMxdJ5MoHIXcAEYbLihUXnGQ9Fg0Z6Ck,17873
15
+ maa/toolkit.py,sha256=QXPEL8nDhtq2mcjxg8YNEd1-1Q-BfuqH8bkHhA-2nso,8318
16
+ maa/agent/__init__.py,sha256=K4vyyD6YgLR6PEQl86t4oKP4eViCdNr3Br94dNk8YjM,257
17
+ maa/agent/agent_server.py,sha256=e0yE_ffWJlTPydJbYLK9OhCM5fVVlZQIcvEQMjB5V68,3636
18
+ maa/bin/DirectML.dll,sha256=d7Dbg_-QPyMj9cr1OEmdda9gOLvqI7eVn30jLZpKudQ,18444832
19
+ maa/bin/MaaAdbControlUnit.dll,sha256=10iMlTjoQL0HntaNW5C4PCe73lChw8ZnpHahBHSK3VU,837632
20
+ maa/bin/MaaAgentClient.dll,sha256=NpNuDiq98fVpLbFN1Zh5Ep4MA8sBEWaw-y-QoP8bQGE,1147392
21
+ maa/bin/MaaAgentServer.dll,sha256=H-K3Ajk09ux4SUHAdw8A7uiifaP0MCHPY6lh-siw3uc,1329152
22
+ maa/bin/MaaCustomControlUnit.dll,sha256=KqEI5ZhIBNce39mxAoMgez94tOYAce--TIHxKDbaVY4,276992
23
+ maa/bin/MaaDbgControlUnit.dll,sha256=NHMz1dXG9sNfsovtAaouSQZ-9jDxGyAnW46JN-V6AaU,394752
24
+ maa/bin/MaaFramework.dll,sha256=Kn_4vKXwF5xdlwO0X0ovFKYjghzA7vguhAiLieCQe6s,2021376
25
+ maa/bin/MaaToolkit.dll,sha256=gfJTgZf8fbpv197BypBNSM6jSORZvvmBXP0cI_CwWnc,496640
26
+ maa/bin/MaaUtils.dll,sha256=ae99sG0yFH2L4zVLDysirQBRYClKi4Nb8cDeOXnTXiM,569344
27
+ maa/bin/MaaWin32ControlUnit.dll,sha256=2EvTFG4B6exP1upYjf61AybCYpe6xdOSyAam2dUMvqA,354304
28
+ maa/bin/fastdeploy_ppocr_maa.dll,sha256=5LEyrao0OSuJyHjRe3HCyzw_2D2Ynt28TOzjAkQgI8o,1049088
29
+ maa/bin/onnxruntime_maa.dll,sha256=r9qt8ChcpFeoZkstIGFHQ5CLAmfERPXBQJJGdlfB8VQ,19039744
30
+ maa/bin/opencv_world4_maa.dll,sha256=fjKN9Dg59liGwlCpkZ8FZNzbMh65SeSRnD98pWtcfuE,12862464
31
+ maafw-5.0.0a2.dist-info/licenses/LICENSE.md,sha256=RG51X65V_wNLuyG-RGcLXxFsKyZnlH5wNvK_5mMlOag,7560
32
+ maafw-5.0.0a2.dist-info/METADATA,sha256=OffwBreKvfTO89DvQNkNKrrpNBmg3yvqPi3tXrCYTEE,25358
33
+ maafw-5.0.0a2.dist-info/WHEEL,sha256=CUnyDJaykcVTxcKkonAaC86WeSAkytRwcxeIq_huwCo,93
34
+ maafw-5.0.0a2.dist-info/RECORD,,
@@ -1,199 +0,0 @@
1
- import ctypes
2
- import json
3
- from abc import ABC
4
- from typing import Optional, Tuple, Any
5
- from enum import IntEnum
6
- from dataclasses import dataclass
7
-
8
- from .define import MaaNotificationCallback
9
-
10
-
11
- # class NotificationEvent(IntEnum):
12
- # ResourceLoading = 1
13
- # ControllerAction = 2
14
- # TaskerTask = 3
15
- # TaskNextList = 4
16
- # TaskRecognition = 5
17
- # TaskAction = 6
18
-
19
-
20
- class NotificationType(IntEnum):
21
- Unknown = 0
22
- Starting = 1
23
- Succeeded = 2
24
- Failed = 3
25
-
26
-
27
- class NotificationHandler(ABC):
28
-
29
- @dataclass
30
- class ResourceLoadingDetail:
31
- res_id: int
32
- hash: str
33
- path: str
34
-
35
- def on_resource_loading(
36
- self, noti_type: NotificationType, detail: ResourceLoadingDetail
37
- ):
38
- pass
39
-
40
- @dataclass
41
- class ControllerActionDetail:
42
- ctrl_id: int
43
- uuid: str
44
- action: str
45
- param: dict
46
-
47
- def on_controller_action(
48
- self, noti_type: NotificationType, detail: ControllerActionDetail
49
- ):
50
- pass
51
-
52
- @dataclass
53
- class TaskerTaskDetail:
54
- task_id: int
55
- entry: str
56
- uuid: str
57
- hash: str
58
-
59
- def on_tasker_task(self, noti_type: NotificationType, detail: TaskerTaskDetail):
60
- pass
61
-
62
- @dataclass
63
- class NodeNextListDetail:
64
- task_id: int
65
- name: str
66
- next_list: list[str]
67
- focus: Any
68
-
69
- def on_node_next_list(
70
- self, noti_type: NotificationType, detail: NodeNextListDetail
71
- ):
72
- pass
73
-
74
- @dataclass
75
- class NodeRecognitionDetail:
76
- task_id: int
77
- reco_id: int
78
- name: str
79
- focus: Any
80
-
81
- def on_node_recognition(
82
- self, noti_type: NotificationType, detail: NodeRecognitionDetail
83
- ):
84
- pass
85
-
86
- @dataclass
87
- class NodeActionDetail:
88
- task_id: int
89
- node_id: int
90
- name: str
91
- focus: Any
92
-
93
- def on_node_action(self, noti_type: NotificationType, detail: NodeActionDetail):
94
- pass
95
-
96
- def on_unknown_notification(self, msg: str, details: dict):
97
- pass
98
-
99
- def on_raw_notification(self, msg: str, details: dict):
100
-
101
- noti_type = NotificationHandler._notification_type(msg)
102
-
103
- if msg.startswith("Resource.Loading"):
104
- detail = self.ResourceLoadingDetail(
105
- res_id=details["res_id"],
106
- hash=details["hash"],
107
- path=details["path"],
108
- )
109
- self.on_resource_loading(noti_type, detail)
110
-
111
- elif msg.startswith("Controller.Action"):
112
- detail = self.ControllerActionDetail(
113
- ctrl_id=details["ctrl_id"],
114
- uuid=details["uuid"],
115
- action=details["action"],
116
- param=details["param"],
117
- )
118
- self.on_controller_action(noti_type, detail)
119
-
120
- elif msg.startswith("Tasker.Task"):
121
- detail = self.TaskerTaskDetail(
122
- task_id=details["task_id"],
123
- entry=details["entry"],
124
- uuid=details["uuid"],
125
- hash=details["hash"],
126
- )
127
- self.on_tasker_task(noti_type, detail)
128
-
129
- elif msg.startswith("Node.NextList"):
130
- detail = self.NodeNextListDetail(
131
- task_id=details["task_id"],
132
- name=details["name"],
133
- next_list=details["list"],
134
- focus=details["focus"],
135
- )
136
- self.on_node_next_list(noti_type, detail)
137
-
138
- elif msg.startswith("Node.Recognition"):
139
- detail = self.NodeRecognitionDetail(
140
- task_id=details["task_id"],
141
- reco_id=details["reco_id"],
142
- name=details["name"],
143
- focus=details["focus"],
144
- )
145
- self.on_node_recognition(noti_type, detail)
146
-
147
- elif msg.startswith("Node.Action"):
148
- detail = self.NodeActionDetail(
149
- task_id=details["task_id"],
150
- node_id=details["node_id"],
151
- name=details["name"],
152
- focus=details["focus"],
153
- )
154
- self.on_node_action(noti_type, detail)
155
-
156
- else:
157
- self.on_unknown_notification(msg, details)
158
-
159
- @property
160
- def c_callback(self) -> MaaNotificationCallback:
161
- return self._c_notification_agent
162
-
163
- @property
164
- def c_callback_arg(self) -> ctypes.c_void_p:
165
- return ctypes.c_void_p.from_buffer(ctypes.py_object(self))
166
-
167
- @staticmethod
168
- def _gen_c_param(
169
- handler: Optional["NotificationHandler"],
170
- ) -> Tuple[MaaNotificationCallback, ctypes.c_void_p]:
171
- if handler:
172
- return handler.c_callback, handler.c_callback_arg
173
- else:
174
- return NotificationHandler._c_notification_agent, ctypes.c_void_p()
175
-
176
- @staticmethod
177
- def _notification_type(message: str) -> NotificationType:
178
- if message.endswith(".Starting"):
179
- return NotificationType.Starting
180
- elif message.endswith(".Succeeded"):
181
- return NotificationType.Succeeded
182
- elif message.endswith(".Failed"):
183
- return NotificationType.Failed
184
- else:
185
- return NotificationType.Unknown
186
-
187
- @staticmethod
188
- @MaaNotificationCallback
189
- def _c_notification_agent(
190
- msg: ctypes.c_char_p,
191
- details_json: ctypes.c_char_p,
192
- callback_arg: ctypes.c_void_p,
193
- ):
194
- if not callback_arg:
195
- return
196
-
197
- self: NotificationHandler = ctypes.cast(callback_arg, ctypes.py_object).value
198
-
199
- self.on_raw_notification(msg.decode(), json.loads(details_json.decode()))