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,181 @@
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 转成字符串,读到的该格为 `None`。
19
+ 5. **锁定等待**: 数据库被占用时最多等待 5 秒。
20
+
21
+ ## 类型定义
22
+
23
+ ### SqliteResult
24
+
25
+ 查询 / 执行结果。
26
+
27
+ ```python
28
+ from typing import Any, Dict, List, Optional
29
+ from kuaijs._types import KuaiJSNamespace
30
+
31
+ class SqliteResult(KuaiJSNamespace):
32
+ rows: List[Dict[str, Any]]
33
+ affectedRows: int
34
+ insertId: Optional[int]
35
+ success: bool
36
+ error: Optional[str]
37
+ ```
38
+
39
+ **参数说明:**
40
+
41
+ | 参数名 | 类型 | 描述 |
42
+ | -------------- | -------------------- | ---------------------------- |
43
+ | `rows` | List[Dict[str, Any]] | 查询结果数据行 |
44
+ | `affectedRows` | int | 受影响的行数 |
45
+ | `insertId` | int | 本次连接最近一次插入的 rowid |
46
+ | `success` | bool | 是否成功 |
47
+ | `error` | str | 错误信息 |
48
+
49
+ ## API 参考
50
+
51
+ ### 连接管理
52
+
53
+ #### open - 打开数据库
54
+
55
+ ```python
56
+ def open(path: str) -> Optional[str]
57
+ ```
58
+
59
+ **参数:**
60
+
61
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
62
+ | ------ | ---- | -------- | ------ | ------------------------- |
63
+ | `path` | str | 是 | | 绝对路径,或 `":memory:"` |
64
+
65
+ **返回值:**
66
+
67
+ | 类型 | 描述 |
68
+ | --------------- | --------------------------- |
69
+ | `Optional[str]` | 成功返回句柄,失败返回 `None` |
70
+
71
+ **示例:**
72
+
73
+ ```python
74
+ from kuaijs import sqlite, file, logger
75
+
76
+ path = file.getInternalDir("documents") + "/app.db"
77
+ db = sqlite.open(path)
78
+ if not db:
79
+ logger.error("打开失败")
80
+ ```
81
+
82
+ #### close - 关闭数据库
83
+
84
+ ```python
85
+ def close(handle: str)
86
+ ```
87
+
88
+ **示例:**
89
+
90
+ ```python
91
+ sqlite.close(db)
92
+ ```
93
+
94
+ #### isOpen - 检查句柄是否仍打开
95
+
96
+ ```python
97
+ def isOpen(handle: str) -> bool
98
+ ```
99
+
100
+ **示例:**
101
+
102
+ ```python
103
+ if sqlite.isOpen(db):
104
+ logger.info("数据库已打开")
105
+ ```
106
+
107
+ ### 数据操作
108
+
109
+ #### query - 执行查询
110
+
111
+ ```python
112
+ def query(handle: str, sql: str, params: list = []) -> SqliteResult
113
+ ```
114
+
115
+ **示例:**
116
+
117
+ ```python
118
+ result = sqlite.query(db, "SELECT * FROM t WHERE id = ?", [1])
119
+ if result.success:
120
+ logger.info(f"查询到 {len(result.rows)} 条记录")
121
+ else:
122
+ logger.error(f"查询失败: {result.error}")
123
+ ```
124
+
125
+ #### execute - 执行更新
126
+
127
+ ```python
128
+ def execute(handle: str, sql: str, params: list = []) -> SqliteResult
129
+ ```
130
+
131
+ **示例:**
132
+
133
+ ```python
134
+ sqlite.execute(
135
+ db,
136
+ "CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)",
137
+ )
138
+ insert_result = sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"])
139
+ if insert_result.success:
140
+ logger.info(f"插入 ID: {insert_result.insertId}")
141
+ ```
142
+
143
+ ### 事务管理
144
+
145
+ #### beginTransaction / commit / rollback
146
+
147
+ ```python
148
+ def beginTransaction(handle: str) -> bool
149
+ def commit(handle: str) -> bool
150
+ def rollback(handle: str) -> bool
151
+ ```
152
+
153
+ **示例:**
154
+
155
+ ```python
156
+ if sqlite.beginTransaction(db):
157
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"])
158
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["b"])
159
+ if not sqlite.commit(db):
160
+ sqlite.rollback(db)
161
+ ```
162
+
163
+ ## 完整使用示例
164
+
165
+ ```python
166
+ from kuaijs import sqlite, file, logger
167
+
168
+ db = sqlite.open(file.getInternalDir("documents") + "/app.db")
169
+ if not db:
170
+ logger.error("打开失败")
171
+ else:
172
+ sqlite.execute(
173
+ db,
174
+ "CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)",
175
+ )
176
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", ["a"])
177
+ r = sqlite.query(db, "SELECT * FROM t WHERE id = ?", [1])
178
+ if r.success:
179
+ logger.info(str(r.rows))
180
+ sqlite.close(db)
181
+ ```
@@ -0,0 +1,117 @@
1
+ # ZIP 模块 (zipFile)
2
+
3
+ 路径必须是绝对路径。只压缩、解压 ZIP;`zip` 只接受目录,不接受文件。
4
+
5
+ ## API 参考
6
+
7
+ ### getFileList - 获取 ZIP 内部文件列表
8
+
9
+ ```python
10
+ from typing import List
11
+
12
+ def getFileList(path: str) -> List[str]
13
+ ```
14
+
15
+ **参数:**
16
+
17
+ | 参数名 | 类型 | 是否必填 | 描述 |
18
+ | ------ | ----- | -------- | ---------------- |
19
+ | `path` | `str` | 是 | ZIP 文件绝对路径 |
20
+
21
+ **返回值:**
22
+
23
+ | 类型 | 描述 |
24
+ | ----------- | ------------------------------------------------------------ |
25
+ | `List[str]` | 包内文件路径;不含目录项。不是合法 ZIP 时返回空列表 |
26
+
27
+ **示例:**
28
+
29
+ ```python
30
+ from kuaijs import file, zipFile
31
+ path = file.getInternalDir("documents") + "/a.zip"
32
+ names = zipFile.getFileList(path)
33
+ ```
34
+
35
+ ### isZip - 检查是否为合法 ZIP
36
+
37
+ ```python
38
+ def isZip(path: str) -> bool
39
+ ```
40
+
41
+ **参数:**
42
+
43
+ | 参数名 | 类型 | 是否必填 | 描述 |
44
+ | ------ | ----- | -------- | ------------ |
45
+ | `path` | `str` | 是 | 文件绝对路径 |
46
+
47
+ **返回值:**
48
+
49
+ | 类型 | 描述 |
50
+ | ------ | ------------------------- |
51
+ | `bool` | 能作为 ZIP 打开为 `True` |
52
+
53
+ **示例:**
54
+
55
+ ```python
56
+ from kuaijs import file, zipFile
57
+ path = file.getInternalDir("documents") + "/a.zip"
58
+ ok = zipFile.isZip(path)
59
+ ```
60
+
61
+ ### unzip - 解压到指定目录
62
+
63
+ 目标目录不存在会创建。包内路径必须落在目标目录内,否则失败。
64
+
65
+ ```python
66
+ def unzip(zipPath: str, destDir: str) -> bool
67
+ ```
68
+
69
+ **参数:**
70
+
71
+ | 参数名 | 类型 | 是否必填 | 描述 |
72
+ | --------- | ----- | -------- | -------------------- |
73
+ | `zipPath` | `str` | 是 | ZIP 文件绝对路径 |
74
+ | `destDir` | `str` | 是 | 解压目标目录绝对路径 |
75
+
76
+ **返回值:**
77
+
78
+ | 类型 | 描述 |
79
+ | ------ | ----------------- |
80
+ | `bool` | 解压成功为 `True` |
81
+
82
+ **示例:**
83
+
84
+ ```python
85
+ from kuaijs import file, zipFile
86
+ base = file.getInternalDir("documents")
87
+ zipFile.unzip(base + "/a.zip", base + "/out")
88
+ ```
89
+
90
+ ### zip - 压缩目录为 ZIP
91
+
92
+ 包内根条目是该目录名。已有同名 ZIP 文件会先删再写。源路径必须是目录,不能是文件。输出 ZIP 不能落在源目录内。
93
+
94
+ ```python
95
+ def zip(dirPath: str, zipPath: str) -> bool
96
+ ```
97
+
98
+ **参数:**
99
+
100
+ | 参数名 | 类型 | 是否必填 | 描述 |
101
+ | --------- | ----- | -------- | ----------------------------------- |
102
+ | `dirPath` | `str` | 是 | 要压缩的目录绝对路径 |
103
+ | `zipPath` | `str` | 是 | 输出 ZIP 绝对路径,不能落在源目录内 |
104
+
105
+ **返回值:**
106
+
107
+ | 类型 | 描述 |
108
+ | ------ | ----------------- |
109
+ | `bool` | 压缩成功为 `True` |
110
+
111
+ **示例:**
112
+
113
+ ```python
114
+ from kuaijs import file, zipFile
115
+ base = file.getInternalDir("documents")
116
+ zipFile.zip(base + "/out", base + "/out.zip")
117
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {