ms-vite-plugin 1.5.19 → 1.5.20

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/docs/api/image.md CHANGED
@@ -16,10 +16,14 @@
16
16
 
17
17
  所有传递`imageId`的函数都可以使用图片路径作为参数,来表示对指定图片进行操作,支持 res 目录文件,和手机文件路径。
18
18
 
19
+ `captureScreen` 默认按 `"screen"` 截图。免越狱调用 `setCaptureImageId` 后,改为按设置的 imageId 截图。越狱版该设置不生效。
20
+
19
21
  ## 图片获取与管理
20
22
 
21
23
  ### captureScreen - 截取屏幕。
22
24
 
25
+ 按 `setCaptureImageId` 设置的 imageId 截取。未设置时为 `"screen"`。越狱版固定为 `"screen"`。
26
+
23
27
  ```typescript
24
28
  function captureScreen(
25
29
  x?: number,
@@ -72,6 +76,36 @@ if (imageId) {
72
76
  }
73
77
  ```
74
78
 
79
+ ### setCaptureImageId - 设置 captureScreen 的默认 imageId。
80
+
81
+ 设置之后,`captureScreen` 按这个 imageId 截图。可传入与其它 image 函数相同的 imageId:`"screen"`、`"shortcut"`、`"actionScreenshot"`、`"vpnScreenshot"`、res 目录或手机绝对路径、已有图片 ID。未传入或空字符串不修改当前来源。越狱版调用后不改变来源。
82
+
83
+ ```typescript
84
+ function setCaptureImageId(imageId: string): void;
85
+ ```
86
+
87
+ **参数:**
88
+
89
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
90
+ | ---------- | ------ | -------- | ------ | ------------------------------------------------- |
91
+ | `imageId` | string | 是 | - | `captureScreen` 使用的来源 |
92
+
93
+ **示例:**
94
+
95
+ ```javascript
96
+ // 之后的 captureScreen 使用快捷指令截图
97
+ image.setCaptureImageId("shortcut");
98
+ const imageId = image.captureScreen();
99
+ const dir = file.getInternalDir("documents");
100
+ if (imageId) {
101
+ image.saveTo(imageId, `${dir}/screenshot.jpg`);
102
+ image.release(imageId);
103
+ }
104
+
105
+ // 恢复为当前屏幕
106
+ image.setCaptureImageId("screen");
107
+ ```
108
+
75
109
  ### readImage - 从文件路径或imageId读取图片。
76
110
 
77
111
  ```typescript
@@ -37,7 +37,7 @@ function startApp(bundleId: string): boolean;
37
37
 
38
38
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
39
39
  | ---------- | ------ | -------- | ------ | ---------------- |
40
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
40
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
41
41
 
42
42
  **返回值:**
43
43
 
@@ -65,7 +65,7 @@ function stopApp(bundleId: string): boolean;
65
65
 
66
66
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
67
67
  | ---------- | ------ | -------- | ------ | ---------------- |
68
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
68
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
69
69
 
70
70
  **返回值:**
71
71
 
@@ -94,7 +94,7 @@ function activateApp(bundleId: string): boolean;
94
94
 
95
95
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
96
96
  | ---------- | ------ | -------- | ------ | ---------------- |
97
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
97
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
98
98
 
99
99
  **返回值:**
100
100
 
@@ -16,10 +16,14 @@
16
16
 
17
17
  所有传递`图片ID`的函数都可以使用图片路径作为参数,来表示对指定图片进行操作,支持 res 目录文件,和手机文件路径。
18
18
 
19
+ `截取屏幕` 默认按 `"screen"` 截图。免越狱调用 `设置默认截图` 后,改为按设置的图片 ID 截图。越狱版该设置不生效。
20
+
19
21
  ## 图片获取与管理
20
22
 
21
23
  ### 截取屏幕
22
24
 
25
+ 按 `设置默认截图` 设置的图片 ID 截取。未设置时为 `"screen"`。越狱版固定为 `"screen"`。
26
+
23
27
  ```typescript
