ms-types 0.11.7 → 0.11.9
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 +2 -2
- package/types/android/draw.d.ts +52 -0
- package/types/android/index.d.ts +7 -0
- package/types/android/javaBridge.d.ts +71 -0
- package/types/android/modules.d.ts +25 -0
- package/types/android/system.d.ts +12 -0
- package/types/global.d.ts +6 -2
- package/types/index.d.ts +1 -0
- package/types/lua/android/javaBridge.lua +71 -0
- package/types/lua/android/modules.lua +21 -0
- package/types/lua/global.lua +7 -3
- package/types/lua/sharedState.lua +31 -0
- package/types/web.d.ts +4 -2
- package/types/zh//345/205/250/345/261/200/346/250/241/345/235/227.d.ts +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-types",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"vitepress": "^1.6.4",
|
|
27
27
|
"vitepress-theme-teek": "^1.6.2",
|
|
28
|
-
"wrangler": "^4.
|
|
28
|
+
"wrangler": "^4.151.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘图模块(Android 独有):在屏幕悬浮层绘制矩形/圆/文字,用于调试标注。
|
|
3
|
+
* JS 全局对象 `draw`(别名 `$绘图`);iOS 无此模块。
|
|
4
|
+
*/
|
|
5
|
+
declare namespace draw {
|
|
6
|
+
/**
|
|
7
|
+
* 绘制矩形
|
|
8
|
+
* @param x 左上角 x
|
|
9
|
+
* @param y 左上角 y
|
|
10
|
+
* @param ex 右下角 x
|
|
11
|
+
* @param ey 右下角 y
|
|
12
|
+
* @param lineWidth 线宽,默认 1
|
|
13
|
+
* @param color 颜色,如 `"#FF0000"`
|
|
14
|
+
* @returns 图形 id,可用于 `draw.clear(id)`
|
|
15
|
+
* @example const id = draw.drawRect(100, 100, 300, 300, 2, "#FF0000");
|
|
16
|
+
*/
|
|
17
|
+
function drawRect(x: number, y: number, ex: number, ey: number, lineWidth?: number, color?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* 绘制圆形
|
|
20
|
+
* @param x 圆心 x
|
|
21
|
+
* @param y 圆心 y
|
|
22
|
+
* @param radius 半径
|
|
23
|
+
* @param lineWidth 线宽,默认 1
|
|
24
|
+
* @param color 颜色
|
|
25
|
+
* @returns 图形 id
|
|
26
|
+
*/
|
|
27
|
+
function drawCircle(x: number, y: number, radius: number, lineWidth?: number, color?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* 绘制文字
|
|
30
|
+
* @param text 文字
|
|
31
|
+
* @param x 区域左上 x
|
|
32
|
+
* @param y 区域左上 y
|
|
33
|
+
* @param ex 区域右下 x
|
|
34
|
+
* @param ey 区域右下 y
|
|
35
|
+
* @param fontSize 字号(dp),默认 20
|
|
36
|
+
* @param color 文字颜色
|
|
37
|
+
* @param bgColor 背景色,空则无背景
|
|
38
|
+
* @returns 图形 id
|
|
39
|
+
*/
|
|
40
|
+
function drawText(text: string, x: number, y: number, ex: number, ey: number, fontSize?: number, color?: string, bgColor?: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* 清除图形
|
|
43
|
+
* @param id 图形 id;不传则清除全部
|
|
44
|
+
*/
|
|
45
|
+
function clear(id?: string): void;
|
|
46
|
+
/** 关闭绘制层并清除全部图形 */
|
|
47
|
+
function close(): void;
|
|
48
|
+
/** 隐藏绘制层 */
|
|
49
|
+
function hide(): void;
|
|
50
|
+
/** 显示绘制层 */
|
|
51
|
+
function show(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Android 独有:Java 类桥接(importClass / implement / showToast 等)。
|
|
3
|
+
* 单独成文件,不放在 global.d.ts;iOS 无对应能力。
|
|
4
|
+
* 运行时以裸全局函数注入,因此仍为环境声明(脚本可直接调用)。
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 按全限定名加载 Java 类(支持 `a.b.Outer.Inner` → `Outer$Inner`)。
|
|
8
|
+
* @param className 类名,如 `"android.os.Build"`、`"java.util.ArrayList"`
|
|
9
|
+
* @returns 类对象(可用于 `new Cls(...)`、读静态字段、调静态方法);找不到返回 null
|
|
10
|
+
* @example
|
|
11
|
+
* const Build = importClass("android.os.Build");
|
|
12
|
+
* logi(Build.MODEL);
|
|
13
|
+
* const list = new (importClass("java.util.ArrayList"))();
|
|
14
|
+
* list.add("a");
|
|
15
|
+
*/
|
|
16
|
+
declare function importClass(className: string): any;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 从 dex/jar/apk 路径加载额外 ClassLoader,之后可用 importClass 加载其中的类。
|
|
20
|
+
* @param path 绝对路径
|
|
21
|
+
* @returns ClassLoader
|
|
22
|
+
*/
|
|
23
|
+
declare function loadDex(path: string): any;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 按包名前缀惰性解析类(JS):`java.util.ArrayList` 形式访问。
|
|
27
|
+
* 顶层已注入 `java` / `android` / `com` / `org` / `net` / `cn` / `javax`。
|
|
28
|
+
* @param packageName 包名,如 `"java.util"`
|
|
29
|
+
*/
|
|
30
|
+
declare function importPackage(packageName: string): any;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 获取应用 Context(Application Context)。
|
|
34
|
+
*/
|
|
35
|
+
declare function getContext(): any;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 在主线程显示 Toast(内部 post,不阻塞脚本线程)。
|
|
39
|
+
* @param msg 文本
|
|
40
|
+
*/
|
|
41
|
+
declare function showToast(msg: string): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 在主线程执行回调。
|
|
45
|
+
* - Python / Lua:阻塞等待结果(默认最多 30s)
|
|
46
|
+
* - JS:回调在主线程的独立 JS 运行时中同步执行并返回结果。回调里只能用全局接口
|
|
47
|
+
* (importClass/getContext/showToast 等),引不到脚本作用域的变量和 JS 对象(会报 ReferenceError 并返回 undefined)
|
|
48
|
+
* @param block 回调
|
|
49
|
+
*/
|
|
50
|
+
declare function runOnUiThread(block: (...args: any[]) => any): any;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 用脚本回调实现 Java 接口(动态 Proxy)。
|
|
54
|
+
* @param iface 接口 Class,或接口全名字符串
|
|
55
|
+
* @param handlers 方法名 → 函数;单方法接口可用 implementOne
|
|
56
|
+
* @example
|
|
57
|
+
* const Runnable = importClass("java.lang.Runnable");
|
|
58
|
+
* const r = implement(Runnable, { run: () => logi("run") });
|
|
59
|
+
* r.run();
|
|
60
|
+
*/
|
|
61
|
+
declare function implement(iface: any, handlers: Record<string, (...args: any[]) => any>): any;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 单方法接口简便形式。
|
|
65
|
+
* @param iface 接口 Class 或全名
|
|
66
|
+
* @param handler 唯一抽象方法的实现
|
|
67
|
+
* @example
|
|
68
|
+
* const r = implementOne("java.lang.Runnable", () => logi("hi"));
|
|
69
|
+
* r.run();
|
|
70
|
+
*/
|
|
71
|
+
declare function implementOne(iface: any, handler: (...args: any[]) => any): any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 共享模块的 Android 独有扩展方法(iOS 无对应方法),通过 namespace 合并到共享声明。
|
|
3
|
+
*/
|
|
4
|
+
declare namespace image {
|
|
5
|
+
/**
|
|
6
|
+
* 获取图片对应的 Android Bitmap(Android 独有,可配合 importClass 使用)
|
|
7
|
+
* @param imageId 图片 id
|
|
8
|
+
* @returns android.graphics.Bitmap;图片不存在返回 undefined
|
|
9
|
+
* @example
|
|
10
|
+
* const img = image.captureScreen();
|
|
11
|
+
* const bmp = image.getBitmap(img);
|
|
12
|
+
* logi(bmp.getWidth() + "x" + bmp.getHeight());
|
|
13
|
+
*/
|
|
14
|
+
function getBitmap(imageId: string): any | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* 获取图片对应的 OpenCV Mat 原始对象(Android 独有)
|
|
17
|
+
* @param imageId 图片 id
|
|
18
|
+
* @returns org.opencv.core.Mat;图片不存在返回 undefined
|
|
19
|
+
* @example
|
|
20
|
+
* const mat = image.getMat(image.captureScreen());
|
|
21
|
+
* logi(mat.cols() + "x" + mat.rows());
|
|
22
|
+
*/
|
|
23
|
+
function getMat(imageId: string): any | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* system 模块的 Android 独有扩展(与 system.d.ts 中的共享声明合并)。
|
|
3
|
+
*/
|
|
4
|
+
declare namespace system {
|
|
5
|
+
/**
|
|
6
|
+
* 执行 Shell 命令(Android 独有;按当前权限以 Root / ADB / 普通 shell 执行)
|
|
7
|
+
* @param command 命令
|
|
8
|
+
* @returns 命令输出
|
|
9
|
+
* @example const out = system.exec("getprop ro.product.model");
|
|
10
|
+
*/
|
|
11
|
+
function exec(command: string): string;
|
|
12
|
+
}
|
package/types/global.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 运行模式。`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选。
|
|
3
3
|
*/
|
|
4
|
-
declare const __runMode__: "agent" | "hid";
|
|
4
|
+
declare const __runMode__: "agent" | "hid" | "pair";
|
|
5
5
|
/**
|
|
6
6
|
* 是否是调试模式
|
|
7
7
|
*/
|
|
@@ -38,6 +38,10 @@ declare const __threadName__: string;
|
|
|
38
38
|
* 子线程启动参数;仅在线程脚本中可用,未传参数时为空对象
|
|
39
39
|
*/
|
|
40
40
|
declare const __threadParams__: Record<string, any>;
|
|
41
|
+
/**
|
|
42
|
+
* 脚本启动参数;由网页 ms.startTask(params) 传入,其他方式启动时为空对象
|
|
43
|
+
*/
|
|
44
|
+
declare const __startParams__: Record<string, any>;
|
|
41
45
|
/**
|
|
42
46
|
* 脚本信息
|
|
43
47
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---@meta
|
|
2
|
+
--- Android 独有:Java 类桥接(运行时注入的全局函数,iOS 无)
|
|
3
|
+
---按全限定名加载 Java 类(支持 Outer.Inner → Outer$Inner)
|
|
4
|
+
---@param className string
|
|
5
|
+
---@return any|nil
|
|
6
|
+
function importClass(className) end
|
|
7
|
+
|
|
8
|
+
---从 dex/jar/apk 加载额外 ClassLoader
|
|
9
|
+
---@param path string
|
|
10
|
+
---@return any
|
|
11
|
+
function loadDex(path) end
|
|
12
|
+
|
|
13
|
+
---获取应用 Context
|
|
14
|
+
---@return any
|
|
15
|
+
function getContext() end
|
|
16
|
+
|
|
17
|
+
---主线程 Toast(不阻塞)
|
|
18
|
+
---@param msg string
|
|
19
|
+
function showToast(msg) end
|
|
20
|
+
|
|
21
|
+
---在主线程执行并等待返回值(Lua / Python)
|
|
22
|
+
---@param block function
|
|
23
|
+
---@return any
|
|
24
|
+
function runOnUiThread(block) end
|
|
25
|
+
|
|
26
|
+
---实现 Java 接口(Proxy);handlers 为 方法名→函数 表,或单函数(单方法接口)
|
|
27
|
+
---@param iface any
|
|
28
|
+
---@param handlers table|function
|
|
29
|
+
---@return any
|
|
30
|
+
function implement(iface, handlers) end
|
|
31
|
+
|
|
32
|
+
---单方法接口简便形式
|
|
33
|
+
---@param iface any
|
|
34
|
+
---@param handler function
|
|
35
|
+
---@return any
|
|
36
|
+
function implementOne(iface, handler) end
|
|
37
|
+
|
|
38
|
+
---importClass 的大写别名
|
|
39
|
+
---@param className string
|
|
40
|
+
---@return any|nil
|
|
41
|
+
function ImportClass(className) end
|
|
42
|
+
|
|
43
|
+
---loadDex 的大写别名
|
|
44
|
+
---@param path string
|
|
45
|
+
---@return any
|
|
46
|
+
function LoadDex(path) end
|
|
47
|
+
|
|
48
|
+
---getContext 的大写别名
|
|
49
|
+
---@return any
|
|
50
|
+
function GetContext() end
|
|
51
|
+
|
|
52
|
+
---showToast 的大写别名
|
|
53
|
+
---@param msg string
|
|
54
|
+
function ShowToast(msg) end
|
|
55
|
+
|
|
56
|
+
---runOnUiThread 的大写别名
|
|
57
|
+
---@param block function
|
|
58
|
+
---@return any
|
|
59
|
+
function RunOnUiThread(block) end
|
|
60
|
+
|
|
61
|
+
---implement 的大写别名
|
|
62
|
+
---@param iface any
|
|
63
|
+
---@param handlers table|function
|
|
64
|
+
---@return any
|
|
65
|
+
function Implement(iface, handlers) end
|
|
66
|
+
|
|
67
|
+
---implementOne 的大写别名
|
|
68
|
+
---@param iface any
|
|
69
|
+
---@param handler function
|
|
70
|
+
---@return any
|
|
71
|
+
function ImplementOne(iface, handler) end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---@meta
|
|
2
|
+
--- Android 独有:共享模块上的扩展方法(iOS 无)
|
|
3
|
+
|
|
4
|
+
---执行 Shell 命令(按当前权限以 Root / ADB / 普通 shell 执行)
|
|
5
|
+
---@param command string
|
|
6
|
+
---@return string
|
|
7
|
+
---@example local out = system.exec("getprop ro.product.model")
|
|
8
|
+
function system.exec(command) end
|
|
9
|
+
|
|
10
|
+
---获取图片对应的 android.graphics.Bitmap;不存在返回 nil
|
|
11
|
+
---@param imageId string
|
|
12
|
+
---@return any|nil
|
|
13
|
+
---@example local b = image.getBitmap(image.captureScreen()); print(b:getWidth())
|
|
14
|
+
function image.getBitmap(imageId) end
|
|
15
|
+
|
|
16
|
+
---获取图片对应的 org.opencv.core.Mat;不存在返回 nil
|
|
17
|
+
---@param imageId string
|
|
18
|
+
---@return any|nil
|
|
19
|
+
---@example local m = image.getMat(image.captureScreen()); print(m:cols())
|
|
20
|
+
function image.getMat(imageId) end
|
|
21
|
+
|
package/types/lua/global.lua
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
---@type boolean
|
|
5
5
|
IsDebug = false
|
|
6
6
|
|
|
7
|
-
---
|
|
8
|
-
---@type
|
|
9
|
-
RunMode = ''
|
|
7
|
+
--- 运行模式:`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选
|
|
8
|
+
---@type "agent"|"hid"|"pair"
|
|
9
|
+
RunMode = 'agent'
|
|
10
10
|
|
|
11
11
|
--- 免越狱包为 `"ios"`,越狱包为 `"ios_jb"`
|
|
12
12
|
---@type "ios"|"ios_jb"
|
|
@@ -32,6 +32,10 @@ AppBundleId = ''
|
|
|
32
32
|
---@type table<string, any>
|
|
33
33
|
PackageJson = {}
|
|
34
34
|
|
|
35
|
+
--- 脚本启动参数;由网页 ms.startTask(params) 传入,其他方式启动时为空表
|
|
36
|
+
---@type table<string, any>
|
|
37
|
+
StartParams = {}
|
|
38
|
+
|
|
35
39
|
---@class CpuThrottleDelay
|
|
36
40
|
---@field minMs integer
|
|
37
41
|
---@field maxMs integer
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---@meta
|
|
2
|
+
--- 共享状态模块
|
|
3
|
+
---@class SharedState
|
|
4
|
+
local _SharedState = {}
|
|
5
|
+
|
|
6
|
+
--- 设置共享状态
|
|
7
|
+
---@param key string 状态键
|
|
8
|
+
---@param value any 状态值,支持 nil、boolean、number、string、table;保存的是值的拷贝
|
|
9
|
+
---@example sharedState.set("count", 1)
|
|
10
|
+
function _SharedState.set(key, value) end
|
|
11
|
+
|
|
12
|
+
--- 获取共享状态
|
|
13
|
+
---@param key string 状态键
|
|
14
|
+
---@return any|nil 状态值;不存在时返回 nil
|
|
15
|
+
---@example sharedState.get("count")
|
|
16
|
+
function _SharedState.get(key) return nil end
|
|
17
|
+
|
|
18
|
+
--- 批量操作共享状态
|
|
19
|
+
---@param block fun() 批量操作回调,无参数;回调里不要调用 Sleep
|
|
20
|
+
---@example sharedState.withBatch(function()
|
|
21
|
+
--- sharedState.set("a", 1)
|
|
22
|
+
--- sharedState.set("b", 2)
|
|
23
|
+
--- end)
|
|
24
|
+
function _SharedState.withBatch(block) end
|
|
25
|
+
|
|
26
|
+
--- 清除所有共享状态
|
|
27
|
+
---@example sharedState.clear()
|
|
28
|
+
function _SharedState.clear() end
|
|
29
|
+
|
|
30
|
+
---@type SharedState
|
|
31
|
+
sharedState = _SharedState
|
package/types/web.d.ts
CHANGED
|
@@ -23,10 +23,12 @@ declare namespace ms {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* 启动脚本 网页页面使用
|
|
26
|
+
* @param params 启动参数,只能传 Object。脚本启动时读取:JavaScript 用 __startParams__,Python 用 g.startParams,Lua 用 StartParams。脚本已在运行时不会重新启动,这次传的参数不生效
|
|
26
27
|
* @returns 如果启动成功返回true,否则返回false
|
|
27
28
|
* @example ms.startTask()
|
|
29
|
+
* @example ms.startTask({ mode: "fast", count: 3 })
|
|
28
30
|
*/
|
|
29
|
-
function startTask(): Promise<boolean>;
|
|
31
|
+
function startTask(params?: Record<string, any>): Promise<boolean>;
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* 停止脚本 网页页面使用
|
|
@@ -134,7 +136,7 @@ declare namespace ms {
|
|
|
134
136
|
|
|
135
137
|
/**
|
|
136
138
|
* 设置网页窗口宽高 仅越狱包可用
|
|
137
|
-
* 一次同时设置竖屏和横屏的像素尺寸。未调用过时,横竖屏都默认使用对应朝向屏幕宽高的
|
|
139
|
+
* 一次同时设置竖屏和横屏的像素尺寸。未调用过时,横竖屏都默认使用对应朝向屏幕宽高的 80%。宽高可以设到整屏,超过屏幕的宽高按整屏处理;铺满整屏后没有空白处可点,需要网页自己调用 closeWebWindow 关闭。免越狱包调用返回 false
|
|
138
140
|
* @param size 横竖屏网页窗口像素尺寸
|
|
139
141
|
* @param size.portraitWidth 竖屏窗口宽度(像素)
|
|
140
142
|
* @param size.portraitHeight 竖屏窗口高度(像素)
|
|
@@ -8,9 +8,9 @@ declare type 字典<T> = Record<字符串, T>;
|
|
|
8
8
|
declare type 无返回值 = void;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* 运行模式。`"agent"`、`"hid"` 或 `"pair"`;`"pair"` 仅 iOS 18 及以上可选。
|
|
12
12
|
*/
|
|
13
|
-
declare const $运行模式: "agent" | "hid";
|
|
13
|
+
declare const $运行模式: "agent" | "hid" | "pair";
|
|
14
14
|
/**
|
|
15
15
|
* 是否是调试模式
|
|
16
16
|
*/
|
|
@@ -47,6 +47,10 @@ declare const $线程名称: 字符串;
|
|
|
47
47
|
* 子线程启动参数;仅在线程脚本中可用,未传参数时为空对象
|
|
48
48
|
*/
|
|
49
49
|
declare const $线程参数: 字典<任意类型>;
|
|
50
|
+
/**
|
|
51
|
+
* 脚本启动参数;由网页 ms.startTask(params) 传入,其他方式启动时为空对象
|
|
52
|
+
*/
|
|
53
|
+
declare const $启动参数: 字典<任意类型>;
|
|
50
54
|
/**
|
|
51
55
|
* 脚本信息
|
|
52
56
|
*/
|