ms-types 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Apple OCR模块 使用Apple Vision框架进行文本识别
3
+ */
4
+ declare namespace appleocr {
5
+ /**
6
+ * 执行OCR识别(使用Apple Vision框架)
7
+ * @param input 输入源(imageId、URL字符串、文件路径或"screen",null表示使用当前屏幕)
8
+ * @param x 边界框左上角x坐标
9
+ * @param y 边界框左上角y坐标
10
+ * @param ex 边界框右下角x坐标
11
+ * @param ey 边界框右下角y坐标
12
+ * @param languages 识别语言数组,默认为["zh-Hans", "en-US"]
13
+ * @returns 识别结果数组,包含文本、置信度、坐标等信息
14
+ * @example
15
+ * const results = appleocr.recognize("screen", 0, 0, 100, 100, ["zh-Hans", "en-US"])
16
+ * results.forEach(result => {
17
+ * console.log(`文本: ${result.text}, 置信度: ${result.confidence}`)
18
+ * })
19
+ */
20
+ function recognize(
21
+ input: string | null,
22
+ x: number,
23
+ y: number,
24
+ ex: number,
25
+ ey: number,
26
+ languages?: string[]
27
+ ): OCRResult[];
28
+
29
+ /**
30
+ * 执行快速OCR识别(仅返回文本内容)
31
+ * @param input 输入源
32
+ * @param x 边界框左上角x坐标
33
+ * @param y 边界框左上角y坐标
34
+ * @param ex 边界框右下角x坐标
35
+ * @param ey 边界框右下角y坐标
36
+ * @param languages 识别语言数组
37
+ * @returns 识别到的文本字符串(多行文本用换行符分隔)
38
+ * @example
39
+ * const text = appleocr.recognizeText("screen", 0, 0, 100, 100)
40
+ * console.log("识别到的文本:", text)
41
+ */
42
+ function recognizeText(
43
+ input: string | null,
44
+ x: number,
45
+ y: number,
46
+ ex: number,
47
+ ey: number,
48
+ languages?: string[]
49
+ ): string;
50
+
51
+ /**
52
+ * OCR识别结果接口
53
+ */
54
+ interface OCRResult {
55
+ /** 识别的文本内容 */
56
+ text: string;
57
+ /** 识别置信度 (0-1) */
58
+ confidence: number;
59
+ /** 文本区域左上角 x 坐标 */
60
+ x: number;
61
+ /** 文本区域左上角 y 坐标 */
62
+ y: number;
63
+ /** 文本区域右下角 x 坐标 */
64
+ ex: number;
65
+ /** 文本区域右下角 y 坐标 */
66
+ ey: number;
67
+ /** 文本区域宽度 */
68
+ width: number;
69
+ /** 文本区域高度 */
70
+ height: number;
71
+ /** 文本区域中心点 x 坐标 */
72
+ centerX: number;
73
+ /** 文本区域中心点 y 坐标 */
74
+ centerY: number;
75
+ }
76
+ }
package/types/global.d.ts CHANGED
@@ -26,10 +26,6 @@ declare const __bundleId__: string;
26
26
  * 当前线程名称
27
27
  */
28
28
  declare const __threadName__: string;
29
- /**
30
- * 当前进程名称
31
- */
32
- declare const __workerName__: string;
33
29
  /**
34
30
  * 应用包信息
35
31
  */
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference path="action.d.ts" />
2
+ /// <reference path="appleocr.d.ts" />
2
3
  /// <reference path="config.d.ts" />
3
4
  /// <reference path="device.d.ts" />
4
5
  /// <reference path="file.d.ts" />
@@ -13,5 +14,4 @@
13
14
  /// <reference path="thread.d.ts" />
14
15
  /// <reference path="ui.d.ts" />
15
16
  /// <reference path="utils.d.ts" />
16
- /// <reference path="workerThread.d.ts" />
17
17
  /// <reference path="yolo.d.ts" />
package/types/system.d.ts CHANGED
@@ -130,4 +130,32 @@ declare namespace system {
130
130
  * system.notify("通知内容", "通知标题", "1111")
131
131
  */
132
132
  function notify(msg: string, title: string, id: string): void;
133
+ /**
134
+ * 获取内存使用信息
135
+ * @returns 内存使用信息,包含已使用内存、可用内存和总内存(单位:MB)
136
+ * @example
137
+ * const memInfo = system.getMemoryInfo()
138
+ * console.log(`已使用: ${memInfo.used}MB, 可用: ${memInfo.available}MB, 总计: ${memInfo.total}MB`)
139
+ */
140
+ function getMemoryInfo(): {
141
+ used: number;
142
+ available: number;
143
+ total: number;
144
+ };
145
+ /**
146
+ * 获取已使用内存
147
+ * @returns 已使用内存大小(单位:MB)
148
+ * @example
149
+ * const usedMemory = system.getUsedMemory()
150
+ * console.log(`已使用内存: ${usedMemory}MB`)
151
+ */
152
+ function getUsedMemory(): number;
153
+ /**
154
+ * 获取可用内存
155
+ * @returns 可用内存大小(单位:MB)
156
+ * @example
157
+ * const availableMemory = system.getAvailableMemory()
158
+ * console.log(`可用内存: ${availableMemory}MB`)
159
+ */
160
+ function getAvailableMemory(): number;
133
161
  }