24
28
  function 截取屏幕(
25
29
  区域左上角X坐标?: 数字,
@@ -72,6 +76,36 @@ if (图片ID) {
72
76
  }
73
77
  ```
74
78
 
79
+ ### 设置默认截图 - 设置截取屏幕使用的图片 ID。
80
+
81
+ 设置之后,`截取屏幕` 按这个图片 ID 截图。可传入与其它图片函数相同的图片 ID:`"screen"`、`"shortcut"`、`"actionScreenshot"`、`"vpnScreenshot"`、res 目录或手机绝对路径、已有图片 ID。未传入或空字符串不修改当前来源。越狱版调用后不改变来源。
82
+
83
+ ```typescript
84
+ function 设置默认截图(图片ID: 字符串): 无返回值;
85
+ ```
86
+
87
+ **参数:**
88
+
89
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
90
+ | -------- | ------ | -------- | ------ | ------------------------------------------------- |
91
+ | `图片ID` | 字符串 | 是 | - | `截取屏幕` 使用的来源 |
92
+
93
+ **示例:**
94
+
95
+ ```javascript
96
+ // 之后的截取屏幕使用快捷指令截图
97
+ $图片.设置默认截图("shortcut");
98
+ const 图片ID = $图片.截取屏幕();
99
+ const 文档目录 = $文件.获取内部目录("documents");
100
+ if (图片ID) {
101
+ $图片.保存图片(图片ID, `${文档目录}/screenshot.jpg`);
102
+ $图片.释放图片(图片ID);
103
+ }
104
+
105
+ // 恢复为当前屏幕
106
+ $图片.设置默认截图("screen");
107
+ ```
108
+
75
109
  ### 读取图片 - 从文件路径或图片ID读取图片。
76
110
 
77
111
  ```typescript
@@ -37,7 +37,7 @@ function 启动应用(bundleId: 字符串): 布尔值;
37
37
 
38
38
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
39
39
  | ---------- | ------ | -------- | ------ | ---------------- |
40
- | `bundleId` | 字符串 | 是 | | 应用的 Bundle ID |
40
+ | `bundleId` | 字符串 | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
41
41
 
42
42
  **返回值:**
43
43
 
@@ -65,7 +65,7 @@ function 停止应用(bundleId: 字符串): 布尔值;
65
65
 
66
66
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
67
67
  | ---------- | ------ | -------- | ------ | ---------------- |
68
- | `bundleId` | 字符串 | 是 | | 应用的 Bundle ID |
68
+ | `bundleId` | 字符串 | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
69
69
 
70
70
  **返回值:**
71
71
 
@@ -94,7 +94,7 @@ function 把应用切入前台(bundleId: 字符串): 布尔值;
94
94
 
95
95
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
96
96
  | ---------- | ------ | -------- | ------ | ---------------- |
97
- | `bundleId` | 字符串 | 是 | | 应用的 Bundle ID |
97
+ | `bundleId` | 字符串 | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
98
98
 
99
99
  **返回值:**
100
100
 
@@ -18,10 +18,14 @@
18
18
 
19
19
  所有传递`imageId`的函数都可以使用图片路径作为参数,来表示对指定图片进行操作,支持 res 目录文件,和手机文件路径。
20
20
 
21
+ `captureScreen` 默认按 `"screen"` 截图。免越狱调用 `setCaptureImageId` 后,改为按设置的 imageId 截图。越狱版该设置不生效。
22
+
21
23
  ## 图片获取与管理
22
24
 
23
25
  ### captureScreen - 截取屏幕。
24
26
 
27
+ 按 `setCaptureImageId` 设置的 imageId 截取。未设置时为 `"screen"`。越狱版固定为 `"screen"`。
28
+
25
29
  ```lua
26
30
  ---@param x number?
27
31
  ---@param y number?
@@ -66,6 +70,37 @@ if rectId then
66
70
  end
67
71
  ```
68
72
 
73
+ ### setCaptureImageId - 设置 captureScreen 的默认 imageId。
74
+
75
+ 设置之后,`captureScreen` 按这个 imageId 截图。可传入与其它 image 函数相同的 imageId:`"screen"`、`"shortcut"`、`"actionScreenshot"`、`"vpnScreenshot"`、res 目录或手机绝对路径、已有图片 ID。越狱版调用后不改变来源。
76
+
77
+ ```lua
78
+ ---@param imageId string
79
+ function setCaptureImageId(imageId) end
80
+ ```
81
+
82
+ **参数:**
83
+
84
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
85
+ | ---------- | ------ | -------- | ------ | ------------------------------------------------- |
86
+ | `imageId` | string | 是 | - | `captureScreen` 使用的来源 |
87
+
88
+ **示例:**
89
+
90
+ ```lua
91
+ -- 之后的 captureScreen 使用快捷指令截图
92
+ image.setCaptureImageId("shortcut")
93
+ local imageId = image.captureScreen()
94
+ local dir = file.getInternalDir("documents")
95
+ if imageId then
96
+ image.saveTo(imageId, dir .. "/screenshot.jpg")
97
+ image.release(imageId)
98
+ end
99
+
100
+ -- 恢复为当前屏幕
101
+ image.setCaptureImageId("screen")
102
+ ```
103
+
69
104
  ### readImage - 从文件路径或imageId读取图片。
70
105
 
71
106
  ```lua
@@ -41,7 +41,7 @@ function startApp(bundleId) end
41
41
 
42
42
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
43
43
  | ---------- | ------ | -------- | ------ | ---------------- |
44
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
44
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
45
45
 
46
46
  **返回值:**
47
47
 
@@ -71,7 +71,7 @@ function stopApp(bundleId) end
71
71
 
72
72
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
73
73
  | ---------- | ------ | -------- | ------ | ---------------- |
74
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
74
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
75
75
 
76
76
  **返回值:**
77
77
 
@@ -102,7 +102,7 @@ function activateApp(bundleId) end
102
102
 
103
103
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
104
104
  | ---------- | ------ | -------- | ------ | ---------------- |
105
- | `bundleId` | string | 是 | | 应用的 Bundle ID |
105
+ | `bundleId` | string | 是 | | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
106
106
 
107
107
  **返回值:**
108
108
 
@@ -16,10 +16,14 @@
16
16
 
17
17
  所有传递`imageId`的函数都可以使用图片路径作为参数,来表示对指定图片进行操作,支持 res 目录文件,和手机文件路径。
18
18
 
19
+ `captureScreen` 默认按 `"screen"` 截图。免越狱调用 `setCaptureImageId` 后,改为按设置的 imageId 截图。越狱版该设置不生效。
20
+
19
21
  ## 图片获取与管理
20
22
 
21
23
  ### captureScreen - 截取屏幕
22
24
 
25
+ 按 `setCaptureImageId` 设置的 imageId 截取。未设置时为 `"screen"`。越狱版固定为 `"screen"`。
26
+
23
27
  ```python
24
28
  def captureScreen(x: Optional[int] = 0, y: Optional[int] = 0, ex: Optional[int] = 0, ey: Optional[int] = 0) -> Optional[str]
25
29
  ```
@@ -65,6 +69,35 @@ else:
65
69
  print("截图失败")
66
70
  ```
67
71
 
72
+ ### setCaptureImageId - 设置 captureScreen 的默认 imageId。
73
+
74
+ 设置之后,`captureScreen` 按这个 imageId 截图。可传入与其它 image 函数相同的 imageId:`"screen"`、`"shortcut"`、`"actionScreenshot"`、`"vpnScreenshot"`、res 目录或手机绝对路径、已有图片 ID。越狱版调用后不改变来源。
75
+
76
+ ```python
77
+ def setCaptureImageId(imageId: str) -> None
78
+ ```
79
+
80
+ **参数:**
81
+
82
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
83
+ | ---------- | ---- | -------- | ------ | ------------------------------------------------- |
84
+ | `imageId` | str | 是 | - | `captureScreen` 使用的来源 |
85
+
86
+ **示例:**
87
+
88
+ ```python
89
+ # 之后的 captureScreen 使用快捷指令截图
90
+ image.setCaptureImageId("shortcut")
91
+ imageId = image.captureScreen()
92
+ dir = file.getInternalDir("documents")
93
+ if imageId:
94
+ image.saveTo(imageId, f"{dir}/screenshot.jpg")
95
+ image.release(imageId)
96
+
97
+ # 恢复为当前屏幕
98
+ image.setCaptureImageId("screen")
99
+ ```
100
+
68
101
  ### readImage - 从文件路径或imageId读取图片。
69
102
 
70
103
  ```python
@@ -79,7 +79,7 @@ def startApp(bundle_id: str) -> bool
79
79
  **参数:**
80
80
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
81
81
  | ------ | ---- | ------- | ------ | ---- |
82
- | `bundle_id` | str | 是 | - | 应用 Bundle ID |
82
+ | `bundle_id` | str | 是 | - | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
83
83
 
84
84
  **返回值:**
85
85
 
@@ -105,7 +105,7 @@ def stopApp(bundle_id: str) -> bool
105
105
  **参数:**
106
106
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
107
107
  |-------------|------|----------|--------|-----------------|
108
- | `bundle_id` | str | 是 | - | 应用 Bundle ID |
108
+ | `bundle_id` | str | 是 | - | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
109
109
 
110
110
  **返回值:**
111
111
 
@@ -129,7 +129,7 @@ def activateApp(bundle_id: str) -> bool
129
129
  **参数:**
130
130
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
131
131
  |-------------|------|----------|--------|-----------------|
132
- | `bundle_id` | str | 是 | - | 应用 Bundle ID |
132
+ | `bundle_id` | str | 是 | - | Bundle ID,或已安装应用的显示名 `appName`。同名多个应用时失败 |
133
133
 
134
134
  **返回值:**
135
135
 
@@ -1831,7 +1831,7 @@ GET /api/control/startApp
1831
1831
 
1832
1832
  | 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
1833
1833
  | -------- | ----- | ------ | ---- | ------ | ---- |
1834
- | bundleId | query | string | 是 | | none |
1834
+ | bundleId | query | string | 是 | | Bundle ID,或已安装应用的显示名 appName。同名多个应用时失败 |
1835
1835
 
1836
1836
  > 返回示例
1837
1837
 
@@ -1865,7 +1865,7 @@ GET /api/control/activateApp
1865
1865
 
1866
1866
  | 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
1867
1867
  | -------- | ----- | ------ | ---- | ------ | ---- |
1868
- | bundleId | query | string | 是 | | none |
1868
+ | bundleId | query | string | 是 | | Bundle ID,或已安装应用的显示名 appName。同名多个应用时失败 |
1869
1869
 
1870
1870
  > 返回示例
1871
1871
 
@@ -1899,7 +1899,7 @@ GET /api/control/stopApp
1899
1899
 
1900
1900
  | 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
1901
1901
  | -------- | ----- | ------ | ---- | ------ | ---- |
1902
- | bundleId | query | string | 是 | | none |
1902
+ | bundleId | query | string | 是 | | Bundle ID,或已安装应用的显示名 appName。同名多个应用时失败 |
1903
1903
 
1904
1904
  > 返回示例
1905
1905
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.5.19",
3
+ "version": "1.5.20",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {