ms-types 0.12.3 → 0.12.5
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/web.d.ts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-types",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
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
|
}
|
package/types/web.d.ts
CHANGED
|
@@ -44,6 +44,22 @@ declare namespace ms {
|
|
|
44
44
|
*/
|
|
45
45
|
function isTaskRunning(): Promise<boolean>;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* 在脚本引擎里执行函数
|
|
49
|
+
* 函数在脚本引擎里执行,可以直接调用引擎的全局方法,例如 click、sleep、time。
|
|
50
|
+
* 网页变量通过函数后面的参数传进去。函数里直接写网页变量名读不到。
|
|
51
|
+
* 每次调用单独执行,和 startTask 启动的脚本不共享变量。
|
|
52
|
+
* 函数同步执行。没有返回值时得到 null。参数和返回值需要能用 JSON 表示。执行失败或函数抛错时 Promise 拒绝。
|
|
53
|
+
* @param func 要在脚本引擎里执行的函数,参数对应后面传入的值
|
|
54
|
+
* @param args 传给函数的网页变量。可以是数字、字符串、布尔、数组或普通对象
|
|
55
|
+
* @returns 函数的返回值
|
|
56
|
+
* @example ms.runScript((x, y) => { click(x, y); return time(); }, 200, 400)
|
|
57
|
+
*/
|
|
58
|
+
function runScript(
|
|
59
|
+
func: (...args: any[]) => any,
|
|
60
|
+
...args: any[]
|
|
61
|
+
): Promise<any>;
|
|
62
|
+
|
|
47
63
|
/**
|
|
48
64
|
* 设置配置项
|
|
49
65
|
* @param key 配置项键
|
|
@@ -98,6 +114,28 @@ declare namespace ms {
|
|
|
98
114
|
*/
|
|
99
115
|
function getOrientation(): Promise<"PORTRAIT" | "LANDSCAPE">;
|
|
100
116
|
|
|
117
|
+
/**
|
|
118
|
+
* 读取当前已加载软件的 package.json
|
|
119
|
+
* 字段和脚本里的 __package__ 相同。name、appVersion、appId 一定有。没有加载软件或读不到文件时返回 null
|
|
120
|
+
* @returns 当前软件的 package.json;没有时为 null
|
|
121
|
+
* @example ms.readPackageJson()
|
|
122
|
+
*/
|
|
123
|
+
function readPackageJson(): Promise<{
|
|
124
|
+
/**
|
|
125
|
+
* 应用名称
|
|
126
|
+
*/
|
|
127
|
+
name: string;
|
|
128
|
+
/**
|
|
129
|
+
* 应用版本
|
|
130
|
+
*/
|
|
131
|
+
appVersion: string;
|
|
132
|
+
/**
|
|
133
|
+
* 应用 Id
|
|
134
|
+
*/
|
|
135
|
+
appId: string;
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
} | null>;
|
|
138
|
+
|
|
101
139
|
/**
|
|
102
140
|
* 获取当前软件包缓存的授权卡密
|
|
103
141
|
* @returns 有缓存的授权卡密时返回卡密字符串,没有缓存时返回空字符串。Android 不支持官方卡密,同名入口固定返回空字符串,不读不存卡密。
|