ms-types 0.12.2 → 0.12.3

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.12.2",
3
+ "version": "0.12.3",
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.156.0"
28
+ "wrangler": "^4.158.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
  * 单方法接口简便形式。
@@ -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
+ }
@@ -5,7 +5,7 @@
5
5
  ---@return any|nil
6
6
  function importClass(className) end
7
7
 
8
- ---从 dex/jar/apk 加载额外 ClassLoader
8
+ ---从 dex/jar/apk 加载额外 ClassLoader(工程资源路径或设备上的文件路径)
9
9
  ---@param path string
10
10
  ---@return any
11
11
  function loadDex(path) end