ms-vite-plugin 1.5.12 → 1.5.13

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.
Files changed (59) hide show
  1. package/dist/build/luaBundle.js +2 -2
  2. package/dist/build/scriptProtect.js +2 -2
  3. package/docs/api/ai.md +16 -16
  4. package/docs/api/config.md +3 -3
  5. package/docs/api/dotocr.md +2 -2
  6. package/docs/api/file.md +18 -18
  7. package/docs/api/hid.md +2 -2
  8. package/docs/api/hotUpdate.md +2 -2
  9. package/docs/api/http.md +4 -4
  10. package/docs/api/image.md +15 -15
  11. package/docs/api/jbclear.md +12 -12
  12. package/docs/api/jbdevice.md +25 -25
  13. package/docs/api/jbdraw.md +139 -0
  14. package/docs/api/jbdylib.md +6 -6
  15. package/docs/api/jbpower.md +85 -0
  16. package/docs/api/jbshell.md +2 -2
  17. package/docs/api/jbsystem.md +6 -6
  18. package/docs/api/jbvpn.md +7 -7
  19. package/docs/api/mysql.md +4 -4
  20. package/docs/api/netCard.md +4 -73
  21. package/docs/api/node.md +2 -2
  22. package/docs/api/opencv.md +116 -116
  23. package/docs/api/plist.md +2 -2
  24. package/docs/api/sqlite.md +231 -0
  25. package/docs/api/system.md +1 -1
  26. package/docs/api/thread.md +2 -2
  27. package/docs/api/tomatoocr.md +2 -2
  28. package/docs/api/yolo.md +2 -2
  29. package/docs/api/yolocls.md +6 -6
  30. package/docs/api/zipFile.md +113 -0
  31. package/docs/apicn/ai.md +16 -16
  32. package/docs/apicn/config.md +2 -2
  33. package/docs/apicn/dotocr.md +2 -2
  34. package/docs/apicn/file.md +16 -16
  35. package/docs/apicn/hid.md +4 -4
  36. package/docs/apicn/hotUpdate.md +2 -2
  37. package/docs/apicn/http.md +4 -4
  38. package/docs/apicn/image.md +13 -13
  39. package/docs/apicn/mysql.md +4 -4
  40. package/docs/apicn/netCard.md +4 -73
  41. package/docs/apicn/node.md +2 -2
  42. package/docs/apicn/sqlite.md +197 -0
  43. package/docs/apicn/system.md +3 -3
  44. package/docs/apicn/thread.md +2 -2
  45. package/docs/apicn/yolo.md +2 -2
  46. package/docs/apicn/yolocls.md +6 -6
  47. package/docs/apicn/zipFile.md +113 -0
  48. package/docs/apilua/jbdraw.md +141 -0
  49. package/docs/apilua/jbpower.md +87 -0
  50. package/docs/apilua/netCard.md +3 -77
  51. package/docs/apilua/sqlite.md +204 -0
  52. package/docs/apilua/zipFile.md +123 -0
  53. package/docs/apipython/jbdraw.md +147 -0
  54. package/docs/apipython/jbpower.md +84 -0
  55. package/docs/apipython/netCard.md +3 -74
  56. package/docs/apipython/overview.md +1 -1
  57. package/docs/apipython/sqlite.md +181 -0
  58. package/docs/apipython/zipFile.md +117 -0
  59. package/package.json +1 -1