package/types/ui.d.ts CHANGED
@@ -3,14 +3,17 @@
3
3
  * @param name 函数名称
4
4
  * @param func 函数
5
5
  */
6
- declare function registerUIFunc(name: string, func: (data: any) => void): void;
6
+ declare function registerUIFunc(
7
+ name: string,
8
+ func: (data: Record<string, any>) => void
9
+ ): void;
7
10
 
8
11
  /**
9
12
  * 发送事件 网页页面使用 给主进程发送事件
10
13
  * @param event 事件名称
11
14
  * @param data 事件参数
12
15
  */
13
- declare function emitEvent(event: string, data: any): void;
16
+ declare function emitEvent(event: string, data: Record<string, any>): void;
14
17
 
15
18
  /**
16
19
  * UI模块 包含加载html文件、调用js方法等功能
@@ -34,9 +37,11 @@ declare namespace ui {
34
37
  * @param key 方法名
35
38
  * @param data 方法参数
36
39
  * @example
37
- * webview.call("jsMethod", "hello world")
40
+ * webview.call("jsMethod", {
41
+ * name: "magicscript",
42
+ * })
38
43
  */
39
- call(key: string, data: any): void;
44
+ call(key: string, data: Record<string, any>): void;
40
45
  }
41
46
  /**
42
47
  * 创建WebView
@@ -58,10 +63,12 @@ declare namespace ui {
58
63
  * }
59
64
  * })
60
65
  * webview.show()
61
- * webview.call("jsMethod", "hello world")
66
+ * webview.call("jsMethod", {
67
+ * name: "magicscript",
68
+ * })
62
69
  */
63
70
  function newWebView(
64
71
  file: string,
65
- onEvent: (event: string, data: any) => void
72
+ onEvent: (event: string, data: string | Record<string, any>) => void
66
73
  ): WebView;
67
74
  }
@@ -1,69 +0,0 @@
1
- /**
2
- * 工作线程模块 包含工作线程操作、工作线程回调等功能
3
- */
4
- declare namespace workerThread {
5
- /**
6
- * 创建新线程
7
- * @param name 线程名称
8
- * @returns 线程id
9
- */
10
- function newWorker(name: string): string;
11
- /**
12
- * 检查线程是否运行
13
- * @param name 线程名称
14
- * @returns 是否运行
15
- */
16
- function isRunning(name: string): boolean;
17
- /**
18
- * 检查线程是否有函数
19
- * @param funcName 函数名称
20
- * @returns 是否有函数
21
- */
22
- function hasWorkerFunction(funcName: string): boolean;
23
- /**
24
- * 添加线程函数
25
- * @param funcName 函数名称
26
- * @param func 函数
27
- * @returns 是否添加成功
28
- */
29
- function addWorkerFunction(
30
- funcName: string,
31
- func: (data: any) => any
32
- ): boolean;
33
- /**
34
- * 移除线程函数
35
- * @param funcName 函数名称
36
- * @returns 是否移除成功
37
- */
38
- function removeWorkerFunction(funcName: string): boolean;
39
- /**
40
- * 调用线程函数
41
- * @param funcName 函数名称
42
- * @param data 数据
43
- * @returns 调用结果
44
- */
45
- function callWorkerFunction(funcName: string, data: any): any;
46
- /**
47
- * 移除线程
48
- * @param name 线程名称
49
- * @returns 是否移除成功
50
- */
51
- function removeWorker(name: string): boolean;
52
- /**
53
- * 检查线程是否取消
54
- * @param name 线程名称
55
- * @returns 是否取消
56
- */
57
- function isCancelled(name: string): boolean;
58
- /**
59
- * 取消线程
60
- * @param name 线程名称
61
- * @returns 是否取消成功
62
- */
63
- function cancelWorker(name: string): boolean;
64
- /**
65
- * 停止所有线程
66
- * @returns 是否停止成功
67
- */
68
- function stopAll(): boolean;
69
- }