ms-types 0.12.2 → 0.12.4
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 +3 -3
- package/types/android/javaBridge.d.ts +12 -3
- package/types/android/zh.d.ts +53 -0
- package/types/lua/android/javaBridge.lua +1 -1
- package/types/web.d.ts +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-types",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"vitepress": "^1.6.4",
|
|
27
|
-
"vitepress-theme-teek": "^1.6.
|
|
28
|
-
"wrangler": "^4.
|
|
27
|
+
"vitepress-theme-teek": "^1.6.3",
|
|
28
|
+
"wrangler": "^4.164.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -17,7 +17,7 @@ declare function importClass(className: string): any;
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 从 dex/jar/apk 路径加载额外 ClassLoader,之后可用 importClass 加载其中的类。
|
|
20
|
-
* @param path
|
|
20
|
+
* @param path 工程资源路径或设备上的文件路径;找不到文件会抛错
|
|
21
21
|
* @returns ClassLoader
|
|
22
22
|
*/
|
|
23
23
|
declare function loadDex(path: string): any;
|
|
@@ -29,6 +29,15 @@ declare function loadDex(path: string): any;
|
|
|
29
29
|
*/
|
|
30
30
|
declare function importPackage(packageName: string): any;
|
|
31
31
|
|
|
32
|
+
/** JS 顶层包名前缀,等价于 `importPackage("java")` 等;仅 Android JS 注入。 */
|
|
33
|
+
declare const java: any;
|
|
34
|
+
declare const android: any;
|
|
35
|
+
declare const com: any;
|
|
36
|
+
declare const org: any;
|
|
37
|
+
declare const net: any;
|
|
38
|
+
declare const cn: any;
|
|
39
|
+
declare const javax: any;
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* 获取应用 Context(Application Context)。
|
|
34
43
|
*/
|
|
@@ -47,7 +56,7 @@ declare function showToast(msg: string): void;
|
|
|
47
56
|
* (importClass/getContext/showToast 等),引不到脚本作用域的变量和 JS 对象(会报 ReferenceError 并返回 undefined)
|
|
48
57
|
* @param block 回调
|
|
49
58
|
*/
|
|
50
|
-
declare function runOnUiThread(block: (...args: any[]) => any): any;
|
|
59
|
+
declare function runOnUiThread(block: (...args: any[]) => any, ...args: any[]): any;
|
|
51
60
|
|
|
52
61
|
/**
|
|
53
62
|
* 用脚本回调实现 Java 接口(动态 Proxy)。
|
|
@@ -58,7 +67,7 @@ declare function runOnUiThread(block: (...args: any[]) => any): any;
|
|
|
58
67
|
* const r = implement(Runnable, { run: () => logi("run") });
|
|
59
68
|
* r.run();
|
|
60
69
|
*/
|
|
61
|
-
declare function implement(iface: any, handlers: Record<string, (...args: any[]) => any>): any;
|
|
70
|
+
declare function implement(iface: any, handlers: Record<string, (...args: any[]) => any> | ((...args: any[]) => any)): any;
|
|
62
71
|
|
|
63
72
|
/**
|
|
64
73
|
* 单方法接口简便形式。
|
package/types/android/zh.d.ts
CHANGED
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
* 需要时单独 `/// <reference path=".../types/android/zh.d.ts" />`,
|
|
6
6
|
* 或通过英文主入口 `types/index.d.ts` → `android/index.d.ts` 间接引用。
|
|
7
7
|
*/
|
|
8
|
+
/** Android 独有:对应 `loadDex`。 */
|
|
9
|
+
declare function $加载Dex(path: string): any;
|
|
10
|
+
|
|
11
|
+
/** Android 独有:对应 `importClass`。 */
|
|
12
|
+
declare function $导入类(className: string): any;
|
|
13
|
+
|
|
14
|
+
/** Android 独有:对应 `getContext`。 */
|
|
15
|
+
declare function $获取上下文(): any;
|
|
16
|
+
|
|
17
|
+
/** Android 独有:对应 `showToast`。 */
|
|
18
|
+
declare function $显示Toast(msg: string): void;
|
|
19
|
+
|
|
20
|
+
/** Android 独有:对应 `runOnUiThread`。 */
|
|
21
|
+
declare function $在UI线程运行(block: (...args: any[]) => any, ...args: any[]): any;
|
|
22
|
+
|
|
23
|
+
/** Android 独有:对应 `implement`。 */
|
|
24
|
+
declare function $实现接口(iface: any, handlers: Record<string, (...args: any[]) => any> | ((...args: any[]) => any)): any;
|
|
25
|
+
|
|
26
|
+
/** Android 独有:对应 `implementOne`。 */
|
|
27
|
+
declare function $实现单方法接口(iface: any, handler: (...args: any[]) => any): any;
|
|
28
|
+
|
|
8
29
|
declare namespace $动作 {
|
|
9
30
|
/**
|
|
10
31
|
* 按下系统按钮(Android)。别名对应 `action.pressButton`。
|
|
@@ -29,3 +50,35 @@ declare namespace $动作 {
|
|
|
29
50
|
}
|
|
30
51
|
|
|
31
52
|
|
|
53
|
+
|
|
54
|
+
declare namespace $绘图 {
|
|
55
|
+
/**
|
|
56
|
+
* Android 独有:对应 `draw.drawRect`。
|
|
57
|
+
*/
|
|
58
|
+
function 绘制矩形(x: number, y: number, ex: number, ey: number, lineWidth?: number, color?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Android 独有:对应 `draw.drawCircle`。
|
|
61
|
+
*/
|
|
62
|
+
function 绘制圆形(x: number, y: number, radius: number, lineWidth?: number, color?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Android 独有:对应 `draw.drawText`。
|
|
65
|
+
*/
|
|
66
|
+
function 绘制文字(
|
|
67
|
+
text: string,
|
|
68
|
+
x: number,
|
|
69
|
+
y: number,
|
|
70
|
+
ex: number,
|
|
71
|
+
ey: number,
|
|
72
|
+
fontSize?: number,
|
|
73
|
+
color?: string,
|
|
74
|
+
bgColor?: string,
|
|
75
|
+
): string;
|
|
76
|
+
/** 对应 `draw.clear`。不传 id 则清除全部。 */
|
|
77
|
+
function 清除(id?: string): void;
|
|
78
|
+
/** 对应 `draw.close`。 */
|
|
79
|
+
function 关闭绘制(): void;
|
|
80
|
+
/** 对应 `draw.hide`。 */
|
|
81
|
+
function 隐藏绘制(): void;
|
|
82
|
+
/** 对应 `draw.show`。 */
|
|
83
|
+
function 显示绘制(): void;
|
|
84
|
+
}
|
package/types/web.d.ts
CHANGED
|
@@ -44,6 +44,17 @@ declare namespace ms {
|
|
|
44
44
|
*/
|
|
45
45
|
function isTaskRunning(): Promise<boolean>;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* 在脚本引擎里执行函数
|
|
49
|
+
* 函数在脚本引擎里执行,可以直接调用引擎的全局方法,例如 click、sleep、time。
|
|
50
|
+
* 网页里的变量不在这次执行里。每次调用单独执行,和 startTask 启动的脚本不共享变量。
|
|
51
|
+
* 函数同步执行。没有返回值时得到 null。返回值需要能用 JSON 表示。执行失败或函数抛错时 Promise 拒绝。
|
|
52
|
+
* @param func 要在脚本引擎里执行的函数
|
|
53
|
+
* @returns 函数的返回值
|
|
54
|
+
* @example ms.runScript(() => { click(200, 400); return time(); })
|
|
55
|
+
*/
|
|
56
|
+
function runScript(func: () => any): Promise<any>;
|
|
57
|
+
|
|
47
58
|
/**
|
|
48
59
|
* 设置配置项
|
|
49
60
|
* @param key 配置项键
|
|
@@ -98,6 +109,28 @@ declare namespace ms {
|
|
|
98
109
|
*/
|
|
99
110
|
function getOrientation(): Promise<"PORTRAIT" | "LANDSCAPE">;
|
|
100
111
|
|
|
112
|
+
/**
|
|
113
|
+
* 读取当前已加载软件的 package.json
|
|
114
|
+
* 字段和脚本里的 __package__ 相同。name、appVersion、appId 一定有。没有加载软件或读不到文件时返回 null
|
|
115
|
+
* @returns 当前软件的 package.json;没有时为 null
|
|
116
|
+
* @example ms.readPackageJson()
|
|
117
|
+
*/
|
|
118
|
+
function readPackageJson(): Promise<{
|
|
119
|
+
/**
|
|
120
|
+
* 应用名称
|
|
121
|
+
*/
|
|
122
|
+
name: string;
|
|
123
|
+
/**
|
|
124
|
+
* 应用版本
|
|
125
|
+
*/
|
|
126
|
+
appVersion: string;
|
|
127
|
+
/**
|
|
128
|
+
* 应用 Id
|
|
129
|
+
*/
|
|
130
|
+
appId: string;
|
|
131
|
+
[key: string]: any;
|
|
132
|
+
} | null>;
|
|
133
|
+
|
|
101
134
|
/**
|
|
102
135
|
* 获取当前软件包缓存的授权卡密
|
|
103
136
|
* @returns 有缓存的授权卡密时返回卡密字符串,没有缓存时返回空字符串。Android 不支持官方卡密,同名入口固定返回空字符串,不读不存卡密。
|