@@ -0,0 +1,231 @@
1
+ # SQLite 数据库模块 (SQLite)
2
+
3
+ SQLite 模块提供本地数据库文件的打开、查询、执行和事务。可以同时打开多个库,每个库用 `open` 返回的句柄操作。
4
+
5
+ ## 功能概览
6
+
7
+ - **多库句柄**: `open` 返回句柄,后续方法把句柄作为第一个参数
8
+ - **数据查询**: 执行 SELECT 查询
9
+ - **数据更新**: 执行 CREATE、INSERT、UPDATE、DELETE
10
+ - **事务支持**: `beginTransaction` / `commit` / `rollback`
11
+ - **参数绑定**: 使用 `?` 占位,防止 SQL 注入
12
+
13
+ ## 注意事项
14
+
15
+ 1. **文件路径**: 路径必须是绝对路径,与 `file` 模块相同。相对路径会打开失败。
16
+ 2. **内存库**: 路径传 `":memory:"` 打开内存数据库。
17
+ 3. **句柄**: 先 `open` 再查询;脚本结束会关闭本次运行打开的全部句柄,仍建议用完 `close`。
18
+ 4. **BLOB**: 第一版不把 BLOB 转成字符串,读到的该格为 `null`。
19
+ 5. **锁定等待**: 数据库被占用时最多等待 5 秒。
20
+
21
+ ## 类型定义
22
+
23
+ ### SqliteResult
24
+
25
+ 查询 / 执行结果。
26
+
27
+ ```typescript
28
+ interface SqliteResult {
29
+ rows: Record<string, any>[];
30
+ affectedRows: number;
31
+ insertId: number | null;
32
+ success: boolean;
33
+ error: string | null;
34
+ }
35
+ ```
36
+
37
+ **数据类型说明:**
38
+
39
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
40
+ | -------------- | --------------------- | -------- | ------ | ------------------------------------------ |
41
+ | `rows` | Record<string, any>[] | 否 | | 查询结果数据行 |
42
+ | `affectedRows` | number | 否 | | 受影响的行数 |
43
+ | `insertId` | number \| null | 否 | | 本次连接最近一次插入的 rowid;没有插入时为 `null` |
44
+ | `success` | boolean | 否 | | 是否成功 |
45
+ | `error` | string \| null | 否 | | 错误信息;成功时为 `null` |
46
+
47
+ ## API 参考
48
+
49
+ ### 连接管理
50
+
51
+ #### open - 打开数据库
52
+
53
+ ```typescript
54
+ function open(path: string): string | undefined;
55
+ ```
56
+
57
+ **参数:**
58
+
59
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
60
+ | ------ | ------ | -------- | ------ | ----------------------------------------- |
61
+ | `path` | string | 是 | | 绝对路径,或 `":memory:"` |
62
+
63
+ **返回值:**
64
+
65
+ | 类型 | 描述 |
66
+ | --------------- | ------------------------ |
67
+ | `string \| undefined` | 成功返回句柄,失败返回 `undefined` |
68
+
69
+ **示例:**
70
+
71
+ ```javascript
72
+ const path = file.getInternalDir("documents") + "/app.db";
73
+ const db = sqlite.open(path);
74
+ if (!db) {
75
+ loge("打开失败");
76
+ }
77
+ ```
78
+
79
+ #### close - 关闭数据库
80
+
81
+ ```typescript
82
+ function close(handle: string): void;
83
+ ```
84
+
85
+ **参数:**
86
+
87
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
88
+ | -------- | ------ | -------- | ------ | ------------------- |
89
+ | `handle` | string | 是 | | `open` 返回的句柄 |
90
+
91
+ **示例:**
92
+
93
+ ```javascript
94
+ sqlite.close(db);
95
+ ```
96
+
97
+ #### isOpen - 检查句柄是否仍打开
98
+
99
+ ```typescript
100
+ function isOpen(handle: string): boolean;
101
+ ```
102
+
103
+ **参数:**
104
+
105
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
106
+ | -------- | ------ | -------- | ------ | ------------------- |
107
+ | `handle` | string | 是 | | `open` 返回的句柄 |
108
+
109
+ **返回值:**
110
+
111
+ | 类型 | 描述 |
112
+ | --------- | ------------------ |
113
+ | `boolean` | 仍打开返回 `true` |
114
+
115
+ **示例:**
116
+
117
+ ```javascript
118
+ if (sqlite.isOpen(db)) {
119
+ logi("数据库已打开");
120
+ }
121
+ ```
122
+
123
+ ### 数据操作
124
+
125
+ #### query - 执行查询
126
+
127
+ ```typescript
128
+ function query(handle: string, sql: string, params?: any[]): SqliteResult;
129
+ ```
130
+
131
+ **参数:**
132
+
133
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
134
+ | -------- | ------ | -------- | ------ | ----------------- |
135
+ | `handle` | string | 是 | | `open` 返回的句柄 |
136
+ | `sql` | string | 是 | | SQL 语句 |
137
+ | `params` | any[] | 否 | | 绑定参数 |
138
+
139
+ **返回值:**
140
+
141
+ | 类型 | 描述 |
142
+ | -------------- | ------------ |
143
+ | `SqliteResult` | 查询结果对象 |
144
+
145
+ **示例:**
146
+
147
+ ```javascript
148
+ const result = sqlite.query(db, "SELECT * FROM t WHERE id = ?", [1]);
149
+ if (result.success) {
150
+ logi(`查询到 ${result.rows.length} 条记录`);
151
+ } else {
152
+ loge(`查询失败: ${result.error}`);
153
+ }
154
+ ```
155
+
156
+ #### execute - 执行更新
157
+
158
+ ```typescript
159
+ function execute(handle: string, sql: string, params?: any[]): SqliteResult;
160
+ ```
161
+
162
+ **参数:**
163
+
164
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
165
+ | -------- | ------ | -------- | ------ | ----------------- |
166
+ | `handle` | string | 是 | | `open` 返回的句柄 |
167
+ | `sql` | string | 是 | | SQL 语句 |
168
+ | `params` | any[] | 否 | | 绑定参数 |
169
+
170
+ **返回值:**
171
+
172
+ | 类型 | 描述 |
173
+ | -------------- | ------------ |
174
+ | `SqliteResult` | 执行结果对象 |
175
+
176
+ **示例:**
177
+
178
+ ```javascript
179
+ sqlite.execute(db, `
180
+ CREATE TABLE IF NOT EXISTS t (
181
+ id INTEGER PRIMARY KEY,
182
+ name TEXT
183
+ )
184
+ `);
185
+ const insertResult = sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"]);
186
+ if (insertResult.success) {
187
+ logi(`插入 ID: ${insertResult.insertId}`);
188
+ }
189
+ ```
190
+
191
+ ### 事务管理
192
+
193
+ #### beginTransaction / commit / rollback
194
+
195
+ ```typescript
196
+ function beginTransaction(handle: string): boolean;
197
+ function commit(handle: string): boolean;
198
+ function rollback(handle: string): boolean;
199
+ ```
200
+
201
+ **示例:**
202
+
203
+ ```javascript
204
+ if (sqlite.beginTransaction(db)) {
205
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"]);
206
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["b"]);
207
+ if (!sqlite.commit(db)) {
208
+ sqlite.rollback(db);
209
+ }
210
+ }
211
+ ```
212
+
213
+ ## 完整使用示例
214
+
215
+ ```javascript
216
+ const db = sqlite.open(file.getInternalDir("documents") + "/app.db");
217
+ if (!db) {
218
+ loge("打开失败");
219
+ } else {
220
+ sqlite.execute(
221
+ db,
222
+ "CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)",
223
+ );
224
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"]);
225
+ const r = sqlite.query(db, "SELECT * FROM t WHERE id = ?", [1]);
226
+ if (r.success) {
227
+ logi(JSON.stringify(r.rows));
228
+ }
229
+ sqlite.close(db);
230
+ }
231
+ ```
@@ -118,7 +118,7 @@ function activateAppInfo(): {
118
118
  bundleId: string;
119
119
  name: string;
120
120
  pid: number;
121
- } | null;
121
+ } | undefined;
122
122
  ```
123
123
 
124
124
  **返回值:**
@@ -25,7 +25,7 @@
25
25
  启动一个新的线程来执行指定的 JS 文件。
26
26
 
27
27
  ```typescript
28
- function run(threadJsFileName: string, params?: Record<string, any>): Thread;
28
+ function run(threadJsFileName: string, params?: Record<string, any>): Thread | undefined;
29
29
  ```
30
30
 
31
31
  **参数:**
@@ -39,7 +39,7 @@ function run(threadJsFileName: string, params?: Record<string, any>): Thread;
39
39
 
40
40
  | 类型 | 描述 |
41
41
  | -------- | ------------ |
42
- | `Thread` | 线程控制对象 |
42
+ | `Thread \| undefined` | 线程控制对象;启动参数不是 Object 或启动失败时返回 undefined |
43
43
 
44
44
  **示例:**
45
45
 
@@ -30,7 +30,7 @@ function initializeWithConfig(
30
30
  message: string;
31
31
  status: string;
32
32
  versionName: string;
33
- } | null;
33
+ } | undefined;
34
34
  ```
35
35
 
36
36
  **参数:**
@@ -43,7 +43,7 @@ function initializeWithConfig(
43
43
 
44
44
  **返回值:**
45
45
 
46
- - 成功时返回包含设备信息的对象,失败时返回 null
46
+ - 成功时返回包含设备信息的对象,失败时返回 undefined
47
47
 
48
48
  | 参数名 | 类型 | 描述 |
49
49
  | ------------- | ------ | -------- |
package/docs/api/yolo.md CHANGED
@@ -70,7 +70,7 @@ function load(
70
70
  nc?: number,
71
71
  version?: number,
72
72
  useGpu?: boolean
73
- ): string | null;
73
+ ): string | undefined;
74
74
  ```
75
75
 
76
76
  **参数:**
@@ -87,7 +87,7 @@ function load(
87
87
 
88
88
  | 类型 | 描述 |
89
89
  | ---------------- | ----------------------------------------- |
90
- | `string \| null` | 加载成功返回模型 ID 字符串,失败返回 null |
90
+ | `string \| undefined` | 加载成功返回模型 ID 字符串,失败返回 undefined |
91
91
 
92
92
  **示例:**
93
93
 
@@ -25,9 +25,9 @@ YOLO 分类概率结果,字段命名与 Ultralytics `Probs` 保持一致。
25
25
  ```typescript
26
26
  interface YoloClsProbs {
27
27
  data: number[]; // 所有类别概率,下标即类别 ID
28
- top1: number | null; // 概率最高的类别 ID
28
+ top1: number | null; // 概率最高的类别 ID;分类失败时为 null
29
29
  top5: number[]; // 概率最高的 5 个类别 ID
30
- top1conf: number | null; // top1 对应的概率
30
+ top1conf: number | null; // top1 对应的概率;分类失败时为 null
31
31
  top5conf: number[]; // top5 对应的概率
32
32
  }
33
33
  ```
@@ -37,9 +37,9 @@ interface YoloClsProbs {
37
37
  | 字段名 | 类型 | 描述 |
38
38
  | ---------- | ---------------- | ---------------------------------------------------------- |
39
39
  | `data` | `number[]` | 所有类别概率数组,下标即类别 ID |
40
- | `top1` | `number \| null` | 概率最高的类别 ID;分类失败时为 `null` |
40
+ | `top1` | `number \| null` | 概率最高的类别 ID;分类失败时为 `null` |
41
41
  | `top5` | `number[]` | 概率最高的 5 个类别 ID,按概率从高到低排序 |
42
- | `top1conf` | `number \| null` | `top1` 对应的概率;分类失败时为 `null` |
42
+ | `top1conf` | `number \| null` | `top1` 对应的概率;分类失败时为 `null` |
43
43
  | `top5conf` | `number[]` | `top5` 对应的概率,顺序与 `top5` 一致 |
44
44
 
45
45
  **结果说明:**
@@ -62,7 +62,7 @@ function load(
62
62
  binPath: string,
63
63
  nc?: number,
64
64
  useGpu?: boolean
65
- ): string | null;
65
+ ): string | undefined;
66
66
  ```
67
67
 
68
68
  **参数:**
@@ -78,7 +78,7 @@ function load(
78
78
 
79
79
  | 类型 | 描述 |
80
80
  | ---------------- | ----------------------------------------- |
81
- | `string \| null` | 加载成功返回模型 ID 字符串,失败返回 null |
81
+ | `string \| undefined` | 加载成功返回模型 ID 字符串,失败返回 undefined |
82
82
 
83
83
  **示例:**
84
84
 
@@ -0,0 +1,113 @@
1
+ # ZIP 模块 (zipFile)
2
+
3
+ 路径必须是绝对路径。只压缩、解压 ZIP;`zip` 只接受目录,不接受文件。
4
+
5
+ ## API 参考
6
+
7
+ ### getFileList - 获取 ZIP 内部文件列表。
8
+
9
+ ```typescript
10
+ function getFileList(path: string): string[];
11
+ ```
12
+
13
+ **参数:**
14
+
15
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
16
+ | ------ | -------- | -------- | ------ | ---------------- |
17
+ | `path` | `string` | 是 | - | ZIP 文件绝对路径 |
18
+
19
+ **返回值:**
20
+
21
+ | 类型 | 描述 |
22
+ | ---------- | ------------------------------------------------------------ |
23
+ | `string[]` | 包内文件路径;不含目录项。不是合法 ZIP 时返回空数组 |
24
+
25
+ **示例:**
26
+
27
+ ```javascript
28
+ const path = file.getInternalDir("documents") + "/a.zip";
29
+ const names = zipFile.getFileList(path);
30
+ ```
31
+
32
+ ### isZip - 检查是否为合法 ZIP。
33
+
34
+ ```typescript
35
+ function isZip(path: string): boolean;
36
+ ```
37
+
38
+ **参数:**
39
+
40
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
41
+ | ------ | -------- | -------- | ------ | ------------ |
42
+ | `path` | `string` | 是 | - | 文件绝对路径 |
43
+
44
+ **返回值:**
45
+
46
+ | 类型 | 描述 |
47
+ | --------- | ------------------------- |
48
+ | `boolean` | 能作为 ZIP 打开为 `true` |
49
+
50
+ **示例:**
51
+
52
+ ```javascript
53
+ const path = file.getInternalDir("documents") + "/a.zip";
54
+ if (zipFile.isZip(path)) {
55
+ logi("是 ZIP");
56
+ }
57
+ ```
58
+
59
+ ### unzip - 解压到指定目录。
60
+
61
+ 目标目录不存在会创建。包内路径必须落在目标目录内,否则失败。
62
+
63
+ ```typescript
64
+ function unzip(zipPath: string, destDir: string): boolean;
65
+ ```
66
+
67
+ **参数:**
68
+
69
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
70
+ | --------- | -------- | -------- | ------ | -------------------- |
71
+ | `zipPath` | `string` | 是 | - | ZIP 文件绝对路径 |
72
+ | `destDir` | `string` | 是 | - | 解压目标目录绝对路径 |
73
+
74
+ **返回值:**
75
+
76
+ | 类型 | 描述 |
77
+ | --------- | ----------------- |
78
+ | `boolean` | 解压成功为 `true` |
79
+
80
+ **示例:**
81
+
82
+ ```javascript
83
+ const dir = file.getInternalDir("documents");
84
+ zipFile.unzip(dir + "/a.zip", dir + "/out");
85
+ ```
86
+
87
+ ### zip - 压缩目录为 ZIP。
88
+
89
+ 包内根条目是该目录名。已有同名 ZIP 文件会先删再写。源路径必须是目录,不能是文件。输出 ZIP 不能落在源目录内。
90
+
91
+ ```typescript
92
+ function zip(dirPath: string, zipPath: string): boolean;
93
+ ```
94
+
95
+ **参数:**
96
+
97
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
98
+ | --------- | -------- | -------- | ------ | ---------------------------------------- |
99
+ | `dirPath` | `string` | 是 | - | 要压缩的目录绝对路径 |
100
+ | `zipPath` | `string` | 是 | - | 输出 ZIP 绝对路径,不能落在源目录内 |
101
+
102
+ **返回值:**
103
+
104
+ | 类型 | 描述 |
105
+ | --------- | ----------------- |
106
+ | `boolean` | 压缩成功为 `true` |
107
+
108
+ **示例:**
109
+
110
+ ```javascript
111
+ const dir = file.getInternalDir("documents");
112
+ zipFile.zip(dir + "/out", dir + "/out.zip");
113
+ ```
package/docs/apicn/ai.md CHANGED
@@ -12,7 +12,7 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
12
12
 
13
13
  模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `$AI.设置模型` 一次即可;脚本停止后配置自动清空,不会存到手机上。
14
14
 
15
- 所有方法同步阻塞,失败时返回 `null` / `false`,原因用 `$AI.获取错误()` 查看。
15
+ 所有方法同步阻塞,失败时返回 `undefined` / `false`,原因用 `$AI.获取错误()` 查看。
16
16
 
17
17
  ## 快速开始
18
18
 
@@ -149,7 +149,7 @@ interface 对话消息 {
149
149
  ### 设置模型
150
150
 
151
151
  ```typescript
152
- function 设置模型(配置: Partial<模型供应商>): 模型供应商 | null;
152
+ function 设置模型(配置: Partial<模型供应商>): 模型供应商 | undefined;
153
153
  ```
154
154
 
155
155
  **参数:**
@@ -162,7 +162,7 @@ function 设置模型(配置: Partial<模型供应商>): 模型供应商 | null;
162
162
 
163
163
  | 类型 | 描述 |
164
164
  | ------------ | ------------------------------------------------------------------------------- |
165
- | `模型供应商` | 保存后的完整配置;`protocol` 不是三者之一或缺 `baseUrl` / `model` 时返回 `null` |
165
+ | `模型供应商` | 保存后的完整配置;`protocol` 不是三者之一或缺 `baseUrl` / `model` 时返回 `undefined` |
166
166
 
167
167
  第一个登记的供应商自动成为默认;`isDefault: true` 会把默认切到它。
168
168
 
@@ -240,14 +240,14 @@ $AI.获取模型列表().forEach((p) => $打印信息日志(`${p.name} -> ${p.mo
240
240
  ### 获取默认模型
241
241
 
242
242
  ```typescript
243
- function 获取默认模型(): 模型供应商 | null;
243
+ function 获取默认模型(): 模型供应商 | undefined;
244
244
  ```
245
245
 
246
246
  **返回值:**
247
247
 
248
248
  | 类型 | 描述 |
249
249
  | ------------ | ------------------------------------- |
250
- | `模型供应商` | 默认供应商;一个都没登记时返回 `null` |
250
+ | `模型供应商` | 默认供应商;一个都没登记时返回 `undefined` |
251
251
 
252
252
  ### 设置默认模型
253
253
 
@@ -290,7 +290,7 @@ function 删除模型(id: 字符串): 布尔值;
290
290
  ### 提问
291
291
 
292
292
  ```typescript
293
- function 提问(问题: 字符串, 选项?: 调用选项): 字符串 | null;
293
+ function 提问(问题: 字符串, 选项?: 调用选项): 字符串 | undefined;
294
294
  ```
295
295
 
296
296
  **参数:**
@@ -304,7 +304,7 @@ function 提问(问题: 字符串, 选项?: 调用选项): 字符串 | null;
304
304
 
305
305
  | 类型 | 描述 |
306
306
  | -------- | --------------------------------------------------- |
307
- | `字符串` | 模型回复文本;失败返回 `null`,原因看 `获取错误()` |
307
+ | `字符串` | 模型回复文本;失败返回 `undefined`,原因看 `获取错误()` |
308
308
 
309
309
  **示例:**
310
310
 
@@ -364,7 +364,7 @@ while (!$AI.判断("顶部是否显示「首页」?", { image: "screen", x: 0,
364
364
  ### 提取
365
365
 
366
366
  ```typescript
367
- function 提取(要求: 字符串, 选项?: 调用选项): 任意类型 | null;
367
+ function 提取(要求: 字符串, 选项?: 调用选项): 任意类型 | undefined;
368
368
  ```
369
369
 
370
370
  要求模型输出 JSON 并自动解析成对象或数组。`schema` 用来告诉模型你想要的结构。
@@ -380,7 +380,7 @@ function 提取(要求: 字符串, 选项?: 调用选项): 任意类型 | null;
380
380
 
381
381
  | 类型 | 描述 |
382
382
  | ----------- | --------------------------------------------------------- |
383
- | `对象/数组` | 解析后的数据;模型没有输出合法 JSON 或请求失败返回 `null` |
383
+ | `对象/数组` | 解析后的数据;模型没有输出合法 JSON 或请求失败返回 `undefined` |
384
384
 
385
385
  **示例:**
386
386
 
@@ -407,14 +407,14 @@ if (位置) $动作.点击(位置.x, 位置.y);
407
407
  ### 对话
408
408
 
409
409
  ```typescript
410
- function 对话(消息列表: 数组<对话消息 | 字符串>, 选项?: 调用选项): 字符串 | null;
410
+ function 对话(消息列表: 数组<对话消息 | 字符串>, 选项?: 调用选项): 字符串 | undefined;
411
411
  ```
412
412
 
413
413
  自己维护完整对话历史时用它;`提问` 是它的单轮封装。模块不记会话,每次都要把到目前为止的消息整表传进来。
414
414
 
415
415
  图片写在**那一条 user 消息**上,不要用 `选项.image`。`选项.system` 也不生效,系统提示写成第一条 `{ role: "system", content: "..." }`。
416
416
 
417
- 失败返回 `null`:不要把空回复推进历史,否则下一轮变成 `user → assistant(null) → user`,Anthropic 会 400。Anthropic 协议下模块会自动合并连续同角色、并在首条是 assistant 时垫一条占位 user;OpenAI 兼容口更宽松,不必为此改脚本。
417
+ 失败返回 `undefined`:不要把空回复推进历史,否则下一轮变成 `user → assistant(null) → user`,Anthropic 会 400。Anthropic 协议下模块会自动合并连续同角色、并在首条是 assistant 时垫一条占位 user;OpenAI 兼容口更宽松,不必为此改脚本。
418
418
 
419
419
  **参数:**
420
420
 
@@ -427,7 +427,7 @@ function 对话(消息列表: 数组<对话消息 | 字符串>, 选项?: 调用
427
427
 
428
428
  | 类型 | 描述 |
429
429
  | -------- | ------------------------- |
430
- | `字符串` | 回复文本;失败返回 `null` |
430
+ | `字符串` | 回复文本;失败返回 `undefined` |
431
431
 
432
432
  **示例:**
433
433
 
@@ -453,7 +453,7 @@ function 问(content, extra) {
453
453
  ### 解析JSON
454
454
 
455
455
  ```typescript
456
- function 解析JSON(文本: 字符串): 任意类型 | null;
456
+ function 解析JSON(文本: 字符串): 任意类型 | undefined;
457
457
  ```
458
458
 
459
459
  自动剥掉 Markdown 代码块和前后的解释文字。`提取` 内部就是用它解析。
@@ -468,19 +468,19 @@ function 解析JSON(文本: 字符串): 任意类型 | null;
468
468
 
469
469
  | 类型 | 描述 |
470
470
  | ----------- | ------------------------- |
471
- | `对象/数组` | 解析结果;失败返回 `null` |
471
+ | `对象/数组` | 解析结果;失败返回 `undefined` |
472
472
 
473
473
  ### 获取错误
474
474
 
475
475
  ```typescript
476
- function 获取错误(): 字符串 | null;
476
+ function 获取错误(): 字符串 | undefined;
477
477
  ```
478
478
 
479
479
  **返回值:**
480
480
 
481
481
  | 类型 | 描述 |
482
482
  | -------- | ------------------------------------- |
483
- | `字符串` | 错误文案;上一次调用成功时返回 `null` |
483
+ | `字符串` | 错误文案;上一次调用成功时返回 `undefined` |
484
484
 
485
485
  常见错误:未登记供应商、Key 错误 / 余额不足(接口返回的原文)、模型不支持图片、图片无效或裁剪越界、超时、模型没有输出 JSON。
486
486
 
@@ -93,7 +93,7 @@ if (是否更新成功1 && 是否更新成功2 && 是否更新成功3) {
93
93
  ### 获取
94
94
 
95
95
  ```typescript
96
- function 获取(配置键: 字符串): 任意类型 | null;
96
+ function 获取(配置键: 字符串): 任意类型 | undefined;
97
97
  ```
98
98
 
99
99
  **参数:**
@@ -106,7 +106,7 @@ function 获取(配置键: 字符串): 任意类型 | null;
106
106
 
107
107
  | 类型 | 描述 |
108
108
  | ------------------ | ------ |
109
- | `任意类型 \| null` | 配置值 |
109
+ | `任意类型 \| undefined` | 配置值 |
110
110
 
111
111
  **示例:**
112
112
 
@@ -64,7 +64,7 @@ interface OCR字符 {
64
64
  加载字库是使用点阵识别功能的前提。建议在脚本初始化时加载一次并保存字库 ID,后续识别时复用,不要每次识别都重新加载。
65
65
 
66
66
  ```typescript
67
- function 加载字库(字库资源路径: 字符串): 字符串 | null;
67
+ function 加载字库(字库资源路径: 字符串): 字符串 | undefined;
68
68
  ```
69
69
 
70
70
  **参数:**
@@ -77,7 +77,7 @@ function 加载字库(字库资源路径: 字符串): 字符串 | null;
77
77
 
78
78
  | 类型 | 描述 |
79
79
  | -------------- | ----------------------------------------- |
80
- | `字符串 \| null` | 加载成功返回字库 ID 字符串,失败返回 null |
80
+ | `字符串 \| undefined` | 加载成功返回字库 ID 字符串,失败返回 undefined |
81
81
 
82
82
  **示例:**
83
83